Repository navigation
Cs-137 Trapping App full pipeline - #284
sophieehaight wants to merge 8 commits into
Conversation
805f82d to
a7c23d4
Compare
|
|
||
| m_PixelCorrect = false; | ||
| m_MultiRoundStripPairing = false; | ||
| m_MultiRoundStripPairing = false; // should this be changed?? |
There was a problem hiding this comment.
Is this a question for us or something to remind yourself?
My understanding is that we would use MModuleStripPairingMultiRoundChiSquare going forward (or at least that's the module that people have been updating recently).
| return false; | ||
| } | ||
| m_ProductsPrefix = MString((ProductsDir / OutPath.filename()).string()); | ||
| cout << "Intermediate products will be stored in " << ProductsDir.string() << endl; |
There was a problem hiding this comment.
you added some later cout statements into c_Info, but not here. Is this intended?
| if (SimCCEs.empty()) { | ||
| std::cerr << "[FATAL] Simulated CCE file is empty or file not found at: " << g_SimulatedCCEPath << std::endl; | ||
| return false; | ||
| } |
There was a problem hiding this comment.
It seems like you're loading using namespace std; at the beginning of the file, so you could just remove std:: here and elsewhere:
| if (SimCCEs.empty()) { | |
| std::cerr << "[FATAL] Simulated CCE file is empty or file not found at: " << g_SimulatedCCEPath << std::endl; | |
| return false; | |
| } | |
| if (SimCCEs.empty() == true) { | |
| cerr << "[FATAL] Simulated CCE file is empty or file not found at: " << g_SimulatedCCEPath << endl; | |
| return false; | |
| } |
| if (!CombinedFile.is_open()) { | ||
| std::cerr << "[Error] Cannot create output file: " << CombinedCSV << std::endl; | ||
| return false; | ||
| } |
There was a problem hiding this comment.
I'm not going to flag everything, but maybe you can have a look for style guide changes:
| if (!CombinedFile.is_open()) { | |
| std::cerr << "[Error] Cannot create output file: " << CombinedCSV << std::endl; | |
| return false; | |
| } | |
| if (CombinedFile.is_open() == false) { | |
| cerr << "[Error] Cannot create output file: " << CombinedCSV << endl; | |
| return false; | |
| } |
| if (!Result.IsValid()) { | ||
| std::cerr << "[Warning] Fit result not valid (status " << Result.Status() << ") for Detector " << DetID << std::endl; | ||
| } |
There was a problem hiding this comment.
If you have warnings, you could do
| if (!Result.IsValid()) { | |
| std::cerr << "[Warning] Fit result not valid (status " << Result.Status() << ") for Detector " << DetID << std::endl; | |
| } | |
| if (Result.IsValid() == false) { | |
| if (m_Verbosity >= c_Warning) cout << "WARNING: Fit result not valid (status " << Result.Status() << ") for Detector " << DetID << endl; | |
| } |
| std::cout << "\n================ JOINT FIT RESULTS ================" << std::endl; | ||
| std::cout << " Detector ID : " << DetID << std::endl; | ||
| std::cout << " A_hv : " << TrappingParams[0] << std::endl; | ||
| std::cout << " A_lv : " << TrappingParams[1] << std::endl; | ||
| std::cout << " B (e-trap) : " << TrappingParams[2] << std::endl; | ||
| std::cout << " C (h-trap) : " << TrappingParams[3] << std::endl; | ||
| std::cout << " Chi2 (Calc) : " << CalculatedChi2 << std::endl; | ||
| std::cout << " NDF : " << NDF << std::endl; | ||
| std::cout << " Chi2 / NDF : " << (NDF > 0 ? CalculatedChi2 / NDF : -1) << std::endl; | ||
| std::cout << "====================================================\n" << std::endl; |
There was a problem hiding this comment.
Should this always be printed to the console?
| Legend->Draw(); | ||
| } | ||
|
|
||
| MString PlotFile = m_ProductsPrefix + MString("_Det_") + DetID + MString("_CCE_fit.png"); |
There was a problem hiding this comment.
Do you always want to create PNG values for the CCE fits or should this be an optional feature that the user can turn off when running the app?
There was a problem hiding this comment.
The module actually produces quite a lot of files characterizing the individual photopeak fits and fitted CCE. I had them read into a separate directory trapping_param_products to tuck them away. I can add an option s.t all output files apart from the trapping parameter file itself are suppressed unless you choose to save them.
I'll also wrap all of the terminal outputs in verbosity checks so that the outputs here are as clean as possible by default!
fixed compilation error, comment cleanup, updated verbosity settings
2ed4928 to
789d4be
Compare
| double m_MaxEnergy; | ||
|
|
||
| //! Verbosity of this app's own output, independent of the MEGAlib g_Verbosity used by the nuclearizer modules | ||
| // Verbosity of this app's own output, independent of the globabl verbosity used by the nuclearizer modules |
There was a problem hiding this comment.
Typo:
| // Verbosity of this app's own output, independent of the globabl verbosity used by the nuclearizer modules | |
| // Verbosity of this app's own output, independent of the global verbosity used by the nuclearizer modules |
| m_MaxEnergy = 700; | ||
| m_NDepthBins = 20; | ||
| m_Verbosity = c_Error; | ||
| m_SaveProducts = false; |
There was a problem hiding this comment.
"Products" as in plots, or also the intermediate CCE files?
If it's both, we might want to have several independent options to save the CCE peak fit results, but not the plots, etc.
| cout<<Usage.str()<<endl; | ||
| if (((argc > i+1) && (argv[i+1][0] != '-' || isalpha(argv[i+1][1]) == 0)) == false) { | ||
| if (m_Verbosity >= c_Error) { | ||
| cout<<"[Error] Option "<<argv[i][1]<<" needs a second argument!"<<endl; |
There was a problem hiding this comment.
We tend to use ERROR: Option ... syntax instead of [Error] Option ... but I don't have too strong of a feeling about this.
There was a problem hiding this comment.
Yep happy to update these
| // Relate the local verbosity setting to the global verbosity levels | ||
| if (m_Verbosity >= c_Info) { | ||
| gErrorIgnoreLevel = kInfo; | ||
| } else if (m_Verbosity >= c_Warning) { | ||
| gErrorIgnoreLevel = kWarning; | ||
| } else if (m_Verbosity >= c_Error) { | ||
| gErrorIgnoreLevel = kError; | ||
| } else { | ||
| gErrorIgnoreLevel = kFatal; | ||
| } |
There was a problem hiding this comment.
I'm wrapping the errors that ROOT outputs for the canvases and plots in this module with my verbosity settings for info, warning, and error so the ROOT errors only get printed at that verbosity setting. I updated the comment to clarify this.
| return false; | ||
| } | ||
|
|
||
| // Check that you ond't trim too mnay depth bins |
There was a problem hiding this comment.
| // Check that you ond't trim too mnay depth bins | |
| // Check that you don't trim too many depth bins |
| return false; | ||
| } | ||
|
|
||
| // Set global verbosity to 0 s.t to supressed output from the nuclearizer modules |
There was a problem hiding this comment.
| // Set global verbosity to 0 s.t to supressed output from the nuclearizer modules | |
| // Set global verbosity to 0 to suppress output from the nuclearizer modules |
| if (m_SaveProducts == true) { | ||
| PlotCCEFit(ExpData, Sim, TrappingParams, DetID); | ||
| SaveTrappingParamFile(OutputCSVPath, TrappingParamPath, TrappingParams, Sim, DetID); | ||
| } |
There was a problem hiding this comment.
Related to my comment above:
I would prefer having separate m_SaveProducts and m_SavePlots for the text files and plots of the fits, respectively.
There was a problem hiding this comment.
Sounds good, I've update this in my next push. I've also added an option to save the hit and depth bin data in ROOT file after they've been calibrated by the nuclearizer modules. This separates the calibration step from the general analysis and ultimately makes it much quicker to fit experimental CCE at various binnings. Let me know what you think!
| //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| void TrappingCorrectionCs137::PlotCCEFit(const std::vector<ExperimentalPoint>& ExpData, | ||
| void TrappingCorrectionCs137::PlotCCEFit(const vector<ExperimentalPoint>& ExpData, |
There was a problem hiding this comment.
Can you attach an example screenshot of what such a PNG file would look like? :)

Standalone app which approximates experimental CCEs using Cs-137 calibration data and fits them to simulated CCE curves to obtain trapping parameters for each detector. The app requires energy, TAC, and depth calibration files as inputs in addition to the detector geometry and simulated CCE files. The final output is a csv file containing trapping parameters for all detectors for which data is read in. Additional plots and outputs characterizing goodness of fit are stored in folder trapping_param_products.
For instructions on usage enter "TrappingCorrectionCs137 -h".