Skip to content

Commit 69fd283

Browse files
authored
Merge pull request #7416 from HimanshuCERN/O2hsharma
FIT: add time-calibration command line option
1 parent 7bd6b53 commit 69fd283

8 files changed

Lines changed: 72 additions & 7 deletions

File tree

Detectors/FIT/FT0/calibration/include/FT0Calibration/FT0ChannelTimeTimeSlotContainer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class FT0ChannelTimeTimeSlotContainer final
2929
{
3030

3131
//ranges to be discussed
32-
static constexpr int HISTOGRAM_RANGE = 200;
32+
static constexpr int HISTOGRAM_RANGE = 2000;
3333
static constexpr unsigned int NUMBER_OF_HISTOGRAM_BINS = 2 * HISTOGRAM_RANGE;
3434

3535
using BoostHistogramType = boost::histogram::histogram<std::tuple<boost::histogram::axis::integer<>,
@@ -43,6 +43,7 @@ class FT0ChannelTimeTimeSlotContainer final
4343
[[nodiscard]] int16_t getMeanGaussianFitValue(std::size_t channelID) const;
4444
void merge(FT0ChannelTimeTimeSlotContainer* prev);
4545
void print() const;
46+
static int sGausFitBins;
4647

4748
private:
4849
std::size_t mMinEntries;

Detectors/FIT/FT0/calibration/src/FT0ChannelTimeTimeSlotContainer.cxx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
using namespace o2::ft0;
1919

20+
int FT0ChannelTimeTimeSlotContainer::sGausFitBins = 999; // NOT USED
21+
2022
FT0ChannelTimeTimeSlotContainer::FT0ChannelTimeTimeSlotContainer(std::size_t minEntries)
2123
: mMinEntries(minEntries)
2224
{
@@ -65,21 +67,38 @@ int16_t FT0ChannelTimeTimeSlotContainer::getMeanGaussianFitValue(std::size_t cha
6567
return 0;
6668
}
6769
LOG(DEBUG) << " for channel " << int(channelID) << " entries " << mEntriesPerChannel[channelID];
70+
6871
std::vector<double> channelHistogramData(NUMBER_OF_HISTOGRAM_BINS);
72+
6973
std::vector<double> outputGaussianFitValues;
74+
double binWidth = (HISTOGRAM_RANGE - (-HISTOGRAM_RANGE)) / NUMBER_OF_HISTOGRAM_BINS;
75+
double minGausFitRange = 0;
76+
double maxGausFitRange = 0;
77+
double MaxValOfHistogram = 0.0;
78+
7079
for (int iBin = 0; iBin < NUMBER_OF_HISTOGRAM_BINS; ++iBin) {
7180
channelHistogramData[iBin] = mHistogram.at(iBin, channelID);
7281
}
7382

83+
int maxElementIndex = std::max_element(channelHistogramData.begin(), channelHistogramData.end()) - channelHistogramData.begin();
84+
int maxElement = *std::max_element(channelHistogramData.begin(), channelHistogramData.end());
85+
86+
// calculating the min & max range values to fit gaussian
87+
minGausFitRange = (-HISTOGRAM_RANGE + (maxElementIndex - sGausFitBins) * binWidth + binWidth / 2.0);
88+
maxGausFitRange = (-HISTOGRAM_RANGE + (maxElementIndex + sGausFitBins) * binWidth + binWidth / 2.0);
89+
7490
double returnCode = math_utils::fitGaus<double>(NUMBER_OF_HISTOGRAM_BINS, channelHistogramData.data(),
75-
-HISTOGRAM_RANGE, HISTOGRAM_RANGE, outputGaussianFitValues);
91+
minGausFitRange, maxGausFitRange, outputGaussianFitValues);
92+
93+
MaxValOfHistogram = (-HISTOGRAM_RANGE + maxElementIndex * binWidth + binWidth / 2.0);
7694
if (returnCode < 0) {
7795
LOG(ERROR) << "Gaussian fit error!";
78-
return 0;
96+
return static_cast<int16_t>(std::round(MaxValOfHistogram));
7997
}
8098

8199
return static_cast<int16_t>(std::round(outputGaussianFitValues[MEAN_VALUE_INDEX_IN_OUTPUT_VECTOR]));
82100
}
101+
83102
void FT0ChannelTimeTimeSlotContainer::print() const
84103
{
85104
//QC will do that part

Detectors/FIT/FT0/calibration/testWorkflow/FT0Calibration-Workflow.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "FT0ChannelTimeCalibrationSpec.h"
13+
#include "FT0Calibration/FT0ChannelTimeTimeSlotContainer.h"
14+
15+
using namespace o2::framework;
1316

1417
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
1518
{
1619
//probably some option will be added
20+
std::vector<o2::framework::ConfigParamSpec> options;
21+
options.push_back(ConfigParamSpec{"time-calib-fitting-nbins", VariantType::Int, 2, {""}});
22+
std::swap(workflowOptions, options);
1723
}
1824

1925
#include "Framework/runDataProcessing.h"
@@ -22,6 +28,7 @@ using namespace o2::framework;
2228
WorkflowSpec defineDataProcessing(ConfigContext const& config)
2329
{
2430
WorkflowSpec workflow;
31+
o2::ft0::FT0ChannelTimeTimeSlotContainer::sGausFitBins = config.options().get<int>("time-calib-fitting-nbins");
2532
workflow.emplace_back(o2::ft0::getFT0ChannelTimeCalibrationSpec());
2633
//add calib spec here...
2734
return workflow;

Detectors/FIT/FT0/calibration/testWorkflow/FT0ChannelTimeCalibration-Workflow.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "FT0ChannelTimeCalibrationSpec.h"
13+
#include "FT0Calibration/FT0ChannelTimeTimeSlotContainer.h"
14+
15+
using namespace o2::framework;
1316

1417
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
1518
{
1619
//probably some option will be added
20+
std::vector<o2::framework::ConfigParamSpec> options;
21+
options.push_back(ConfigParamSpec{"time-calib-fitting-nbins", VariantType::Int, 2, {""}});
22+
std::swap(workflowOptions, options);
1723
}
1824

1925
#include "Framework/runDataProcessing.h"
@@ -22,6 +28,7 @@ using namespace o2::framework;
2228
WorkflowSpec defineDataProcessing(ConfigContext const& config)
2329
{
2430
WorkflowSpec workflow;
31+
o2::ft0::FT0ChannelTimeTimeSlotContainer::sGausFitBins = config.options().get<int>("time-calib-fitting-nbins");
2532
workflow.emplace_back(o2::ft0::getFT0ChannelTimeCalibrationSpec());
2633
return workflow;
2734
}

Detectors/FIT/FT0/calibration/testWorkflow/FT0TFProcessor-Workflow.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
7878

7979
WorkflowSpec workflow;
8080
workflow.emplace_back(dataProcessorSpec);
81+
8182
return workflow;
8283
}

Detectors/FIT/FV0/calibration/include/FV0Calibration/FV0ChannelTimeTimeSlotContainer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FV0ChannelTimeTimeSlotContainer final
3030
{
3131

3232
//ranges to be discussed
33-
static constexpr int HISTOGRAM_RANGE = 200;
33+
static constexpr int HISTOGRAM_RANGE = 2000;
3434
static constexpr unsigned int NUMBER_OF_HISTOGRAM_BINS = 2 * HISTOGRAM_RANGE;
3535

3636
using BoostHistogramType = boost::histogram::histogram<std::tuple<boost::histogram::axis::integer<>,
@@ -44,6 +44,7 @@ class FV0ChannelTimeTimeSlotContainer final
4444
[[nodiscard]] int16_t getMeanGaussianFitValue(std::size_t channelID) const;
4545
void merge(FV0ChannelTimeTimeSlotContainer* prev);
4646
void print() const;
47+
static int sGausFitBins;
4748

4849
private:
4950
std::size_t mMinEntries;

Detectors/FIT/FV0/calibration/src/FV0ChannelTimeTimeSlotContainer.cxx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
using namespace o2::fv0;
1919

20+
int FV0ChannelTimeTimeSlotContainer::sGausFitBins = 999; // NOT USED
21+
2022
FV0ChannelTimeTimeSlotContainer::FV0ChannelTimeTimeSlotContainer(std::size_t minEntries)
2123
: mMinEntries(minEntries)
2224
{
@@ -65,22 +67,41 @@ int16_t FV0ChannelTimeTimeSlotContainer::getMeanGaussianFitValue(std::size_t cha
6567
if (0 == mEntriesPerChannel[channelID]) {
6668
return 0;
6769
}
70+
LOG(DEBUG) << " for channel " << int(channelID) << " entries " << mEntriesPerChannel[channelID];
71+
72+
std::vector<double> channelHistogramData(NUMBER_OF_HISTOGRAM_BINS, 0);
6873

69-
std::vector<double> channelHistogramData(NUMBER_OF_HISTOGRAM_BINS);
7074
std::vector<double> outputGaussianFitValues;
75+
double binWidth = (HISTOGRAM_RANGE - (-HISTOGRAM_RANGE)) / NUMBER_OF_HISTOGRAM_BINS;
76+
double minGausFitRange = 0;
77+
double maxGausFitRange = 0;
78+
double MaxValOfHistogram = 0.0;
79+
7180
for (int iBin = 0; iBin < NUMBER_OF_HISTOGRAM_BINS; ++iBin) {
7281
channelHistogramData[iBin] = mHistogram.at(iBin, channelID);
7382
}
7483

84+
int maxElementIndex = std::max_element(channelHistogramData.begin(), channelHistogramData.end()) - channelHistogramData.begin();
85+
int maxElement = *std::max_element(channelHistogramData.begin(), channelHistogramData.end());
86+
87+
// calculating the min & max range values to fit gaussian
88+
minGausFitRange = (-HISTOGRAM_RANGE + (maxElementIndex - sGausFitBins) * binWidth + binWidth / 2.0);
89+
maxGausFitRange = (-HISTOGRAM_RANGE + (maxElementIndex + sGausFitBins) * binWidth + binWidth / 2.0);
90+
7591
double returnCode = math_utils::fitGaus<double>(NUMBER_OF_HISTOGRAM_BINS, channelHistogramData.data(),
76-
-HISTOGRAM_RANGE, HISTOGRAM_RANGE, outputGaussianFitValues);
92+
minGausFitRange, maxGausFitRange, outputGaussianFitValues);
93+
94+
MaxValOfHistogram = (-HISTOGRAM_RANGE + maxElementIndex * binWidth + binWidth / 2.0);
95+
7796
if (returnCode < 0) {
7897
LOG(ERROR) << "Gaussian fit error!";
79-
return 0;
98+
return static_cast<int16_t>(std::round(MaxValOfHistogram));
99+
//return 0;
80100
}
81101

82102
return static_cast<int16_t>(std::round(outputGaussianFitValues[MEAN_VALUE_INDEX_IN_OUTPUT_VECTOR]));
83103
}
104+
84105
void FV0ChannelTimeTimeSlotContainer::print() const
85106
{
86107
//QC will do that part

Detectors/FIT/FV0/calibration/workflow/FV0ChannelTimeCalibration-Workflow.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include "FV0ChannelTimeCalibrationSpec.h"
13+
#include "FV0Calibration/FV0ChannelTimeTimeSlotContainer.h"
14+
15+
using namespace o2::framework;
1316

1417
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
1518
{
19+
1620
//probably some option will be added
21+
std::vector<o2::framework::ConfigParamSpec> options;
22+
options.push_back(ConfigParamSpec{"time-calib-fitting-nbins", VariantType::Int, 2, {""}});
23+
std::swap(workflowOptions, options);
1724
}
1825

1926
#include "Framework/runDataProcessing.h"
@@ -22,6 +29,7 @@ using namespace o2::framework;
2229
WorkflowSpec defineDataProcessing(ConfigContext const& config)
2330
{
2431
WorkflowSpec workflow;
32+
o2::fv0::FV0ChannelTimeTimeSlotContainer::sGausFitBins = config.options().get<int>("time-calib-fitting-nbins");
2533
workflow.emplace_back(o2::fv0::getFV0ChannelTimeCalibrationSpec());
2634
return workflow;
2735
}

0 commit comments

Comments
 (0)