From 0bfcc11ba8d774a9a52a9f34947dcb24108961f9 Mon Sep 17 00:00:00 2001 From: Ole Hansen Date: Wed, 10 Jan 2018 14:50:02 -0500 Subject: [PATCH] Improved & consistent debug output from standard detector classes --- OldVDC/OldVDCPlane.cxx | 9 +++--- src/THaAnalysisObject.C | 24 ++++++++++++++- src/THaAnalysisObject.h | 9 ++++-- src/THaCherenkov.C | 40 ++++++++++++++++++++----- src/THaScintillator.C | 65 +++++++++++++++++++++++++++++------------ src/THaShower.C | 39 +++++++++++++++++++++---- src/THaVDCPlane.C | 45 +++++++++++++++++++++++----- 7 files changed, 184 insertions(+), 47 deletions(-) diff --git a/OldVDC/OldVDCPlane.cxx b/OldVDC/OldVDCPlane.cxx index 36346374..38d08a78 100644 --- a/OldVDC/OldVDCPlane.cxx +++ b/OldVDC/OldVDCPlane.cxx @@ -214,11 +214,10 @@ Int_t OldVDCPlane::DoReadDatabase( FILE* file, const TDatime& date ) { "Number of wires", &fNelem, kInt }, { "Detector position", pos, kDouble, 3 }, { "Detector size", fSize, kFloat, 3 }, - { "Wire angle (deg)", &angle, }, - { "Wire start pos (m)", &fWBeg, }, - { "Wire spacing (m)", &fWSpac, }, - { "Wire angle (deg)", &angle, }, - { "TDC resolution (s/chan)", &fTDCRes, }, + { "Wire angle (deg)", &angle }, + { "Wire start pos (m)", &fWBeg }, + { "Wire spacing (m)", &fWSpac }, + { "TDC resolution (s/chan)", &fTDCRes }, { "Drift Velocity (m/s) ", &fDriftVel }, { "Max gap in cluster", &fNMaxGap, kInt }, { "Min TDC raw time", &fMinTime, kInt }, diff --git a/src/THaAnalysisObject.C b/src/THaAnalysisObject.C index 888900a7..c0a3d098 100644 --- a/src/THaAnalysisObject.C +++ b/src/THaAnalysisObject.C @@ -1777,7 +1777,8 @@ vector THaAnalysisObject::vsplit(const string& s) return ret; } -//----------------------------------------------------------------------------- +#ifdef WITH_DEBUG +//_____________________________________________________________________________ void THaAnalysisObject::DebugPrint( const DBRequest* list ) { // Print values of database parameters given in 'list' @@ -1792,6 +1793,8 @@ void THaAnalysisObject::DebugPrint( const DBRequest* list ) cout << " " << std::left << setw(maxw) << it->name; UInt_t maxc = it->nelem; if( maxc == 0 ) maxc = 1; + if( it->type == kDoubleV ) + maxc = static_cast( ((vector*)it->var)->size() ); for (UInt_t i=0; itype ) { @@ -1804,6 +1807,8 @@ void THaAnalysisObject::DebugPrint( const DBRequest* list ) case kInt: cout << ((Int_t*)it->var)[i]; break; + case kDoubleV: + cout << ((vector*)it->var)->at(i); default: break; } @@ -1812,6 +1817,23 @@ void THaAnalysisObject::DebugPrint( const DBRequest* list ) } } +//_____________________________________________________________________________ +template +void THaAnalysisObject::WriteValue( T val, int p, int w ) +{ + // Helper function for printing debug information + if( val < kBig ) + cout << fixed << setprecision(p) << setw(w) << val; + else + cout << " --- "; +} + +// Explicit instantiations +template void THaAnalysisObject::WriteValue( Double_t val, int p=0, int w=5 ); +template void THaAnalysisObject::WriteValue( Float_t val, int p=0, int w=5 ); + +#endif + //_____________________________________________________________________________ TString& THaAnalysisObject::GetObjArrayString( const TObjArray* array, Int_t i ) { diff --git a/src/THaAnalysisObject.h b/src/THaAnalysisObject.h index fb2e4caf..b3333472 100644 --- a/src/THaAnalysisObject.h +++ b/src/THaAnalysisObject.h @@ -15,7 +15,7 @@ #include #include #include -#include +//#include class THaEvData; //needed by derived classes class TList; @@ -180,7 +180,12 @@ class THaAnalysisObject : public TNamed { static char* ReadComment( FILE* fp, char* buf, const int len ); - void DebugPrint( const DBRequest* list ); +#ifdef WITH_DEBUG + void DebugPrint( const DBRequest* list ); + + template // available for double and float + static void WriteValue( T val, int p=0, int w=5 ); +#endif // Only derived classes may construct THaAnalysisObject( const char* name, const char* description ); diff --git a/src/THaCherenkov.C b/src/THaCherenkov.C index 33786a29..d91dcdb1 100644 --- a/src/THaCherenkov.C +++ b/src/THaCherenkov.C @@ -18,9 +18,10 @@ #include #include -#include #include #include +#include +#include using namespace std; @@ -151,6 +152,25 @@ Int_t THaCherenkov::ReadDatabase( const TDatime& date ) if( err ) return err; +#ifdef WITH_DEBUG + // Debug printout + if ( fDebug > 2 ) { + const UInt_t N = static_cast(fNelem); + Double_t pos[3]; fOrigin.GetXYZ(pos); + DBRequest list[] = { + { "Number of mirrors", &fNelem, kInt }, + { "Detector position", pos, kDouble, 3 }, + { "Detector size", fSize, kDouble, 3 }, + { "Detector angle", &angle }, + { "TDC offsets", fOff, kFloat, N }, + { "ADC pedestals", fPed, kFloat, N }, + { "ADC gains", fGain, kFloat, N }, + { 0 } + }; + DebugPrint( list ); + } +#endif + return kOK; } @@ -272,27 +292,33 @@ Int_t THaCherenkov::Decode( const THaEvData& evdata ) } } +#ifdef WITH_DEBUG if ( fDebug > 3 ) { - printf("\nCherenkov %s:\n",GetPrefix()); + cout << endl << "Cherenkov " << GetPrefix() << ":" << endl; int ncol=3; for (int i=0; i -#include #include #include #include +#include using namespace std; @@ -219,20 +219,35 @@ Int_t THaScintillator::ReadDatabase( const TDatime& date ) if( fResolution == kBig ) fResolution = fTdc2T; - // If doing debugging, print the calibration parameters we've just read - if ( fDebug > 1 ) { - cout << '\n' << GetPrefix() << " calibration parameters: " << endl;; - for ( DBRequest *li = calib_request; li->name; li++ ) { - cout << " " << li->name; - UInt_t maxc = li->nelem; - if (maxc==0)maxc=1; - for (UInt_t i=0; itype==kDouble) cout << " " << ((Double_t*)li->var)[i]; - if (li->type==kInt) cout << " " << ((Int_t*)li->var)[i]; - } - cout << endl; - } +#ifdef WITH_DEBUG + // Debug printout + if ( fDebug > 2 ) { + const UInt_t N = static_cast(fNelem); + Double_t pos[3]; fOrigin.GetXYZ(pos); + DBRequest list[] = { + { "Number of paddles", &fNelem, kInt }, + { "Detector position", pos, kDouble, 3 }, + { "Detector size", fSize, kDouble, 3 }, + { "Detector angle", &angle, }, + { "TDC offsets Left", fLOff, kDouble, N }, + { "TDC offsets Right", fROff, kDouble, N }, + { "ADC pedestals Left", fLPed, kDouble, N }, + { "ADC pedestals Right", fRPed, kDouble, N }, + { "ADC gains Left", fLGain, kDouble, N }, + { "ADC gains Right", fRGain, kDouble, N }, + { "TDC resolution", &fTdc2T }, + { "Light propag. speed", &fCn }, + { "ADC MIP", &fAdcMIP }, + { "Num timewalk params", &fNTWalkPar, kInt }, + { "Timewalk params", fTWalkPar, kDouble, 2*N }, + { "Trigger time offsets", fTrigOff, kDouble, N }, + { "Time resolution", &fResolution }, + { "Attenuation", &fAttenuation }, + { 0 } + }; + DebugPrint( list ); } +#endif return kOK; } @@ -400,15 +415,27 @@ Int_t THaScintillator::Decode( const THaEvData& evdata ) } } } + +#ifdef WITH_DEBUG if ( fDebug > 3 ) { - printf("\n\nEvent %d Trigger %d Scintillator %s\n:", - evdata.GetEvNum(), evdata.GetEvType(), GetPrefix() ); - printf(" paddle Left(TDC ADC ADC_p) Right(TDC ADC ADC_p)\n"); + cout << endl << endl; + cout << "Event " << evdata.GetEvNum() << " Trigger " << evdata.GetEvType() + << " Scintillator " << GetPrefix() << endl; + cout << " paddle Left(TDC ADC ADC_p) Right(TDC ADC ADC_p)" << endl; + cout << right; for ( int i=0; i #include +#include #include using namespace std; @@ -211,6 +212,29 @@ Int_t THaShower::ReadDatabase( const TDatime& date ) if( err ) return err; +#ifdef WITH_DEBUG + // Debug printout + if ( fDebug > 2 ) { + const UInt_t N = static_cast(fNelem); + Double_t pos[3]; fOrigin.GetXYZ(pos); + DBRequest list[] = { + { "Number of blocks", &fNelem, kInt }, + { "Detector center", pos, kDouble, 3 }, + { "Detector size", fSize, kDouble, 3 }, + { "Detector angle", &angle }, + { "Channel map", &chanmap[0], kInt, N }, + { "Position of block 1", &xy, kDoubleV }, + { "Block x/y spacings", &dxy, kDoubleV }, + { "Minimum cluster energy", &fEmin, kFloat, 1 }, + { "ADC pedestals", fPed, kFloat, N }, + { "ADC pedestals", fPed, kFloat, N }, + { "ADC gains", fGain, kFloat, N }, + { 0 } + }; + DebugPrint( list ); + } +#endif + return kOK; } @@ -348,24 +372,27 @@ Int_t THaShower::Decode( const THaEvData& evdata ) #ifdef WITH_DEBUG if ( fDebug > 3 ) { - printf("\nShower Detector %s:\n",GetPrefix()); + cout << endl << "Shower Detector " << GetPrefix() << ":" << endl; int ncol=3; for (int i=0; i #include #include +#include #ifdef CLUST_RAWDATA_HACK #include @@ -262,6 +263,34 @@ Int_t THaVDCPlane::ReadDatabase( const TDatime& date ) // "Event-by-event time offsets will NOT be used!!",nm); } +#ifdef WITH_DEBUG + if( fDebug > 2 ) { + Double_t pos[3]; fOrigin.GetXYZ(pos); + Double_t angle = fWAngle*TMath::RadToDeg(); + DBRequest list[] = { + { "Number of wires", &fNelem, kInt }, + { "Detector position", pos, kDouble, 3 }, + { "Detector size", fSize, kDouble, 3 }, + { "Wire angle (deg)", &angle }, + { "Wire start pos (m)", &fWBeg }, + { "Wire spacing (m)", &fWSpac }, + { "TDC resolution (s/chan)", &fTDCRes }, + { "Drift Velocity (m/s) ", &fDriftVel }, + { "Min TDC raw time", &fMinTime, kInt }, + { "Max TDC raw time", &fMaxTime, kInt }, + { "Min adj wire tdiff (s)", &fMinTdiff }, + { "Max adj wire tdiff (s)", &fMaxTdiff }, + { "Time-to-dist conv param", &ttd_param, kDoubleV }, + { "Max gap in cluster", &fNMaxGap, kInt }, + { "Min cluster size", &fMinClustSize, kInt }, + { "Max cluster span", &fMaxClustSpan, kInt }, + { "t0 resolution (s)", &fT0Resolution }, + { 0 } + }; + DebugPrint( list ); + } +#endif + fIsInit = true; return kOK; } @@ -432,31 +461,33 @@ Int_t THaVDCPlane::Decode( const THaEvData& evData ) fHits->Sort(); +#ifdef WITH_DEBUG if ( fDebug > 3 ) { - printf("\nVDC %s:\n",GetPrefix()); + cout << endl << "VDC plane " << GetPrefix() << endl; int ncol=4; for (int i=0; i(fHits->At(ind)); - printf(" %3d %5d ",hit->GetWireNum(),hit->GetRawTime()); + cout << " " << setw(3) << hit->GetWireNum() + << " " << setw(5) << hit->GetRawTime() << " "; } else { - // printf("\n"); + // cout << endl; break; } } - printf("\n"); + cout << endl; } } +#endif return 0; - }