Project
Loading...
Searching...
No Matches
CalibTOF.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef ALICEO2_GLOBTRACKING_CALIBTOF_
17#define ALICEO2_GLOBTRACKING_CALIBTOF_
18
19#include <Rtypes.h>
20#include <array>
21#include <vector>
22#include <string>
23#include <TStopwatch.h>
27#include "TOFBase/Geo.h"
28#include "TH1F.h"
29#include "TH1D.h"
30#include "TH2F.h"
31#include "TF1.h"
32#include "TFile.h"
33#include "TGraphErrors.h"
34#include "TOFBase/CalibTOFapi.h"
35
36class TTree;
37
38namespace o2
39{
40
41namespace globaltracking
42{
44{
45 using Geo = o2::tof::Geo;
47
48 public:
49 static constexpr int NSTRIPSPERSTEP = 13; // we chose this number because we process per sector, and
50 // each sector has 91 = 13x7 strips
51 static constexpr int NPADSPERSTEP = Geo::NPADS * NSTRIPSPERSTEP;
52 static constexpr int NSTEPSPERSECTOR = 91 / NSTRIPSPERSTEP;
53 enum CalibType : int { kLHCphase = 1,
55 kChannelTimeSlewing = 4 }; // enum to define which calibration we will do
56
58 CalibTOF();
59
61 ~CalibTOF();
62
64 void run(int flag, int sector = -1);
66
68 void init();
69
71 void setInputTreeTOFCollectedCalibInfo(TTree* tree) { mTreeCollectedCalibInfoTOF = tree; }
72
74 void setOutputTree(TTree* tr) { mOutputTree = tr; }
75
77 void setCollectedCalibInfoTOFBranchName(const std::string& nm) { mCollectedCalibInfoTOFBranchName = nm; }
78 void setOutputBranchName(const std::string& nm) { mOutputBranchName = nm; }
79
81 const std::string& getCollectedCalibInfoTOFBranchName() const { return mCollectedCalibInfoTOFBranchName; }
82 const std::string& getOutputBranchName() const { return mOutputBranchName; }
83
85 void print() const;
86
87 TH2F* getLHCphaseHisto() { return mHistoLHCphase; }
88 TH2F* getChTimeSlewingHistoAll() { return mHistoChTimeSlewingAll; };
89 void setMinTimestamp(int minTimestamp) { mMinTimestamp = minTimestamp; }
90 void setMaxTimestamp(int maxTimestamp) { mMaxTimestamp = maxTimestamp; }
91
92 TGraphErrors* processSlewing(TH2F* histo, Bool_t forceZero, TF1* fitFunc);
93 Int_t FitPeak(TF1* fitFunc, TH1* h, Float_t startSigma, Float_t nSigmaMin, Float_t nSigmaMax, const char* debuginfo = "", TH2* hdbg = nullptr);
94
95 void setDebugMode(Int_t flag = kTRUE) { mDebugMode = flag; }
96 Int_t getDebugMode() const { return mDebugMode; }
97
98 void merge(const char* name);
99
100 void flagProblematics();
101
102 void setNsigmaFractionProblematicCut(float value) { mNsigmaFractionProblematicCut = value; }
103 void setNsigmaSigmaProblematicCut(float value) { mNsigmaSigmaProblematicCut = value; }
104 float getNsigmaFractionProblematicCut() const { return mNsigmaFractionProblematicCut; }
105 float getNsigmaSigmaProblematicCut() const { return mNsigmaSigmaProblematicCut; }
106
107 void setFillCCDB(bool flag) { mFillCCDB = flag; }
108 bool getFillCCDB() const { return mFillCCDB; }
109
110 void setCCDBpath(const std::string path) { mCCDBpath = path; }
111 std::string getCCDBpath() const { return mCCDBpath; }
112
113 private:
114 Int_t mDebugMode = 0;
115
116 float mNsigmaFractionProblematicCut = 5;
117 float mNsigmaSigmaProblematicCut = 5;
118
119 void fillLHCphaseCalibInput(std::vector<o2::dataformats::CalibInfoTOFshort>* calibinfotof);
120 void doLHCPhaseCalib(); // calibrate with respect LHC phase
121 void fillChannelCalibInput(std::vector<o2::dataformats::CalibInfoTOFshort>* calibinfotof, float offset, int ipad, TH1F* histo, std::vector<o2::dataformats::CalibInfoTOFshort>* calibTimePad); // we will fill the input for the channel-level calibration
122 void fillChannelTimeSlewingCalib(float offset, int ipad, TH2F* histo, std::vector<o2::dataformats::CalibInfoTOFshort>* calibTimePad); // we will fill the input for the channel-time-slewing calibration
123 float doChannelCalibration(int ipad, TH1F* histo, TF1* func); // calibrate single channel from histos --> return fraction of entries under the peak
124 void resetChannelLevelHistos(TH1F* histoOffset[NPADSPERSTEP], TH2F* histoTimeSlewing, std::vector<o2::dataformats::CalibInfoTOFshort>* calibTimePad[NPADSPERSTEP]); // reset signle channel histos
125
126 // objects needed for calibration
127 TH2F* mHistoLHCphase = nullptr;
128 TH2F* mHistoChTimeSlewingAll; // time slewing all channels
129
130 TH1D* mProjTimeSlewingTemp; // temporary histo for time slewing
131
132 void attachInputTrees();
133 bool loadTOFCollectedCalibInfo(TTree* localTree, int& currententry, int increment = 1);
134
135 //================================================================
136
137 // Data members
138
139 bool mInitDone = false;
140 bool mFillCCDB = false;
141 std::string mCCDBpath = "http://alice-ccdb.cern.ch";
142
144
145 // to be done later
146
147 TTree* mTreeCollectedCalibInfoTOF = nullptr;
148
149 TTree* mOutputTree = nullptr;
150
151 std::string mCollectedCalibInfoTOFBranchName = "TOFCollectedCalibInfo";
152 std::string mOutputBranchName = "TOFCalibParam";
153 // output calibration
156 float mCalibChannelOffset[Geo::NCHANNELS];
157 float mCalibChannelOffsetErr[Geo::NCHANNELS];
158
159 // previous calibration read from CCDB
160 float mInitialCalibChannelOffset[Geo::NCHANNELS];
161
162 TF1* mFuncLHCphase = nullptr;
163
164 int mMinTimestamp = 0;
166
167 int mMaxTimestamp = 1;
169
170 CalibTOFapi mCalibTOFapi;
171
172 // ClassDefNV(CalibTOF, 1);
173};
174} // namespace globaltracking
175} // namespace o2
176
177#endif
Class to store the output of the matching to TOF for calibration (no channel info,...
Class to store the output of the matching to TOF for calibration.
Class to use TOF calibration (decalibration, calibration)
Class to store the output of the matching to TOF for calibration.
Class for time synchronization of RawReader instances.
float getNsigmaFractionProblematicCut() const
Definition CalibTOF.h:104
static constexpr int NPADSPERSTEP
Definition CalibTOF.h:51
Int_t FitPeak(TF1 *fitFunc, TH1 *h, Float_t startSigma, Float_t nSigmaMin, Float_t nSigmaMax, const char *debuginfo="", TH2 *hdbg=nullptr)
Definition CalibTOF.cxx:571
Int_t getDebugMode() const
Definition CalibTOF.h:96
std::string getCCDBpath() const
Definition CalibTOF.h:111
void setNsigmaSigmaProblematicCut(float value)
Definition CalibTOF.h:103
void setOutputTree(TTree *tr)
set input branch names for the input from the tree
Definition CalibTOF.h:74
const std::string & getCollectedCalibInfoTOFBranchName() const
Definition CalibTOF.h:81
void setMinTimestamp(int minTimestamp)
Definition CalibTOF.h:89
void merge(const char *name)
Definition CalibTOF.cxx:658
void setInputTreeTOFCollectedCalibInfo(TTree *tree)
set output tree to write calibration objects
Definition CalibTOF.h:71
TGraphErrors * processSlewing(TH2F *histo, Bool_t forceZero, TF1 *fitFunc)
Definition CalibTOF.cxx:485
void setCCDBpath(const std::string path)
Definition CalibTOF.h:110
void run(int flag, int sector=-1)
Definition CalibTOF.cxx:126
void init()
set tree/chain containing TOF calib info
Definition CalibTOF.cxx:72
void setFillCCDB(bool flag)
Definition CalibTOF.h:107
~CalibTOF()
calibrate using the provided input
Definition CalibTOF.cxx:43
void setMaxTimestamp(int maxTimestamp)
Definition CalibTOF.h:90
static constexpr int NSTRIPSPERSTEP
Definition CalibTOF.h:49
void fillOutput(int flag=kLHCphase|kChannelOffset|kChannelTimeSlewing)
perform all initializations
Definition CalibTOF.cxx:272
const std::string & getOutputBranchName() const
print settings
Definition CalibTOF.h:82
void setDebugMode(Int_t flag=kTRUE)
Definition CalibTOF.h:95
float getNsigmaSigmaProblematicCut() const
Definition CalibTOF.h:105
void setCollectedCalibInfoTOFBranchName(const std::string &nm)
Definition CalibTOF.h:77
void flagProblematics()
problematics are flagged with negative values for frationUnderPeak: -100 empty channels,...
Definition CalibTOF.cxx:688
static constexpr int NSTEPSPERSECTOR
Definition CalibTOF.h:52
void setNsigmaFractionProblematicCut(float value)
Definition CalibTOF.h:102
void setOutputBranchName(const std::string &nm)
get input branch names for the input from the tree
Definition CalibTOF.h:78
TOF geo parameters (only statics)
Definition Geo.h:28
static constexpr Int_t NPADS
Definition Geo.h:110
static constexpr int NCHANNELS
Definition Geo.h:124
GLenum func
Definition glcorearb.h:778
GLuint const GLchar * name
Definition glcorearb.h:781
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLintptr offset
Definition glcorearb.h:660
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))