Fix Coverity defects
[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 "AliTRDrecoParam.h"
29 #include "AliTRDrawStreamBase.h"
30
31 ClassImp(AliTRDrecoParam)
32
33
34 //______________________________________________________________
35 AliTRDrecoParam::AliTRDrecoParam()
36   :AliDetectorRecoParam()
37   ,fkdNchdy(12.)
38   ,fkMaxTheta(1.0)      
39   ,fkMaxPhi(2.0) 
40   ,fkRoad0y(6.0)
41   ,fkRoad0z(8.5) 
42   ,fkRoad1y(2.0)
43   ,fkRoad1z(20.0)       
44   ,fkRoad2y(3.0)
45   ,fkRoad2z(20.0)
46   ,fkPtThreshold(2.0) 
47   ,fkPlaneQualityThreshold(5.0)// 4.2? under Investigation
48   ,fkRoadzMultiplicator(1.5)
49   ,fkFindable(.333)
50   ,fkChi2Z(30./*14.*//*12.5*/)
51   ,fkChi2Y(.25)
52   ,fkChi2YSlope(7.73)
53   ,fkChi2ZSlope(0.069)
54   ,fkChi2YCut(0.5)
55   ,fkPhiSlope(10.6)
56   ,fkNMeanClusters(20.)
57   ,fkNSigmaClusters(2.)
58   ,fkNClusterNoise(0.)
59   ,fkNMeanTracklets(5.5)
60   ,fkTrackLikelihood(-15.)
61   ,fNumberOfConfigs(3)
62   ,fFlags(0)
63   ,fRawStreamVersion("REAL")
64   ,fMinMaxCutSigma(4.)
65   ,fMinLeftRightCutSigma(8.)
66   ,fClusMaxThresh(4.5)
67   ,fClusSigThresh(3.5)
68   ,fTCnexp(1)
69   ,fRecEveryNTB(1)
70   ,fNumberOfPresamples(0)
71   ,fNumberOfPostsamples(0)
72 {
73   //
74   // Default constructor
75   //
76   fSysCovMatrix[0] = 0.; // y direction (1 cm)
77   fSysCovMatrix[1] = 0.; // z direction (1 cm)
78   fSysCovMatrix[2] = 0.; // snp
79   fSysCovMatrix[3] = 0.; // tgl
80   fSysCovMatrix[4] = 0.; // 1/pt
81
82   // Xe tail cancellation parameters
83   fTCParams[0] = 1.156; // r1
84   fTCParams[1] = 0.130; // r2
85   fTCParams[2] = 0.114; // c1
86   fTCParams[3] = 0.624; // c2
87   // Ar tail cancellation parameters
88   fTCParams[4] = 6.;    // r1
89   fTCParams[5] = 0.62;  // r2
90   fTCParams[6] = 0.0087;// c1
91   fTCParams[7] = 0.07;  // c2
92
93   memset(fPIDThreshold, 0, AliTRDCalPID::kNMom*sizeof(Double_t));
94   memset(fStreamLevel, 0, kTRDreconstructionTasks * sizeof(Int_t));
95
96   SetPIDNeuralNetwork();
97   SetEightSlices();
98   SetImproveTracklets();
99   SetLUT();
100   SetTailCancelation();
101 }
102
103 //______________________________________________________________
104 AliTRDrecoParam::AliTRDrecoParam(const AliTRDrecoParam &ref)
105   :AliDetectorRecoParam(ref)
106   ,fkdNchdy(ref.fkdNchdy)
107   ,fkMaxTheta(ref.fkMaxTheta)
108   ,fkMaxPhi(ref.fkMaxPhi)
109   ,fkRoad0y(ref.fkRoad0y)
110   ,fkRoad0z(ref.fkRoad0z) 
111   ,fkRoad1y(ref.fkRoad1y)
112   ,fkRoad1z(ref.fkRoad1z)       
113   ,fkRoad2y(ref.fkRoad2y)
114   ,fkRoad2z(ref.fkRoad2z)
115   ,fkPtThreshold(ref.fkPtThreshold) 
116   ,fkPlaneQualityThreshold(ref.fkPlaneQualityThreshold)
117   ,fkRoadzMultiplicator(ref.fkRoadzMultiplicator)
118   ,fkFindable(ref.fkFindable)
119   ,fkChi2Z(ref.fkChi2Z)
120   ,fkChi2Y(ref.fkChi2Y)
121   ,fkChi2YSlope(ref.fkChi2YSlope)
122   ,fkChi2ZSlope(ref.fkChi2ZSlope)
123   ,fkChi2YCut(ref.fkChi2YCut)
124   ,fkPhiSlope(ref.fkPhiSlope)
125   ,fkNMeanClusters(ref.fkNMeanClusters)
126   ,fkNSigmaClusters(ref.fkNSigmaClusters)
127   ,fkNClusterNoise(ref.fkNClusterNoise)
128   ,fkNMeanTracklets(ref.fkNMeanTracklets)
129   ,fkTrackLikelihood(ref.fkTrackLikelihood)
130   ,fNumberOfConfigs(ref.fNumberOfConfigs)
131   ,fFlags(ref.fFlags)
132   ,fRawStreamVersion(ref.fRawStreamVersion)
133   ,fMinMaxCutSigma(ref.fMinMaxCutSigma)
134   ,fMinLeftRightCutSigma(ref.fMinLeftRightCutSigma)
135   ,fClusMaxThresh(ref.fClusMaxThresh)
136   ,fClusSigThresh(ref.fClusSigThresh)
137   ,fTCnexp(ref.fTCnexp)
138   ,fRecEveryNTB(ref.fRecEveryNTB)
139   ,fNumberOfPresamples(ref.fNumberOfPresamples)
140   ,fNumberOfPostsamples(ref.fNumberOfPostsamples)
141 {
142   //
143   // Copy constructor
144   //
145   memcpy(fSysCovMatrix, ref.fSysCovMatrix, 5*sizeof(Double_t));
146   memcpy(fTCParams, ref.fTCParams, 8*sizeof(Double_t));
147   memcpy(fPIDThreshold, ref.fPIDThreshold, AliTRDCalPID::kNMom*sizeof(Double_t));
148   memcpy(fStreamLevel, ref.fStreamLevel, kTRDreconstructionTasks * sizeof(Int_t));
149 }
150
151 //______________________________________________________________
152 AliTRDrecoParam *AliTRDrecoParam::GetLowFluxParam()
153 {
154   //
155   // Parameters for the low flux environment
156   //
157
158   AliTRDrecoParam *rec = new AliTRDrecoParam();
159   rec->fkdNchdy = 12.; // pp in TRD
160   rec->SetVertexConstrained();
161   rec->SetCheckTimeConsistency();
162   return rec;
163
164 }
165
166 //______________________________________________________________
167 AliTRDrecoParam *AliTRDrecoParam::GetLowFluxHLTParam()
168 {
169   //
170   // Parameters for the high flux environment in HLT
171   //
172
173   AliTRDrecoParam *rec = GetLowFluxParam();
174   rec->fNumberOfConfigs = 2;
175   return rec;
176
177 }
178
179 //______________________________________________________________
180 AliTRDrecoParam *AliTRDrecoParam::GetHighFluxParam()
181 {
182   //
183   // Parameters for the high flux environment
184   //
185
186   AliTRDrecoParam *rec = new AliTRDrecoParam();
187   rec->fkdNchdy = 4000.; // PbPb in TRD
188   rec->SetVertexConstrained();
189   rec->SetCheckTimeConsistency();
190   return rec;
191
192 }
193
194 //______________________________________________________________
195 AliTRDrecoParam *AliTRDrecoParam::GetHighFluxHLTParam()
196 {
197   //
198   // Parameters for the high flux environment in HLT
199   //
200
201   AliTRDrecoParam *rec = GetHighFluxParam();
202   rec->fNumberOfConfigs = 1;
203   return rec;
204
205 }
206
207 //______________________________________________________________
208 AliTRDrecoParam *AliTRDrecoParam::GetCosmicTestParam()
209 {
210   //
211   // Parameters for the cosmics data
212   //
213
214   AliTRDrecoParam *par = new AliTRDrecoParam();
215   par->fSysCovMatrix[0] = 2.; // y direction (1 cm)
216   par->fSysCovMatrix[1] = 2.; // z direction (1 cm)
217   par->fkChi2YSlope     = 0.11853;
218   par->fkChi2ZSlope     = 0.04527;
219   par->fkChi2YCut       = 1.;
220   par->fkPhiSlope       = 10.; //3.17954;
221   par->fkMaxTheta       = 2.1445;
222   par->fkMaxPhi         = 2.7475;
223   par->fkNMeanClusters  = 12.89;
224   par->fkNSigmaClusters = 2.095;
225   par->fkRoadzMultiplicator = 3.;
226   par->fStreamLevel[kTracker] = 1;
227   par->SetCheckTimeConsistency();
228   return par;
229
230 }
231
232
233 //______________________________________________________________
234 Float_t AliTRDrecoParam::GetNClusters() const
235 {
236   // Estimate the number of clusters in the TRD detector
237   
238   Float_t nclusters = (fkNMeanClusters + 2*fkNSigmaClusters)*fkNMeanTracklets*fkdNchdy;
239   nclusters *= 1.+fkNClusterNoise;
240   return nclusters;
241 }
242
243 //______________________________________________________________
244 void AliTRDrecoParam::SetPIDLQslices(Int_t s)
245 {
246 // Setting number of slices used by the PID LQ method s={1, 2}
247 // If PID NN is set this function will change to PID LQ.
248  
249   if(IsPIDNeuralNetwork()){
250     AliWarning("PID set to NN. Changing to LQ.");
251     SetPIDNeuralNetwork(kFALSE);
252   } 
253
254   switch(s){
255   case 1: 
256     if(TESTBIT(fFlags, kLQ2D)) CLRBIT(fFlags, kLQ2D);
257     break;
258   case 2:
259     SETBIT(fFlags, kLQ2D);
260     break;
261   default:
262     AliWarning(Form("N[%d] PID LQ slices not implemented. Using default 2.", s));
263     SETBIT(fFlags, kLQ2D);
264     break;
265   }
266 }
267