00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #include "CalScheme.h"
00014 #include "MessageService/MsgService.h"
00015 #include <cassert>
00016 #include <iostream>
00017
00018 CVSID( " $Id: CalScheme.cxx,v 1.9 2005/03/22 12:22:14 tagg Exp $ ");
00019 ClassImp(CalScheme)
00020
00021 Int_t CalScheme::fsCalls[kNumberOfSchemeTypes]= {0};
00022 Int_t CalScheme::fsErrors[kNumberOfSchemeTypes][kNumberOfErrorTypes] = {{0},{0}};
00023 std::map<GenericThingId,int> CalScheme::fsChannelErrors;
00024
00025 std::ostream& operator<<(std::ostream& os, const CalScheme& s)
00026 {
00027 s.PrintConfig(os);
00028 return os;
00029 }
00030
00031 CalScheme::CalScheme() : fContext()
00032 {
00033 }
00034
00035 CalScheme::~CalScheme()
00036 {
00037 }
00038
00040
00042
00043 DoubleErr CalScheme::GetCalibratedTime(DoubleErr , FloatErr, const PlexStripEndId& ) const
00044 {
00056 Unimplimented();
00057 return 0;
00058 }
00059
00060 FloatErr CalScheme::GetPhotoElectrons(FloatErr, const PlexStripEndId& ) const
00061 {
00072
00073 Unimplimented(); return 0;
00074 }
00075
00076 FloatErr CalScheme::GetLinearizedVA(FloatErr, const RawChannelId& ) const
00077 {
00089
00090 Unimplimented(); return 0;
00091 }
00092
00093
00094 FloatErr CalScheme::GetDriftCorrected(FloatErr, const PlexStripEndId& ) const
00095 {
00106 Unimplimented(); return 0;
00107 }
00108
00109 FloatErr CalScheme::GetLinearized(FloatErr, const PlexStripEndId& ) const
00110 {
00121 Unimplimented(); return 0;
00122 }
00123
00124 FloatErr CalScheme::GetStripToStripCorrected(FloatErr, const PlexStripEndId& ) const
00125 {
00139 Unimplimented(); return 0;
00140 }
00141
00142 FloatErr CalScheme::GetAttenCorrected(FloatErr, FloatErr, const PlexStripEndId& ) const
00143 {
00155
00156 Unimplimented(); return 0;
00157 }
00158
00159 FloatErr CalScheme::GetMIP(FloatErr, const PlexStripEndId&) const
00160 {
00173 Unimplimented(); return 0;
00174 }
00175
00177
00179
00180
00181 DoubleErr CalScheme::DecalTime(DoubleErr , FloatErr , const PlexStripEndId& ) const
00182 {
00196 Unimplimented(); return 0;
00197 }
00198
00199 void CalScheme::DecalGainAndWidth(FloatErr& , FloatErr& , const PlexStripEndId& ) const
00200 {
00212 Unimplimented(); return;
00213 }
00214
00215 void CalScheme::DecalGainAndWidth(FloatErr& , FloatErr& , const PlexPixelSpotId& ) const
00216 {
00230 Unimplimented(); return;
00231 }
00232
00233 FloatErr CalScheme::DecalVALinearity(FloatErr , const RawChannelId& ) const
00234 {
00247 Unimplimented(); return 0;
00248 }
00249
00250 FloatErr CalScheme::DecalDrift(FloatErr , const PlexStripEndId& ) const
00251 {
00264 Unimplimented(); return 0;
00265 }
00266
00267 FloatErr CalScheme::DecalLinearity(FloatErr , const PlexStripEndId& ) const
00268 {
00281
00282 Unimplimented(); return 0;
00283 }
00284
00285 FloatErr CalScheme::DecalStripToStrip(FloatErr , const PlexStripEndId& ) const
00286 {
00299
00300 Unimplimented(); return 0;
00301 }
00302
00303 FloatErr CalScheme::DecalAttenCorrected(FloatErr , FloatErr, const PlexStripEndId& ) const
00304 {
00318
00319 Unimplimented(); return 0;
00320 }
00321
00322 FloatErr CalScheme::DecalMIP(FloatErr , const PlexStripEndId& ) const
00323 {
00336
00337 Unimplimented(); return 0;
00338 }
00339
00341
00343 Float_t CalScheme::GetTemperature(Int_t ) const
00344 {
00356 Unimplimented(); return 0;
00357 }
00358
00359
00360
00361
00362 void CalScheme::Reset( const VldContext& context, Bool_t force)
00363 {
00370
00371
00372
00373 if(context.IsValid()) {
00374
00375
00376
00377 if( (fContext!=context) || (force) ) {
00378 MSG("Calib",Msg::kVerbose) << "Resetting " << this->GetName() << " " << context.AsString() << endl;
00379 fContext = context;
00380 this->DoReset(context);
00381 }
00382 }
00383 }
00384
00385
00386
00387 void CalScheme::Unimplimented() const
00388 {
00393 MSG("Calib",Msg::kFatal) << this->GetName() << " called with unimplimented function. " << endl
00394 << "Calibrator is not set up correctly!" << endl;
00395 assert(0);
00396 }
00397
00398
00399 void CalScheme::ResetStatistics()
00400 {
00406 for(int i=0;i<kNumberOfSchemeTypes;i++) {
00407 fsCalls[i] = 0;
00408 for(int j=0;j<kNumberOfErrorTypes;j++)
00409 fsErrors[i][j] = 0;
00410 }
00411 fsChannelErrors.clear();
00412 }
00413
00414 void CalScheme::IncrementErrors(SchemeType_t i,
00415 ErrorType_t j)
00416 {
00420
00421
00422
00423 fsErrors[i % kNumberOfSchemeTypes][j % kNumberOfErrorTypes]++;
00424 }
00425
00426 void CalScheme::IncrementErrors(SchemeType_t i,
00427 ErrorType_t j,
00428 const GenericThingId& id)
00429 {
00433
00434
00435 IncrementErrors(i,j);
00436 fsChannelErrors[id]++;
00437 }
00438
00439
00440 void CalScheme::IncrementErrors(SchemeType_t i, ErrorType_t j,
00441 Int_t c)
00442 {
00443 IncrementErrors(i,j,GenericThingId(c));
00444 }
00445
00446 void CalScheme::IncrementErrors(SchemeType_t i, ErrorType_t j,
00447 const PlexStripEndId& c)
00448 {
00449 IncrementErrors(i,j,GenericThingId(c));
00450 }
00451
00452 void CalScheme::IncrementErrors(SchemeType_t i, ErrorType_t j,
00453 const RawChannelId& c)
00454 {
00455 IncrementErrors(i,j,GenericThingId(c));
00456 }
00457
00458 void CalScheme::IncrementErrors(SchemeType_t i, ErrorType_t j,
00459 const PlexPixelSpotId& c)
00460 {
00461 IncrementErrors(i,j,GenericThingId(c));
00462 }
00463
00464 void CalScheme::IncrementErrors(SchemeType_t i, ErrorType_t j,
00465 const PlexLedId& c)
00466 {
00467 IncrementErrors(i,j,GenericThingId(c));
00468 }
00469
00470
00471 void CalScheme::IncrementCalls(SchemeType_t i)
00472 {
00476
00477
00478 fsCalls[i % kNumberOfSchemeTypes]++;
00479 }
00480
00481
00482
00483 void CalScheme::PrintErrorStats( std::ostream& os ) const
00484 {
00485 os << "Calibrator Errors Statistics:" << endl;
00486 os << Form("%20s %10s ||%10s|%10s|%10s|%10s|%10s|%10s\n",
00487 "Calibrator","Calls","General","Miss Table","Miss Row","FP Error","Insuf.Data","Bad Input");
00488 for(int type = 0; type < kNumberOfSchemeTypes; type ++) {
00489 os << Form("%20s %10d || %8d | %8d | %8d | %8d | %8d | %8d\n",
00490 SchemeTypeName((SchemeType_t)type),
00491 fsCalls[type],
00492 fsErrors[type][kGeneralErr],
00493 fsErrors[type][kMissingTable],
00494 fsErrors[type][kMissingRow],
00495 fsErrors[type][kFPE],
00496 fsErrors[type][kDataInsufficient],
00497 fsErrors[type][kBadInput]);
00498 }
00499
00500
00501
00502
00503
00504
00505 os << "Channels with the most errors: " << endl;
00506 std::multimap<int,GenericThingId> sortedChannels;
00507 std::map<GenericThingId,int>::iterator it;
00508 for(it = fsChannelErrors.begin(); it!= fsChannelErrors.end(); it++) {
00509 sortedChannels.insert(std::pair<int,GenericThingId>(-(it->second),it->first));
00510 }
00511
00512 std::multimap<int,GenericThingId>::iterator it2;
00513 it2 = sortedChannels.begin();
00514 int i=0;
00515 while((i<10) && (it2!=sortedChannels.end())) {
00516 os << "Errors: " << Form("%8d",-(it2->first)) << " " << (it2->second).AsString() << endl;
00517 it2++; i++;
00518 }
00519 }
00520
00521
00522
00523
00524 void CalScheme::PrintConfig(std::ostream &os) const
00525 {
00530 os << "Generic CalScheme PrintConfig()" <<endl;
00531 const Registry& r = this->GetConfig();
00532 r.PrettyPrint(os);
00533 }
00534
00535
00536
00537 void CalScheme::PrintConfig( MsgStream& ms ) const
00538 {
00539 stringstream oss;
00540 PrintConfig(oss);
00541 ms << oss.str();
00542 }
00543
00544 void CalScheme::PrintConfig() const
00545 {
00546 PrintConfig(*(MsgService::Instance()->GetStream("Calib")));
00547 }
00548
00549
00550 void CalScheme::PrintErrorStats( MsgStream& ms ) const
00551 {
00552 stringstream oss;
00553 PrintErrorStats(oss);
00554 ms << oss.str();
00555 }
00556
00557 void CalScheme::PrintErrorStats() const
00558 {
00559 PrintErrorStats(*(MsgService::Instance()->GetStream("Calib")));
00560 }
00561