From c2366398e6d00ec1fcb06134969cbfc624492e41 Mon Sep 17 00:00:00 2001 From: Felix Hagemann Date: Wed, 2 Sep 2026 11:19:28 -0700 Subject: [PATCH] CHG: Enclose all `cout` statements in `g_Verbosity` --- src/MGUIExpoDepthCalibration.cxx | 2 +- src/MGUIExpoTACcut.cxx | 2 +- src/MModuleDepthCalibration.cxx | 99 ++++++++++++++------------ src/MModuleEnergyCalibration.cxx | 8 +-- src/MModuleLoaderMeasurementsHDF.cxx | 20 +++--- src/MModuleLoaderMeasurementsL0.cxx | 2 +- src/MModuleLoaderMeasurementsROA.cxx | 16 +++-- src/MModuleLoaderSimulationsCosima.cxx | 2 +- src/MModuleResponseGenerator.cxx | 4 +- src/MModuleRevan.cxx | 4 +- src/MModuleTACCalibration.cxx | 14 ++-- src/MSubModuleChargeTransport.cxx | 14 ++-- src/MSubModuleShieldTrigger.cxx | 6 +- src/MSubModuleStripTrigger.cxx | 4 +- 14 files changed, 107 insertions(+), 90 deletions(-) diff --git a/src/MGUIExpoDepthCalibration.cxx b/src/MGUIExpoDepthCalibration.cxx index c4a0751e..d1a3d55b 100644 --- a/src/MGUIExpoDepthCalibration.cxx +++ b/src/MGUIExpoDepthCalibration.cxx @@ -98,7 +98,7 @@ void MGUIExpoDepthCalibration::SetDepthHistogramArrangement(vector unsigned int max_columns = 4; unsigned int NDetectors = DetIDs->size(); - cout<<"MGUIExpoDepthCalibration::SetDepthHistogramArrangement: Number of detectors:" << NDetectors<= c_Info) cout<<"MGUIExpoDepthCalibration::SetDepthHistogramArrangement: Number of detectors:" << NDetectors< DetID unsigned int max_columns = 4; unsigned int NDetectors = DetIDs.size(); - cout<<"MGUIExpoTACcut::SetTACHistogramArrangement: Number of detectors:"<< NDetectors<= c_Info) cout<<"MGUIExpoTACcut::SetTACHistogramArrangement: Number of detectors:"<< NDetectors<= c_Error) cout<< m_XmlTag << ": ERROR: No Strip3D detectors were found."<= c_Info) cout << m_XmlTag << ": !!! Mask Metrology Enabled !!!" << endl; m_MaskMetrologyFileIsLoaded = LoadMaskMetrologyFile(m_MaskMetrologyFileName); if (m_MaskMetrologyFileIsLoaded == false) { - if (g_Verbosity >= c_Error) cout << m_XmlTag << "Unable to open Metrology file" << endl; + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: Unable to open Metrology file" << endl; return false; } } @@ -154,7 +154,9 @@ bool MModuleDepthCalibration::Initialize() MSupervisor* S = MSupervisor::GetSupervisor(); m_EnergyCalibration = (MModuleEnergyCalibration*) S->GetAvailableModuleByXmlTag("XmlTagEnergyCalibration"); if (m_EnergyCalibration == nullptr) { - cout << "MModuleDepthCalibration: couldn't resolve pointer to Energy Calibration Module... need access to this module for energy resolution lookup!" << endl; + if (g_Verbosity >= c_Error) { + cout << m_XmlTag << ": ERROR: Could not resolve pointer to Energy Calibration Module... need access to this module for energy resolution lookup!" << endl; + } return false; } @@ -316,11 +318,11 @@ bool MModuleDepthCalibration::AnalyzeEvent(MReadOutAssembly* Event) Event->SetDepthCalibrationError("No calibration coefficients"); ++m_Error1; } else if (CTDVec.size() == 0) { - if (g_Verbosity >= c_Error) cout << m_XmlTag << "Empty CTD vector" << endl; + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: Empty CTD vector" << endl; H->SetNoDepth(); Event->SetDepthCalibrationError("No calibration coefficients"); } else if (DepthVec.size() == 0) { - if (g_Verbosity >= c_Error) cout << m_XmlTag << "Empty Depth vector" << endl; + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: Empty Depth vector" << endl; H->SetNoDepth(); Event->SetDepthCalibrationError("No calibration coefficients"); } else if ((LVTiming < 1.0E-6) || (HVTiming < 1.0E-6)) { @@ -391,7 +393,7 @@ bool MModuleDepthCalibration::AnalyzeEvent(MReadOutAssembly* Event) } } - if (g_Verbosity >= c_Info) cout << m_XmlTag << "Strip ID :" << LVStripID << " " << HVStripID << endl << "Hit position: "<< Xpos << " " << Ypos << " " << Zpos << endl; + if (g_Verbosity >= c_Info) cout << m_XmlTag << ": Strip ID :" << LVStripID << " " << HVStripID << endl << "Hit position: "<< Xpos << " " << Ypos << " " << Zpos << endl; MVector LocalPosition(Xpos, Ypos, Zpos); MVector LocalOrigin(0.0, 0.0, 0.0); @@ -498,7 +500,7 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry) DetectorName.RemoveAllInPlace("GeD_"); // The number after GeD is the COSI detector ID if (DetID != DetectorName.ToUnsignedInt()) { if (g_Verbosity >= c_Error) { - cout << "ERROR in MModuleDepthCalibration::Initialize: Non-matching DetID="<GetName() == "COSI-SMEX-Payload"){ @@ -507,7 +509,7 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry) } } else if (Geometry->GetName() == "COSI-SMEX-Payload") { if (g_Verbosity >= c_Error) { - cout << "ERROR in MModuleDepthCalibration::Initialize: COSI-SMEX-Payload expects all Strip3D detectors to follow the name scheme GeD_X"<= c_Error) { - cout<<"ERROR in MModuleDepthCalibration::Initialize: Found a duplicate detector: "<= c_Error) { - cout<<"ERROR in MModuleDepthCalibration::Initialize: Found a Strip3D detector with "<GetNSensitiveVolumes()<<" Sensitive Volumes."<GetNSensitiveVolumes()<<" Sensitive Volumes."<= c_Error) cout << m_XmlTag << ": ERROR: Failed to open depth coefficients file." << endl; return false; } @@ -662,7 +664,7 @@ bool MModuleDepthCalibration::LoadCoeffsFile(MString FileName) std::vector Tokens = Line.Tokenize(" "); m_Coeffs_Energy = Tokens[5].ToDouble(); if (g_Verbosity >= c_Info) { - cout << m_XmlTag << "The stretch and offset were calculated for " << m_Coeffs_Energy << " keV." << endl; + cout << m_XmlTag << ": The stretch and offset were calculated for " << m_Coeffs_Energy << " keV." << endl; } } else { std::vector Tokens = Line.Tokenize(","); @@ -698,12 +700,14 @@ std::vector* MModuleDepthCalibration::GetPixelCoeffs(int PixelCode) return &m_Coeffs[PixelCode]; } else { if (g_Verbosity >= c_Warning) { - cout << "MModuleDepthCalibration::GetPixelCoeffs: cannot get stretch and offset; pixel code " << PixelCode << " not found." << endl; + cout << m_XmlTag << ": GetPixelCoeffs cannot get stretch and offset; pixel code " << PixelCode << " not found." << endl; } return nullptr; } } else { - cout << "MModuleDepthCalibration::GetPixelCoeffs: cannot get stretch and offset; file has not yet been loaded." << endl; + if (g_Verbosity >= c_Warning) { + cout << m_XmlTag << ": GetPixelCoeffs cannot get stretch and offset; file has not yet been loaded." << endl; + } return nullptr; } @@ -735,7 +739,7 @@ bool MModuleDepthCalibration::LoadSplinesFile(MString FileName) // '' '' '' MFile SplineFile; if (SplineFile.Open(FileName) == false) { - cout << "ERROR in MModuleDepthCalibration::LoadSplinesFile: failed to open splines file." << endl; + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: LoadSplinesFile failed to open depth splines file." << endl; return false; } @@ -795,7 +799,7 @@ bool MModuleDepthCalibration::LoadMaskMetrologyFile(MString FileName) // Det ID, Side (l,h), Strip ID (0-63), x_mm, y_mm, z_mm, roll_deg, pitch_deg, yaw_deg MFile MetrologyFile; if (MetrologyFile.Open(FileName) == false) { - cout << "ERROR in MModuleDepthCalibration::LoadMaskMetrologyFile: failed to open metrology file." << endl; + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: LoadMaskMetrologyFile failed to open metrology file." << endl; return false; } @@ -823,7 +827,7 @@ bool MModuleDepthCalibration::LoadMaskMetrologyFile(MString FileName) // Make the map that defines the metrology info for each readout element m_MaskMetrology[R] = maskmet; } else { - cout << "ERROR in MModuleDepthCalibration::LoadMaskMetrologyFile: incorrect number of tokens in the file." << endl; + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: LoadMaskMetrologyFile found incorrect number of tokens in the file." << endl; return false; } } @@ -859,7 +863,7 @@ vector MModuleDepthCalibration::GetStripIntersection(MReadOutElementDoub double denominator1 = tan(LVStripMet[5]*TMath::DegToRad()); double denominator2 = tan((HVStripMet[5]-90)*TMath::DegToRad())-1/tan(LVStripMet[5]*TMath::DegToRad()); if (denominator1 == 0.0 || denominator2 == 0.0) { - if (g_Verbosity >= c_Error) cout << m_XmlTag << ": Strip Intersection gives divide by zero - returning unrotated hit position" << endl; + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: Strip Intersection gives divide by zero - returning unrotated hit position" << endl; double Xpos = m_YPitches[DetID]*((double)R_LVStrip.GetStripID() - ((m_NYStrips[DetID]-1)/2.0)); double Ypos = m_XPitches[DetID]*((double)R_HVStrip.GetStripID() - ((m_NXStrips[DetID]-1)/2.0)); return {Xpos, Ypos}; @@ -889,7 +893,7 @@ int MModuleDepthCalibration::GetHitGrade(MHit* H){ } if (H->GetNStripHits() == 0) { // Error if no strip hits listed. Bad grade is returned - if (g_Verbosity >= c_Error) cout << m_XmlTag << "ERROR in MModuleDepthCalibration: HIT WITH NO STRIP HITS" << endl; + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: Hit with no strip hits" << endl; return -1; } @@ -900,12 +904,12 @@ int MModuleDepthCalibration::GetHitGrade(MHit* H){ vector HVStripIDs; for (unsigned int j = 0; j < H->GetNStripHits(); ++j) { MStripHit* SH = H->GetStripHit(j); - if (SH == nullptr ) { - if (g_Verbosity >= c_Error) cout << m_XmlTag << "ERROR in MModuleDepthCalibration: Depth Calibration: got NULL strip hit :( " << endl; + if (SH == nullptr) { + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: Got nullptr as strip hit :( " << endl; return -1; } - if (SH->GetEnergy() == 0 ) { - if (g_Verbosity >= c_Error) cout << m_XmlTag << "ERROR in MModuleDepthCalibration: Depth Calibration: got strip without energy :( " << endl; + if (SH->GetEnergy() == 0) { + if (g_Verbosity >= c_Error) cout << m_XmlTag << ": ERROR: Got strip without energy :( " << endl; return -1; } if (SH->IsLowVoltageStrip()) { @@ -1027,14 +1031,16 @@ bool MModuleDepthCalibration::AddDepthCTD(vector Depth, vector 0.01) { - cout<<"ERROR in MModuleDepthCalibration::AddDepthCTD: The thickness of detector "<= c_Error) { + cout<0) { - cout<<"MModuleDepthCalibration::AddDepthCTD: Splines already added for DetID "<= c_Error) cout< TempVec; @@ -1108,7 +1114,7 @@ vector MModuleDepthCalibration::GetCTD(int DetID, int Grade) if (m_SplinesFileIsLoaded == false) { if (g_Verbosity >= c_Warning) { - cout << "MModuleDepthCalibration::GetCTD: cannot return Depth to CTD relation because the file was not loaded." << endl; + cout << m_XmlTag << ": GetCTD cannot return Depth to CTD relation because the file was not loaded." << endl; } return vector (); } @@ -1122,7 +1128,7 @@ vector MModuleDepthCalibration::GetCTD(int DetID, int Grade) // } } else { if (g_Verbosity >= c_Warning) { - cout << "MModuleDepthCalibration::GetCTD: No CTD map is loaded for Det " << DetID << "." << endl; + cout << m_XmlTag << ": GetCTD: No CTD map is loaded for Det " << DetID << "." << endl; } return vector (); } @@ -1138,7 +1144,7 @@ vector MModuleDepthCalibration::GetDepth(int DetID) if (m_SplinesFileIsLoaded == false) { if (g_Verbosity >= c_Warning) { - cout << "MModuleDepthCalibration::GetDepth: cannot return Depth grid because the file was not loaded." << endl; + cout << m_XmlTag << ": GetDepth cannot return Depth grid because the file was not loaded." << endl; } return vector (); } @@ -1147,7 +1153,7 @@ vector MModuleDepthCalibration::GetDepth(int DetID) return m_DepthGrid[DetID]; } else { if (g_Verbosity >= c_Warning) { - cout << "MModuleDepthCalibration::GetDepth: No Depth grid is loaded for Det " << DetID << "." << endl; + cout << m_XmlTag << ": GetDepth: No Depth grid is loaded for Det " << DetID << "." << endl; } return vector (); } @@ -1162,7 +1168,7 @@ TSpline3* MModuleDepthCalibration::GetSpline(int DetID, int Grade) if(m_SplinesFileIsLoaded == false){ if (g_Verbosity >= c_Warning) { - cout << "MModuleDepthCalibration::GetSpline: cannot return Depth to CTD spline because the file was not loaded." << endl; + cout << m_XmlTag << ": GetSpline cannot return Depth to CTD spline because the file was not loaded." << endl; } return nullptr; } @@ -1178,7 +1184,7 @@ TSpline3* MModuleDepthCalibration::GetSpline(int DetID, int Grade) // } } else { if (g_Verbosity >= c_Warning) { - cout << "MModuleDepthCalibration::GetSpline: No spline is loaded for Det " << DetID << "." << endl; + cout << m_XmlTag << ": GetSpline: No spline is loaded for Det " << DetID << "." << endl; } return nullptr; } @@ -1265,19 +1271,22 @@ void MModuleDepthCalibration::Finalize() { MModule::Finalize(); - cout << "###################" << endl; - cout << "AWL depth cal stats" << endl; - cout << "###################" << endl; - cout << "Good hits: " << m_NoError << endl; - cout << "Number of hits missing calibration coefficients: " << m_Error1 << endl; - cout << "Number of hits too far outside of detector: " << m_Error2 << endl; - cout << "Number of hits missing timing information: " << m_Error3 << endl; - cout << "Number of hits with strips hit multiple times: " << m_Error5 << endl; - cout << "Number of hits with non-adjacent strip hits: " << m_Error6 << endl; - cout << "Number of hits with too many strip hits: " << m_Error4 << endl; - cout << "Number of hits with no strip hits on one or both sides: " << m_ErrorSH << endl; - cout << "Number of hits with null strip hits: " << m_ErrorNullSH << endl; - cout << "Number of hits 0 energy on a strip hit: " << m_ErrorNoE << endl; + + if (g_Verbosity >= c_Info) { + cout << "###################" << endl; + cout << "AWL depth cal stats" << endl; + cout << "###################" << endl; + cout << "Good hits: " << m_NoError << endl; + cout << "Number of hits missing calibration coefficients: " << m_Error1 << endl; + cout << "Number of hits too far outside of detector: " << m_Error2 << endl; + cout << "Number of hits missing timing information: " << m_Error3 << endl; + cout << "Number of hits with strips hit multiple times: " << m_Error5 << endl; + cout << "Number of hits with non-adjacent strip hits: " << m_Error6 << endl; + cout << "Number of hits with too many strip hits: " << m_Error4 << endl; + cout << "Number of hits with no strip hits on one or both sides: " << m_ErrorSH << endl; + cout << "Number of hits with null strip hits: " << m_ErrorNullSH << endl; + cout << "Number of hits 0 energy on a strip hit: " << m_ErrorNoE << endl; + } // Clean up maps and vectors m_Coeffs.clear(); diff --git a/src/MModuleEnergyCalibration.cxx b/src/MModuleEnergyCalibration.cxx index b4c54b62..cf142d86 100644 --- a/src/MModuleEnergyCalibration.cxx +++ b/src/MModuleEnergyCalibration.cxx @@ -284,7 +284,7 @@ double MModuleEnergyCalibration::GetEnergy(MReadOutElementDoubleStrip R, double Energy = 0.0; } } else { - cout << m_Name << ": GetEnergy: Error unable to find calibration" << endl; + if (g_Verbosity >= c_Warning) cout << m_XmlTag << ": GetEnergy: Error unable to find calibration" << endl; return 0; } @@ -303,7 +303,7 @@ double MModuleEnergyCalibration::GetADC(MReadOutElementDoubleStrip R, double Ene if (Fit != nullptr) { return Fit->GetX(Energy); } else { - cout << m_Name << ": GetADC: Error unable to find calibration" << endl; + if (g_Verbosity >= c_Warning) cout << m_XmlTag << ": GetADC: Error unable to find calibration" << endl; return 0; } } @@ -638,12 +638,12 @@ double MModuleEnergyCalibration::LookupEnergyResolution(MStripHit* SH, double En MReadOutElementDoubleStrip* ROE = dynamic_cast(SH->GetReadOutElement()); if (ROE == nullptr) { - cout << m_Name << ": LookupEnergyResolution: Error unable to get read-out element" << endl; + if (g_Verbosity >= c_Error) cout << m_Name << ": ERROR: LookupEnergyResolution unable to get read-out element" << endl; return -1; } TF1* FitRes = m_ResolutionCalibration[*ROE]; if (FitRes == nullptr) { - cout << m_Name << ": LookupEnergyResolutio: Error: Couldn't locate energy resolution" << endl; + if (g_Verbosity >= c_Error) cout << m_Name << ": ERROR: LookupEnergyResolution couldn't locate energy resolution" << endl; return -1.0; } else { return FitRes->Eval(Energy); diff --git a/src/MModuleLoaderMeasurementsHDF.cxx b/src/MModuleLoaderMeasurementsHDF.cxx index a7d7e4a3..94001668 100644 --- a/src/MModuleLoaderMeasurementsHDF.cxx +++ b/src/MModuleLoaderMeasurementsHDF.cxx @@ -266,7 +266,7 @@ bool MModuleLoaderMeasurementsHDF::OpenHDF5File(MString FileName) Config.read(Config.getStrType(), ConfigJSON); } - cout<= c_Info) cout<= c_Error) cout<= c_Info) cout<= c_Info) cout<= c_Info) cout<= c_Info) cout<= c_Info) { + cout<<"MModuleLoaderMeasurementsHDF: "<= c_Info) cout<= c_Info) cout<= c_Info) cout<= c_Info) { + cout<<"MModuleLoaderMeasurementsROA: "<Clear(); m_ROAFile.ReadNext(*Event); if (Event->GetNumberOfReadOuts() == 0) { - cout<= c_Info) cout<Open(m_SimulationFileName) == false) { - cout<<"Unable to open sim file "<= c_Error) cout<GetSimulationStartAreaFarField(); diff --git a/src/MModuleResponseGenerator.cxx b/src/MModuleResponseGenerator.cxx index 327b4c56..2f502c06 100644 --- a/src/MModuleResponseGenerator.cxx +++ b/src/MModuleResponseGenerator.cxx @@ -167,12 +167,12 @@ bool MModuleResponseGenerator::AnalyzeEvent(MReadOutAssembly* Event) Event->StreamEvta(Out); if (m_Response->SetEvent(MString(Out.str()), false, 25) == false) { - cout<<"Unable to set event"<= c_Error) cout<Analyze() == false) { - cout<<"Analysis failed"<= c_Error) cout<ScanSetupFile(m_Geometry->GetFileName(), false) == false) { - cout<<"Loading of geometry "<GetName()<<" failed!!"<= c_Error) cout<GetName()<<" failed!!"<SetTrackingAlgorithm(MRawEventAnalyzer::c_TrackingAlgoNone); if (m_RawEventAnalyzer->PreAnalysis() == false) { - cout<<"Revan pre-analysis failed!"<= c_Error) cout<= c_Error) cout<= c_Error) cout<= c_Warning) cout<= c_Warning) cout<= c_Error) cout<= c_Error) cout<= c_Error) cout<= c_Error) { - cout << "ERROR in MModuleDepthCalibration::Initialize: Non-matching DetID="<GetName() == "COSI-SMEX-Payload"){ @@ -105,7 +105,7 @@ bool MSubModuleChargeTransport::Initialize() } } else if (m_Geometry->GetName() == "COSI-SMEX-Payload") { if (g_Verbosity >= c_Error) { - cout << "ERROR in MModuleDepthCalibration::Initialize: COSI-SMEX-Payload expects all Strip3D detectors to follow the name scheme GeD_X"<= c_Error) { + cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a duplicate detector: " << DetName << endl; + } } } else { - cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a Strip3D detector with " << det->GetNSensitiveVolumes() << " Sensitive Volumes." << endl; + if (g_Verbosity >= c_Error) { + cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a Strip3D detector with " << det->GetNSensitiveVolumes() << " Sensitive Volumes." << endl; + } } } } if (m_DetectorIDs.size() == 0) { - cout<<"No Strip3D detectors were found."<= c_Error) cout<<"ERROR in MSubModuleChargeTransport::Initialize: No Strip3D detectors were found in the geometry."<= c_Error) cout << m_Name << ": Unable to open deadtime parameters file: " << m_DeadtimeFileName << endl; return false; } if (Parser.GetNLines() < 4) { - cout << m_Name << ": Deadtime file does not have enough data" << endl; + if (g_Verbosity >= c_Error) cout << m_Name << ": Deadtime file does not have enough data" << endl; return false; } MTokenizer* ShieldTokenizer = Parser.GetTokenizerAt(3); if (ShieldTokenizer->GetNTokens() != 5) { - cout << m_Name << ": Shield deadtime row must contain exactly 5 values" << endl; + if (g_Verbosity >= c_Error) cout << m_Name << ": Shield deadtime row must contain exactly 5 values" << endl; return false; } diff --git a/src/MSubModuleStripTrigger.cxx b/src/MSubModuleStripTrigger.cxx index ec1f4a63..7c262ea1 100644 --- a/src/MSubModuleStripTrigger.cxx +++ b/src/MSubModuleStripTrigger.cxx @@ -539,12 +539,12 @@ bool MSubModuleStripTrigger::ParseDeadtimeFile() MParser Parser; if (Parser.Open(m_DeadtimeFileName) == false) { - cout << m_Name << ": Unable to open deadtime parameters file: " << m_DeadtimeFileName << endl; + if (g_Verbosity >= c_Error) cout << m_Name << ": ERROR: Unable to open deadtime parameters file: " << m_DeadtimeFileName << endl; return false; } if (Parser.GetNLines() < 2) { - cout << m_Name << ": Deadtime file does not have enough data" << endl; + if (g_Verbosity >= c_Error) cout << m_Name << ": ERROR: Deadtime file does not have enough data" << endl; return false; }