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