Skip to content

Commit 56f4a20

Browse files
committed
FIT: add time-calibration command line option
1 parent c0e0d04 commit 56f4a20

6 files changed

Lines changed: 80 additions & 15 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: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
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
{
2325

26+
2427
mHistogram = boost::histogram::make_histogram(boost::histogram::axis::integer<>(-HISTOGRAM_RANGE, HISTOGRAM_RANGE, "channel_times"),
2528
boost::histogram::axis::integer<>(0, o2::ft0::Nchannels_FT0, "channel_ID"));
2629
}
2730

31+
2832
bool FT0ChannelTimeTimeSlotContainer::hasEnoughEntries() const
2933
{
3034
return *std::min_element(mEntriesPerChannel.begin(), mEntriesPerChannel.end()) > mMinEntries;
@@ -65,21 +69,41 @@ int16_t FT0ChannelTimeTimeSlotContainer::getMeanGaussianFitValue(std::size_t cha
6569
return 0;
6670
}
6771
LOG(DEBUG) << " for channel " << int(channelID) << " entries " << mEntriesPerChannel[channelID];
72+
6873
std::vector<double> channelHistogramData(NUMBER_OF_HISTOGRAM_BINS);
74+
6975
std::vector<double> outputGaussianFitValues;
76+
double binWidth = (HISTOGRAM_RANGE - (-HISTOGRAM_RANGE))/NUMBER_OF_HISTOGRAM_BINS;
77+
double minGausFitRange = 0;
78+
double maxGausFitRange = 0;
79+
double MaxValOfHistogram = 0.0;
80+
81+
7082
for (int iBin = 0; iBin < NUMBER_OF_HISTOGRAM_BINS; ++iBin) {
7183
channelHistogramData[iBin] = mHistogram.at(iBin, channelID);
7284
}
7385

86+
int maxElementIndex = std::max_element(channelHistogramData.begin(),channelHistogramData.end()) - channelHistogramData.begin();
87+
int maxElement = *std::max_element(channelHistogramData.begin(), channelHistogramData.end());
88+
89+
// calculating the min & max range values to fit gaussian
90+
minGausFitRange = (-HISTOGRAM_RANGE + (maxElementIndex-sGausFitBins) * binWidth + binWidth/2.0 );
91+
maxGausFitRange = (-HISTOGRAM_RANGE + (maxElementIndex+sGausFitBins) * binWidth + binWidth/2.0 );
92+
7493
double returnCode = math_utils::fitGaus<double>(NUMBER_OF_HISTOGRAM_BINS, channelHistogramData.data(),
75-
-HISTOGRAM_RANGE, HISTOGRAM_RANGE, outputGaussianFitValues);
76-
if (returnCode < 0) {
77-
LOG(ERROR) << "Gaussian fit error!";
78-
return 0;
79-
}
94+
minGausFitRange, maxGausFitRange, outputGaussianFitValues);
8095

81-
return static_cast<int16_t>(std::round(outputGaussianFitValues[MEAN_VALUE_INDEX_IN_OUTPUT_VECTOR]));
96+
MaxValOfHistogram = (-HISTOGRAM_RANGE + maxElementIndex * binWidth + binWidth/2.0 );
97+
if (returnCode < 0)
98+
{
99+
LOG(ERROR) << "Gaussian fit error!";
100+
return static_cast<int16_t>(std::round(MaxValOfHistogram));
101+
}
102+
103+
return static_cast<int16_t>(std::round(outputGaussianFitValues[MEAN_VALUE_INDEX_IN_OUTPUT_VECTOR]));
82104
}
105+
106+
83107
void FT0ChannelTimeTimeSlotContainer::print() const
84108
{
85109
//QC will do that part

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/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: 31 additions & 7 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,44 @@ 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+
80+
7181
for (int iBin = 0; iBin < NUMBER_OF_HISTOGRAM_BINS; ++iBin) {
7282
channelHistogramData[iBin] = mHistogram.at(iBin, channelID);
7383
}
7484

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

82-
return static_cast<int16_t>(std::round(outputGaussianFitValues[MEAN_VALUE_INDEX_IN_OUTPUT_VECTOR]));
104+
return static_cast<int16_t>(std::round(outputGaussianFitValues[MEAN_VALUE_INDEX_IN_OUTPUT_VECTOR]));
83105
}
106+
107+
84108
void FV0ChannelTimeTimeSlotContainer::print() const
85109
{
86110
//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)