Integrating the Cooked Matrix tracker into the commom reconstruction framework
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSURecoParam.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, 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 #include "AliITSURecoParam.h"
17 #include "AliLog.h"
18 #include "AliITSUTrackCond.h"
19
20 ///////////////////////////////////////////////////////////////////////////////
21 //                                                                           //
22 // Class with ITS reconstruction parameters                                  //
23 //                                                                           //
24 ///////////////////////////////////////////////////////////////////////////////
25
26 ClassImp(AliITSURecoParam)
27
28
29 const Double_t AliITSURecoParam::fgkMaxDforV0dghtrForProlongation = 30;
30 const Double_t AliITSURecoParam::fgkMaxDForProlongation           = 40; 
31 const Double_t AliITSURecoParam::fgkMaxDZForProlongation          = 60;      
32 const Double_t AliITSURecoParam::fgkMinPtForProlongation          = 0.0; 
33 const Double_t AliITSURecoParam::fgkSigmaRoadY                    = 20.E-4;//1000e-4;
34 const Double_t AliITSURecoParam::fgkSigmaRoadZ                    = 20.E-4;//1000e-4;
35 const Double_t AliITSURecoParam::fgkTanLorentzAngle               = 0;
36 const Bool_t   AliITSURecoParam::fgkAllowDiagonalClusterization   = kFALSE;
37 //
38 // hardwired params for TPC-ITS border layer
39 const Double_t AliITSURecoParam::fgkTPCITSWallRMin                = 50.;
40 const Double_t AliITSURecoParam::fgkTPCITSWallRMax                = 80.;
41 const Double_t AliITSURecoParam::fgkTPCITSWallZSpanH              = 250.;
42 const Double_t AliITSURecoParam::fgkTPCITSWallMaxStep             = 6.;
43 //
44 const Bool_t   AliITSURecoParam::fgkUseMatLUT[kNTrackingPhases] = {kFALSE,kFALSE,kFALSE};
45
46 //
47 //_____________________________________________________________________________
48 AliITSURecoParam::AliITSURecoParam()
49   :  fNLayers(0)
50   ,fMaxDforV0dghtrForProlongation(fgkMaxDforV0dghtrForProlongation)
51   ,fMaxDForProlongation(fgkMaxDForProlongation)
52   ,fMaxDZForProlongation(fgkMaxDZForProlongation)
53   ,fMinPtForProlongation(fgkMinPtForProlongation)
54      //
55   ,fTPCITSWallRMin(fgkTPCITSWallRMin)
56   ,fTPCITSWallRMax(fgkTPCITSWallRMax)
57   ,fTPCITSWallZSpanH(fgkTPCITSWallZSpanH)
58   ,fTPCITSWallMaxStep(fgkTPCITSWallMaxStep)
59      //
60   ,fAllowDiagonalClusterization(0)
61   ,fTanLorentzAngle(0)
62   ,fSigmaY2(0)
63   ,fSigmaZ2(0)
64   ,fTrackingConditions(0)
65   ,fTracker(0)
66   ,fSAonly(kFALSE)
67 {
68   // def c-tor
69   SetName("ITS");
70   SetTitle("ITS");
71   for (int i=kNTrackingPhases;i--;) fUseMatLUT[i] = fgkUseMatLUT[i];
72 }
73
74 //_____________________________________________________________________________
75 AliITSURecoParam::AliITSURecoParam(Int_t nLr)
76   :  fNLayers(0)
77   ,fMaxDforV0dghtrForProlongation(fgkMaxDforV0dghtrForProlongation)
78   ,fMaxDForProlongation(fgkMaxDForProlongation)
79   ,fMaxDZForProlongation(fgkMaxDZForProlongation)
80   ,fMinPtForProlongation(fgkMinPtForProlongation)
81      //
82   ,fTPCITSWallRMin(fgkTPCITSWallRMin)
83   ,fTPCITSWallRMax(fgkTPCITSWallRMax)
84   ,fTPCITSWallZSpanH(fgkTPCITSWallZSpanH)
85   ,fTPCITSWallMaxStep(fgkTPCITSWallMaxStep)
86      //
87   ,fAllowDiagonalClusterization(0)
88   ,fTanLorentzAngle(0)
89   ,fSigmaY2(0)
90   ,fSigmaZ2(0)
91   ,fTrackingConditions(0)
92   ,fTracker(0)
93   ,fSAonly(kFALSE)
94 {
95   // def c-tor
96   SetName("ITS");
97   SetTitle("ITS");
98   SetNLayers(nLr);
99 }
100
101 //_____________________________________________________________________________
102 AliITSURecoParam::~AliITSURecoParam() 
103 {
104   // destructor
105   delete[] fTanLorentzAngle;
106   delete[] fSigmaY2;
107   delete[] fSigmaZ2;
108   delete[] fAllowDiagonalClusterization;
109   fTrackingConditions.Delete();
110 }
111
112 //_____________________________________________________________________________
113 AliITSURecoParam *AliITSURecoParam::GetHighFluxParam() 
114 {
115   // make default reconstruction  parameters for hig  flux env.
116
117   // The settings below are taken from Ruben's MakeITSRecoParam.C
118     enum {
119       kBit0=0x1<<0, kBit1=0x1<<1, kBit2=0x1<<2, kBit3=0x1<<3,
120       kBit4=0x1<<4, kBit5=0x1<<5, kBit6=0x1<<6, kBit7=0x7<<2, kBit8=0x1<<8
121     };
122     const Bool_t kAllowDiagCl = kFALSE;
123     const Bool_t kUseLUT[3]={kTRUE,kTRUE,kFALSE};
124     //Use TGeo mat.queries only for RefitInward
125
126     Int_t nLr=7;
127
128     AliITSURecoParam * itsRecoParam = new AliITSURecoParam();
129     //
130     itsRecoParam->SetNLayers(nLr);
131     //
132     //******************************************************************
133     itsRecoParam->SetEventSpecie(AliRecoParam::kHighMult);
134     itsRecoParam->SetTitle("HighMult");
135     //******************************************************************
136     for (int i=0; i<nLr; i++) 
137         itsRecoParam->SetAllowDiagonalClusterization(i,kAllowDiagCl);
138     for (int i=AliITSURecoParam::kNTrackingPhases; i--;) 
139         itsRecoParam->SetUseMatLUT(i,kUseLUT[i]);
140
141     // Add tracking conditions >>>
142     AliITSUTrackCond *trCond=0;
143     {
144     int c0nBranch[7] = {3,9,15,4,5,7,10}; // max branching for the seed on layer
145     int c0nCands[7]  = {10,15,45,20,60,20,10};// max candidates for the TPC seed
146     float c0tr2clChi2[7] ={20,25,30,40,45,45,70};//cut on cluster to track chi2 
147     float c0gloChi2[7]   = {6,10,20,30,60,60,70}; //cut on seed global norm chi2
148     float c0missPen[7] = {2.,2.,2.,2.,2.,2.,2.};  // missing cluster penalty
149     float c0maxChi2SA[14]={0.,0.,0.,0.,2.5,5.,10.,20.,20.,20.,20.,20.,20.,20.};
150     // chi2SA vs Nclus
151     float c0maxChi2Match = 10.;
152  
153     trCond = new AliITSUTrackCond();
154     trCond->SetNLayers(nLr); 
155     trCond->SetMaxITSTPCMatchChi2(c0maxChi2Match);
156     //
157     for (int i=0; i<nLr; i++) {
158       trCond->SetMaxBranches(i,c0nBranch[i]);    // each seed propagated to given layer can produce max nBranch branches
159       trCond->SetMaxCandidates(i,c0nCands[i]);   // each tpc track may have at most nCands prolongations
160       trCond->SetMaxTr2ClChi2(i,c0tr2clChi2[i]);   // cut on cluster to track chi2
161       trCond->SetMaxChi2GloNrm(i,c0gloChi2[i]);  // cut on cluster to track global chi2
162       trCond->SetMissPenalty(i,c0missPen[i]);    // missing cluster penalty
163     }
164
165     for (int i=1; i<=2*nLr; i++) trCond->SetMaxITSSAChi2(i,c0maxChi2SA[i-1]);
166
167     trCond->AddNewCondition(5); // min hits
168     trCond->AddGroupPattern( kBit0|kBit1|kBit2, 2); // at least 2 hits in 3 inner layers
169     trCond->AddGroupPattern( kBit3|kBit4      , 1); // at least 1 hit in 2 middle layers
170     trCond->AddGroupPattern( kBit5|kBit6      , 1); // at least 1 hit in 2 outer layers
171     //
172     trCond->Init();
173     //
174     itsRecoParam->AddTrackingCondition(trCond);
175     }
176
177     //-----------------------------------------------------------
178     // short tracks
179     {
180     int c1nBranch[7] = {0,0,0,4,6,6,10}; // max branching for the seed on layer
181     int c1nCands[7]  = {0,0,0,5,5,5,8}; // max candidates for the TPC seed
182     float c1tr2clChi2[7]= {0,0,0,20,20,20,30}; // cut on cluster to track chi2 
183     float c1gloChi2[7]  = {0,0,0,16,40,35,30}; // cut on seed global norm chi2
184     float c1missPen[7]  = {0.,0.,0.,2.,2.,2.,2.};    // missing cluster penalty
185     float c1maxChi2SA[14]={0.,0.,0.,5.,13.,13.,18.,10.,10.,10.,10.,10.,10.,10.};
186     // chi2SA vs Nclus
187     float c1maxChi2Match = 10.;
188
189     trCond = new AliITSUTrackCond();
190     trCond->SetNLayers(nLr); 
191     //
192     trCond->ExcludeLayer(0);
193     trCond->ExcludeLayer(1);
194     trCond->ExcludeLayer(2);
195     //
196     trCond->SetMaxITSTPCMatchChi2(c1maxChi2Match);
197     //
198     // to exclude some layer use trCon->ExcludeLayer(lrID);
199     //
200     for (int i=0; i<nLr; i++) {
201       trCond->SetMaxBranches(i,c1nBranch[i]);    // each seed propagated to given layer can produce max nBranch branches
202       trCond->SetMaxCandidates(i,c1nCands[i]);   // each tpc track may have at most nCands prolongations
203       trCond->SetMaxTr2ClChi2(i,c1tr2clChi2[i]); // cut on cluster to track chi2
204       trCond->SetMaxChi2GloNrm(i,c1gloChi2[i]);  // cut on cluster to track global chi2
205       trCond->SetMissPenalty(i,c1missPen[i]);    // missing cluster penalty
206     }
207
208     for (int i=1; i<=2*nLr; i++) trCond->SetMaxITSSAChi2(i,c1maxChi2SA[i-1]);
209     
210     trCond->AddNewCondition(4); // min hits
211     trCond->AddGroupPattern( kBit3|kBit4|kBit5|kBit6, 4);
212     
213     trCond->Init();
214     
215     itsRecoParam->AddTrackingCondition(trCond);
216     }
217
218     //-----------------------------------------------------------
219     // very short tracks
220     {
221     int c2nBranch[7] = {0,0,0,0,0,6,10}; // max branching for the seed on layer
222     int c2nCands[7]  = {0,0,0,0,0,5,8}; // max candidates for the TPC seed
223     float c2tr2clChi2[7]= {0,0,0,0,0,15,20}; // cut on cluster to track chi2
224     float c2gloChi2[7]  = {0,0,0,0,0,15,20}; // cut on seed global norm chi2
225     float c2missPen[7]  = {0.,0.,0.,0.,0.,2.,2.};    // missing cluster penalty
226     float c2maxChi2SA[14]={0.,5.,5.,5.,13.,13.,18.,10.,10.,10.,10.,10.,10.,10.};
227     // chi2SA vs Nclus, meaningless for 2 point tracks 
228     float c2maxChi2Match = 6.;
229
230     trCond = new AliITSUTrackCond();
231     trCond->SetNLayers(nLr); 
232     //
233     trCond->ExcludeLayer(0);
234     trCond->ExcludeLayer(1);
235     trCond->ExcludeLayer(2);
236     trCond->ExcludeLayer(3);
237     trCond->ExcludeLayer(4);
238     
239     trCond->SetMaxITSTPCMatchChi2(c2maxChi2Match);
240     //
241     // to exclude some layer use trCon->ExcludeLayer(lrID);
242     //
243     for (int i=0; i<nLr; i++) {
244       trCond->SetMaxBranches(i,c2nBranch[i]);    // each seed propagated to given layer can produce max nBranch branches
245       trCond->SetMaxCandidates(i,c2nCands[i]);   // each tpc track may have at most nCands prolongations
246       trCond->SetMaxTr2ClChi2(i,c2tr2clChi2[i]); // cut on cluster to track chi2
247       trCond->SetMaxChi2GloNrm(i,c2gloChi2[i]);  // cut on cluster to track global chi2
248       trCond->SetMissPenalty(i,c2missPen[i]);    // missing cluster penalty
249     }
250
251     for (int i=1;i<=2*nLr;i++) trCond->SetMaxITSSAChi2(i,c2maxChi2SA[i-1]);
252     //
253     trCond->AddNewCondition(2); // min hits
254     trCond->AddGroupPattern( kBit5|kBit6, 2);
255     //
256     trCond->Init();
257     //
258     itsRecoParam->AddTrackingCondition(trCond);
259     }
260     return itsRecoParam;
261 }
262
263 //_____________________________________________________________________________
264 AliITSURecoParam *AliITSURecoParam::GetLowFluxParam() 
265 {
266   // make default reconstruction  parameters for low  flux env.
267   AliITSURecoParam *param = new AliITSURecoParam();
268   // put here params
269   return param;
270 }
271
272 //_____________________________________________________________________________
273 AliITSURecoParam *AliITSURecoParam::GetCosmicTestParam() 
274 {
275   // make default reconstruction  parameters for cosmics
276   AliITSURecoParam *param = new AliITSURecoParam();
277   // put here params
278   return param;
279 }
280
281 //_____________________________________________________________________________
282 void  AliITSURecoParam::SetNLayers(Int_t n)
283 {
284   // set n layers and init all layer dependent arrays
285   if (fNLayers>0) AliFatal(Form("Number of layers was already set to %d",fNLayers));
286   if (n<1) n = 1; // in case we want to have dummy params
287   fNLayers = n;
288   fTanLorentzAngle = new Double_t[n];
289   fSigmaY2 = new Double_t[n];
290   fSigmaZ2 = new Double_t[n];
291   fAllowDiagonalClusterization = new Bool_t[n];
292   //
293   for (int i=n;i--;) {
294     fAllowDiagonalClusterization[i] = fgkAllowDiagonalClusterization;
295     fTanLorentzAngle[i] = fgkTanLorentzAngle;
296     fSigmaY2[i] = fgkSigmaRoadY*fgkSigmaRoadY;
297     fSigmaZ2[i] = fgkSigmaRoadZ*fgkSigmaRoadZ;
298   }
299   //
300 }
301
302 //_____________________________________________________________________________
303 void  AliITSURecoParam::SetTanLorentzAngle(Int_t lr, Double_t v)
304 {
305   // set Lorentz angle value
306   if (lr>=fNLayers) AliFatal(Form("Number of defined layers is %d",fNLayers));
307   fTanLorentzAngle[lr] = v;
308 }
309
310 //_____________________________________________________________________________
311 void  AliITSURecoParam::SetSigmaY2(Int_t lr, Double_t v)
312 {
313   // set Lorentz angle value
314   if (lr>=fNLayers) AliFatal(Form("Number of defined layers is %d",fNLayers));
315   fSigmaY2[lr] = v;
316 }
317
318 //_____________________________________________________________________________
319 void  AliITSURecoParam::SetSigmaZ2(Int_t lr, Double_t v)
320 {
321   // set Lorentz angle value
322   if (lr>=fNLayers) AliFatal(Form("Number of defined layers is %d",fNLayers));
323   fSigmaZ2[lr] = v;
324 }
325
326 //_____________________________________________________________________________
327 void  AliITSURecoParam::SetAllowDiagonalClusterization(Int_t lr, Bool_t v)
328 {
329   // set Lorentz angle value
330   if (lr>=fNLayers) AliFatal(Form("Number of defined layers is %d",fNLayers));
331   fAllowDiagonalClusterization[lr] = v;
332 }
333
334 //========================================================================
335 //_____________________________________________________________________________
336 void AliITSURecoParam::Print(Option_t *) const
337 {
338   // print params
339   printf("%s: %s %s\n",ClassName(),GetName(),GetTitle());
340   printf("%-30s\t%f\n","fMaxDforV0dghtrForProlongation",fMaxDforV0dghtrForProlongation);
341   printf("%-30s\t%f\n","fMaxDForProlongation",fMaxDForProlongation); 
342   printf("%-30s\t%f\n","fMaxDZForProlongation",fMaxDZForProlongation);
343   printf("%-30s\t%f\n","fMinPtForProlongation",fMinPtForProlongation);
344   //
345   printf("Use material LUT at steps: "); 
346   for (int i=0;i<kNTrackingPhases;i++) printf("%d : %s |",i,GetUseMatLUT(i) ? "ON":"OFF"); printf("\n");
347   printf("TPC-ITS wall: %.3f<R<%.3f DZ/2=%.3f MaxStep=%.3f\n",
348          fTPCITSWallRMin,fTPCITSWallRMax,fTPCITSWallZSpanH,fTPCITSWallMaxStep);
349   //
350   printf("N.Layers: %d\n",fNLayers);
351   if (fNLayers>0) {
352     printf("Layer-wise data:\n");
353     printf("%-30s\t:","fTanLorentzAngle");  for (int i=0;i<fNLayers;i++) printf(" %+.2e",fTanLorentzAngle[i]); printf("\n");
354     printf("%-30s\t:","fSigmaY2");          for (int i=0;i<fNLayers;i++) printf(" %+.2e",fSigmaY2[i]); printf("\n");
355     printf("%-30s\t:","fSigmaZ2");          for (int i=0;i<fNLayers;i++) printf(" %+.2e",fSigmaZ2[i]); printf("\n");
356   }
357   //
358   int nTrCond = GetNTrackingConditions();
359   printf("%d tracking conditions defined\n",nTrCond);
360   for (int itc=0;itc<nTrCond;itc++) {
361     printf("Tracking condition %d\n",itc);
362     GetTrackingCondition(itc)->Print();
363   }
364 }
365
366 //__________________________________________________
367 void  AliITSURecoParam::AddTrackingCondition(AliITSUTrackCond* cond)
368 {
369   // Add new tracking condition
370   fTrackingConditions.AddLast(cond);
371 }