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_TLinearFitter
18 # include <TLinearFitter.h>
20 #ifndef ROOT_TProfile2D
21 # include <TProfile2D.h>
36 class AliTRDCalibraMode;
37 class AliTRDCalibraVector;
40 class AliTRDRawStream;
43 class AliTRDmcmTracklet;
44 class TTreeSRedirector;
46 struct eventHeaderStruct;
48 class AliTRDCalibraFillHisto : public TObject {
53 static AliTRDCalibraFillHisto *Instance();
54 static void Terminate();
55 static void Destroy();
57 AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c);
58 AliTRDCalibraFillHisto &operator=(const AliTRDCalibraFillHisto &) { return *this; }
60 // Functions for initialising the AliTRDCalibraFillHisto in the code
61 Bool_t Init2Dhistos();
63 // Functions for filling the histos in the code
65 Bool_t UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t);
66 Bool_t UpdateHistogramcm(AliTRDmcmTracklet *trk);
69 Bool_t ProcessEventDAQ(AliTRDRawStream *rawStream);
70 Bool_t ProcessEventDAQ(AliRawReader *rawReader);
71 Bool_t ProcessEventDAQ(eventHeaderStruct *event);
73 Bool_t UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Int_t signal, Int_t nbtimebins);
77 Bool_t IsPadOn(Int_t detector, Int_t col, Int_t row) const;
79 // Functions for plotting the 2D
82 // Functions for write
83 void Write2d(const Char_t *filename = "TRD.calibration.root", Bool_t append = kFALSE);
85 // Reset the linearfitter objects
86 void ResetLinearFitter();
87 void ResetCHHisto() { if(fCH2d) fCH2d->Reset(); }
88 void ResetPHHisto() { if(fPH2d) fPH2d->Reset(); }
89 void ResetPRFHisto() { if(fPRF2d) fPRF2d->Reset();}
92 Double_t *StatH(TH2 *ch, Int_t i);
93 Double_t *GetMeanMedianRMSNumberCH();
94 Double_t *GetMeanMedianRMSNumberLinearFitter() const;
98 // Set of Get the variables
101 // Choice to fill or not the 2D
102 void SetMITracking(Bool_t mitracking = kTRUE) { fMITracking = mitracking; }
103 void SetMcmTracking(Bool_t mcmtracking = kTRUE) { fMcmTracking = mcmtracking; }
104 void SetMcmCorrectAngle() { fMcmCorrectAngle = kTRUE; }
105 void SetPH2dOn() { fPH2dOn = kTRUE; }
106 void SetCH2dOn() { fCH2dOn = kTRUE; }
107 void SetPRF2dOn() { fPRF2dOn = kTRUE; }
108 void SetHisto2d() { fHisto2d = kTRUE; }
109 void SetVector2d() { fVector2d = kTRUE; }
110 void SetLinearFitterOn() { fLinearFitterOn = kTRUE; }
111 void SetLinearFitterDebugOn() { fLinearFitterDebugOn = kTRUE; }
114 Bool_t GetMITracking() const { return fMITracking; }
115 Bool_t GetMcmTracking() const { return fMcmTracking; }
116 Bool_t GetMcmCorrectAngle() const { return fMcmCorrectAngle; }
117 Bool_t GetPH2dOn() const { return fPH2dOn; }
118 Bool_t GetCH2dOn() const { return fCH2dOn; }
119 Bool_t GetPRF2dOn() const { return fPRF2dOn; }
120 Bool_t GetHisto2d() const { return fHisto2d; }
121 Bool_t GetVector2d() const { return fVector2d; }
122 TH2I *GetCH2d() const { return fCH2d; }
123 TProfile2D *GetPH2d(Int_t nbtimebin=24, Float_t samplefrequency= 10.0, Bool_t force=kFALSE);
124 TProfile2D *GetPRF2d() const { return fPRF2d; }
125 TObjArray GetLinearFitterArray() const { return fLinearFitterArray; }
126 TLinearFitter *GetLinearFitter(Int_t detector, Bool_t force=kFALSE);
127 TH2F *GetLinearFitterHisto(Int_t detector, Bool_t force=kFALSE);
129 // How to fill the 2D
130 void SetRelativeScale(Float_t relativeScale);
131 void SetThresholdClusterPRF2(Float_t thresholdClusterPRF2) { fThresholdClusterPRF2 = thresholdClusterPRF2; }
132 void SetNz(Int_t i, Short_t nz);
133 void SetNrphi(Int_t i, Short_t nrphi);
134 void SetProcent(Float_t procent) { fProcent = procent; }
135 void SetDifference(Short_t difference) { fDifference = difference; }
136 void SetNumberClusters(Short_t numberClusters) { fNumberClusters = numberClusters; }
137 void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; }
138 void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; }
139 void SetNumberGroupsPRF(Short_t numberGroupsPRF);
141 Float_t GetRelativeScale() const { return fRelativeScale; }
142 Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; }
143 Float_t GetProcent() const { return fProcent; }
144 Short_t GetDifference() const { return fDifference; }
145 Short_t GetNumberClusters() const { return fNumberClusters; }
146 Short_t GetNumberBinCharge() const { return fNumberBinCharge; }
147 Short_t GetNumberBinPRF() const { return fNumberBinPRF; }
148 Short_t GetNumberGroupsPRF() const { return fNgroupprf; }
149 Int_t *GetEntriesLinearFitter() const { return fEntriesLinearFitter; }
151 AliTRDCalibraMode *GetCalibraMode() const { return fCalibraMode; }
154 void SetDebugLevel(Short_t level) { fDebugLevel = level; }
157 AliTRDCalibraVector *GetCalibraVector() const { return fCalibraVector; }
161 // This is a singleton, contructor is private!
162 AliTRDCalibraFillHisto();
163 virtual ~AliTRDCalibraFillHisto();
167 // Choice to fill or not the 2D
168 Bool_t fMITracking; // Chose to fill the 2D histos or vectors during the offline MI tracking
169 Bool_t fMcmTracking; // Chose to fill the 2D histos or vectors during the tracking with tracklets
170 Bool_t fMcmCorrectAngle; // Apply correction due to the mcmtrackletangle in the z direction (only) assuming from vertex
171 Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration
172 Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0
173 Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration
174 Bool_t fHisto2d; // Chose to fill the 2D histos
175 Bool_t fVector2d; // Chose to fill vectors
176 Bool_t fLinearFitterOn; // Method with linear fit for drift velocity
177 Bool_t fLinearFitterDebugOn; // Method with linear fit for drift velocity
179 // How to fill the 2D
180 Float_t fRelativeScale; // Scale of the deposited charge
181 Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals
183 AliTRDCalibraMode *fCalibraMode; // Calibration mode
186 TTreeSRedirector *fDebugStreamer; //!Debug streamer
187 Short_t fDebugLevel; // Flag for debugging
189 // Internal variables
192 // Fill the 2D histos in the offline tracking
193 Bool_t fDetectorAliTRDtrack; // Change of track
194 Int_t fDetectorPreviousTrack; // Change of detector
195 Short_t fNumberClusters; // Minimum number of clusters in the tracklets
196 Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
197 Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
198 Int_t fNumberTrack; // How many tracks could be used (Debug for the moment)
199 Int_t fNumberUsedCh[2]; // How many tracks have been really used for the gain (0, strict; 1 with fProcent)
200 Int_t fNumberUsedPh[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fDifference)
201 Int_t fTimeMax; // Number of time bins
202 Float_t fSf; // Sampling frequence
203 Short_t fNumberBinCharge; // Number of bins for the gain factor
204 Short_t fNumberBinPRF; // Number of bin for the PRF
205 Short_t fNgroupprf; // Number of groups in tnp bins for PRF /2.0
207 // Variables per tracklet
208 TObjArray *fListClusters; // List of clusters
209 Double_t *fPar0; // List of track parameter fP[0]
210 Double_t *fPar1; // List of track parameter fP[1]
211 Double_t *fPar2; // List of track parameter fP[2]
212 Double_t *fPar3; // List of track parameter fP[3]
213 Double_t *fPar4; // List of track paarmeter fP[4]
214 Float_t *fAmpTotal; // Energy deposited in the calibration group by the track
215 Short_t *fPHPlace; // Calibration group of PH
216 Float_t *fPHValue; // PH
217 Bool_t fGoodTracklet; // Good tracklet
218 // Variables per track
219 Bool_t fGoodTrack; // no return
222 Int_t *fEntriesCH; // Number of entries CH
223 Int_t *fEntriesLinearFitter; // Number of entries LinearFitter
231 AliTRDCalibraVector *fCalibraVector; // The vector object
234 // Histograms to store the info from the digits, from the tracklets or from the tracks
235 TProfile2D *fPH2d; // 2D average pulse height
236 TProfile2D *fPRF2d; // 2D PRF
237 TH2I *fCH2d; // 2D deposited charge
238 TObjArray fLinearFitterArray; // TObjArray of Linear Fitters for the detectors
239 TObjArray fLinearFitterHistoArray; // TObjArray of histo2D for debugging Linear Fitters
242 // A lot of internal functions......
244 // Create the 2D histo to be filled Online
245 void CreateCH2d(Int_t nn);
246 void CreatePH2d(Int_t nn);
247 void CreatePRF2d(Int_t nn);
250 void FillTheInfoOfTheTrackPH();
251 void FillTheInfoOfTheTrackCH();
252 void FillCH2d(Int_t x, Float_t y);
253 void FillCHSm(Int_t supermodule, Float_t y);
254 Bool_t FindP1TrackPH();
255 void ResetfVariables();
256 Bool_t LocalisationDetectorXbins(Int_t detector);
257 Int_t *CalculateRowCol(AliTRDcluster *cl) const;
258 void CheckGoodTracklet(Int_t detector, Int_t *rowcol);
259 Int_t CalculateCalibrationGroup(Int_t i, Int_t *rowcol) const;
260 Int_t CalculateTotalNumberOfBins(Int_t i);
261 void StoreInfoCHPH(AliTRDcluster *cl, AliTRDtrack *t, Int_t *group);
267 // Some basic geometry function
268 virtual Int_t GetPlane(Int_t d) const;
269 virtual Int_t GetChamber(Int_t d) const;
270 virtual Int_t GetSector(Int_t d) const;
273 // Instance of this class and so on
274 static AliTRDCalibraFillHisto *fgInstance; // Instance
275 static Bool_t fgTerminated; // If terminated
278 ClassDef(AliTRDCalibraFillHisto,2) // TRD Calibration class