From 2a31779100407c8d99ea2e9e10c5463b661f5b51 Mon Sep 17 00:00:00 2001 From: Chao Peng <thor1009@gmail.com> Date: Wed, 1 Jan 2020 16:50:42 -0600 Subject: [PATCH] add logger messages in helicity related classes and expose data in THcHelicityScaler --- src/THcHelicity.cxx | 18 ++++++++---------- src/THcHelicityReader.cxx | 9 ++++----- src/THcHelicityScaler.h | 9 +++++++++ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/THcHelicity.cxx b/src/THcHelicity.cxx index a242703..69453bb 100644 --- a/src/THcHelicity.cxx +++ b/src/THcHelicity.cxx @@ -490,17 +490,15 @@ Int_t THcHelicity::Decode(const THaEvData& evdata) { } } else { if (fNCycle - fFirstCycle > 4) { // Not at start of run. Reset - _logger->warn("Lost quarted sync at cycle {}", fNCycle); - cout << fQuartet[0] << " " << fQuartet[1] << " " << fQuartet[2] << " " - << fQuartet[3] << endl; + _logger->warn("Lost quartet sync at cycle {}: {} {} {} {}", fNCycle, + fQuartet[0], fQuartet[1], fQuartet[2], fQuartet[3]); fFirstCycle += 4 * ((fNCycle - fFirstCycle) / 4); // Update, but don't change phase } fFoundQuartet = kFALSE; fNBits = 0; - _logger->info("Searching for first of a quaret at cycle {}", fFirstCycle); - cout << fQuartet[0] << " " << fQuartet[1] << " " << fQuartet[2] << " " - << fQuartet[3] << endl; + _logger->info("Searching for first of a quartet at cycle {}: {} {} {} {}", fFirstCycle, + fQuartet[0], fQuartet[1], fQuartet[2], fQuartet[3]); fFirstCycle++; } } else { @@ -577,6 +575,7 @@ void THcHelicity::SetDebug(Int_t level) { //_____________________________________________________________________________ void THcHelicity::LoadHelicity(Int_t reportedhelicity, Int_t cyclecount, Int_t missedcycles) { + // static const char* const here = "THcHelicity::LoadHelicity"; int quartetphase = (cyclecount - fFirstCycle) % 4; fnQrt = quartetphase; @@ -619,13 +618,12 @@ void THcHelicity::LoadHelicity(Int_t reportedhelicity, Int_t cyclecount, Int_t m fNBits = 0; fRingSeed_reported = 0; } else if (fNBits == fMAXBIT) { - cout << "Seed Found " << bitset<32>(fRingSeed_reported) << " at cycle " << cyclecount - << " with first cycle " << fFirstCycle << endl; + _logger->info("Seed Found {:32b} at cycle {} with first cycle {}", fRingSeed_reported, cyclecount, fFirstCycle); if (fglHelicityScaler) { - cout << "Scaler Seed " << bitset<32>(fScalerSeed) << endl; + _logger->info("Scaler Seed {:32b}", fScalerSeed); } Int_t backseed = GetSeed30(fRingSeed_reported); - cout << "Seed at cycle " << fFirstCycle << " should be " << hex << backseed << dec << endl; + _logger->info("Seed at cycle {} should be {:#x}", fFirstCycle, backseed); // Create the "actual seed" fRingSeed_actual = fRingSeed_reported; for (Int_t i = 0; i < fHelDelay / 4; i++) { diff --git a/src/THcHelicityReader.cxx b/src/THcHelicityReader.cxx index 39080f5..d6ad9a1 100644 --- a/src/THcHelicityReader.cxx +++ b/src/THcHelicityReader.cxx @@ -45,9 +45,10 @@ Int_t THcHelicityReader::ReadDatabase(const char* /*dbfilename*/, const char* /* const TDatime& /*date*/, int /*debug_flag*/) { // Eventually get these from the parameter file + const static char* const here = "THcHelicityReader::ReadDatabase"; // SHMS settings see https://logbooks.jlab.org/entry/3614445 - cout << "THcHelicityReader: Helicity information from ROC 2 (SHMS)" << endl; + _logger->info("{}: Helicity information from ROC 2 (SHMS)", here); SetROCinfo(kHel, 2, 14, 9); SetROCinfo(kHelm, 2, 14, 8); SetROCinfo(kMPS, 2, 14, 10); @@ -106,8 +107,7 @@ Int_t THcHelicityReader::ReadData(const THaEvData& evdata) { // Check if ROC info is correct if (!evdata.GetModule(fROCinfo[kTime].roc, fROCinfo[kTime].slot)) { - cout << "THcHelicityReader: ROC 2 not found" << endl; - cout << "Changing to ROC 1 (HMS)" << endl; + _logger->info("{}: ROC 2 not found, changing to ROC 1 (HMS)", here); SetROCinfo(kHel, 1, 18, 9); SetROCinfo(kHelm, 1, 18, 8); SetROCinfo(kMPS, 1, 18, 10); @@ -122,8 +122,7 @@ Int_t THcHelicityReader::ReadData(const THaEvData& evdata) { (UInt_t)evdata.GetData(fROCinfo[kTime].roc, fROCinfo[kTime].slot, fROCinfo[kTime].index, 0); // Check again if ROC info is correct if (titime == 0 && fTITime_last == 0) { - cout << "THcHelicityReader: ROC 2 not found" << endl; - cout << "Changing to ROC 1 (HMS)" << endl; + _logger->info("{}: ROC 2 not found, changing to ROC 1 (HMS)", here); SetROCinfo(kHel, 1, 18, 9); SetROCinfo(kHelm, 1, 18, 8); SetROCinfo(kMPS, 1, 18, 10); diff --git a/src/THcHelicityScaler.h b/src/THcHelicityScaler.h index f39b2b7..9b193df 100644 --- a/src/THcHelicityScaler.h +++ b/src/THcHelicityScaler.h @@ -49,6 +49,15 @@ public: virtual Int_t GetReportedActual() {return fRingSeed_actual;} virtual Bool_t IsSeedGood() {return fNBits>=30;} + const std::vector<Double_t> &GetScalerSums() const { return fScalerSums; } + const std::vector<Double_t> &GetAsymmetry() const { return fAsymmetry; } + const std::vector<Double_t> &GetAsymmetryError() const { return fAsymmetryError; } + const std::vector<Double_t> &GetCharge() const { return fCharge; } + const std::vector<Double_t> &GetChargeAsymmetry() const { return fChargeAsymmetry; } + Double_t GetTime() const { return fTime; } + Double_t GetTimeAsymmetry() const { return fTimeAsymmetry; } + Double_t GetTriggerAsymmetry() const { return fTriggerAsymmetry; } + private: Int_t RanBit30(Int_t ranseed); -- GitLab