]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/testITSU/DetectorK.h
Integrating the Cooked Matrix tracker into the commom reconstruction framework
[u/mrichter/AliRoot.git] / ITS / UPGRADE / testITSU / DetectorK.h
1 #ifndef DETECTORK_H
2 #define DETECTORK_H
3
4 #include <TNamed.h>
5 #include <TClonesArray.h>
6 #include <TList.h>
7 #include <TGraph.h>
8 #include <Riostream.h>
9
10 /***********************************************************
11
12 Fast Simulation tool for Inner Tracker Systems
13
14 original code of using the billoir technique was developed
15 for the HFT (STAR), James H. Thomas, jhthomas@lbl.gov
16 http://rnc.lbl.gov/~jhthomas
17
18 Changes by S. Rossegger
19
20 July 2011  - Adding the possibility of "fake calculation" and "efficiency calculation" 
21              with a number of "at least correct clusters on the track"
22              Done using the complete combinatorics table with 3^nLayer track outcomes.
23
24 April 2011 - Now uses the Kalman method (aliroot implementation) instead of the Billoir
25              technique ... (changes by Ruben Shahoyan)
26
27 March 2011 - Changes to comply with the Alice Offline coding conventions
28
29 Feb. 2011 - Improvement in "lowest pt allowed" -> now uses helix param. for calc. of a,b
30
31           - Adding a more sophisticaed efficiency calculation which includes
32             the possibility to make chi2 cuts via Confidence Levels (method of Ruben Shahoyan)
33             plus adding 'basic' detection efficiencies per layer ...
34
35           - Adding "ITS Stand alone" tracking capabilities via 
36             forward+backward tracking -> Kalman smoothing is then 
37             used for the parameter estimates (important for efficiencies)
38
39 Jan. 2011 - Inclusion of ImpactParameter Plots (with vtx estimates)
40             to allow comparison with ITS performances in pp data
41
42 Dec. 2010 - Translation into C++ class format 
43           - Adding various Setters and Getters to build the geometry 
44             (based on cylinders) plus handling of the layer properties 
45
46
47 ***********************************************************/
48
49 class AliExternalTrackParam; 
50 #include <TMatrixD.h>
51
52 class TrackSol: public TObject
53 {
54  public:
55   enum {kInw,kOut,kCmb};
56   //
57  TrackSol(int nL, double pt, double eta, int q, double m=0.140) 
58    : fPt(nL>0 ? pt : -1), fEta(eta), fMass(m), fCharge(q),  
59     fTrackInw("AliExternalTrackParam",nL),
60     fTrackOutB("AliExternalTrackParam",nL),
61     fTrackOutA("AliExternalTrackParam",nL),
62     fTrackCmb("AliExternalTrackParam",nL)
63     {
64       for (int i=3;i--;) fProb[i][0] = fProb[i][1] = 0;
65     }
66   //
67   void Clear(Option_t*) {
68     fTrackInw.Clear();
69     fTrackOutB.Clear();
70     fTrackOutA.Clear();
71     fTrackCmb.Clear();
72     fPt = -1;
73     for (int i=3;i--;) fProb[i][0] = fProb[i][1] = 0;
74   }
75   //
76   Double_t        fPt;
77   Double_t        fEta;
78   Double_t        fMass;
79   Int_t           fCharge;
80   Double_t        fProb[3][2]; // corr/fake prob for inw,out and cmb tracking
81   TClonesArray fTrackInw;
82   TClonesArray fTrackOutB; // outward before update
83   TClonesArray fTrackOutA; // outward after update
84   TClonesArray fTrackCmb;
85   //
86   ClassDef(TrackSol,1)
87 };
88
89
90 class CylLayerK : public TNamed {
91 public:
92
93   CylLayerK(char *name) : TNamed(name,name) {}
94   
95   Float_t GetRadius()   const {return radius;}
96   Float_t GetRadL()     const {return radL;}
97   Float_t GetPhiRes()   const {return phiRes;}
98   Float_t GetZRes()     const {return zRes;}
99   Float_t GetLayerEff() const {return eff;}
100
101   //  void Print() {printf("  r=%3.1lf X0=%1.6lf sigPhi=%1.4lf sigZ=%1.4lf\n",radius,radL,phiRes,zRes); }
102   Float_t radius; Float_t radL; Float_t phiRes; Float_t zRes;   
103   Float_t eff;
104   Bool_t isDead;
105
106  ClassDef(CylLayerK,1);
107 };
108
109
110 class DetectorK : public TNamed {
111
112  public:
113   
114   DetectorK();
115   DetectorK(char *name,char *title);
116   virtual ~DetectorK();
117
118   enum {kNptBins = 50}; // less then 400 !!
119  
120   void AddLayer(char *name, Float_t radius, Float_t radL, Float_t phiRes=999999, Float_t zRes=999999, Float_t eff=0.95);
121   void KillLayer(char *name);
122   void SetRadius(char *name, Float_t radius);
123   void SetRadiationLength(char *name, Float_t radL);
124   void SetResolution(char *name, Float_t phiRes=999999, Float_t zRes=999999);
125   void SetLayerEfficiency(char *name, Float_t eff=0.95);
126   void RemoveLayer(char *name);
127   CylLayerK* FindLayer(char* name) const;
128   CylLayerK* FindLayer(double r, int mode) const;
129   Int_t      FindLayerID(double r, int mode) const;
130   //
131   Float_t GetRadius(char *name);
132   Float_t GetRadiationLength(char *name);
133   Float_t GetResolution(char *name, Int_t axis=0);
134   Float_t GetLayerEfficiency(char *name);
135
136   void PrintLayout(Bool_t full = kFALSE); 
137   void PlotLayout(Int_t plotDead = kTRUE);
138   
139   void MakeAliceAllNew(Bool_t flagTPC =1,Bool_t flagMon=1);
140   void MakeAliceCurrent(Int_t AlignResiduals = 0, Bool_t flagTPC =1);
141   void AddTPC(Float_t phiResMean=0.1, Float_t zResMean=0.1, Int_t skip=1);
142   void AddTRD(Float_t phiResMean=0.02, Float_t zResMean=2.5, Float_t lrEff=0.9);
143   void RemoveTPC();
144
145   void SetBField(Float_t bfield) {fBField = bfield; }
146   Float_t GetBField() const {return fBField; }
147   void SetLhcUPCscale(Float_t lhcUPCscale) {fLhcUPCscale = lhcUPCscale; }
148   Float_t GetLhcUPCscale() const { return fLhcUPCscale; }
149   void SetParticleMass(Float_t particleMass) {fParticleMass = particleMass; }
150   Float_t GetParticleMass() const { return fParticleMass; }
151   void SetIntegrationTime(Float_t integrationTime) {fIntegrationTime = integrationTime; }
152   Float_t GetIntegrationTime() const { return fIntegrationTime; }
153   void SetMaxRadiusOfSlowDetectors(Float_t maxRadiusSlowDet) {fMaxRadiusSlowDet =  maxRadiusSlowDet; }
154   Float_t GetMaxRadiusOfSlowDetectors() const { return fMaxRadiusSlowDet; }
155   void SetAvgRapidity(Float_t avgRapidity) {fAvgRapidity = avgRapidity; }
156   Float_t GetAvgRapidity() const { return fAvgRapidity; }
157   void SetConfidenceLevel(Float_t confLevel) {fConfLevel = confLevel; }
158   Float_t GetConfidenceLevel() const { return fConfLevel; }
159
160   void SetAtLeastHits(Int_t atLeast ) {fAtLeastHits = atLeast; }
161   Int_t GetAtLeastHits() const { return fAtLeastHits; }
162
163   void SetAtLeastCorr(Int_t atLeastCorr ) {fAtLeastCorr = atLeastCorr; }
164   Int_t GetAtLeastCorr() const { return fAtLeastCorr; }
165   void SetAtLeastFake(Int_t atLeastFake ) {fAtLeastFake = atLeastFake; }
166   Int_t GetAtLeastFake() const { return fAtLeastFake; }
167
168   void SetMaxSeedRadius(Double_t maxSeedRadius ) {fMaxSeedRadius = maxSeedRadius; }
169   Int_t GetMaxSeedRadius() const { return fMaxSeedRadius; }
170
171   void SetptScale(Double_t ptScale ) {fptScale = ptScale; }
172   Int_t GetptScale() const { return fptScale; }
173
174   
175
176   void SetdNdEtaCent(Int_t dNdEtaCent ) {fdNdEtaCent = dNdEtaCent; }
177   Float_t GetdNdEtaCent() const { return fdNdEtaCent; }
178   
179   
180   Float_t GetNumberOfLayers()          const {return fNumberOfLayers; }
181   Float_t GetNumberOfActiveLayers() const {return fNumberOfActiveLayers; }
182   Float_t GetNumberOfActiveITSLayers() const {return fNumberOfActiveITSLayers; }
183
184   void SolveViaBilloir(Int_t flagD0=1,Int_t print=1, Bool_t allPt=1, Double_t meanPt =0.095, char* detLayer=((char*)""));
185   //
186   Bool_t SolveTrack(TrackSol& ts);
187   Bool_t CalcITSEff(TrackSol& ts, Bool_t verbose=kTRUE);
188   Bool_t ExtrapolateToR(AliExternalTrackParam* probTr, double rTgt, double mass=0.14);
189   //
190   void   SetMinRadTrack(double r=132) {  fMinRadTrack = r; }
191   Double_t GetMinRadTrack()  const { return fMinRadTrack;}
192
193   //
194   //
195   // Helper functions
196   Double_t ThetaMCS                 ( Double_t mass, Double_t RadLength, Double_t momentum ) const;
197   Double_t ProbGoodHit              ( Double_t radius, Double_t searchRadiusRPhi, Double_t searchRadiusZ )   ; 
198   Double_t ProbGoodChiSqHit         ( Double_t radius, Double_t searchRadiusRPhi, Double_t searchRadiusZ )   ; 
199   Double_t ProbGoodChiSqPlusConfHit ( Double_t radius, Double_t leff, Double_t searchRadiusRPhi, Double_t searchRadiusZ )   ; 
200   Double_t ProbNullChiSqPlusConfHit ( Double_t radius, Double_t leff, Double_t searchRadiusRPhi, Double_t searchRadiusZ )   ; 
201  
202   // Howard W. hit distribution and convolution integral
203   Double_t Dist              ( Double_t Z, Double_t radius ) ;  
204   Double_t HitDensity        ( Double_t radius )   ;
205   Double_t UpcHitDensity     ( Double_t radius )   ;
206   Double_t IntegratedHitDensity  ( Double_t multiplicity, Double_t radius )   ;
207   Double_t OneEventHitDensity    ( Double_t multiplicity, Double_t radius ) const   ;
208   Double_t D0IntegratedEfficiency( Double_t pt, Double_t corrEfficiency[][400] ) const ;
209   
210   TGraph* GetGraphMomentumResolution(Int_t color, Int_t linewidth=1);
211   TGraph* GetGraphPointingResolution(Int_t axis,Int_t color, Int_t linewidth=1);
212   TGraph* GetGraphPointingResolutionTeleEqu(Int_t axis,Int_t color, Int_t linewidth=1);
213   TGraph* GetGraphLayerInfo(Int_t plot, Int_t color, Int_t linewidth=1);
214
215   TGraph* GetGraphImpactParam(Int_t mode, Int_t axis, Int_t color, Int_t linewidth=1);
216
217   TGraph* GetGraphRecoEfficiency(Int_t particle, Int_t color, Int_t linewidth=1); 
218   TGraph* GetGraphRecoFakes(Int_t particle,Int_t color, Int_t linewidth);
219   TGraph* GetGraphRecoPurity(Int_t particle,Int_t color, Int_t linewidth);
220
221   TGraph* GetGraph(Int_t number, Int_t color, Int_t linewidth=1);
222
223   void MakeStandardPlots(Bool_t add =0, Int_t color=1, Int_t linewidth=1,Bool_t onlyPionEff=0);
224
225   // method to extend AliExternalTrackParam functionality
226   static Bool_t GetXatLabR(AliExternalTrackParam* tr,Double_t r,Double_t &x, Double_t bz, Int_t dir=0);
227   static Bool_t PropagateToR(AliExternalTrackParam* trc, double r, double b, int dir=0);
228   Double_t* PrepareEffFakeKombinations(TMatrixD *probKomb, TMatrixD *probLay, double* prob=0);
229
230   Bool_t IsITSLayer(const TString& lname);
231
232   static Bool_t verboseR;
233  protected:
234  
235   Int_t fNumberOfLayers;        // total number of layers in the model
236   Int_t fNumberOfActiveLayers;  // number of active layers in the model
237   Int_t fNumberOfActiveITSLayers;  // number of active ITS layers in the model
238   TList fLayers;                // List of layer pointers
239   Float_t fBField;              // Magnetic Field in Tesla
240   Float_t fLhcUPCscale;         // UltraPeripheralElectrons: scale from RHIC to LHC
241   Float_t fIntegrationTime;     // electronics integration time
242   Float_t fConfLevel;           // Confidence Level for the tracking
243   Float_t fAvgRapidity;         // rapidity of the track (= mean)
244   Float_t fParticleMass;        // Particle used for tracking. Standard: mass of pion
245   Double_t fMaxRadiusSlowDet;   // Maximum radius for slow detectors.  Fast detectors 
246                                 // and only fast detectors reside outside this radius.
247
248   Int_t fAtLeastHits;     // min. number of hits for the track to account it
249   Int_t fAtLeastCorr;     // min. number of correct hits for the track to be "good"
250   Int_t fAtLeastFake;     // min. number of fake hits for the track to be "fake"
251
252   Double_t fMaxSeedRadius; // max seeding radius, e.g. to exclude TRD
253   Double_t fptScale;      // used for maxPt
254
255   Int_t fdNdEtaCent;       // Multiplicity
256
257   enum {kMaxNumberOfDetectors = 200};
258  
259   Double_t fTransMomenta[kNptBins];                          // array of transverse momenta
260   Double_t fMomentumRes[kNptBins];                           // array of momentum resolution
261   Double_t fResolutionRPhi[kNptBins];                        // array of rphi resolution
262   Double_t fResolutionZ[kNptBins];                           // array of z resolution
263   Double_t fDetPointRes[kMaxNumberOfDetectors][kNptBins];    // array of rphi resolution per layer
264   Double_t fDetPointZRes[kMaxNumberOfDetectors][kNptBins];   // array of z resolution per layer
265   Double_t fEfficiency[3][kNptBins];                         // efficiency for different particles
266   Double_t fFake[3][kNptBins];                               // fake prob for different particles
267
268   Int_t kDetLayer;                              // layer for which a few more details are extracted
269   Double_t fResolutionRPhiLay[kNptBins];                        // array of rphi resolution
270   Double_t fResolutionZLay[kNptBins];                           // array of z resolution
271   Double_t fEfficProlongLay[kNptBins];                           // array of z resolution
272
273   Double_t fMinRadTrack;
274
275   static const Double_t kPtMinFix;
276   static const Double_t kPtMaxFix;
277
278   ClassDef(DetectorK,1);
279 };
280
281 #endif
282