]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSTrackleterSPDEff.h
All the changes have been done in order to integrate in the standard
[u/mrichter/AliRoot.git] / ITS / AliITSTrackleterSPDEff.h
1 #ifndef ALIITSTRACKLETERSPDEFF_H
2 #define ALIITSTRACKLETERSPDEFF_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 // AliITSTrackleterSPDEff - find SPD chips efficiencies by using tracklets.
11 // 
12 // This class was originally derived from AliITSMultReconstructor (see
13 // it for more details). Later on, the inheritance was changed to AliTracker
14 // It is the class for the Trackleter used to estimate
15 // SPD plane efficiency.
16 // The trackleter prediction is built using the vertex and 1 cluster.
17
18 //
19 // 
20 //  Author :  Giuseppe Eugenio Bruno, based on the skeleton of Reconstruct method  provided by Tiziano Virgili
21 //  email:    giuseppe.bruno@ba.infn.it
22 //  
23 //____________________________________________________________________
24
25 class AliStack;
26 class TTree;
27 class TH1F;
28 class TH2F;
29 #include "AliTracker.h"
30 #include "AliITSPlaneEffSPD.h"
31 #include "AliPlaneEff.h"
32
33 class AliITSTrackleterSPDEff : public  AliTracker
34 {
35 public:
36   AliITSTrackleterSPDEff();
37   virtual ~AliITSTrackleterSPDEff();
38   Int_t Clusters2Tracks(AliESDEvent *);
39   Int_t PostProcess(AliESDEvent *);
40
41   virtual Int_t PropagateBack(AliESDEvent*) {return 0;}
42   virtual Int_t RefitInward(AliESDEvent*) {return 0;}
43   Int_t LoadClusters(TTree* cl) {LoadClusterArrays(cl); return 0;} // see implementation in AliITSMultReconstructor
44   virtual void UnloadClusters() {return;}
45   virtual AliCluster *GetCluster(Int_t) const {return NULL;}
46
47   // Main method to perform the trackleter and the SPD efficiency evaluation
48   void Reconstruct(AliStack* pStack=0x0, TTree* tRef=0x0);
49
50   void SetReflectClusterAroundZAxisForLayer(Int_t ilayer,Bool_t b=kTRUE){  // method to study residual background:
51     if(b) AliInfo(Form("All clusters on layer %d will be rotated by 180 deg around z",ilayer)); 
52     if(ilayer==0) fReflectClusterAroundZAxisForLayer0=b;                   // a rotation by 180degree around the Z axis  
53     else if(ilayer==1) fReflectClusterAroundZAxisForLayer1=b;              // (x->-x; y->-y) to all RecPoints on a 
54     else AliInfo("Nothing done: input argument (ilayer) either 0 or 1");   // given layer is applied. In such a way 
55   }                                                                        // you remove all the true tracklets.
56
57   void SetOnlyOneTrackletPerC2(Bool_t b = kTRUE) {fOnlyOneTrackletPerC2 = b;}
58   void SetPhiWindow(Float_t w=0.08) {fPhiWindow=w;}
59   void SetZetaWindow(Float_t w=1.) {fZetaWindow=w;}
60
61   void SetPhiWindowL1(Float_t w=0.08) {fPhiWindowL1=w;}  // method to set the cuts in the interpolation
62   void SetZetaWindowL1(Float_t w=1.) {fZetaWindowL1=w;}  // phase; use method of the base class for extrap.
63   void SetOnlyOneTrackletPerC1(Bool_t b = kTRUE) {fOnlyOneTrackletPerC1 = b;} // as in the base class but 
64
65   Int_t GetNClustersLayer1() const {return fNClustersLay1;}
66   Int_t GetNClustersLayer2() const {return fNClustersLay2;}
67   Int_t GetNTracklets() const {return fNTracklets;}
68
69   Float_t* GetClusterLayer1(Int_t n) {return fClustersLay1[n];}
70   Float_t* GetClusterLayer2(Int_t n) {return fClustersLay2[n];}
71   Float_t* GetTracklet(Int_t n) {return fTracklets[n];}
72                                                                               // for the inner layer
73   void SetUpdateOncePerEventPlaneEff(Bool_t b = kTRUE) {fUpdateOncePerEventPlaneEff = b;}
74   
75   AliITSPlaneEffSPD* GetPlaneEffSPD() const {return fPlaneEffSPD;}  // return a pointer to the AliITSPlaneEffSPD
76   AliPlaneEff *GetPlaneEff() {return (AliPlaneEff*)fPlaneEffSPD;}   // return the pointer to AliPlaneEff
77   
78   void SetMC(Bool_t mc=kTRUE) {fMC=mc; fMC? InitPredictionMC() : DeletePredictionMC(); return;}  // switch on access to MC true 
79   Bool_t GetMC() const {return fMC;}  // check the access to MC true
80   // Only for MC: use only "primary" particles (according to PrimaryTrackChecker) for the tracklet prediction
81   void SetUseOnlyPrimaryForPred(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlyPrimaryForPred = flag; } 
82   // Only for MC: use only "secondary" particles (according to PrimaryTrackChecker) for the tracklet prediction
83   void SetUseOnlySecondaryForPred(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlySecondaryForPred = flag;}
84   // Only for MC: associate a cluster to the tracklet prediction if  from the same particle
85   void SetUseOnlySameParticle(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlySameParticle = flag;}
86   // Only for MC: associate a cluster to the tracklet prediction if  from different particles
87   void SetUseOnlyDifferentParticle(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlyDifferentParticle = flag;}
88   //  Only for MC: re-define "primary" a particle if it is also "stable" (according to definition in method DecayingTrackChecker)
89   void SetUseOnlyStableParticle(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlyStableParticle = flag;}
90   // only for MC: Getters relative to the above setters
91   Bool_t GetUseOnlyPrimaryForPred() const {CallWarningMC(); return fUseOnlyPrimaryForPred; }
92   Bool_t GetUseOnlySecondaryForPred() const {CallWarningMC(); return fUseOnlySecondaryForPred;}
93   Bool_t GetUseOnlySameParticle() const {CallWarningMC(); return fUseOnlySameParticle;}
94   Bool_t GetUseOnlyDifferentParticle() const {CallWarningMC(); return fUseOnlyDifferentParticle;}
95   Bool_t GetUseOnlyStableParticle() const {CallWarningMC(); return fUseOnlyStableParticle;}
96   // Getters for the data members related to MC true statisitcs (see below)
97   Int_t GetPredictionPrimary(const UInt_t key) const;
98   Int_t GetPredictionSecondary(const UInt_t key) const;
99   Int_t GetClusterPrimary(const UInt_t key) const;
100   Int_t GetClusterSecondary(const UInt_t key) const;
101   Int_t GetSuccessPP(const UInt_t key) const;
102   Int_t GetSuccessTT(const UInt_t key) const;
103   Int_t GetSuccessS(const UInt_t key) const;
104   Int_t GetSuccessP(const UInt_t key) const;
105   Int_t GetFailureS(const UInt_t key) const;
106   Int_t GetFailureP(const UInt_t key) const;
107   Int_t GetRecons(const UInt_t key) const;
108   Int_t GetNonRecons(const UInt_t key) const;
109   Int_t GetPredictionPrimary(const UInt_t mod, const UInt_t chip) const
110         {return GetPredictionPrimary(fPlaneEffSPD->GetKey(mod,chip));};
111   Int_t GetPredictionSecondary(const UInt_t mod, const UInt_t chip) const
112         {return GetPredictionSecondary(fPlaneEffSPD->GetKey(mod,chip));};
113   Int_t GetClusterPrimary(const UInt_t mod, const UInt_t chip) const
114         {return GetClusterPrimary(fPlaneEffSPD->GetKey(mod,chip));};
115   Int_t GetClusterSecondary(const UInt_t mod, const UInt_t chip) const
116         {return GetClusterSecondary(fPlaneEffSPD->GetKey(mod,chip));};
117   Int_t GetSuccessPP(const UInt_t mod, const UInt_t chip) const
118         {return GetSuccessPP(fPlaneEffSPD->GetKey(mod,chip));};
119   Int_t GetSuccessTT(const UInt_t mod, const UInt_t chip) const
120        {return GetSuccessTT(fPlaneEffSPD->GetKey(mod,chip));};
121   Int_t GetSuccessS(const UInt_t mod, const UInt_t chip) const
122        {return GetSuccessS(fPlaneEffSPD->GetKey(mod,chip));};
123   Int_t GetSuccessP(const UInt_t mod, const UInt_t chip) const
124        {return GetSuccessP(fPlaneEffSPD->GetKey(mod,chip));};
125   Int_t GetFailureS(const UInt_t mod, const UInt_t chip) const
126        {return GetFailureS(fPlaneEffSPD->GetKey(mod,chip));};
127   Int_t GetFailureP(const UInt_t mod, const UInt_t chip) const
128        {return GetFailureP(fPlaneEffSPD->GetKey(mod,chip));};
129   Int_t GetRecons(const UInt_t mod, const UInt_t chip) const
130        {return GetRecons(fPlaneEffSPD->GetKey(mod,chip));};
131   Int_t GetNonRecons(const UInt_t mod, const UInt_t chip) const
132        {return GetNonRecons(fPlaneEffSPD->GetKey(mod,chip));};
133   // methods to write/reas cuts and MC statistics into/from file 
134   // if filename contains  ".root", then data are stored into histograms (->root file). 
135   void SavePredictionMC(TString filename="TrackletsMCpred.txt") const;
136   void ReadPredictionMC(TString filename="TrackletsMCpred.txt");
137   // Print some class info in ascii form to stream (cut values and MC statistics)
138   virtual void PrintAscii(ostream *os)const;
139   // Read some class info in ascii form from stream (cut values and MC statistics)
140   virtual void ReadAscii(istream *is);
141   Bool_t GetHistOn() const {return fHistOn;}; // return status of histograms
142   // write histograms into a root file on disk
143   Bool_t WriteHistosToFile(TString filename="TrackleterSPDHistos.root",Option_t* option = "RECREATE");
144   // switch on/off the extra histograms
145   void SetHistOn(Bool_t his=kTRUE) {fHistOn=his; 
146          if(GetHistOn()) {DeleteHistos(); BookHistos();} else DeleteHistos(); return;}
147
148 protected:
149   AliITSTrackleterSPDEff(const AliITSTrackleterSPDEff& mr); // protected method: no copy allowed from outside
150   AliITSTrackleterSPDEff& operator=(const AliITSTrackleterSPDEff& mr);
151 //
152 //// From AliITSMultReconstructor
153 //
154   Float_t**     fClustersLay1;               // clusters in the 1st layer of ITS
155   Float_t**     fClustersLay2;               // clusters in the 2nd layer of ITS
156
157   Float_t**     fTracklets;            // tracklets
158   Bool_t*       fAssociationFlag;      // flag for the associations
159
160   Int_t         fNClustersLay1;        // Number of clusters (Layer1)
161   Int_t         fNClustersLay2;        // Number of clusters (Layer2)
162   Int_t         fNTracklets;           // Number of tracklets
163
164   // Following members are set via AliITSRecoParam
165   Bool_t        fOnlyOneTrackletPerC2;         // Allow only one tracklet per cluster in the outer layer
166   Float_t       fPhiWindow;                    // Search window in phi
167   Float_t       fZetaWindow;                   // Search window in eta
168   Float_t       fPhiOverlapCut;                // Fiducial window in phi for overlap cut
169   Float_t       fZetaOverlapCut;               // Fiducial window in eta for overlap cut
170
171   Bool_t        fHistOn;               // Option to define and fill the histograms
172
173   TH1F*         fhClustersDPhiAcc;     // Phi2 - Phi1 for tracklets
174   TH1F*         fhClustersDThetaAcc;   // Theta2 - Theta1 for tracklets
175   TH1F*         fhClustersDZetaAcc;    // z2 - z1projected for tracklets
176   TH1F*         fhClustersDPhiAll;     // Phi2 - Phi1 all the combinations
177   TH1F*         fhClustersDThetaAll;   // Theta2 - Theta1 all the combinations
178   TH1F*         fhClustersDZetaAll;    // z2 - z1projected all the combinations
179
180   TH2F*         fhDPhiVsDThetaAll;     // 2D plot for all the combinations
181   TH2F*         fhDPhiVsDThetaAcc;     // same plot for tracklets
182   TH2F*         fhDPhiVsDZetaAll;      // 2d plot for all the combination
183   TH2F*         fhDPhiVsDZetaAcc;      // same plot for tracklets
184
185   TH1F*         fhetaTracklets;        // Pseudorapidity distr. for tracklets
186   TH1F*         fhphiTracklets;        // Azimuthal (Phi) distr. for tracklets
187   TH1F*         fhetaClustersLay1;     // Pseudorapidity distr. for Clusters L. 1
188   TH1F*         fhphiClustersLay1;     // Azimuthal (Phi) distr. for Clusters L. 1
189 //
190 // 
191   Bool_t*       fAssociationFlag1;    // flag for the associations (Layer 1)
192   UInt_t*       fChipPredOnLay2;      // prediction for the chip traversed by the tracklet 
193                                       // based on vtx and ClusterLay1 (to be used in extrapolation)
194   UInt_t*       fChipPredOnLay1;      // prediction for the chip traversed by the tracklet 
195                                       // based on vtx and ClusterLay2 (to be used in interpolation)
196   Int_t         fNTracklets1;   // Number of tracklets layer 1
197   // possible cuts :
198   Float_t       fPhiWindowL1;     // Search window in phi (Layer 1)
199   Float_t       fZetaWindowL1;    // SEarch window in zeta (Layer 1)
200   Bool_t        fOnlyOneTrackletPerC1; // only one tracklet per cluster in L. 1
201   Bool_t        fUpdateOncePerEventPlaneEff;  //  If this is kTRUE, then you can update the chip efficiency only once
202                                               //  per event in that chip. This to avoid double counting from the
203                                               //  same tracklets which has two rec-points on one layer.
204   Bool_t*       fChipUpdatedInEvent;          //  boolean (chip by chip) to flag which chip has been updated its efficiency
205                                               //  in that event
206   AliITSPlaneEffSPD* fPlaneEffSPD; // pointer to SPD plane efficiency class
207   Bool_t   fReflectClusterAroundZAxisForLayer0;  // if kTRUE, then a 180degree rotation around Z is applied to all 
208   Bool_t   fReflectClusterAroundZAxisForLayer1;  // clusters on that layer (x->-x; y->-y)
209   Bool_t   fMC; // Boolean to access Kinematics (only for MC events )
210   Bool_t   fUseOnlyPrimaryForPred; // Only for MC: if this is true, build tracklet prediction using only primary particles
211   Bool_t   fUseOnlySecondaryForPred; // Only for MC: if this is true build tracklet prediction using only secondary particles
212   Bool_t   fUseOnlySameParticle; // Only for MC: if this is true, assign a success only if clusters from same particles 
213                                  // (i.e. PP or SS) otherwise ignore the combination
214   Bool_t   fUseOnlyDifferentParticle; // Only for MC: if this is true, assign a success only if clusters from different particles 
215                                       // (i.e. PP' or PS or SS') otherwise ignore the combination
216   Bool_t   fUseOnlyStableParticle; // Only for MC: if this is kTRUE then method PrimaryTrackChecker return kTRUE only 
217                                 //              for particles decaying (eventually) after pixel layers
218   Int_t *fPredictionPrimary;  // those for correction of bias from secondaries
219   Int_t *fPredictionSecondary; // chip_by_chip: number of Prediction built with primaries/secondaries
220   Int_t *fClusterPrimary;  //   number of clusters on a given chip fired by (at least) a primary
221   Int_t *fClusterSecondary; //  number of clusters on a given chip fired by (only) secondaries
222   Int_t *fSuccessPP;     // number of successes by using the same primary track (vs. chip of the success)
223   Int_t *fSuccessTT;     // number of successes by using the same track (either a primary or a secondary) (vs. chip of the success)
224   Int_t *fSuccessS;      // number of successes by using a secondary for the prediction (vs. chip of the success)
225   Int_t *fSuccessP;      // number of successes by using a primary for the prediction (vs. chip of the success)
226   Int_t *fFailureS;      // number of failures by using a secondary for the prediction (vs. chip of the failure)
227   Int_t *fFailureP;      // number of failures by using a primary for the prediction (vs. chip of the failure)
228   Int_t *fRecons;        // number of particle which can be reconstructed (only for MC from TrackRef)
229   Int_t *fNonRecons;     // unmber of particle which cannot be reconstructed (only for MC from TrackRef)
230  // extra histograms with respect to the base class AliITSMultReconstructor
231   TH1F*         fhClustersDPhiInterpAcc;   // Phi2 - Phi1 for tracklets (interpolation phase)
232   TH1F*         fhClustersDThetaInterpAcc; // Theta2 - Theta1 for tracklets (interpolation phase)
233   TH1F*         fhClustersDZetaInterpAcc;  // z2 - z1projected for tracklets (interpolation phase)
234   TH1F*         fhClustersDPhiInterpAll;   // Phi2 - Phi1 all the combinations (interpolation phase)
235   TH1F*         fhClustersDThetaInterpAll; // Theta2 - Theta1 all the combinations (interpolation phase)
236   TH1F*         fhClustersDZetaInterpAll;  // z2 - z1projected all the combinations (interpolation phase)
237   TH2F*         fhDPhiVsDThetaInterpAll; // 2D plot for all the combinations
238   TH2F*         fhDPhiVsDThetaInterpAcc; // same plot for tracklets
239   TH2F*         fhDPhiVsDZetaInterpAll;  // 2d plot for all the combination
240   TH2F*         fhDPhiVsDZetaInterpAcc;  // same plot for tracklets
241   TH1F*         fhetaClustersLay2; // Pseudorapidity distr. for Clusters L. 2
242   TH1F*         fhphiClustersLay2; // Azimuthal (Phi) distr. for Clusters L. 2
243 //
244   Double_t GetRLayer(Int_t layer); // return average radius of layer (0,1) from Geometry
245   Bool_t PrimaryTrackChecker(Int_t ipart,AliStack* stack=0x0);  // check if a MC particle is primary (need AliStack)
246   Int_t DecayingTrackChecker(Int_t ipart,AliStack* stack=0x0);  // For a primary particle, check if it is stable (see cxx)
247 // check if a MC particle is reconstructable
248   Bool_t IsReconstructableAt(Int_t layer,Int_t iC,Int_t ipart,Float_t* vtx,AliStack* stack=0x0,TTree* ref=0x0);
249   void InitPredictionMC(); // allocate memory for cuts and MC data memebers
250   void DeletePredictionMC(); // deallocate memory
251   // method to locate a chip using current vtx and polar coordinate od tracklet w.r.t. to vtx (zVtx may not be given)
252   Bool_t FindChip(UInt_t &key, Int_t layer,  Float_t* vtx, Float_t thetaVtx, Float_t phiVtx, Float_t zVtx=999.); 
253   // method to transform from Global Cilindrical coordinate to local (module) Cartesian coordinate
254   Bool_t FromGloCilToLocCart(Int_t ilayer,Int_t idet, Double_t r, Double_t phi, Double_t z,
255                            Float_t &xloc, Float_t &zloc);
256   // method to obtain the module (detector) index using global coordinates
257   Int_t FindDetectorIndex(Int_t layer, Double_t phi, Double_t z);
258   // this method gives you the intersections between a line and a circle (centred in the origin) 
259   // using polar coordinates
260   Bool_t FindIntersectionPolar(Double_t vtx[2],Double_t phiVtx, Double_t R,Double_t &phi);
261   Bool_t SetAngleRange02Pi(Double_t &angle); // set the range of angle in [0,2pi[ 
262   Bool_t SetAngleRange02Pi(Float_t  &angle) 
263   {Double_t tmp=(Double_t)angle; Bool_t ret=SetAngleRange02Pi(tmp);angle=(Float_t)tmp;return ret;};  
264   void CallWarningMC() const {if(!fMC) AliWarning("You can use this method only for MC! Call SetMC() first");}
265   Bool_t SaveHists();
266   void BookHistos(); // booking of extra histograms w.r.t. base class
267   void DeleteHistos(); //delete histos from memory
268   // Method to apply a rotation by 180degree to all RecPoints (x->-x; y->-y) on a given layer
269   void ReflectClusterAroundZAxisForLayer(Int_t ilayer); // to be used for backgnd estimation on real data 
270
271   void LoadClusterArrays(TTree* tree);
272
273   ClassDef(AliITSTrackleterSPDEff,3)
274 };
275 // Input and output function for standard C++ input/output (for the cut values and MC statistics).
276 ostream &operator<<(ostream &os,const AliITSTrackleterSPDEff &s);
277 istream &operator>>(istream &is, AliITSTrackleterSPDEff &s);
278 #endif