1 #ifndef ALITRDCALIBRAFILLHISTO_H
2 #define ALITRDCALIBRAFILLHISTO_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 ///////////////////////////////////////////////////////////////////////////////
10 // TRD calibration class for the HLT parameters //
12 ///////////////////////////////////////////////////////////////////////////////
17 #ifndef ROOT_TProfile2D
18 # include <TProfile2D.h>
29 class TTreeSRedirector;
34 class AliTRDCalibraMode;
35 class AliTRDCalibraVector;
36 class AliTRDCalibraVdriftLinearFit;
46 class AliTRDdigitsManager;
47 class AliTRDSignalIndex;
49 struct eventHeaderStruct;
51 class AliTRDCalibraFillHisto : public TObject {
56 static AliTRDCalibraFillHisto *Instance();
57 static void Terminate();
58 static void Destroy();
59 void DestroyDebugStreamer();
62 AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c);
63 AliTRDCalibraFillHisto &operator=(const AliTRDCalibraFillHisto &) { return *this; }
65 // Functions for initialising and filling with AliTRDtrackV1
66 Bool_t Init2Dhistos(Int_t nboftimebin = -1);
68 Bool_t UpdateHistograms(const AliTRDtrack *t);
69 Bool_t UpdateHistogramsV1(const AliTRDtrackV1 *t);
72 Int_t ProcessEventDAQ(AliRawReader *rawReader);
75 Bool_t IsPadOn(Int_t detector, Int_t row, Int_t col) const;
77 // Functions for write
78 void Write2d(const Char_t *filename = "TRD.calibration.root", Bool_t append = kFALSE);
81 Double_t *StatH(TH2 *ch, Int_t i);
82 Double_t *GetMeanMedianRMSNumberCH();
83 Double_t *GetMeanMedianRMSNumberLinearFitter() const;
85 void AnalyseLinearFitter();
89 // Set of Get the variables
92 void SetIsHLT(Bool_t isHLT = kTRUE) { fIsHLT = isHLT; }
93 Bool_t IsHLT() const { return fIsHLT; }
95 // Choice to fill or not the 2D
96 void SetPH2dOn(Bool_t ph2don = kTRUE) { fPH2dOn = ph2don; }
97 void SetCH2dOn(Bool_t ch2don = kTRUE) { fCH2dOn = ch2don; }
98 void SetPRF2dOn(Bool_t prf2don = kTRUE) { fPRF2dOn = prf2don; }
99 void SetHisto2d(Bool_t histo2d = kTRUE) { fHisto2d = histo2d; }
100 void SetVector2d(Bool_t vector2d = kTRUE) { fVector2d = vector2d; }
101 void SetLinearFitterOn(Bool_t linearfitteron = kTRUE) { fLinearFitterOn = linearfitteron;}
102 void SetLinearFitterDebugOn(Bool_t debug = kTRUE) { fLinearFitterDebugOn = debug; }
103 void SetVersionGainUsed(Int_t versionGainUsed) { fVersionGainUsed = versionGainUsed; }
104 void SetSubVersionGainUsed(Int_t subVersionGainUsed) { fSubVersionGainUsed = subVersionGainUsed; }
105 void SetVersionGainLocalUsed(Int_t versionGainLocalUsed) { fVersionGainLocalUsed = versionGainLocalUsed; }
106 void SetSubVersionGainLocalUsed(Int_t subVersionGainLocalUsed) { fSubVersionGainLocalUsed = subVersionGainLocalUsed; }
107 void SetVersionVdriftUsed(Int_t versionVdriftUsed) { fVersionVdriftUsed = versionVdriftUsed; }
108 void SetSubVersionVdriftUsed(Int_t subVersionVdriftUsed) { fSubVersionVdriftUsed = subVersionVdriftUsed; }
111 Bool_t GetPH2dOn() const { return fPH2dOn; }
112 Bool_t GetCH2dOn() const { return fCH2dOn; }
113 Bool_t GetPRF2dOn() const { return fPRF2dOn; }
114 Bool_t GetHisto2d() const { return fHisto2d; }
115 Bool_t GetVector2d() const { return fVector2d; }
116 Bool_t GetLinearFitterOn() const { return fLinearFitterOn; }
117 Bool_t GetLinearFitterDebugOn() const { return fLinearFitterDebugOn; }
118 Int_t GetVersionGainUsed() const { return fVersionGainUsed; }
119 Int_t GetSubVersionGainUsed() const { return fSubVersionGainUsed; }
120 Int_t GetVersionVdriftUsed() const { return fVersionVdriftUsed; }
121 Int_t GetSubVersionVdriftUsed() const { return fSubVersionVdriftUsed; }
124 // Get stuff that are filled
126 TProfile2D *GetPH2d(Int_t nbtimebin=24, Float_t samplefrequency= 10.0);
127 TProfile2D *GetPRF2d() const { return fPRF2d; }
128 TObjArray GetLinearFitterArray() const { return fLinearFitterArray; }
129 TLinearFitter *GetLinearFitter(Int_t detector, Bool_t force=kFALSE);
130 AliTRDCalibraVdriftLinearFit *GetVdriftLinearFit() const { return fLinearVdriftFit; }
133 // How to fill the 2D
134 void SetRelativeScale(Float_t relativeScale);
135 void SetThresholdClusterPRF2(Float_t thresholdClusterPRF2) { fThresholdClusterPRF2 = thresholdClusterPRF2; }
136 void SetLimitChargeIntegration(Bool_t limitChargeIntegration) { fLimitChargeIntegration = limitChargeIntegration; }
137 void SetFillWithZero(Bool_t fillWithZero) { fFillWithZero = fillWithZero; }
138 void SetNormalizeNbOfCluster(Bool_t normalizeNbOfCluster) { fNormalizeNbOfCluster = normalizeNbOfCluster; }
139 void SetMaxCluster(Float_t maxCluster) { fMaxCluster = maxCluster; }
140 void SetNbMaxCluster(Short_t nbMaxCluster) { fNbMaxCluster = nbMaxCluster; }
141 void SetNz(Int_t i, Short_t nz);
142 void SetNrphi(Int_t i, Short_t nrphi);
143 void SetAllTogether(Int_t i);
144 void SetPerSuperModule(Int_t i);
145 void SetProcent(Float_t procent) { fProcent = procent; }
146 void SetDifference(Short_t difference) { fDifference = difference; }
147 void SetNumberClusters(Short_t numberClusters) { if(numberClusters >= 0) fNumberClusters = numberClusters; }
148 void SetNumberClustersf(Short_t numberClustersf) { fNumberClustersf = numberClustersf; }
149 void SetNumberClustersProcent(Float_t numberClustersProcent) { fNumberClustersProcent = numberClustersProcent; }
150 void SetThresholdClustersDAQ(Float_t thresholdClustersDAQ) { fThresholdClustersDAQ = thresholdClustersDAQ; }
151 void SetNumberRowDAQ(Short_t numberRowDAQ) { fNumberRowDAQ = numberRowDAQ; }
152 void SetNumberColDAQ(Short_t numberColDAQ) { fNumberColDAQ = numberColDAQ; }
153 void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; }
154 void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; }
155 void SetNumberGroupsPRF(Short_t numberGroupsPRF);
157 Float_t GetRelativeScale() const { return fRelativeScale; }
158 Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; }
159 Bool_t GetLimitChargeIntegration() const { return fLimitChargeIntegration; }
160 Bool_t GetFillWithZero() const { return fFillWithZero; }
161 Bool_t GetNormalizeNbOfCluster() const { return fNormalizeNbOfCluster; }
162 Float_t GetMaxCluster() const { return fMaxCluster; }
163 Short_t GetNbMaxCluster() const { return fNbMaxCluster; }
164 Float_t GetProcent() const { return fProcent; }
165 Short_t GetDifference() const { return fDifference; }
166 Short_t GetNumberClusters() const { return fNumberClusters; }
167 Short_t GetNumberClustersf() const { return fNumberClustersf; }
168 Short_t GetNumberBinCharge() const { return fNumberBinCharge; }
169 Short_t GetNumberBinPRF() const { return fNumberBinPRF; }
170 Short_t GetNumberGroupsPRF() const { return fNgroupprf; }
171 Int_t *GetEntriesLinearFitter() const { return fEntriesLinearFitter; }
174 void SetDebugLevel(Short_t level) { fDebugLevel = level; }
177 AliTRDCalibraVector *GetCalibraVector() const { return fCalibraVector; }
182 AliTRDgeometry *fGeo; //! The TRD geometry
184 AliTRDcalibDB *fCalibDB; //! The pointer to the TRDcalibDB instance
187 Bool_t fIsHLT; // Now if HLT, the per detector
189 // Choice to fill or not the 2D
190 Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration
191 Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0
192 Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration
193 Bool_t fHisto2d; // Chose to fill the 2D histos
194 Bool_t fVector2d; // Chose to fill vectors
195 Bool_t fLinearFitterOn; // Method with linear fit for drift velocity
196 Bool_t fLinearFitterDebugOn; // Method with linear fit for drift velocity
198 // How to fill the 2D
199 Float_t fRelativeScale; // Scale of the deposited charge
200 Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals
201 Bool_t fLimitChargeIntegration; // Integration range for the gain calibration
202 Bool_t fFillWithZero; // Fill with zero or not the average pulse height
203 Bool_t fNormalizeNbOfCluster; // Normalize with the number of cluster for the gain
204 Float_t fMaxCluster; // Max amplitude of one cluster
205 Short_t fNbMaxCluster; // Number of tb at the end
207 Int_t fVersionGainUsed; // VersionGainUsed
208 Int_t fSubVersionGainUsed; // SubVersionGainUsed
209 Int_t fVersionGainLocalUsed; // VersionGainUsed
210 Int_t fSubVersionGainLocalUsed;// SubVersionGainUsed
211 Int_t fVersionVdriftUsed; // VersionVdriftUsed
212 Int_t fSubVersionVdriftUsed; // SubVersionVdriftUsed
214 AliTRDCalibraMode *fCalibraMode; // Calibration mode
217 TTreeSRedirector *fDebugStreamer; //!Debug streamer
218 Short_t fDebugLevel; // Flag for debugging
220 // Internal variables
223 // Fill the 2D histos in the offline tracking
224 Int_t fDetectorPreviousTrack; // Change of detector
225 Int_t fMCMPrevious; // Change of MCM
226 Int_t fROBPrevious; // Change of ROB
227 Short_t fNumberClusters; // Minimum number of clusters in the tracklets
228 Short_t fNumberClustersf; // Maximum number of clusters in the tracklets
229 Float_t fNumberClustersProcent; // Procent of number of time bins for fNumberClusters
230 Float_t fThresholdClustersDAQ; // Threshold clusters for DAQ algorithm
231 Short_t fNumberRowDAQ; // Size of the spot for DAQ algorithm
232 Short_t fNumberColDAQ; // Size of the spot for DAQ algorithm
233 Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
234 Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
235 Int_t fNumberTrack; // How many tracks could be used (Debug for the moment)
236 Int_t fNumberUsedCh[2]; // How many tracks have been really used for the gain (0, strict; 1 with fProcent)
237 Int_t fNumberUsedPh[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fDifference)
238 Int_t fTimeMax; // Number of time bins
239 Float_t fSf; // Sampling frequence
240 Short_t fNumberBinCharge; // Number of bins for the gain factor
241 Short_t fNumberBinPRF; // Number of bin for the PRF
242 Short_t fNgroupprf; // Number of groups in tnp bins for PRF /2.0
244 // Variables per tracklet
245 Float_t *fAmpTotal; // Energy deposited in the calibration group by the track
246 Short_t *fPHPlace; // Calibration group of PH
247 Float_t *fPHValue; // PH
248 Bool_t fGoodTracklet; // Good tracklet
249 TLinearFitter *fLinearFitterTracklet; // linear fitter tracklet
251 Int_t *fEntriesCH; // Number of entries CH
252 Int_t *fEntriesLinearFitter; // Number of entries LinearFitter
259 AliTRDCalibraVector *fCalibraVector; // The vector object
262 // Histograms to store the info from the digits, from the tracklets or from the tracks
263 TProfile2D *fPH2d; // 2D average pulse height
264 TProfile2D *fPRF2d; // 2D PRF
265 TH2I *fCH2d; // 2D deposited charge
266 TObjArray fLinearFitterArray; // TObjArray of Linear Fitters for the detectors
267 AliTRDCalibraVdriftLinearFit *fLinearVdriftFit; // Info Linear Fit
269 // Current calib object: to correct for the database used
270 AliTRDCalDet *fCalDetGain; // Current calib object gain
271 AliTRDCalROC *fCalROCGain; // Current calib object gain
274 // A lot of internal functions......
276 Bool_t InitCalPad(Int_t detector);
278 // Create the 2D histo to be filled Online
279 void CreateCH2d(Int_t nn);
280 void CreatePH2d(Int_t nn);
281 void CreatePRF2d(Int_t nn);
283 // Calibration with AliTRDtrackV1
284 void FillTheInfoOfTheTrackPH();
285 void FillTheInfoOfTheTrackCH(Int_t nbclusters);
286 Bool_t FindP1TrackPHtracklet(const AliTRDtrack *t, Int_t index0, Int_t index1);
287 Bool_t FindP1TrackPHtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters);
288 Bool_t HandlePRFtracklet(const AliTRDtrack *t, Int_t index0, Int_t index1);
289 Bool_t HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters);
290 void ResetfVariablestracklet();
291 void StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col,const AliTRDcluster *cls=0x0);
292 void FillCH2d(Int_t x, Float_t y);
294 // Calibration on DAQ
296 Int_t FillDAQ(Double_t phvalue[16][144][36]);
297 Bool_t UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Float_t signal, Int_t nbtimebins);
299 // row col calibration groups stuff
300 Bool_t LocalisationDetectorXbins(Int_t detector);
301 Int_t CalculateTotalNumberOfBins(Int_t i);
302 void CheckGoodTrackletV0(const Int_t detector,const Int_t row,const Int_t col);
303 void CheckGoodTrackletV1(const AliTRDcluster *cl);
304 Int_t CalculateCalibrationGroup(Int_t i, Int_t row, Int_t col) const;
309 // Some basic geometry function
310 virtual Int_t GetLayer(Int_t d) const;
311 virtual Int_t GetStack(Int_t d) const;
312 virtual Int_t GetSector(Int_t d) const;
315 // Instance of this class and so on
316 static AliTRDCalibraFillHisto *fgInstance; // Instance
317 static Bool_t fgTerminated; // If terminated
321 // This is a singleton, contructor is private!
322 AliTRDCalibraFillHisto();
323 virtual ~AliTRDCalibraFillHisto();
325 ClassDef(AliTRDCalibraFillHisto,4) // TRD Calibration class