Skip to content

Commit 569a10a

Browse files
chiarazampollishahor02
authored andcommitted
First version
Not tested, it is Friday evening... Adding to compilation Not working yet, still using a struct for TOFChannelData, but with the boost histogram it seems too complicated. Now I will try using a class. I make the commit only to save the current version. Compiling TOFChannelData for now Adding TOFChannelCalibrator to compilation - but it fails adding destructors Fixes + updates Using 18 histograms Trying to make integral work - not successful for now misc fixes (#18) Co-authored-by: shahoian <ruben.shahoyan@cern.ch> Fixing integral function Leaving for now alternative methods, just for reference (they do not work as wanted anyway) Better integral functions. In the functions, there are still the three possibilities: 1) integral over reduced indexed loop (fastest); 2) integral over the complete indexed loop; 3) projection + accumulate (slowest). They are kept for reference for now, until the boost people find maybe a better way (see boostorg/histogram#277) Improve finalizeSlot Adding faster way to get the integral
1 parent 4245362 commit 569a10a

6 files changed

Lines changed: 616 additions & 3 deletions

File tree

Detectors/Calibration/include/DetectorsCalibration/TimeSlot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef DETECTOR_CALIB_TIMESLOT_H_
1212
#define DETECTOR_CALIB_TIMESLOT_H_
1313

14+
#include <memory>
1415
#include <Rtypes.h>
1516
#include "Framework/Logger.h"
1617

Detectors/TOF/calibration/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ o2_add_library(TOFCalibration
1313
src/CalibTOF.cxx
1414
src/CollectCalibInfoTOF.cxx
1515
src/LHCClockCalibrator.cxx
16+
src/TOFChannelCalibrator.cxx
1617
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF O2::TOFBase
1718
O2::CCDB
1819
O2::DetectorsCalibration
@@ -24,6 +25,7 @@ o2_target_root_dictionary(TOFCalibration
2425
HEADERS include/TOFCalibration/CalibTOFapi.h
2526
include/TOFCalibration/CalibTOF.h
2627
include/TOFCalibration/LHCClockCalibrator.h
28+
include/TOFCalibration/TOFChannelCalibrator.h
2729
include/TOFCalibration/CollectCalibInfoTOF.h)
2830

2931

Detectors/TOF/calibration/include/TOFCalibration/LHCClockCalibrator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
1010

11-
#ifndef TOF_CALIBWORKFLOW_H_
12-
#define TOF_CALIBWORKFLOW_H_
11+
#ifndef TOF_LHCPHASE_CALIBRATION_H_
12+
#define TOF_LHCPHASE_CALIBRATION_H_
1313

1414
#include "DetectorsCalibration/TimeSlotCalibration.h"
1515
#include "DetectorsCalibration/TimeSlot.h"
@@ -86,4 +86,4 @@ class LHCClockCalibrator : public o2::calibration::TimeSlotCalibration<o2::dataf
8686
} // end namespace tof
8787
} // end namespace o2
8888

89-
#endif /* TOF_CALIBWORKFLOW_H_ */
89+
#endif /* TOF_LHCPHASE_CALIBRATION_H_ */
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#ifndef TOF_CHANNEL_CALIBRATOR_H_
12+
#define TOF_CHANNEL_CALIBRATOR_H_
13+
14+
#include "DetectorsCalibration/TimeSlotCalibration.h"
15+
#include "DetectorsCalibration/TimeSlot.h"
16+
#include "DataFormatsTOF/CalibInfoTOF.h"
17+
#include "TOFCalibration/CalibTOFapi.h"
18+
#include "DataFormatsTOF/CalibLHCphaseTOF.h"
19+
#include "TOFBase/Geo.h"
20+
#include "CCDB/CcdbObjectInfo.h"
21+
#include <array>
22+
#include <boost/histogram.hpp>
23+
24+
namespace o2
25+
{
26+
namespace tof
27+
{
28+
29+
class TOFChannelData {
30+
31+
using Slot = o2::calibration::TimeSlot<o2::tof::TOFChannelData>;
32+
using boostHisto = boost::histogram::histogram<std::tuple<boost::histogram::axis::regular<double, boost::use_default, boost::use_default, boost::use_default>, boost::histogram::axis::integer<> >, boost::histogram::unlimited_storage<std::allocator<char> > >;
33+
34+
public:
35+
36+
static constexpr int NCHANNELSXSECTOR = o2::tof::Geo::NCHANNELS / o2::tof::Geo::NSECTORS;
37+
38+
TOFChannelData() {
39+
LOG(INFO) << "Default c-tor, not to be used";
40+
}
41+
42+
TOFChannelData(int nb, float r) : mNBins(nb), mRange(r)
43+
{
44+
if (r <= 0. || nb < 1) {
45+
throw std::runtime_error("Wrong initialization of the histogram");
46+
}
47+
mV2Bin = mNBins / (2 * mRange);
48+
for (int isect = 0; isect < 18; isect ++){
49+
mHisto[isect] = boost::histogram::make_histogram(boost::histogram::axis::regular<>(mNBins, -mRange, mRange, "t-texp"),
50+
boost::histogram::axis::integer<>(0, o2::tof::Geo::NPADSXSECTOR, "channel index in sector" + std::to_string(isect))); // bin is defined as [low, high[
51+
}
52+
mEntries.resize(o2::tof::Geo::NCHANNELS, 0);
53+
}
54+
55+
~TOFChannelData() = default;
56+
57+
void print() const;
58+
void print(int isect) const;
59+
void fill(const gsl::span<const o2::dataformats::CalibInfoTOF> data);
60+
void merge(const TOFChannelData* prev);
61+
int findBin(float v) const;
62+
float integral(int chmin, int chmax, float binmin, float binmax) const;
63+
float integral(int chmin, int chmax, int binxmin, int binxmax) const;
64+
float integral(int ch, float binmin, float binmax) const;
65+
float integral(int ch, int binxmin, int binxmax) const;
66+
float integral(int ch) const;
67+
bool hasEnoughData(int minEntries) const;
68+
69+
float getRange() const { return mRange; }
70+
void setRange(float r) { mRange = r; }
71+
72+
int getNbins() const { return mNBins; }
73+
void setNbins(int nb) { mNBins = nb; }
74+
75+
boostHisto& getHisto(int isect) { return mHisto[isect]; }
76+
const boostHisto& getHisto(int isect) const { return mHisto[isect]; }
77+
//const boostHisto getHisto() const { return &mHisto[0]; }
78+
// boostHisto* getHisto(int isect) const { return &mHisto[isect]; }
79+
80+
private:
81+
float mRange = 24400;
82+
int mNBins = 1000;
83+
float mV2Bin;
84+
// do I really have to initialize it like below?
85+
std::array<boostHisto,18> mHisto;
86+
std::vector<int> mEntries; // vector containing number of entries per channel
87+
88+
ClassDefNV(TOFChannelData, 1);
89+
};
90+
91+
class TOFChannelCalibrator : public o2::calibration::TimeSlotCalibration<o2::dataformats::CalibInfoTOF, o2::tof::TOFChannelData>
92+
{
93+
using TFType = uint64_t;
94+
using Slot = o2::calibration::TimeSlot<o2::tof::TOFChannelData>;
95+
using CalibTOFapi = o2::tof::CalibTOFapi;
96+
using TimeSlewing = o2::dataformats::CalibTimeSlewingParamTOF;
97+
using CcdbObjectInfo = o2::ccdb::CcdbObjectInfo;
98+
using CcdbObjectInfoVector = std::vector<CcdbObjectInfo>;
99+
using TimeSlewingVector = std::vector<TimeSlewing>;
100+
101+
public:
102+
103+
static const int NCHANNELSXSECTOR = o2::tof::Geo::NCHANNELS / o2::tof::Geo::NSECTORS;
104+
TOFChannelCalibrator(int minEnt = 500, int nb = 1000, float r = 24400, const std::string path = "http://ccdb-test.cern.ch:8080") : mMinEntries(minEnt), mNBins(nb), mRange(r) { mCalibTOFapi.setURL(path); }
105+
106+
~TOFChannelCalibrator() final = default;
107+
108+
bool hasEnoughData(const Slot& slot) const final;
109+
void initOutput() final;
110+
void finalizeSlot(Slot& slot) final;
111+
Slot& emplaceNewSlot(bool front, TFType tstart, TFType tend) final;
112+
113+
const TimeSlewingVector& getTimeSlewingVector() const { return mTimeSlewingVector; }
114+
const CcdbObjectInfoVector& getTimeSlewingInfoVector() const { return mInfoVector; }
115+
CcdbObjectInfoVector& getTimeSlewingInfoVector() { return mInfoVector; }
116+
117+
private:
118+
int mMinEntries = 0; // min number of entries to calibrate the TimeSlot
119+
int mNBins = 0; // bins of the histogram with the t-text per channel
120+
float mRange = 0.; // range of the histogram with the t-text per channel
121+
CalibTOFapi mCalibTOFapi;
122+
CcdbObjectInfoVector mInfoVector; // vector of CCDB Infos , each element is filled with the CCDB description of the accompanying TimeSlewing object
123+
TimeSlewingVector mTimeSlewingVector; // vector of TimeSlewing, each element is filled in "process"
124+
// when we finalize one slot (multiple can be finalized
125+
// during the same "process", which is why we have a vector).
126+
// Each element is to be considered the output of the device,
127+
// and will go to the CCDB. Note that for the channel offset
128+
// we still fill the TimeSlewing object
129+
130+
ClassDefOverride(TOFChannelCalibrator, 1);
131+
};
132+
133+
} // end namespace tof
134+
} // end namespace o2
135+
136+
#endif /* TOF_CHANNEL_CALIBRATOR_H_ */

Detectors/TOF/calibration/src/TOFCalibrationLinkDef.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@
2323
#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::dataformats::CalibInfoTOF, o2::tof::LHCClockDataHisto> + ;
2424
#pragma link C++ class o2::tof::LHCClockCalibrator + ;
2525

26+
#pragma link C++ class o2::tof::TOFChannelData + ;
27+
#pragma link C++ class o2::tof::TOFChannelCalibrator + ;
28+
#pragma link C++ class o2::calibration::TimeSlot < o2::tof::TOFChannelData> + ;
29+
#pragma link C++ class o2::calibration::TimeSlotCalibration<o2::dataformats::CalibInfoTOF, o2::tof::TOFChannelData> + ;
30+
2631
#endif

0 commit comments

Comments
 (0)