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>
34 class TTreeSRedirector;
39 class AliTRDCalibraMode;
40 class AliTRDCalibraVector;
41 class AliTRDCalibraVdriftLinearFit;
42 class AliTRDRawStream;
45 class AliTRDmcmTracklet;
48 struct eventHeaderStruct;
50 class AliTRDCalibraFillHisto : public TObject {
55 static AliTRDCalibraFillHisto *Instance();
56 static void Terminate();
57 static void Destroy();
59 AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c);
60 AliTRDCalibraFillHisto &operator=(const AliTRDCalibraFillHisto &) { return *this; }
62 // Functions for initialising the AliTRDCalibraFillHisto in the code
63 Bool_t Init2Dhistos();
65 // Functions for filling the histos in the code
67 Bool_t UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t);
68 Bool_t UpdateHistogramcm(AliTRDmcmTracklet *trk);
71 Int_t ProcessEventDAQ(AliTRDRawStream *rawStream, Bool_t nocheck = kFALSE);
72 Int_t ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck = kFALSE);
73 Int_t ProcessEventDAQ(eventHeaderStruct *event, Bool_t nocheck = kFALSE);
75 Bool_t UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Int_t signal, Int_t nbtimebins);
78 Bool_t IsPadOn(Int_t detector, Int_t col, Int_t row) const;
80 // Functions for write
81 void Write2d(const Char_t *filename = "TRD.calibration.root", Bool_t append = kFALSE);
84 Double_t *StatH(TH2 *ch, Int_t i);
85 Double_t *GetMeanMedianRMSNumberCH();
86 Double_t *GetMeanMedianRMSNumberLinearFitter() const;
90 // Set of Get the variables
93 // Choice to fill or not the 2D
94 void SetMITracking(Bool_t mitracking = kTRUE) { fMITracking = mitracking; }
95 void SetMcmTracking(Bool_t mcmtracking = kTRUE) { fMcmTracking = mcmtracking; }
96 void SetMcmCorrectAngle(Bool_t mcmcorrectangle = kTRUE) { fMcmCorrectAngle = mcmcorrectangle; }
97 void SetPH2dOn(Bool_t ph2don = kTRUE) { fPH2dOn = ph2don; }
98 void SetCH2dOn(Bool_t ch2don = kTRUE) { fCH2dOn = ch2don; }
99 void SetPRF2dOn(Bool_t prf2don = kTRUE) { fPRF2dOn = prf2don; }
100 void SetHisto2d(Bool_t histo2d = kTRUE) { fHisto2d = histo2d; }
101 void SetVector2d(Bool_t vector2d = kTRUE) { fVector2d = vector2d; }
102 void SetLinearFitterOn(Bool_t linearfitteron = kTRUE) { fLinearFitterOn = linearfitteron;}
103 void SetLinearFitterDebugOn(Bool_t debug = kTRUE) { fLinearFitterDebugOn = debug; }
106 Bool_t GetMITracking() const { return fMITracking; }
107 Bool_t GetMcmTracking() const { return fMcmTracking; }
108 Bool_t GetMcmCorrectAngle() const { return fMcmCorrectAngle; }
109 Bool_t GetPH2dOn() const { return fPH2dOn; }
110 Bool_t GetCH2dOn() const { return fCH2dOn; }
111 Bool_t GetPRF2dOn() const { return fPRF2dOn; }
112 Bool_t GetHisto2d() const { return fHisto2d; }
113 Bool_t GetVector2d() const { return fVector2d; }
114 Bool_t GetLinearFitterOn() const { return fLinearFitterOn; }
115 Bool_t GetLinearFitterDebugOn() const { return fLinearFitterDebugOn; }
117 TH2I *GetCH2d() const { return fCH2d; }
118 TProfile2D *GetPH2d(Int_t nbtimebin=24, Float_t samplefrequency= 10.0);
119 TProfile2D *GetPRF2d() const { return fPRF2d; }
120 TObjArray GetLinearFitterArray() const { return fLinearFitterArray; }
121 TLinearFitter *GetLinearFitter(Int_t detector, Bool_t force=kFALSE);
124 // How to fill the 2D
125 void SetRelativeScale(Float_t relativeScale);
126 void SetThresholdClusterPRF2(Float_t thresholdClusterPRF2) { fThresholdClusterPRF2 = thresholdClusterPRF2; }
127 void SetNz(Int_t i, Short_t nz);
128 void SetNrphi(Int_t i, Short_t nrphi);
129 void SetProcent(Float_t procent) { fProcent = procent; }
130 void SetDifference(Short_t difference) { fDifference = difference; }
131 void SetNumberClusters(Short_t numberClusters) { fNumberClusters = numberClusters; }
132 void SetNumberBinCharge(Short_t numberBinCharge) { fNumberBinCharge = numberBinCharge; }
133 void SetNumberBinPRF(Short_t numberBinPRF) { fNumberBinPRF = numberBinPRF; }
134 void SetNumberGroupsPRF(Short_t numberGroupsPRF);
136 Float_t GetRelativeScale() const { return fRelativeScale; }
137 Float_t GetThresholdClusterPRF2() const { return fThresholdClusterPRF2; }
138 Float_t GetProcent() const { return fProcent; }
139 Short_t GetDifference() const { return fDifference; }
140 Short_t GetNumberClusters() const { return fNumberClusters; }
141 Short_t GetNumberBinCharge() const { return fNumberBinCharge; }
142 Short_t GetNumberBinPRF() const { return fNumberBinPRF; }
143 Short_t GetNumberGroupsPRF() const { return fNgroupprf; }
144 Int_t *GetEntriesLinearFitter() const { return fEntriesLinearFitter; }
147 void SetDebugLevel(Short_t level) { fDebugLevel = level; }
150 AliTRDCalibraVector *GetCalibraVector() const { return fCalibraVector; }
154 // This is a singleton, contructor is private!
155 AliTRDCalibraFillHisto();
156 virtual ~AliTRDCalibraFillHisto();
161 AliTRDgeometry *fGeo; //! The TRD geometry
163 // Choice to fill or not the 2D
164 Bool_t fMITracking; // Chose to fill the 2D histos or vectors during the offline MI tracking
165 Bool_t fMcmTracking; // Chose to fill the 2D histos or vectors during the tracking with tracklets
166 Bool_t fMcmCorrectAngle; // Apply correction due to the mcmtrackletangle in the z direction (only) assuming from vertex
167 Bool_t fCH2dOn; // Chose to fill the 2D histos or vectors for the relative gain calibration
168 Bool_t fPH2dOn; // Chose to fill the 2D histos or vectors for the drift velocity and T0
169 Bool_t fPRF2dOn; // Chose to fill the 2D histos or vectors for the pad response function calibration
170 Bool_t fHisto2d; // Chose to fill the 2D histos
171 Bool_t fVector2d; // Chose to fill vectors
172 Bool_t fLinearFitterOn; // Method with linear fit for drift velocity
173 Bool_t fLinearFitterDebugOn; // Method with linear fit for drift velocity
175 // How to fill the 2D
176 Float_t fRelativeScale; // Scale of the deposited charge
177 Float_t fThresholdClusterPRF2; // Threshold on cluster pad signals
179 AliTRDCalibraMode *fCalibraMode; // Calibration mode
182 TTreeSRedirector *fDebugStreamer; //!Debug streamer
183 Short_t fDebugLevel; // Flag for debugging
185 // Internal variables
188 // Fill the 2D histos in the offline tracking
189 Bool_t fDetectorAliTRDtrack; // Change of track
190 Int_t fDetectorPreviousTrack; // Change of detector
191 Short_t fNumberClusters; // Minimum number of clusters in the tracklets
192 Float_t fProcent; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
193 Short_t fDifference; // Limit to take the info of the most important calibration group if the track goes through 2 groups (CH)
194 Int_t fNumberTrack; // How many tracks could be used (Debug for the moment)
195 Int_t fNumberUsedCh[2]; // How many tracks have been really used for the gain (0, strict; 1 with fProcent)
196 Int_t fNumberUsedPh[2]; // How many tracks have been really used for the drift velocity (0, strict; 1 with fDifference)
197 Int_t fTimeMax; // Number of time bins
198 Float_t fSf; // Sampling frequence
199 Short_t fNumberBinCharge; // Number of bins for the gain factor
200 Short_t fNumberBinPRF; // Number of bin for the PRF
201 Short_t fNgroupprf; // Number of groups in tnp bins for PRF /2.0
203 // Variables per tracklet
204 TObjArray *fListClusters; // List of clusters
205 Double_t *fPar0; // List of track parameter fP[0]
206 Double_t *fPar1; // List of track parameter fP[1]
207 Double_t *fPar2; // List of track parameter fP[2]
208 Double_t *fPar3; // List of track parameter fP[3]
209 Double_t *fPar4; // List of track paarmeter fP[4]
210 Float_t *fAmpTotal; // Energy deposited in the calibration group by the track
211 Short_t *fPHPlace; // Calibration group of PH
212 Float_t *fPHValue; // PH
213 Bool_t fGoodTracklet; // Good tracklet
214 // Variables per track
215 Bool_t fGoodTrack; // no return
218 Int_t *fEntriesCH; // Number of entries CH
219 Int_t *fEntriesLinearFitter; // Number of entries LinearFitter
227 AliTRDCalibraVector *fCalibraVector; // The vector object
230 // Histograms to store the info from the digits, from the tracklets or from the tracks
231 TProfile2D *fPH2d; // 2D average pulse height
232 TProfile2D *fPRF2d; // 2D PRF
233 TH2I *fCH2d; // 2D deposited charge
234 TObjArray fLinearFitterArray; // TObjArray of Linear Fitters for the detectors
235 AliTRDCalibraVdriftLinearFit *fLinearVdriftFit; // Info Linear Fit
239 // A lot of internal functions......
241 // Create the 2D histo to be filled Online
242 void CreateCH2d(Int_t nn);
243 void CreatePH2d(Int_t nn);
244 void CreatePRF2d(Int_t nn);
247 void FillTheInfoOfTheTrackPH();
248 void FillTheInfoOfTheTrackCH();
249 void FillCH2d(Int_t x, Float_t y);
250 Bool_t FindP1TrackPH();
251 void ResetfVariables();
252 Bool_t LocalisationDetectorXbins(Int_t detector);
253 Int_t *CalculateRowCol(AliTRDcluster *cl) const;
254 void CheckGoodTracklet(Int_t detector, Int_t *rowcol);
255 Int_t CalculateCalibrationGroup(Int_t i, Int_t *rowcol) const;
256 Int_t CalculateTotalNumberOfBins(Int_t i);
257 void StoreInfoCHPH(AliTRDcluster *cl, AliTRDtrack *t, Int_t *group);
261 void AnalyseLinearFitter();
266 // Some basic geometry function
267 virtual Int_t GetPlane(Int_t d) const;
268 virtual Int_t GetChamber(Int_t d) const;
269 virtual Int_t GetSector(Int_t d) const;
272 // Instance of this class and so on
273 static AliTRDCalibraFillHisto *fgInstance; // Instance
274 static Bool_t fgTerminated; // If terminated
277 ClassDef(AliTRDCalibraFillHisto,3) // TRD Calibration class