Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / TRD / AliTRDrecoParam.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  Parameter class for the TRD reconstruction                               //
21 //                                                                           //
22 //  Authors:                                                                 //
23 //    Alex Bercuci <A.Bercuci@gsi.de>                                        //
24 //    Markus Fasel <M.Fasel@gsi.de>                                          //
25 //                                                                           //
26 ///////////////////////////////////////////////////////////////////////////////
27
28 #include "AliLog.h"
29
30 #include "AliTRDrecoParam.h"
31
32 ClassImp(AliTRDrecoParam)
33
34
35 //______________________________________________________________
36 AliTRDrecoParam::AliTRDrecoParam()
37   :AliDetectorRecoParam()
38   ,fkdNchdy(12.)
39   ,fkMaxTheta(1.0)      
40   ,fkMaxPhi(2.0) 
41   ,fkRoad0y(6.0)
42   ,fkRoad0z(8.5) 
43   ,fkRoad1y(2.0)
44   ,fkRoad1z(20.0)       
45   ,fkRoad2y(3.0)
46   ,fkRoad2z(20.0)
47   ,fkPtThreshold(2.0) 
48   ,fkPlaneQualityThreshold(5.0)// 4.2? under Investigation
49   ,fkRoadzMultiplicator(1.5)
50   ,fkFindable(.333)
51   ,fkChi2Z(30./*14.*//*12.5*/)
52   ,fkChi2Y(.25)
53   ,fkChi2YSlope(7.73)
54   ,fkChi2ZSlope(0.069)
55   ,fChi2Cut(25)
56   ,fkChi2YCut(0.5)
57   ,fkPhiSlope(10.6)
58   ,fkNMeanClusters(20.)
59   ,fkNSigmaClusters(2.)
60   ,fkNClusterNoise(0.)
61   ,fkNMeanTracklets(5.5)
62   ,fkTrackLikelihood(-15.)
63   ,fNumberOfConfigs(3)
64   ,fFlags(0)
65   ,fRawStreamVersion("DEFAULT")
66   ,fdzdxXcrossFactor(0.)
67   ,fMinMaxCutSigma(4.)
68   ,fMinLeftRightCutSigma(8.)
69   ,fClusMaxThresh(4.5)
70   ,fClusSigThresh(3.5)
71   ,fTCnexp(1)
72   ,fRecEveryNTB(1)
73   ,fNumberOfPresamples(0)
74   ,fNumberOfPostsamples(0)
75 {
76   //
77   // Default constructor
78   //
79   fSysCovMatrix[0] = 0.; // y direction (1 cm)
80   fSysCovMatrix[1] = 0.; // z direction (1 cm)
81   fSysCovMatrix[2] = 0.; // snp
82   fSysCovMatrix[3] = 0.; // tgl
83   fSysCovMatrix[4] = 0.; // 1/pt
84
85   // Xe tail cancellation parameters
86   fTCParams[0] = 1.156; // r1
87   fTCParams[1] = 0.130; // r2
88   fTCParams[2] = 0.114; // c1
89   fTCParams[3] = 0.624; // c2
90   // Ar tail cancellation parameters
91   fTCParams[4] = 6.;    // r1
92   fTCParams[5] = 0.62;  // r2
93   fTCParams[6] = 0.0087;// c1
94   fTCParams[7] = 0.07;  // c2
95
96   memset(fPIDThreshold, 0, AliTRDCalPID::kNMom*sizeof(Double_t));
97   memset(fStreamLevel, 0, kTRDreconstructionTasks * sizeof(Int_t));
98
99   SetPIDmethod(AliTRDPIDResponse::kLQ1D);
100   SetEightSlices();
101   SetImproveTracklets();
102   SetLUT();
103   SetTailCancelation();
104   SetTrackletParams();
105 }
106
107 //______________________________________________________________
108 AliTRDrecoParam::AliTRDrecoParam(const AliTRDrecoParam &ref)
109   :AliDetectorRecoParam(ref)
110   ,fkdNchdy(ref.fkdNchdy)
111   ,fkMaxTheta(ref.fkMaxTheta)
112   ,fkMaxPhi(ref.fkMaxPhi)
113   ,fkRoad0y(ref.fkRoad0y)
114   ,fkRoad0z(ref.fkRoad0z)
115   ,fkRoad1y(ref.fkRoad1y)
116   ,fkRoad1z(ref.fkRoad1z)
117   ,fkRoad2y(ref.fkRoad2y)
118   ,fkRoad2z(ref.fkRoad2z)
119   ,fkPtThreshold(ref.fkPtThreshold)
120   ,fkPlaneQualityThreshold(ref.fkPlaneQualityThreshold)
121   ,fkRoadzMultiplicator(ref.fkRoadzMultiplicator)
122   ,fkFindable(ref.fkFindable)
123   ,fkChi2Z(ref.fkChi2Z)
124   ,fkChi2Y(ref.fkChi2Y)
125   ,fkChi2YSlope(ref.fkChi2YSlope)
126   ,fkChi2ZSlope(ref.fkChi2ZSlope)
127   ,fChi2Cut(ref.fChi2Cut)
128   ,fkChi2YCut(ref.fkChi2YCut)
129   ,fkPhiSlope(ref.fkPhiSlope)
130   ,fkNMeanClusters(ref.fkNMeanClusters)
131   ,fkNSigmaClusters(ref.fkNSigmaClusters)
132   ,fkNClusterNoise(ref.fkNClusterNoise)
133   ,fkNMeanTracklets(ref.fkNMeanTracklets)
134   ,fkTrackLikelihood(ref.fkTrackLikelihood)
135   ,fNumberOfConfigs(ref.fNumberOfConfigs)
136   ,fFlags(ref.fFlags)
137   ,fRawStreamVersion(ref.fRawStreamVersion)
138   ,fdzdxXcrossFactor(ref.fdzdxXcrossFactor)
139   ,fMinMaxCutSigma(ref.fMinMaxCutSigma)
140   ,fMinLeftRightCutSigma(ref.fMinLeftRightCutSigma)
141   ,fClusMaxThresh(ref.fClusMaxThresh)
142   ,fClusSigThresh(ref.fClusSigThresh)
143   ,fTCnexp(ref.fTCnexp)
144   ,fRecEveryNTB(ref.fRecEveryNTB)
145   ,fNumberOfPresamples(ref.fNumberOfPresamples)
146   ,fNumberOfPostsamples(ref.fNumberOfPostsamples)
147 {
148   //
149   // Copy constructor
150   //
151   memcpy(fSysCovMatrix, ref.fSysCovMatrix, 5*sizeof(Double_t));
152   memcpy(fTCParams, ref.fTCParams, 8*sizeof(Double_t));
153   memcpy(fPIDThreshold, ref.fPIDThreshold, AliTRDCalPID::kNMom*sizeof(Double_t));
154   memcpy(fStreamLevel, ref.fStreamLevel, kTRDreconstructionTasks * sizeof(Int_t));
155
156   // tracklet params
157   memcpy(fdzdxCorrFactor, ref.fdzdxCorrFactor, 2*sizeof(Double_t));
158   memcpy(fdzdxCorrRCbias, ref.fdzdxCorrRCbias, 2*sizeof(Double_t));
159   memcpy(fYcorrTailCancel, ref.fdzdxCorrRCbias, 12*sizeof(Double_t));
160   memcpy(fS2Ycorr, ref.fS2Ycorr, 4*sizeof(Double_t));
161 }
162
163 //______________________________________________________________
164 AliTRDrecoParam& AliTRDrecoParam::operator=(const AliTRDrecoParam &ref)
165 {
166   //
167   // assignment operator
168   //
169
170   if(this == &ref) return *this;
171   AliDetectorRecoParam::operator=(ref);
172   fkdNchdy              = ref.fkdNchdy;
173   fkMaxTheta            = ref.fkMaxTheta;
174   fkMaxPhi              = ref.fkMaxPhi;
175   fkRoad0y              = ref.fkRoad0y;
176   fkRoad0z              = ref.fkRoad0z;
177   fkRoad1y              = ref.fkRoad1y;
178   fkRoad1z              = ref.fkRoad1z;
179   fkRoad2y              = ref.fkRoad2y;
180   fkRoad2z              = ref.fkRoad2z;
181   fkPtThreshold         = ref.fkPtThreshold;
182   fkPlaneQualityThreshold= ref.fkPlaneQualityThreshold;
183   fkRoadzMultiplicator  = ref.fkRoadzMultiplicator;
184   fkFindable            = ref.fkFindable;
185   fkChi2Z               = ref.fkChi2Z;
186   fkChi2Y               = ref.fkChi2Y;
187   fkChi2YSlope          = ref.fkChi2YSlope;
188   fkChi2ZSlope          = ref.fkChi2ZSlope;
189   fChi2Cut            = ref.fChi2Cut;
190   fkChi2YCut            = ref.fkChi2YCut;
191   fkPhiSlope            = ref.fkPhiSlope;
192   fkNMeanClusters       = ref.fkNMeanClusters;
193   fkNSigmaClusters      = ref.fkNSigmaClusters;
194   fkNClusterNoise       = ref.fkNClusterNoise;
195   fkNMeanTracklets      = ref.fkNMeanTracklets;
196   fkTrackLikelihood     = ref.fkTrackLikelihood;
197   fNumberOfConfigs      = ref.fNumberOfConfigs;
198   fFlags                = ref.fFlags;
199   fRawStreamVersion     = ref.fRawStreamVersion;
200   fdzdxXcrossFactor     = ref.fdzdxXcrossFactor;
201   fMinMaxCutSigma       = ref.fMinMaxCutSigma;
202   fMinLeftRightCutSigma = ref.fMinLeftRightCutSigma;
203   fClusMaxThresh        = ref.fClusMaxThresh;
204   fClusSigThresh        = ref.fClusSigThresh;
205   fTCnexp               = ref.fTCnexp;
206   fRecEveryNTB          = ref.fRecEveryNTB;
207   fNumberOfPresamples   = ref.fNumberOfPresamples;
208   fNumberOfPostsamples  = ref.fNumberOfPostsamples;
209
210   memcpy(fSysCovMatrix, ref.fSysCovMatrix, 5*sizeof(Double_t));
211   memcpy(fTCParams, ref.fTCParams, 8*sizeof(Double_t));
212   memcpy(fPIDThreshold, ref.fPIDThreshold, AliTRDCalPID::kNMom*sizeof(Double_t));
213   memcpy(fStreamLevel, ref.fStreamLevel, kTRDreconstructionTasks * sizeof(Int_t));
214
215   // tracklet params
216   memcpy(fdzdxCorrFactor, ref.fdzdxCorrFactor, 2*sizeof(Double_t));
217   memcpy(fdzdxCorrRCbias, ref.fdzdxCorrRCbias, 2*sizeof(Double_t));
218   memcpy(fYcorrTailCancel, ref.fdzdxCorrRCbias, 12*sizeof(Double_t));
219   memcpy(fS2Ycorr, ref.fS2Ycorr, 4*sizeof(Double_t));
220   return *this;
221 }
222
223 //______________________________________________________________
224 AliTRDrecoParam *AliTRDrecoParam::GetLowFluxParam()
225 {
226   //
227   // Parameters for the low flux environment
228   //
229
230   AliTRDrecoParam *rec = new AliTRDrecoParam();
231   rec->fkdNchdy = 12.; // pp in TRD
232   rec->SetVertexConstrained();
233   rec->SetCheckTimeConsistency();
234   return rec;
235
236 }
237
238 //______________________________________________________________
239 AliTRDrecoParam *AliTRDrecoParam::GetLowFluxHLTParam()
240 {
241   //
242   // Parameters for the high flux environment in HLT
243   //
244
245   AliTRDrecoParam *rec = GetLowFluxParam();
246   rec->fNumberOfConfigs = 2;
247   return rec;
248
249 }
250
251 //______________________________________________________________
252 AliTRDrecoParam *AliTRDrecoParam::GetHighFluxParam()
253 {
254   //
255   // Parameters for the high flux environment
256   //
257
258   AliTRDrecoParam *rec = new AliTRDrecoParam();
259   rec->fkdNchdy = 4000.; // PbPb in TRD
260   rec->SetVertexConstrained();
261   rec->SetCheckTimeConsistency();
262   return rec;
263
264 }
265
266 //______________________________________________________________
267 AliTRDrecoParam *AliTRDrecoParam::GetHighFluxHLTParam()
268 {
269   //
270   // Parameters for the high flux environment in HLT
271   //
272
273   AliTRDrecoParam *rec = GetHighFluxParam();
274   rec->fNumberOfConfigs = 1;
275   return rec;
276
277 }
278
279 //______________________________________________________________
280 AliTRDrecoParam *AliTRDrecoParam::GetCosmicTestParam()
281 {
282   //
283   // Parameters for the cosmics data
284   //
285
286   AliTRDrecoParam *par = new AliTRDrecoParam();
287   par->fSysCovMatrix[0] = 2.; // y direction (1 cm)
288   par->fSysCovMatrix[1] = 2.; // z direction (1 cm)
289   par->fkChi2YSlope     = 0.11853;
290   par->fkChi2ZSlope     = 0.04527;
291   par->fkChi2YCut       = 25.;
292   par->fkChi2YCut       = 1.;
293   par->fkPhiSlope       = 10.; //3.17954;
294   par->fkMaxTheta       = 2.1445;
295   par->fkMaxPhi         = 2.7475;
296   par->fkNMeanClusters  = 12.89;
297   par->fkNSigmaClusters = 2.095;
298   par->fkRoadzMultiplicator = 3.;
299   par->fStreamLevel[kTracker] = 1;
300   par->SetCheckTimeConsistency();
301   return par;
302
303 }
304
305
306 //______________________________________________________________
307 Float_t AliTRDrecoParam::GetNClusters() const
308 {
309   // Estimate the number of clusters in the TRD detector
310   
311   Float_t nclusters = (fkNMeanClusters + 2*fkNSigmaClusters)*fkNMeanTracklets*fkdNchdy;
312   nclusters *= 1.+fkNClusterNoise;
313   return nclusters;
314 }
315
316 //______________________________________________________________
317 void AliTRDrecoParam::SetPIDLQslices(Int_t s)
318 {
319 // Setting number of slices used by the PID LQ method s={1, 2}
320 // If PID NN is set this function will change to PID LQ.
321  
322   if(IsPIDNeuralNetwork()){
323     AliWarning("PID set to NN. Changing to LQ.");
324     SetPIDNeuralNetwork(kFALSE);
325   } 
326
327   switch(s){
328   case 1: 
329     if(TESTBIT(fFlags, kLQ2D)) CLRBIT(fFlags, kLQ2D);
330     break;
331   case 2:
332     SETBIT(fFlags, kLQ2D);
333     break;
334   default:
335     AliWarning(Form("N[%d] PID LQ slices not implemented. Using default 2.", s));
336     SETBIT(fFlags, kLQ2D);
337     break;
338   }
339 }
340
341 //___________________________________________________
342 void  AliTRDrecoParam::SetTrackletParams(Double_t *par)
343 {
344   // Load tracklet reconstruction parameters. If none are set use defaults
345   if(par){
346     // correct dzdx for the bias in z
347     fdzdxCorrFactor[0] = par[0];  // !RC 
348     fdzdxCorrFactor[1] = par[1];  // RC
349     // correct dzdx in RC tracklets for the bias in cluster attachment
350     fdzdxCorrRCbias[0] = par[2];   // dz/dx > 0  
351     fdzdxCorrRCbias[1] = par[3];   // dz/dx < 0
352     /// correct x_cross for the bias in dzdx
353     fdzdxXcrossFactor  = par[4];
354     // y correction due to wrong tail cancellation. 
355     fYcorrTailCancel[0][0] = par[5];fYcorrTailCancel[0][1] = par[6];fYcorrTailCancel[0][2] = par[7]; 
356     fYcorrTailCancel[1][0] = par[8];fYcorrTailCancel[1][1] = par[9];fYcorrTailCancel[1][2] = par[10]; 
357     fYcorrTailCancel[2][0] = par[11];fYcorrTailCancel[2][1] = par[12];fYcorrTailCancel[2][2] = par[13];
358     fYcorrTailCancel[3][0] = par[14];fYcorrTailCancel[3][1] = par[15];fYcorrTailCancel[3][2] = par[16];
359     // inflation factor of error parameterization in r-phi due to wrong estimation of residuals. 
360     fS2Ycorr[0] = par[17];
361     fS2Ycorr[1] = par[18];
362     fS2Ycorr[2] = par[19];
363     fS2Ycorr[3] = par[20];
364     
365   } else {
366     // correct dzdx for the bias in z
367     fdzdxCorrFactor[0] = 1.09;  // !RC 
368     fdzdxCorrFactor[1] = 1.05;  // RC
369     // correct dzdx in RC tracklets for the bias in cluster attachment
370     fdzdxCorrRCbias[0] = 0.;     // dz/dx > 0  
371     fdzdxCorrRCbias[1] = -0.012; // dz/dx < 0
372     /// correct x_cross for the bias in dzdx
373     fdzdxXcrossFactor  = 0.14;
374     // y correction due to wrong tail cancellation. 
375         // bz<0 && !RC
376     fYcorrTailCancel[0][0] = 0.04; fYcorrTailCancel[0][1] = 2.151; fYcorrTailCancel[0][2] = 0.013;
377         // bz>0 && !RC
378     fYcorrTailCancel[1][0] = 0.034; fYcorrTailCancel[1][1] = 1.817; fYcorrTailCancel[1][2] = -0.01;
379         // bz<0 && RC
380     fYcorrTailCancel[2][0] = 0.04; fYcorrTailCancel[2][1] = 2.513; fYcorrTailCancel[2][2] = 0.015;
381         // bz>0 && RC
382     fYcorrTailCancel[3][0] = 0.034; fYcorrTailCancel[3][1] = 2.476; fYcorrTailCancel[3][2] = -0.01;
383     // inflation factor of error parameterization in r-phi due to wrong estimation of residuals. 
384         // chg<0 && !RC
385     fS2Ycorr[0] = 5.52; 
386         // chg>0 && !RC
387     fS2Ycorr[1] = 3.61; 
388         // chg<0 && RC
389     fS2Ycorr[2] = 4.84; 
390         // chg>0 && RC
391     fS2Ycorr[3] = 3.24; 
392   }
393 }