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