From b125a9d8fa4b19d615b2acf2192475471a1ccc46 Mon Sep 17 00:00:00 2001 From: Whitney Armstrong <warmstrong@anl.gov> Date: Tue, 11 Dec 2018 11:00:12 -0600 Subject: [PATCH] Added logging to many. - Added logging to hodoscope, aerogel hitlist and detectormap - Working on scandalizer features. --- src/Scandalizer.cxx | 22 ++++++++++------------ src/Scandalizer.h | 3 ++- src/THcAerogel.cxx | 10 ++++++---- src/THcAerogel.h | 5 ++++- src/THcDetectorMap.cxx | 2 +- src/THcHitList.cxx | 6 ++++-- src/THcHodoscope.cxx | 12 ++++++++---- 7 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/Scandalizer.cxx b/src/Scandalizer.cxx index df88dca..6d10a1d 100644 --- a/src/Scandalizer.cxx +++ b/src/Scandalizer.cxx @@ -141,23 +141,14 @@ Int_t Scandalizer::Process( THaRunBase* run ) //&& (status = ReadOneEvent()) != THaRunBase::READ_EOF ) //std::cout << " evtype(last) " << fEvData->GetEvType() << "\n"; status = ReadOneEvent(); - //std::cout << " status " << status << "\n"; - //std::cout << " evtype " << fEvData->GetEvType() << "\n"; // If an interupt signal is sent (ctrl-c) - // // if(sig_caught) { terminate = true; break; } - if( status == THaRunBase::READ_EOF ) { - //if( fEvData->GetEvType() != 20 ) { - // std::cout << " sleeping...."; - // //gSystem->Sleep(1000); - //}else { - //} break; } @@ -175,10 +166,10 @@ Int_t Scandalizer::Process( THaRunBase* run ) // Count events according to the requested mode // Whether or not to ignore events prior to fRun->GetFirstEvent() // is up to the analysis routines. - switch(fCountMode) { + switch (fCountMode) { case kCountPhysics: - if( fEvData->IsPhysicsTrigger() ) - fNev++; + if (fEvData->IsPhysicsTrigger()) + fNev++; break; case kCountAll: fNev++; @@ -194,10 +185,17 @@ Int_t Scandalizer::Process( THaRunBase* run ) if( (fVerbose>1) && (evnum > 0) && (evnum % fMarkInterval == 0)){ cout << "test run: "<< fRun->GetNumber() << ", " << dec << evnum << endl; } + // Auto save file so it is not junk and can be processed while we write if( (evnum > 0) &&(evnum % fAutoSaveInterval == 0)){ fOutput->GetTree()->AutoSave("SaveSelf"); } + if(_skip_events > 0 ) { + _skip_events--; + continue; + } + + //--- Update run parameters with current event if( fUpdateRun ){ fRun->Update( fEvData ); diff --git a/src/Scandalizer.h b/src/Scandalizer.h index 7b08e1c..0e662ea 100644 --- a/src/Scandalizer.h +++ b/src/Scandalizer.h @@ -14,8 +14,9 @@ namespace hcana { virtual Int_t Process(THaRunBase* run = nullptr); virtual Int_t ReadOneEvent(); + //Int_t GoToEndOfCodaFile(); - Int_t GoToEndOfCodaFile(); + int _skip_events = 0; ClassDef(Scandalizer, 0) // Hall C Analyzer Standard Event Loop }; diff --git a/src/THcAerogel.cxx b/src/THcAerogel.cxx index 3b53d46..5da888e 100644 --- a/src/THcAerogel.cxx +++ b/src/THcAerogel.cxx @@ -36,7 +36,7 @@ using namespace std; //_____________________________________________________________________________ THcAerogel::THcAerogel( const char* name, const char* description, THaApparatus* apparatus ) : - THaNonTrackingDetector(name,description,apparatus) + hcana::ConfigLogging<THaNonTrackingDetector>(name,description,apparatus) { InitArrays(); @@ -45,7 +45,7 @@ THcAerogel::THcAerogel( const char* name, const char* description, //_____________________________________________________________________________ THcAerogel::THcAerogel( ) : - THaNonTrackingDetector() + hcana::ConfigLogging<THaNonTrackingDetector>() { // Constructor frPosAdcPedRaw = NULL; @@ -234,8 +234,10 @@ Int_t THcAerogel::ReadDatabase( const TDatime& date ) Bool_t optional = true ; - cout << "Created aerogel detector " << GetApparatus()->GetName() << "." - << GetName() << " with " << fNelem << " PMT pairs" << endl; + _logger->info("Created aerogel detector {}.{} with {} PMT pairs.", GetApparatus()->GetName(), + GetName(), fNelem); + //cout << "Created aerogel detector " << GetApparatus()->GetName() << "." + // << GetName() << " with " << fNelem << " PMT pairs" << endl; fPosGain = new Double_t[fNelem]; fNegGain = new Double_t[fNelem]; diff --git a/src/THcAerogel.h b/src/THcAerogel.h index a3e7176..1ac0606 100644 --- a/src/THcAerogel.h +++ b/src/THcAerogel.h @@ -11,9 +11,12 @@ #include "THaNonTrackingDetector.h" #include "THcHitList.h" #include "THcAerogelHit.h" + +#include "Logger.h" + class THcHodoscope; -class THcAerogel : public THaNonTrackingDetector, public THcHitList { +class THcAerogel : public hcana::ConfigLogging<THaNonTrackingDetector>, public THcHitList { public: THcAerogel(const char* name, const char* description = "", THaApparatus* a = NULL); diff --git a/src/THcDetectorMap.cxx b/src/THcDetectorMap.cxx index 2d54023..3cdc61d 100644 --- a/src/THcDetectorMap.cxx +++ b/src/THcDetectorMap.cxx @@ -411,7 +411,7 @@ void THcDetectorMap::Load(const char *fname) for(Int_t i=0; i < fNIDs; i++) { //cout << " "; //cout << fIDMap[i].name << " " << fIDMap[i].id << endl; - _logger->info(" {:>12} {:<10} ", fIDMap[i].name ,fIDMap[i].id ); + _logger->info(" {:<10} {:<10} ", fIDMap[i].name ,fIDMap[i].id ); } //cout << endl; diff --git a/src/THcHitList.cxx b/src/THcHitList.cxx index 3113776..777fcc0 100644 --- a/src/THcHitList.cxx +++ b/src/THcHitList.cxx @@ -23,10 +23,12 @@ using namespace std; #define SUPPRESSMISSINGADCREFTIMEMESSAGES 1 THcHitList::THcHitList() : fMap(0), fTISlot(0), fDisableSlipCorrection(kFALSE) { - _hitlist_logger = spdlog::get("hitlist"); + _hitlist_logger = spdlog::get("hitlst"); if(!_hitlist_logger) { - _hitlist_logger = spdlog::stdout_color_mt("hitlist"); + _hitlist_logger = spdlog::stdout_color_mt("hitlst"); + _hitlist_logger->set_pattern("[%t] [%n] %^[%l]%$ %v"); } + /// Normal constructor. fRawHitList = NULL; diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index 15d70e9..1e54a6f 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -159,7 +159,8 @@ THaAnalysisObject::EStatus THcHodoscope::Init( const TDatime& date ) EngineDID[0] = toupper(GetApparatus()->GetName()[0]); if( gHcDetectorMap->FillMap(fDetMap, EngineDID) < 0 ) { static const char* const here = "Init()"; - Error( Here(here), "Error filling detectormap for %s.", EngineDID ); + //Error( Here(here), "Error filling detectormap for %s.", EngineDID ); + _logger->error("Error filling detectormap for {}.",EngineDID); return kInitError; } @@ -167,7 +168,8 @@ THaAnalysisObject::EStatus THcHodoscope::Init( const TDatime& date ) // maximum number of hits after setting up the detector map // But it needs to happen before the sub detectors are initialized // so that they can get the pointer to the hitlist. - cout << " Hodo tdc ref time cut = " << fTDC_RefTimeCut << " " << fADC_RefTimeCut << endl; + _logger->info("Hodo tdc ref time cut = {} {}", fTDC_RefTimeCut, fADC_RefTimeCut); + //cout << " Hodo tdc ref time cut = " << fTDC_RefTimeCut << " " << fADC_RefTimeCut << endl; InitHitList(fDetMap, "THcRawHodoHit", fDetMap->GetTotNumChan()+1, fTDC_RefTimeCut, fADC_RefTimeCut); @@ -516,11 +518,13 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) } // if ((fTofTolerance > 0.5) && (fTofTolerance < 10000.)) { - cout << "USING "<<fTofTolerance<<" NSEC WINDOW FOR FP NO_TRACK CALCULATIONS.\n"; + //cout << "USING "<<fTofTolerance<<" NSEC WINDOW FOR FP NO_TRACK CALCULATIONS.\n"; + _logger->info("Using {} nsec window for fp no_track calculations.",fTofTolerance); } else { fTofTolerance= 3.0; - cout << "*** USING DEFAULT 3 NSEC WINDOW FOR FP NO_TRACK CALCULATIONS!! ***\n"; + //cout << "*** USING DEFAULT 3 NSEC WINDOW FOR FP NO_TRACK CALCULATIONS!! ***\n"; + _logger->warn("Using default {} nsec window for fp no_track calculations.",fTofTolerance); } fIsInit = true; return kOK; -- GitLab