Skip to content

Commit 011c489

Browse files
chiarazampollisawenzel
authored andcommitted
Macro to populate CCDB (with comments added to an existing one)
For now we use the dummy workflow as in #2629. Later we will modify the LifeTime and adapt to the common framework. Using CCDB in clusterization (but with bug still) attempt to fix inputspec in TOF clusterizer (calibration) (#16)
1 parent 58b398f commit 011c489

File tree

17 files changed

+197
-26
lines changed

17 files changed

+197
-26
lines changed

DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define ALICEO2_CALIBTIMESLEWINGPARAMTOF_H
1616

1717
#include <vector>
18+
#include "Rtypes.h"
1819

1920
namespace o2
2021
{
@@ -87,7 +88,7 @@ class CalibTimeSlewingParamTOF
8788
float mFractionUnderPeak[NSECTORS][NCHANNELXSECTOR]; ///< array with the fraction of entries below the peak
8889
float mSigmaPeak[NSECTORS][NCHANNELXSECTOR]; ///< array with the sigma of the peak
8990

90-
// ClassDefNV(CalibTimeSlewingParamTOF, 2); // class for TOF time slewing params
91+
ClassDefNV(CalibTimeSlewingParamTOF, 1); // class for TOF time slewing params
9192
};
9293
} // namespace dataformats
9394
} // namespace o2

Detectors/TOF/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# submit itself to any jurisdiction.
1010

1111
add_subdirectory(base)
12+
add_subdirectory(calibration)
1213
add_subdirectory(simulation)
1314
add_subdirectory(reconstruction)
14-
add_subdirectory(calibration)
1515
if(BUILD_TESTING)
1616
add_subdirectory(prototyping)
1717
endif()

Detectors/TOF/base/include/TOFBase/Digit.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class Digit
7070
Int_t getElTDCIndex() const { return Geo::getTDCFromECH(mElectronIndex); } // to be derived from mElectronIndex
7171
Int_t getElChIndex() const { return Geo::getTDCChFromECH(mElectronIndex); } // to be derived from mElectronIndex
7272

73+
void setCalibratedTime(Double_t time) {mCalibratedTime = time;}
74+
double getCalibratedTime() const {return mCalibratedTime;}
75+
76+
void setIsProblematic(bool flag) {mIsProblematic = flag;}
77+
bool isProblematic() const {return mIsProblematic;}
78+
7379
private:
7480
friend class boost::serialization::access;
7581

@@ -80,7 +86,9 @@ class Digit
8086
Int_t mLabel; ///< Index of the corresponding entry in the MC label array
8187
Bool_t mIsUsedInCluster; //!/< flag to declare that the digit was used to build a cluster
8288
Int_t mElectronIndex; //!/< index in electronic format
83-
89+
Double_t mCalibratedTime; //!< time of the digits after calibration (not persistent; it will be filled during clusterization)
90+
Bool_t mIsProblematic = false; //!< flag to tell whether the channel of the digit was problemati; not persistent; default = ok
91+
8492
ClassDefNV(Digit, 1);
8593
};
8694

Detectors/TOF/base/include/TOFBase/Geo.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,16 @@ class Geo
110110

111111
static constexpr Float_t DEADTIME = 25E+03; // Single channel dead time (ps)
112112
static constexpr Float_t DEADTIMETDC = DEADTIME / TDCBIN; ///< Single channel TDC dead time (ps)
113-
static constexpr Float_t MATCHINGWINDOW = TDCBIN * 8192; // Matching window (ps) 2^13=8192
114113
static constexpr int NWINDOW_IN_ORBIT = 3; //< Number of tof window in 1 orbit
115-
static constexpr Float_t READOUTWINDOW = o2::constants::lhc::LHCOrbitNS / NWINDOW_IN_ORBIT; // Readout window (ns)
114+
static constexpr Double_t READOUTWINDOW = o2::constants::lhc::LHCOrbitNS / NWINDOW_IN_ORBIT; // Readout window (ns) - time between two consecutive triggers = 1/3 orbit
116115
static constexpr int BC_IN_WINDOW = BC_IN_ORBIT / NWINDOW_IN_ORBIT; // N. bunch crossing in 1 tof window
117-
static constexpr Float_t READOUTWINDOW_INV = 1. / READOUTWINDOW; // Readout window (ns)
116+
static constexpr Double_t READOUTWINDOW_INV = 1. / READOUTWINDOW; // Readout window (ns)
117+
118+
static constexpr Int_t LATENCYWINDOW_IN_BC = 1400; // Latency window in BC (larger than 1/3 orbit 1188 BC)
119+
static constexpr Int_t MATCHINGWINDOW_IN_BC = 1200; // Latency window in BC (larger than 1/3 orbit 1188 BC)
120+
static constexpr Double_t LATENCYWINDOW = LATENCYWINDOW_IN_BC * o2::constants::lhc::LHCBunchSpacingNS; // Latency window in ns
121+
static constexpr Double_t MATCHINGWINDOW = MATCHINGWINDOW_IN_BC * o2::constants::lhc::LHCBunchSpacingNS; // Matching window in ns
122+
static constexpr Double_t WINDOWOVERLAP = MATCHINGWINDOW - READOUTWINDOW; // overlap between two consecutive matchingwindow
118123

119124
static constexpr Float_t ANGLES[NPLATES][NMAXNSTRIP] = { // Strip Tilt Angles
120125
{43.99, 43.20, 42.40, 41.59, 40.77, 39.94, 39.11, 38.25, 37.40, 36.53,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ using CcdbApi = o2::ccdb::CcdbApi;
3535
public:
3636
CalibTOFapi() = default;
3737
CalibTOFapi(const std::string url);
38+
CalibTOFapi(long timestamp, o2::dataformats::CalibLHCphaseTOF* phase, o2::dataformats::CalibTimeSlewingParamTOF* slew) : mTimeStamp(timestamp), mLHCphase(phase), mSlewParam(slew) {}
3839
~CalibTOFapi() = default;
3940
void setTimeStamp(long t) {
4041
mTimeStamp = t;

Detectors/TOF/calibration/src/CalibTOFapi.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// or submit itself to any jurisdiction.
1010

1111
#include "TOFCalibration/CalibTOFapi.h"
12+
#include "FairLogger.h" // for LOG
1213

1314
using namespace o2::tof;
1415

@@ -92,7 +93,10 @@ float CalibTOFapi::getTimeCalibration(int ich, float tot) {
9293
// time calibration to correct measured TOF times
9394

9495
float corr = 0;
95-
96+
if (!mLHCphase || !mSlewParam) {
97+
LOG(WARNING) << "Either LHC phase or slewing object null: mLHCphase = " << mLHCphase << ", mSlewParam = " << mSlewParam;
98+
return corr;
99+
}
96100
// LHCphase
97101
corr += mLHCphase->getLHCphase(int(mTimeStamp/1000)); // timestamp that we use in LHCPhase is in seconds, but for CCDB we need it in ms
98102

Detectors/TOF/prototyping/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ o2_add_test_root_macro(findTOFclusterFromLabel.C
4343
o2_add_test_root_macro(checkTS.C
4444
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
4545
LABELS tof)
46+
47+
o2_add_test_root_macro(testCCDB.C
48+
PUBLIC_LINK_LIBRARIES O2::DataFormatsTOF
49+
O2::TOFCalibration
50+
LABELS tof)

Detectors/TOF/prototyping/ConvertRun2CalibrationToO2.C

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@
1111
#include "TH1C.h"
1212
#include "AliTOFGeometry.h"
1313

14+
// macro to be run in *** AliRoot *** to convert the TOF OCDB entries in CCDB entries
15+
// How to run (see below for futher instructions):
16+
// gROOT->LoadMacro("CalibTimeSlewingParamTOF.cxx+")
17+
// .x ConvertRun2CalibrationToO2.C+
18+
19+
1420
class MyFineTimeSlewing : public AliTOFCalibFineSlewing
21+
22+
// class needed to access some data members of the AliTOFCalibFineSlewing class that are protected
23+
1524
{
1625
public:
1726

@@ -33,17 +42,34 @@ public:
3342

3443
void ConvertRun2CalibrationToO2() {
3544

45+
// Remember: Use AliRoot!!
46+
47+
// actually you need to call this outside the macro, or it won't work
48+
3649
gROOT->LoadMacro("CalibTimeSlewingParamTOF.cxx+");
3750

51+
// so you should first:
52+
// - copy
53+
// - DataFormats/Detectors/TOF/src/CalibTimeSlewingParamTOF.cxx
54+
// and
55+
// - DataFormats/Detectors/TOF/include/DataFormatsTOF/CalibTimeSlewingParamTOF.h
56+
// in the local working directory, substituting:
57+
// - #include "DataFormatsTOF/CalibTimeSlewingParamTOF.h"
58+
// with
59+
// - #include "CalibTimeSlewingParamTOF.h"
60+
// - then call:
61+
// - gROOT->LoadMacro("CalibTimeSlewingParamTOF.cxx+")
62+
// from the prompt
63+
3864
o2::dataformats::CalibTimeSlewingParamTOF* mTimeSlewingObj = new o2::dataformats::CalibTimeSlewingParamTOF();
3965

40-
TFile* ffineSlewing = new TFile("OCDB/TOF/Calib/FineSlewing/Run0_999999999_v2_s0.root");
66+
TFile* ffineSlewing = new TFile("TOF/Calib/FineSlewing/Run0_999999999_v2_s0.root");
4167
AliCDBEntry* efineSlewing = (AliCDBEntry*)ffineSlewing->Get("AliCDBEntry");
4268
AliTOFCalibFineSlewing* fs = (AliTOFCalibFineSlewing*)efineSlewing->GetObject();
43-
TFile* foffset = new TFile("OCDB/TOF/Calib/ParOffline/Run297624_999999999_v4_s0.root");
69+
TFile* foffset = new TFile("TOF/Calib/ParOffline/Run297624_999999999_v4_s0.root");
4470
AliCDBEntry* eoffset = (AliCDBEntry*)foffset->Get("AliCDBEntry");
4571
TObjArray* foff = (TObjArray*)eoffset->GetObject();
46-
TFile *fproblematic = new TFile("OCDB/TOF/Calib/Problematic/Run296631_999999999_v3_s0.root");
72+
TFile *fproblematic = new TFile("TOF/Calib/Problematic/Run296631_999999999_v3_s0.root");
4773
AliCDBEntry* eproblematic = (AliCDBEntry*)fproblematic->Get("AliCDBEntry");
4874
TH1C* hProb = (TH1C*)eproblematic->GetObject();
4975

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
void testCCDB() {
2+
3+
// macro to populate CCDB for TOF from a "dummy" LHCphase object, and the timeSlewing (+ offset + fineSlewing + problematic) from Run2 latest OCDB objects
4+
5+
o2::dataformats::CalibLHCphaseTOF* mLHCphaseObj = new o2::dataformats::CalibLHCphaseTOF(); ///< LHCPhase to be written in the output
6+
mLHCphaseObj->addLHCphase(1567771312, 12); // "random" numbers, in ps
7+
mLHCphaseObj->addLHCphase(1567771312+86400, 65); // "random" numbers, in ps
8+
9+
o2::dataformats::CalibTimeSlewingParamTOF* mTimeSlewingObj = new o2::dataformats::CalibTimeSlewingParamTOF(); ///< Time Slewing object to be written in the output
10+
TFile *f = new TFile("TranslateFromRun2/outputCCDBfromOCDB.root");
11+
TTree *t = (TTree *) f->Get("tree");
12+
t->SetBranchAddress("CalibTimeSlewingParamTOF", &mTimeSlewingObj);
13+
t->GetEvent(0);
14+
15+
std::map<std::string, std::string> metadataLHCphase; // can be empty
16+
o2::tof::CalibTOFapi api("http://ccdb-test.cern.ch:8080"); // or http://localhost:8080 for a local installation
17+
api.writeLHCphase(mLHCphaseObj, metadataLHCphase, 1567771312000, 1567771312000+86400000); // 06/09/2019 @ 12:01:52am (UTC), till 10/09/2019 @ 12:01:52am (UTC)
18+
19+
std::map<std::string, std::string> metadataChannelCalib; // can be empty
20+
api.writeTimeSlewingParam(mTimeSlewingObj, metadataChannelCalib, 1567771312000); // 06/09/2019 @ 12:01am (UTC), contains both offset and time slewing
21+
22+
return;
23+
}

Detectors/TOF/reconstruction/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ o2_add_library(TOFReconstruction
1313
src/ClustererTask.cxx src/Encoder.cxx
1414
src/Decoder.cxx
1515
PUBLIC_LINK_LIBRARIES O2::TOFBase O2::DataFormatsTOF
16-
O2::SimulationDataFormat)
16+
O2::SimulationDataFormat
17+
O2::TOFCalibration)
1718

1819
o2_target_root_dictionary(TOFReconstruction
1920
HEADERS include/TOFReconstruction/DataReader.h

0 commit comments

Comments
 (0)