coverity fix
[u/mrichter/AliRoot.git] / TRD / AliTRDrecoParam.h
1 #ifndef ALITRDRECOPARAM_H
2 #define ALITRDRECOPARAM_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ////////////////////////////////////////////////////////////////////////////
9 //                                                                        //
10 //  Parameter class for the TRD reconstruction                            //
11 //                                                                        //
12 ////////////////////////////////////////////////////////////////////////////
13
14 #ifndef ALIDETECTORRECOPARAM_H
15 #include "AliDetectorRecoParam.h"
16 #endif
17
18 #ifndef ALITRDCALPID_H
19 #include "Cal/AliTRDCalPID.h"
20 #endif
21
22 #ifndef ALITRDPIDRESPONSE_H
23 #include "AliTRDPIDResponse.h"
24 #endif
25
26 class TString;
27
28 class AliTRDrecoParam : public AliDetectorRecoParam
29 {
30 public:
31   enum ETRDReconstructionTask{
32     kClusterizer = 0,
33     kTracker = 1,
34     kPID = 2,
35     kTRDreconstructionTasks = 3
36   };
37   enum ETRDflags {
38     kDriftGas
39     ,kVertexConstraint
40     ,kTailCancelation
41     ,kImproveTracklet
42     ,kLUT
43     ,kGAUS
44     ,kClusterSharing
45     ,kSteerPID
46     ,kEightSlices
47     ,kCheckTimeConsistency
48     ,kLQ2D
49   };
50   AliTRDrecoParam();
51   AliTRDrecoParam(const AliTRDrecoParam &rec);
52   ~AliTRDrecoParam() { }
53
54   Double_t GetChi2Y() const                 { return fkChi2Y;    }
55   Double_t GetChi2Z() const                 { return fkChi2Z;    }
56   Double_t GetChi2YSlope() const            { return fkChi2YSlope; }
57   Double_t GetChi2ZSlope() const            { return fkChi2ZSlope; }
58         Double_t GetChi2YCut() const              { return fkChi2YCut; }
59   Double_t GetPhiSlope() const              { return fkPhiSlope;   }
60   Float_t  GetNClusters() const;
61   Double_t GetNMeanClusters() const         { return fkNMeanClusters; }
62   Double_t GetNSigmaClusters() const        { return fkNSigmaClusters; }
63   Double_t GetFindableClusters() const      { return fkFindable; }
64   inline Int_t    GetPIDLQslices() const;
65   inline AliTRDPIDResponse::ETRDPIDMethod GetPIDmethod() const;
66   Double_t GetMaxTheta() const              { return fkMaxTheta; }
67   Double_t GetMaxPhi() const                { return fkMaxPhi;   }
68   Double_t GetPlaneQualityThreshold() const { return fkPlaneQualityThreshold; }
69   Double_t GetPIDThreshold(Float_t /*p*/) const { return 0.;}
70   Double_t GetRoad0y() const                { return fkRoad0y;   }
71   Double_t GetRoad0z() const                { return fkRoad0z;   }
72   Double_t GetRoad1y() const                { return fkRoad1y;   }
73   Double_t GetRoad1z() const                { return fkRoad1z;   }
74   Double_t GetRoad2y() const                { return fkRoad2y;   }
75   Double_t GetRoad2z() const                { return fkRoad2z;   }
76   Double_t GetRoadzMultiplicator() const    { return fkRoadzMultiplicator; }
77   Double_t GetTrackLikelihood() const       { return fkTrackLikelihood;       }
78   inline void GetSysCovMatrix(Double_t *sys) const;  
79   inline void GetTCParams(Double_t *par) const;
80   inline Int_t GetStreamLevel(ETRDReconstructionTask task) const;
81   const TString *GetRawStreamVersion() const{ return &fRawStreamVersion; };
82   Double_t GetMinMaxCutSigma() const        { return fMinMaxCutSigma;     };
83   Double_t GetMinLeftRightCutSigma() const  { return fMinLeftRightCutSigma;  };
84   Double_t GetClusMaxThresh() const         { return fClusMaxThresh;   };
85   Double_t GetClusSigThresh() const         { return fClusSigThresh;   };
86   Int_t    GetTCnexp() const                { return fTCnexp;          };
87   Int_t    GetNumberOfPresamples()  const   { return fNumberOfPresamples;}
88   Int_t    GetNumberOfPostsamples() const   { return fNumberOfPostsamples;}
89   Int_t    GetNumberOfSeedConfigs() const   { return fNumberOfConfigs;}
90   Int_t    GetRecEveryNTB() const           { return fRecEveryNTB; }
91   Bool_t   IsArgon() const                  { return TESTBIT(fFlags, kDriftGas); }
92   Bool_t   IsCheckTimeConsistency() const   { return kCheckTimeConsistency;}
93   Bool_t   IsOverPtThreshold(Double_t pt) const {return Bool_t(pt>fkPtThreshold);}
94   Bool_t   IsXenon() const                  { return !TESTBIT(fFlags, kDriftGas); }
95   Bool_t   IsPIDNeuralNetwork() const       { return TESTBIT(fFlags, kSteerPID);}
96   Bool_t   IsVertexConstrained() const      { return TESTBIT(fFlags, kVertexConstraint); }
97   Bool_t   IsEightSlices() const            { return TESTBIT(fFlags, kEightSlices);}
98   Bool_t   HasImproveTracklets() const      { return TESTBIT(fFlags, kImproveTracklet);}
99   Bool_t   UseClusterSharing() const        { return TESTBIT(fFlags, kClusterSharing);}
100   Bool_t   UseLUT() const                   { return TESTBIT(fFlags, kLUT);}
101   Bool_t   UseGAUS() const                  { return TESTBIT(fFlags, kGAUS);}
102   Bool_t   UseTailCancelation() const       { return TESTBIT(fFlags, kTailCancelation); }
103         
104   static   AliTRDrecoParam *GetLowFluxParam();
105   static   AliTRDrecoParam *GetLowFluxHLTParam();
106   static   AliTRDrecoParam *GetHighFluxParam();
107   static   AliTRDrecoParam *GetHighFluxHLTParam();
108   static   AliTRDrecoParam *GetCosmicTestParam();
109
110   void     SetArgon(Bool_t b = kTRUE)                         {if(b) SETBIT(fFlags, kDriftGas); else CLRBIT(fFlags, kDriftGas);}
111   void     SetCheckTimeConsistency(Bool_t b = kTRUE)          {if(b) SETBIT(fFlags, kCheckTimeConsistency); else CLRBIT(fFlags, kCheckTimeConsistency);}
112   void     SetClusterSharing(Bool_t b = kTRUE)                {if(b) SETBIT(fFlags, kClusterSharing); else CLRBIT(fFlags, kClusterSharing);}
113   void     SetEightSlices(Bool_t b = kTRUE)                   {if(b) SETBIT(fFlags, kEightSlices); else CLRBIT(fFlags, kEightSlices);}
114   void     SetImproveTracklets(Bool_t b = kTRUE)              {if(b) SETBIT(fFlags, kImproveTracklet); else CLRBIT(fFlags, kImproveTracklet);}
115   void     SetLUT(Bool_t b=kTRUE)                             {if(b) SETBIT(fFlags, kLUT); else CLRBIT(fFlags, kLUT);}
116   void     SetGAUS(Bool_t b=kTRUE)                            {if(b) SETBIT(fFlags, kGAUS); else CLRBIT(fFlags, kGAUS);}
117   void     SetPIDNeuralNetwork(Bool_t b=kTRUE)                {if(b) SETBIT(fFlags, kSteerPID); else CLRBIT(fFlags, kSteerPID);}
118   inline void  SetPIDmethod(AliTRDPIDResponse::ETRDPIDMethod method);
119   void     SetPIDLQslices(Int_t s);
120   void     SetTailCancelation(Bool_t b=kTRUE)                 {if(b) SETBIT(fFlags, kTailCancelation); else CLRBIT(fFlags, kTailCancelation);}
121   void     SetXenon(Bool_t b = kTRUE)                         {if(b) CLRBIT(fFlags, kDriftGas); else SETBIT(fFlags, kDriftGas);}
122   void     SetVertexConstrained()                             {SETBIT(fFlags, kVertexConstraint);}
123   void     SetMaxTheta(Double_t maxTheta)                     {fkMaxTheta = maxTheta;}
124   void     SetMaxPhi(Double_t maxPhi)                         {fkMaxPhi = maxPhi;}
125   void     SetFindableClusters(Double_t r)                    {fkFindable = r;}
126   void     SetChi2Y(Double_t chi2)                            {fkChi2Y = chi2;}
127   void     SetChi2Z(Double_t chi2)                            {fkChi2Z = chi2;}
128   void     SetChi2YSlope(Double_t chi2YSlope)                 {fkChi2YSlope = chi2YSlope;}
129   void     SetChi2ZSlope(Double_t chi2ZSlope)                 {fkChi2ZSlope = chi2ZSlope;}
130         void       SetChi2YCut(Double_t chi2Cut)                      {fkChi2YCut = chi2Cut; }
131   void     SetPhiSlope(Double_t phiSlope)                     {fkPhiSlope = phiSlope;}
132   void     SetNMeanClusters(Double_t meanNclusters)           {fkNMeanClusters = meanNclusters;}
133   void     SetNSigmaClusters(Double_t sigmaNclusters)         {fkNSigmaClusters = sigmaNclusters;} 
134   void     SetRawStreamVersion(const Char_t *version)         {fRawStreamVersion = version; }
135   void     SetRoadzMultiplicator(Double_t mult)               {fkRoadzMultiplicator = mult; } 
136   void     SetMinMaxCutSigma(Float_t minMaxCutSigma)          { fMinMaxCutSigma   = minMaxCutSigma; }
137   void     SetMinLeftRightCutSigma(Float_t minLeftRightCutSigma) { fMinLeftRightCutSigma   = minLeftRightCutSigma; };
138   void     SetClusMaxThresh(Float_t thresh)                   { fClusMaxThresh   = thresh; };
139   void     SetClusSigThresh(Float_t thresh)                   { fClusSigThresh   = thresh; };
140   inline void SetPIDThreshold(Double_t *pid);
141   void     SetPtThreshold(Double_t pt) {fkPtThreshold = pt;}
142   void     SetNexponential(Int_t nexp)                        { fTCnexp          = nexp;   };
143   inline void SetTCParams(Double_t *par);
144   inline void SetStreamLevel(ETRDReconstructionTask task, Int_t level);
145   inline void SetSysCovMatrix(Double_t *sys);
146   void     SetNumberOfPresamples(Int_t n)                     { fNumberOfPresamples = n;}
147   void     SetNumberOfPostsamples(Int_t n)                    { fNumberOfPostsamples = n;}
148   void     SetRecEveryTwoTB()                                 { fRecEveryNTB = 2; fkNMeanClusters = 10; }
149
150 private:
151   // Physics reference values for TRD
152   Double_t  fkdNchdy;                // dNch/dy
153   Double_t  fkMaxTheta;              // Maximum theta
154   Double_t  fkMaxPhi;                // Maximum phi - momentum cut
155   // Tracker params 
156   Double_t  fkRoad0y;                // Road for middle cluster
157   Double_t  fkRoad0z;                // Road for middle cluster
158
159   Double_t  fkRoad1y;                // Road in y for seeded cluster
160   Double_t  fkRoad1z;                // Road in z for seeded cluster
161
162   Double_t  fkRoad2y;                // Road in y for extrapolated cluster
163   Double_t  fkRoad2z;                // Road in z for extrapolated cluster
164   Double_t  fkPtThreshold;           // pt threshold for using TRD points for updating Kalaman track
165   Double_t  fkPlaneQualityThreshold; // Quality threshold
166   Double_t  fkRoadzMultiplicator;    // Multiplicator for the Roads in z 
167   Double_t  fkFindable;              // minimum ratio of clusters per tracklet supposed to be attached.
168   Double_t  fkChi2Z;                 // Max chi2 on the z direction for seeding clusters fit
169   Double_t  fkChi2Y;                 // Max chi2 on the y direction for seeding clusters Rieman fit
170   Double_t  fkChi2YSlope;            // Slope of the chi2-distribution in y-direction
171   Double_t  fkChi2ZSlope;            // Slope of the chi2-distribution in z-direction
172   Double_t  fkChi2YCut;                                                  // Cut on the Chi2 in y-direction in the likelihood filter
173   Double_t  fkPhiSlope;              // Slope of the distribution of the deviation between track angle and tracklet angle
174   Double_t  fkNMeanClusters;         // Mean number of clusters per tracklet
175   Double_t  fkNSigmaClusters;        // Sigma of the number of clusters per tracklet
176   Double_t  fkNClusterNoise;         // ratio of noisy clusters to the true one
177   Double_t  fkNMeanTracklets;        // Mean number of tracklets per track
178   Double_t  fkTrackLikelihood;       // Track likelihood for tracklets Rieman fit
179   
180   Double_t  fSysCovMatrix[5];        // Systematic uncertainty from calibration and alignment for each tracklet
181   Double_t  fPIDThreshold[AliTRDCalPID::kNMom];   // PID Thresholds for Electron candidate decision
182   Int_t     fNumberOfConfigs;        // Used number of seed configurations
183
184   // Reconstruction Options for TRD reconstruction
185   Int_t     fStreamLevel[kTRDreconstructionTasks]; // Stream Level
186   Long64_t  fFlags;                  // option Flags
187
188   // Raw Reader Params
189   TString   fRawStreamVersion;       // Raw Reader version
190
191   // Clusterization parameter
192   Double_t  fMinMaxCutSigma;         // Threshold sigma noise pad middle
193   Double_t  fMinLeftRightCutSigma;   // Threshold sigma noise sum pad
194   Double_t  fClusMaxThresh;          // Threshold value for cluster maximum
195   Double_t  fClusSigThresh;          // Threshold value for cluster signal
196   Int_t     fTCnexp;                 // Number of exponentials, digital filter
197   Double_t  fTCParams[8];            // Tail Cancellation parameters for drift gases 
198   Int_t     fRecEveryNTB;            // Reconstruct each nth timebin
199
200   // ADC parameter
201   Int_t     fNumberOfPresamples;     // number of presamples 
202   Int_t     fNumberOfPostsamples;     // number of postsamples 
203
204   ClassDef(AliTRDrecoParam, 12)       // Reconstruction parameters for TRD detector
205
206 };
207
208 //___________________________________________________
209 inline void AliTRDrecoParam::GetSysCovMatrix(Double_t *sys) const
210 {
211   if(!sys) return;
212   memcpy(sys, fSysCovMatrix, 5*sizeof(Double_t));
213 }
214
215 //___________________________________________________
216 inline void AliTRDrecoParam::SetSysCovMatrix(Double_t *sys)
217 {
218   if(!sys) return;
219   memcpy(fSysCovMatrix, sys, 5*sizeof(Double_t));
220 }
221
222 //___________________________________________________
223 inline void AliTRDrecoParam::SetPIDThreshold(Double_t *pid)
224 {
225   if(!pid) return;
226   memcpy(fPIDThreshold, pid, AliTRDCalPID::kNMom*sizeof(Double_t));
227 }
228
229 //___________________________________________________
230 inline void AliTRDrecoParam::SetStreamLevel(ETRDReconstructionTask task, Int_t level){
231   if(task >= kTRDreconstructionTasks) return;
232   fStreamLevel[static_cast<Int_t>(task)] = level;
233 }
234
235 //___________________________________________________
236 inline Int_t AliTRDrecoParam::GetStreamLevel(ETRDReconstructionTask task) const{
237   if(task >= kTRDreconstructionTasks) return 0;
238   return fStreamLevel[static_cast<Int_t>(task)];
239 }
240
241 //___________________________________________________
242 inline void AliTRDrecoParam::GetTCParams(Double_t *par) const
243 {
244   if(!par) return;
245   if(IsArgon()) memcpy(par, &fTCParams[4], 4*sizeof(Double_t));
246   else memcpy(par, &fTCParams[0], 4*sizeof(Double_t));
247 }
248
249 //___________________________________________________
250 inline void AliTRDrecoParam::SetTCParams(Double_t *par)
251 {
252   if(!par) return;
253   memcpy(fTCParams, par, 8*sizeof(Double_t));
254 }
255
256 //___________________________________________________
257 inline Int_t AliTRDrecoParam::GetPIDLQslices() const
258 {
259   if(IsPIDNeuralNetwork()) return -1;
260   return TESTBIT(fFlags, kLQ2D) ? 2 : 1;
261 }
262
263 //___________________________________________________
264 inline AliTRDPIDResponse::ETRDPIDMethod AliTRDrecoParam::GetPIDmethod() const
265 {
266   AliTRDPIDResponse::ETRDPIDMethod method = AliTRDPIDResponse::kLQ1D;
267   if(IsPIDNeuralNetwork()) method = AliTRDPIDResponse::kNN;
268   else if(TESTBIT(fFlags, kLQ2D)) method = AliTRDPIDResponse::kLQ2D;
269   return method;
270 }
271
272 //___________________________________________________
273 inline void  AliTRDrecoParam::SetPIDmethod(AliTRDPIDResponse::ETRDPIDMethod method)
274 {
275   switch(method){
276   case AliTRDPIDResponse::kLQ2D:
277     CLRBIT(fFlags, kSteerPID); 
278     SETBIT(fFlags, kLQ2D);
279     break;
280   case AliTRDPIDResponse::kNN:
281     SETBIT(fFlags, kSteerPID); 
282     break;
283   case AliTRDPIDResponse::kLQ1D:
284   default:
285     CLRBIT(fFlags, kSteerPID); 
286     CLRBIT(fFlags, kLQ2D);
287     break;
288   }
289 }
290
291 #endif