-
Notifications
You must be signed in to change notification settings - Fork 494
[EMCAL-566] Add executable for performing time and bad cell calibration #7886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,10 @@ | |
| #include "EMCALBase/Geometry.h" | ||
| #include <boost/histogram.hpp> | ||
|
|
||
| #if (defined(WITH_OPENMP) && !defined(__CLING__)) | ||
| #include <omp.h> | ||
| #endif | ||
|
|
||
| namespace o2 | ||
| { | ||
| namespace emcal | ||
|
|
@@ -45,6 +49,9 @@ class EMCALCalibExtractor | |
| int getNsigma() const { return mSigma; } | ||
| void setNsigma(int ns) { mSigma = ns; } | ||
|
|
||
| void setNThreads(int n) { mNThreads = std::min(n, NCELLS); } | ||
| int getNThreads() const { return mNThreads; } | ||
|
|
||
| void setUseScaledHistoForBadChannels(bool useScaledHistoForBadChannels) { mUseScaledHistoForBadChannels = useScaledHistoForBadChannels; } | ||
|
|
||
| /// \brief Average energy per hit is caluclated for each cell. | ||
|
|
@@ -88,16 +95,46 @@ class EMCALCalibExtractor | |
|
|
||
| /// \brief For now a dummy function to calibrate the time. | ||
| template <typename... axes> | ||
| o2::emcal::TimeCalibrationParams calibrateTime(boost::histogram::histogram<axes...>& hist) | ||
| o2::emcal::TimeCalibrationParams calibrateTime(boost::histogram::histogram<axes...>& hist, double minTime = 0, double maxTime = 1000) | ||
| { | ||
|
|
||
| auto histReduced = boost::histogram::algorithm::reduce(hist, boost::histogram::algorithm::shrink(minTime, maxTime), boost::histogram::algorithm::shrink(0, NCELLS)); | ||
|
|
||
| o2::emcal::TimeCalibrationParams TCP; | ||
| TCP.addTimeCalibParam(1234, 600, 0); | ||
|
|
||
| #if (defined(WITH_OPENMP) && !defined(__CLING__)) | ||
| if (mNThreads < 1) { | ||
| mNThreads = std::min(omp_get_max_threads(), NCELLS); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 17644 threads is probably out of order for local machines :) Needs to be checked with @shahor02 and @chiarazampolli where to put the maximum here, I guess omp threads will need to be shared among components.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes NCells is unrealistic. But like this it will use all available resources when calling the omp_get_max_threads(), right? |
||
| } | ||
| LOG(info) << "Number of threads that will be used = " << mNThreads; | ||
| #pragma omp parallel for num_threads(mNThreads) | ||
| #else | ||
| LOG(info) << "OPEN MP will not be used for the time calibration"; | ||
| mNThreads = 1; | ||
| #endif | ||
|
|
||
| for (unsigned int i = 0; i < NCELLS; ++i) { | ||
| // project boost histogram to 1d just for 1 cell | ||
| auto boostHist1d = o2::utils::ProjectBoostHistoX(histReduced, i, i + 1); | ||
| // maybe cut histo to max +- 25 ns | ||
|
|
||
| // fit with gaussian to extract mean | ||
| try { | ||
| auto fitValues = o2::utils::fitBoostHistoWithGaus<double>(boostHist1d); | ||
| double mean = fitValues.at(1); | ||
| // add mean to time calib params | ||
| TCP.addTimeCalibParam(i, mean, 0); | ||
| } catch (o2::utils::FitGausError_t) { | ||
| TCP.addTimeCalibParam(i, 400, 0); // 400 ns shift default value | ||
| } | ||
| } | ||
| return TCP; | ||
| } | ||
|
|
||
| private: | ||
| bool mUseScaledHistoForBadChannels = false; ///< variable to specify whether or not we want to use the scaled histo for the claibration of bad channels. | ||
| int mSigma = 4; ///< number of sigma used in the calibration to define outliers | ||
| int mNThreads = 1; ///< number of threads used for calibration | ||
|
|
||
| ClassDefNV(EMCALCalibExtractor, 1); | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this is to circumvent the problem with the multiple definition of TFormula when running with OMP threads > 1. This could become tricky in a multi-threaded environment. As far as I understand the variables should be allocated per thread (thread-local storage) based on our build settings. However would be good if we could find a way to avoid making members static.