Store number of TRD tracklets on ESD for tracking and PID. Reuse data
[u/mrichter/AliRoot.git] / ITS / AliITSTrackleterSPDEff.h
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
6/* $Id$ */
10// AliITSTrackleterSPDEff - find SPD chips efficiencies by using tracklets.
12// This class has been derived from AliITSMultReconstructor (see
13// it for more details). It is the class for the Trackleter used to estimate
14// SPD plane efficiency.
15// The trackleter prediction is built using the vertex and 1 cluster.
19// Author : Giuseppe Eugenio Bruno, based on the skeleton of Reconstruct method provided by Tiziano Virgili
20// email:
84161aec 24class AliStack;
275a301c 25#include "AliITSMultReconstructor.h"
26#include "AliITSPlaneEffSPD.h"
275a301c 28class AliITSTrackleterSPDEff : public AliITSMultReconstructor
31 AliITSTrackleterSPDEff();
32 virtual ~AliITSTrackleterSPDEff();
84161aec 33 // Main method to perform the trackleter and the SPD efficiency evaluation
a3b31967 34 void Reconstruct(TTree* tree, Float_t* vtx, Float_t* vtxRes, AliStack* pStack=0x0, TTree* tRef=0x0);
275a301c 35
0fce916f 36 void SetReflectClusterAroundZAxisForLayer(Int_t ilayer,Bool_t b=kTRUE){ // method to study residual background:
37 if(b) AliInfo(Form("All clusters on layer %d will be rotated by 180 deg around z",ilayer));
38 if(ilayer==0) fReflectClusterAroundZAxisForLayer0=b; // a rotation by 180degree around the Z axis
39 else if(ilayer==1) fReflectClusterAroundZAxisForLayer1=b; // (x->-x; y->-y) to all RecPoints on a
40 else AliInfo("Nothing done: input argument (ilayer) either 0 or 1"); // given layer is applied. In such a way
41 } // you remove all the true tracklets.
84161aec 43 void SetPhiWindowL1(Float_t w=0.08) {fPhiWindowL1=w;} // method to set the cuts in the interpolation
44 void SetZetaWindowL1(Float_t w=1.) {fZetaWindowL1=w;} // phase; use method of the base class for extrap.
45 void SetOnlyOneTrackletPerC1(Bool_t b = kTRUE) {fOnlyOneTrackletPerC1 = b;} // as in the base class but
46 // for the inner layer
a3b31967 47 void SetUpdateOncePerEventPlaneEff(Bool_t b = kTRUE) {fUpdateOncePerEventPlaneEff = b;}
275a301c 48
84161aec 49 AliITSPlaneEffSPD* GetPlaneEff() const {return fPlaneEffSPD;} // return a pointer to the AliITSPlaneEffSPD
275a301c 50
c6a05d92 51 void SetMC(Bool_t mc=kTRUE) {fMC=mc; fMC? InitPredictionMC() : DeletePredictionMC(); return;} // switch on access to MC true
84161aec 52 Bool_t GetMC() const {return fMC;} // check the access to MC true
53 // Only for MC: use only "primary" particles (according to PrimaryTrackChecker) for the tracklet prediction
54 void SetUseOnlyPrimaryForPred(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlyPrimaryForPred = flag; }
55 // Only for MC: use only "secondary" particles (according to PrimaryTrackChecker) for the tracklet prediction
275a301c 56 void SetUseOnlySecondaryForPred(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlySecondaryForPred = flag;}
84161aec 57 // Only for MC: associate a cluster to the tracklet prediction if from the same particle
275a301c 58 void SetUseOnlySameParticle(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlySameParticle = flag;}
84161aec 59 // Only for MC: associate a cluster to the tracklet prediction if from different particles
275a301c 60 void SetUseOnlyDifferentParticle(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlyDifferentParticle = flag;}
84161aec 61 // Only for MC: re-define "primary" a particle if it is also "stable" (according to definition in method DecayingTrackChecker)
275a301c 62 void SetUseOnlyStableParticle(Bool_t flag=kTRUE) {CallWarningMC(); fUseOnlyStableParticle = flag;}
84161aec 63 // only for MC: Getters relative to the above setters
275a301c 64 Bool_t GetUseOnlyPrimaryForPred() const {CallWarningMC(); return fUseOnlyPrimaryForPred; }
65 Bool_t GetUseOnlySecondaryForPred() const {CallWarningMC(); return fUseOnlySecondaryForPred;}
66 Bool_t GetUseOnlySameParticle() const {CallWarningMC(); return fUseOnlySameParticle;}
67 Bool_t GetUseOnlyDifferentParticle() const {CallWarningMC(); return fUseOnlyDifferentParticle;}
68 Bool_t GetUseOnlyStableParticle() const {CallWarningMC(); return fUseOnlyStableParticle;}
84161aec 69 // Getters for the data members related to MC true statisitcs (see below)
275a301c 70 Int_t GetPredictionPrimary(const UInt_t key) const;
71 Int_t GetPredictionSecondary(const UInt_t key) const;
72 Int_t GetClusterPrimary(const UInt_t key) const;
73 Int_t GetClusterSecondary(const UInt_t key) const;
a3b31967 74 Int_t GetSuccessPP(const UInt_t key) const;
75 Int_t GetSuccessTT(const UInt_t key) const;
76 Int_t GetSuccessS(const UInt_t key) const;
77 Int_t GetSuccessP(const UInt_t key) const;
78 Int_t GetFailureS(const UInt_t key) const;
79 Int_t GetFailureP(const UInt_t key) const;
80 Int_t GetRecons(const UInt_t key) const;
81 Int_t GetNonRecons(const UInt_t key) const;
275a301c 82 Int_t GetPredictionPrimary(const UInt_t mod, const UInt_t chip) const
83 {return GetPredictionPrimary(fPlaneEffSPD->GetKey(mod,chip));};
84 Int_t GetPredictionSecondary(const UInt_t mod, const UInt_t chip) const
85 {return GetPredictionSecondary(fPlaneEffSPD->GetKey(mod,chip));};
86 Int_t GetClusterPrimary(const UInt_t mod, const UInt_t chip) const
87 {return GetClusterPrimary(fPlaneEffSPD->GetKey(mod,chip));};
88 Int_t GetClusterSecondary(const UInt_t mod, const UInt_t chip) const
89 {return GetClusterSecondary(fPlaneEffSPD->GetKey(mod,chip));};
a3b31967 90 Int_t GetSuccessPP(const UInt_t mod, const UInt_t chip) const
91 {return GetSuccessPP(fPlaneEffSPD->GetKey(mod,chip));};
92 Int_t GetSuccessTT(const UInt_t mod, const UInt_t chip) const
93 {return GetSuccessTT(fPlaneEffSPD->GetKey(mod,chip));};
94 Int_t GetSuccessS(const UInt_t mod, const UInt_t chip) const
95 {return GetSuccessS(fPlaneEffSPD->GetKey(mod,chip));};
96 Int_t GetSuccessP(const UInt_t mod, const UInt_t chip) const
97 {return GetSuccessP(fPlaneEffSPD->GetKey(mod,chip));};
98 Int_t GetFailureS(const UInt_t mod, const UInt_t chip) const
99 {return GetFailureS(fPlaneEffSPD->GetKey(mod,chip));};
100 Int_t GetFailureP(const UInt_t mod, const UInt_t chip) const
101 {return GetFailureP(fPlaneEffSPD->GetKey(mod,chip));};
102 Int_t GetRecons(const UInt_t mod, const UInt_t chip) const
103 {return GetRecons(fPlaneEffSPD->GetKey(mod,chip));};
104 Int_t GetNonRecons(const UInt_t mod, const UInt_t chip) const
105 {return GetNonRecons(fPlaneEffSPD->GetKey(mod,chip));};
c6a05d92 106 // methods to write/reas cuts and MC statistics into/from file
107 // if filename contains ".root", then data are stored into histograms (->root file).
275a301c 108 void SavePredictionMC(TString filename="TrackletsMCpred.txt") const;
109 void ReadPredictionMC(TString filename="TrackletsMCpred.txt");
110 // Print some class info in ascii form to stream (cut values and MC statistics)
111 virtual void PrintAscii(ostream *os)const;
112 // Read some class info in ascii form from stream (cut values and MC statistics)
113 virtual void ReadAscii(istream *is);
114 Bool_t GetHistOn() const {return fHistOn;}; // return status of histograms
84161aec 115 // write histograms into a root file on disk
275a301c 116 Bool_t WriteHistosToFile(TString filename="TrackleterSPDHistos.root",Option_t* option = "RECREATE");
84161aec 117 // switch on/off the extra histograms
275a301c 118 void SetHistOn(Bool_t his=kTRUE) {AliITSMultReconstructor::SetHistOn(his);
119 if(GetHistOn()) {DeleteHistos(); BookHistos();} else DeleteHistos(); return;}
84161aec 122 AliITSTrackleterSPDEff(const AliITSTrackleterSPDEff& mr); // protected method: no copy allowed from outside
275a301c 123 AliITSTrackleterSPDEff& operator=(const AliITSTrackleterSPDEff& mr);
125 Bool_t* fAssociationFlag1; // flag for the associations (Layer 1)
126 UInt_t* fChipPredOnLay2; // prediction for the chip traversed by the tracklet
127 // based on vtx and ClusterLay1 (to be used in extrapolation)
128 UInt_t* fChipPredOnLay1; // prediction for the chip traversed by the tracklet
129 // based on vtx and ClusterLay2 (to be used in interpolation)
130 Int_t fNTracklets1; // Number of tracklets layer 1
a3b31967 131 // possible cuts :
275a301c 132 Float_t fPhiWindowL1; // Search window in phi (Layer 1)
133 Float_t fZetaWindowL1; // SEarch window in zeta (Layer 1)
134 Bool_t fOnlyOneTrackletPerC1; // only one tracklet per cluster in L. 1
a3b31967 135 Bool_t fUpdateOncePerEventPlaneEff; // If this is kTRUE, then you can update the chip efficiency only once
136 // per event in that chip. This to avoid double counting from the
137 // same tracklets which has two rec-points on one layer.
138 Bool_t* fChipUpdatedInEvent; // boolean (chip by chip) to flag which chip has been updated its efficiency
139 // in that event
275a301c 140 AliITSPlaneEffSPD* fPlaneEffSPD; // pointer to SPD plane efficiency class
0fce916f 141 Bool_t fReflectClusterAroundZAxisForLayer0; // if kTRUE, then a 180degree rotation around Z is applied to all
142 Bool_t fReflectClusterAroundZAxisForLayer1; // clusters on that layer (x->-x; y->-y)
275a301c 143 Bool_t fMC; // Boolean to access Kinematics (only for MC events )
144 Bool_t fUseOnlyPrimaryForPred; // Only for MC: if this is true, build tracklet prediction using only primary particles
145 Bool_t fUseOnlySecondaryForPred; // Only for MC: if this is true build tracklet prediction using only secondary particles
146 Bool_t fUseOnlySameParticle; // Only for MC: if this is true, assign a success only if clusters from same particles
147 // (i.e. PP or SS) otherwise ignore the combination
148 Bool_t fUseOnlyDifferentParticle; // Only for MC: if this is true, assign a success only if clusters from different particles
149 // (i.e. PP' or PS or SS') otherwise ignore the combination
150 Bool_t fUseOnlyStableParticle; // Only for MC: if this is kTRUE then method PrimaryTrackChecker return kTRUE only
151 // for particles decaying (eventually) after pixel layers
152 Int_t *fPredictionPrimary; // those for correction of bias from secondaries
153 Int_t *fPredictionSecondary; // chip_by_chip: number of Prediction built with primaries/secondaries
154 Int_t *fClusterPrimary; // number of clusters on a given chip fired by (at least) a primary
155 Int_t *fClusterSecondary; // number of clusters on a given chip fired by (only) secondaries
a3b31967 156 Int_t *fSuccessPP; // number of successes by using the same primary track (vs. chip of the success)
157 Int_t *fSuccessTT; // number of successes by using the same track (either a primary or a secondary) (vs. chip of the success)
158 Int_t *fSuccessS; // number of successes by using a secondary for the prediction (vs. chip of the success)
159 Int_t *fSuccessP; // number of successes by using a primary for the prediction (vs. chip of the success)
160 Int_t *fFailureS; // number of failures by using a secondary for the prediction (vs. chip of the failure)
161 Int_t *fFailureP; // number of failures by using a primary for the prediction (vs. chip of the failure)
162 Int_t *fRecons; // number of particle which can be reconstructed (only for MC from TrackRef)
163 Int_t *fNonRecons; // unmber of particle which cannot be reconstructed (only for MC from TrackRef)
275a301c 164 // extra histograms with respect to the base class AliITSMultReconstructor
165 TH1F* fhClustersDPhiInterpAcc; // Phi2 - Phi1 for tracklets (interpolation phase)
166 TH1F* fhClustersDThetaInterpAcc; // Theta2 - Theta1 for tracklets (interpolation phase)
167 TH1F* fhClustersDZetaInterpAcc; // z2 - z1projected for tracklets (interpolation phase)
168 TH1F* fhClustersDPhiInterpAll; // Phi2 - Phi1 all the combinations (interpolation phase)
169 TH1F* fhClustersDThetaInterpAll; // Theta2 - Theta1 all the combinations (interpolation phase)
170 TH1F* fhClustersDZetaInterpAll; // z2 - z1projected all the combinations (interpolation phase)
171 TH2F* fhDPhiVsDThetaInterpAll; // 2D plot for all the combinations
172 TH2F* fhDPhiVsDThetaInterpAcc; // same plot for tracklets
173 TH2F* fhDPhiVsDZetaInterpAll; // 2d plot for all the combination
174 TH2F* fhDPhiVsDZetaInterpAcc; // same plot for tracklets
175 TH1F* fhetaClustersLay2; // Pseudorapidity distr. for Clusters L. 2
176 TH1F* fhphiClustersLay2; // Azimuthal (Phi) distr. for Clusters L. 2
178 Double_t GetRLayer(Int_t layer); // return average radius of layer (0,1) from Geometry
179 Bool_t PrimaryTrackChecker(Int_t ipart,AliStack* stack=0x0); // check if a MC particle is primary (need AliStack)
180 Int_t DecayingTrackChecker(Int_t ipart,AliStack* stack=0x0); // For a primary particle, check if it is stable (see cxx)
a3b31967 181// check if a MC particle is reconstructable
182 Bool_t IsReconstructableAt(Int_t layer,Int_t iC,Int_t ipart,Float_t* vtx,AliStack* stack=0x0,TTree* ref=0x0);
c6a05d92 183 void InitPredictionMC(); // allocate memory for cuts and MC data memebers
184 void DeletePredictionMC(); // deallocate memory
275a301c 185 // method to locate a chip using current vtx and polar coordinate od tracklet w.r.t. to vtx (zVtx may not be given)
186 Bool_t FindChip(UInt_t &key, Int_t layer, Float_t* vtx, Float_t thetaVtx, Float_t phiVtx, Float_t zVtx=999.);
187 // method to transform from Global Cilindrical coordinate to local (module) Cartesian coordinate
188 Bool_t FromGloCilToLocCart(Int_t ilayer,Int_t idet, Double_t r, Double_t phi, Double_t z,
189 Float_t &xloc, Float_t &zloc);
190 // method to obtain the module (detector) index using global coordinates
191 Int_t FindDetectorIndex(Int_t layer, Double_t phi, Double_t z);
192 // this method gives you the intersections between a line and a circle (centred in the origin)
193 // using polar coordinates
194 Bool_t FindIntersectionPolar(Double_t vtx[2],Double_t phiVtx, Double_t R,Double_t &phi);
195 Bool_t SetAngleRange02Pi(Double_t &angle); // set the range of angle in [0,2pi[
196 Bool_t SetAngleRange02Pi(Float_t &angle)
197 {Double_t tmp=(Double_t)angle; Bool_t ret=SetAngleRange02Pi(tmp);angle=(Float_t)tmp;return ret;};
198 void CallWarningMC() const {if(!fMC) AliWarning("You can use this method only for MC! Call SetMC() first");}
199 Bool_t SaveHists();
200 void BookHistos(); // booking of extra histograms w.r.t. base class
201 void DeleteHistos(); //delete histos from memory
0fce916f 202 // Method to apply a rotation by 180degree to all RecPoints (x->-x; y->-y) on a given layer
203 void ReflectClusterAroundZAxisForLayer(Int_t ilayer); // to be used for backgnd estimation on real data
275a301c 204
0fce916f 205 ClassDef(AliITSTrackleterSPDEff,3)
275a301c 206};
207// Input and output function for standard C++ input/output (for the cut values and MC statistics).
208ostream &operator<<(ostream &os,const AliITSTrackleterSPDEff &s);
209istream &operator>>(istream &is, AliITSTrackleterSPDEff &s);