Update (Rossella)
[u/mrichter/AliRoot.git] / ITS / AliITSMultReconstructor.h
CommitLineData
ac903f1b 1#ifndef ALIITSMULTRECONSTRUCTOR_H
2#define ALIITSMULTRECONSTRUCTOR_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
fa9ed8e9 6//_________________________________________________________________________
ac903f1b 7//
fa9ed8e9 8// Implementation of the ITS-SPD trackleter class
ac903f1b 9//
fa9ed8e9 10// It retrieves clusters in the pixels (theta and phi) and finds tracklets.
11// These can be used to extract charged particle multiplicity from the ITS.
ac903f1b 12//
fa9ed8e9 13// A tracklet consists of two ITS clusters, one in the first pixel layer and
14// one in the second. The clusters are associated if the differences in
15// Phi (azimuth) and Theta (polar angle) are within fiducial windows.
16// In case of multiple candidates the candidate with minimum
17// distance is selected.
18//_________________________________________________________________________
1f9831ab 19#include "AliTrackleter.h"
f9f90134 20#include "AliITSsegmentationSPD.h"
21#include "TMath.h"
ac903f1b 22
1f9831ab 23class TBits;
ac903f1b 24class TTree;
25class TH1F;
3ef75756 26class TH2F;
1f9831ab 27class AliITSDetTypeRec;
ac903f1b 28class AliITSgeom;
1f9831ab 29class AliESDEvent;
30class AliESDtrack;
31class AliVertex;
6de485aa 32class AliESDVertex;
1f9831ab 33class AliMultiplicity;
f9f90134 34class AliRefArray;
9cb64105 35class AliITSRecPoint;
ac903f1b 36
1f9831ab 37class AliITSMultReconstructor : public AliTrackleter
ac903f1b 38{
39public:
1f9831ab 40 //
41 enum {kClTh,kClPh,kClZ,kClMC0,kClMC1,kClMC2,kClNPar};
42 enum {kTrTheta,kTrPhi,kTrDPhi,kTrDTheta,kTrLab1,kTrLab2,kClID1,kClID2,kTrNPar};
d7c5c1e4 43 enum {kSCTh,kSCPh,kSCLab,kSCID,kSCNPar};
1f9831ab 44 enum {kITSTPC,kITSSAP,kITSTPCBit=BIT(kITSTPC),kITSSAPBit=BIT(kITSSAP)}; // RS
ac903f1b 45 AliITSMultReconstructor();
ddced3c8 46 virtual ~AliITSMultReconstructor();
ac903f1b 47
1f9831ab 48 void Reconstruct(AliESDEvent* esd, TTree* treeRP);
f9f90134 49 void Reconstruct(TTree* tree, Float_t* vtx, Float_t* vtxRes=0); // old reconstructor invocation
b80c197e 50 void ReconstructMix(TTree* clusterTree, TTree* clusterTreeMix, const Float_t* vtx, Float_t* vtrRes=0);
1f9831ab 51 void FindTracklets(const Float_t* vtx);
9b373e9a 52 void LoadClusterFiredChips(TTree* tree);
7b116aa1 53 void FlagClustersInOverlapRegions(Int_t ic1,Int_t ic2);
34581d1e 54 void FlagTrackClusters(Int_t id);
6de485aa 55 void FlagIfSecondary(AliESDtrack* track, const AliVertex* vtx);
56 void FlagV0s(const AliESDVertex *vtx);
1f9831ab 57 void ProcessESDTracks();
6de485aa 58 Bool_t CanBeElectron(const AliESDtrack* trc) const;
1f9831ab 59
f9f90134 60 virtual void CreateMultiplicityObject();
1f9831ab 61 //
7b116aa1 62 // Following members are set via AliITSRecoParam
f9f90134 63 void SetPhiWindow(Float_t w=0.08) {fDPhiWindow=w; fDPhiWindow2 = w*w;}
64 void SetThetaWindow(Float_t w=0.025) {fDThetaWindow=w; fDThetaWindow2=w*w;}
fa9ed8e9 65 void SetPhiShift(Float_t w=0.0045) {fPhiShift=w;}
7b116aa1 66 void SetRemoveClustersFromOverlaps(Bool_t b = kFALSE) {fRemoveClustersFromOverlaps = b;}
67 void SetPhiOverlapCut(Float_t w=0.005) {fPhiOverlapCut=w;}
68 void SetZetaOverlapCut(Float_t w=0.05) {fZetaOverlapCut=w;}
7c6da836 69 void SetPhiRotationAngle(Float_t w=0.0) {fPhiRotationAngle=w;}
7b116aa1 70
f9f90134 71 Int_t GetNClustersLayer1() const {return fNClustersLay[0];}
72 Int_t GetNClustersLayer2() const {return fNClustersLay[1];}
73 Int_t GetNClustersLayer(Int_t i) const {return fNClustersLay[i];}
ac903f1b 74 Int_t GetNTracklets() const {return fNTracklets;}
968e8539 75 Int_t GetNSingleClusters() const {return fNSingleCluster;}
9b373e9a 76 Short_t GetNFiredChips(Int_t layer) const {return fNFiredChips[layer];}
ac903f1b 77
9cb64105 78 Float_t* GetClusterLayer1(Int_t n) const {return &fClustersLay[0][n*kClNPar];}
79 Float_t* GetClusterLayer2(Int_t n) const {return &fClustersLay[1][n*kClNPar];}
80 Float_t* GetClusterOfLayer(Int_t lr,Int_t n) const {return &fClustersLay[lr][n*kClNPar];}
81 Int_t GetClusterCopyIndex(Int_t lr,Int_t n) const {return fClusterCopyIndex[lr] ? fClusterCopyIndex[lr][n] : -1;}
82 AliITSRecPoint* GetRecPoint(Int_t lr, Int_t n) const;
f9f90134 83
9cb64105 84 Float_t* GetTracklet(Int_t n) const {return fTracklets[n];}
85 Float_t* GetCluster(Int_t n) const {return fSClusters[n];}
ac903f1b 86
f9f90134 87 void SetScaleDThetaBySin2T(Bool_t v=kTRUE) {fScaleDTBySin2T = v;}
88 Bool_t GetScaleDThetaBySin2T() const {return fScaleDTBySin2T;}
89 //
90 void SetNStdDev(Float_t f=1.) {fNStdDev = f<0.01 ? 0.01 : f; fNStdDevSq=TMath::Sqrt(fNStdDev);}
91 Float_t GetNStdDev() const {return fNStdDev;}
92 //
ac903f1b 93 void SetHistOn(Bool_t b=kFALSE) {fHistOn=b;}
94 void SaveHists();
e73fcfbb 95 //
96 void SetBuildRefs(Bool_t v=kTRUE) {fBuildRefs = v;}
97 Bool_t GetBuildRefs() const {return fBuildRefs;}
3ef75756 98
1f9831ab 99 AliITSDetTypeRec *GetDetTypeRec() const {return fDetTypeRec;}
100 void SetDetTypeRec(AliITSDetTypeRec *ptr){fDetTypeRec = ptr;}
6de485aa 101 //
102 void SetCutPxDrSPDin(Float_t v=0.1) { fCutPxDrSPDin = v;}
103 void SetCutPxDrSPDout(Float_t v=0.15) { fCutPxDrSPDout = v;}
104 void SetCutPxDz(Float_t v=0.2) { fCutPxDz = v;}
105 void SetCutDCArz(Float_t v=0.5) { fCutDCArz = v;}
106 void SetCutMinElectronProbTPC(Float_t v=0.5) { fCutMinElectronProbTPC = v;}
107 void SetCutMinElectronProbESD(Float_t v=0.1) { fCutMinElectronProbESD = v;}
108 void SetCutMinP(Float_t v=0.05) { fCutMinP = v;}
109 void SetCutMinRGamma(Float_t v=2.) { fCutMinRGamma = v;}
110 void SetCutMinRK0(Float_t v=1.) { fCutMinRK0 = v;}
111 void SetCutMinPointAngle(Float_t v=0.98) { fCutMinPointAngle = v;}
112 void SetCutMaxDCADauther(Float_t v=0.5) { fCutMaxDCADauther = v;}
113 void SetCutMassGamma(Float_t v=0.03) { fCutMassGamma = v;}
114 void SetCutMassGammaNSigma(Float_t v=5.) { fCutMassGammaNSigma = v;}
115 void SetCutMassK0(Float_t v=0.03) { fCutMassK0 = v;}
116 void SetCutMassK0NSigma(Float_t v=5.) { fCutMassK0NSigma = v;}
117 void SetCutChi2cGamma(Float_t v=2.) { fCutChi2cGamma = v;}
118 void SetCutChi2cK0(Float_t v=2.) { fCutChi2cK0 = v;}
119 void SetCutGammaSFromDecay(Float_t v=-10.) { fCutGammaSFromDecay = v;}
120 void SetCutK0SFromDecay(Float_t v=-10.) { fCutK0SFromDecay = v;}
121 void SetCutMaxDCA(Float_t v=1.) { fCutMaxDCA = v;}
122 //
123 Float_t GetCutPxDrSPDin() const {return fCutPxDrSPDin;}
124 Float_t GetCutPxDrSPDout() const {return fCutPxDrSPDout;}
125 Float_t GetCutPxDz() const {return fCutPxDz;}
126 Float_t GetCutDCArz() const {return fCutDCArz;}
127 Float_t GetCutMinElectronProbTPC() const {return fCutMinElectronProbTPC;}
128 Float_t GetCutMinElectronProbESD() const {return fCutMinElectronProbESD;}
129 Float_t GetCutMinP() const {return fCutMinP;}
130 Float_t GetCutMinRGamma() const {return fCutMinRGamma;}
131 Float_t GetCutMinRK0() const {return fCutMinRK0;}
132 Float_t GetCutMinPointAngle() const {return fCutMinPointAngle;}
133 Float_t GetCutMaxDCADauther() const {return fCutMaxDCADauther;}
134 Float_t GetCutMassGamma() const {return fCutMassGamma;}
135 Float_t GetCutMassGammaNSigma() const {return fCutMassGammaNSigma;}
136 Float_t GetCutMassK0() const {return fCutMassK0;}
137 Float_t GetCutMassK0NSigma() const {return fCutMassK0NSigma;}
138 Float_t GetCutChi2cGamma() const {return fCutChi2cGamma;}
139 Float_t GetCutChi2cK0() const {return fCutChi2cK0;}
140 Float_t GetCutGammaSFromDecay() const {return fCutGammaSFromDecay;}
141 Float_t GetCutK0SFromDecay() const {return fCutK0SFromDecay;}
142 Float_t GetCutMaxDCA() const {return fCutMaxDCA;}
143 //
f9f90134 144 void InitAux();
145 void ClusterPos2Angles(const Float_t *vtx);
b80c197e 146 void ClusterPos2Angles(Float_t *clPar, const Float_t *vtx) const;
f9f90134 147 Int_t AssociateClusterOfL1(Int_t iC1);
148 Int_t StoreTrackletForL2Cluster(Int_t iC2);
149 void StoreL1Singles();
150 TClonesArray* GetClustersOfLayer(Int_t il) const {return fClArr[il];}
151 void LoadClusters() {LoadClusterArrays(fTreeRP);}
152 void SetTreeRP(TTree* rp) {fTreeRP = rp;}
153 void SetTreeRPMix(TTree* rp=0) {fTreeRPMix = rp;}
154 Bool_t AreClustersLoaded() const {return fClustersLoaded;}
155 Bool_t GetCreateClustersCopy() const {return fCreateClustersCopy;}
156 Bool_t IsRecoDone() const {return fRecoDone;}
157 void SetCreateClustersCopy(Bool_t v=kTRUE) {fCreateClustersCopy=v;}
158 //
ce189d7c 159 // Float_t* GetClustersArray(Int_t lr) const {return (Float_t*) (lr==0) ? fClustersLay[0]:fClustersLay[1];}
160 Float_t* GetClustersArray(Int_t lr) const {if(lr==0){return fClustersLay[0];}
161 else {return fClustersLay[1];}}
f9f90134 162 Int_t* GetPartnersOfL2() const {return (Int_t*)fPartners;}
163 Float_t* GetMinDistsOfL2() const {return (Float_t*)fMinDists;}
164 Double_t GetDPhiShift() const {return fDPhiShift;}
165 Double_t GetDPhiWindow2() const {return fDPhiWindow2;}
166 Double_t GetDThetaWindow2() const {return fDThetaWindow2;}
167 Double_t CalcDist(Double_t dphi, Double_t dtheta, Double_t theta) const;
168 //
169 protected:
170 void SetClustersLoaded(Bool_t v=kTRUE) {fClustersLoaded = v;}
3ef75756 171 AliITSMultReconstructor(const AliITSMultReconstructor& mr);
7537d03c 172 AliITSMultReconstructor& operator=(const AliITSMultReconstructor& mr);
f9f90134 173 void CalcThetaPhi(float dx,float dy,float dz,float &theta,float &phi) const;
1f9831ab 174 AliITSDetTypeRec* fDetTypeRec; //! pointer to DetTypeRec
175 AliESDEvent* fESDEvent; //! pointer to ESD event
176 TTree* fTreeRP; //! ITS recpoints
f9f90134 177 TTree* fTreeRPMix; //! ITS recpoints for mixing
178 AliRefArray* fUsedClusLay[2][2]; //! RS: clusters usage in ESD tracks
179 //
180 Float_t* fClustersLay[2]; //! clusters in the SPD layers of ITS
181 Int_t* fDetectorIndexClustersLay[2]; //! module index for clusters in ITS layers
9cb64105 182 Int_t* fClusterCopyIndex[2]; //! when clusters copy is requested, store here the reference on the index
f9f90134 183 Bool_t* fOverlapFlagClustersLay[2]; //! flag for clusters in the overlap regions in ITS layers
ac903f1b 184
f9f90134 185 Float_t** fTracklets; //! tracklets
186 Float_t** fSClusters; //! single clusters (unassociated)
ac903f1b 187
f9f90134 188 Int_t fNClustersLay[2]; // Number of clusters on each layer
9b373e9a 189 Int_t fNTracklets; // Number of tracklets
190 Int_t fNSingleCluster; // Number of unassociated clusters
191 Short_t fNFiredChips[2]; // Number of fired chips in the two SPD layers
6de485aa 192 //
7b116aa1 193 // Following members are set via AliITSRecoParam
6de485aa 194 //
f9f90134 195 Float_t fDPhiWindow; // Search window in phi
196 Float_t fDThetaWindow; // Search window in theta
fa9ed8e9 197 Float_t fPhiShift; // Phi shift reference value (at 0.5 T)
7b116aa1 198 Bool_t fRemoveClustersFromOverlaps; // Option to skip clusters in the overlaps
199 Float_t fPhiOverlapCut; // Fiducial window in phi for overlap cut
200 Float_t fZetaOverlapCut; // Fiducial window in eta for overlap cut
7c6da836 201 Float_t fPhiRotationAngle; // Angle to rotate the inner layer cluster for combinatorial reco only
f9f90134 202 //
203 Bool_t fScaleDTBySin2T; // use in distance definition
204 Float_t fNStdDev; // number of standard deviations to keep
205 Float_t fNStdDevSq; // sqrt of number of standard deviations to keep
206 //
6de485aa 207 // cuts for secondaries identification
208 Float_t fCutPxDrSPDin; // max P*DR for primaries involving at least 1 SPD
209 Float_t fCutPxDrSPDout; // max P*DR for primaries not involving any SPD
210 Float_t fCutPxDz; // max P*DZ for primaries
211 Float_t fCutDCArz; // max DR or DZ for primares
212 //
213 // cuts for flagging tracks in V0s
214 Float_t fCutMinElectronProbTPC; // min probability for e+/e- PID involving TPC
215 Float_t fCutMinElectronProbESD; // min probability for e+/e- PID not involving TPC
216 //
217 Float_t fCutMinP; // min P of V0
218 Float_t fCutMinRGamma; // min transv. distance from ESDVertex to V0 for gammas
219 Float_t fCutMinRK0; // min transv. distance from ESDVertex to V0 for K0s
220 Float_t fCutMinPointAngle; // min pointing angle cosine
221 Float_t fCutMaxDCADauther; // max DCA of daughters at V0
222 Float_t fCutMassGamma; // max gamma mass
223 Float_t fCutMassGammaNSigma; // max standard deviations from 0 for gamma
224 Float_t fCutMassK0; // max K0 mass difference from PGD value
225 Float_t fCutMassK0NSigma; // max standard deviations for K0 mass from PDG value
226 Float_t fCutChi2cGamma; // max constrained chi2 cut for gammas
227 Float_t fCutChi2cK0; // max constrained chi2 cut for K0s
228 Float_t fCutGammaSFromDecay; // min path*P for gammas
229 Float_t fCutK0SFromDecay; // min path*P for K0s
230 Float_t fCutMaxDCA; // max DCA for V0 at ESD vertex
231
9b373e9a 232 Bool_t fHistOn; // Option to define and fill the histograms
ddced3c8 233
9b373e9a 234 TH1F* fhClustersDPhiAcc; // Phi2 - Phi1 for tracklets
235 TH1F* fhClustersDThetaAcc; // Theta2 - Theta1 for tracklets
9b373e9a 236 TH1F* fhClustersDPhiAll; // Phi2 - Phi1 all the combinations
237 TH1F* fhClustersDThetaAll; // Theta2 - Theta1 all the combinations
3ef75756 238
9b373e9a 239 TH2F* fhDPhiVsDThetaAll; // 2D plot for all the combinations
240 TH2F* fhDPhiVsDThetaAcc; // same plot for tracklets
9b373e9a 241
242 TH1F* fhetaTracklets; // Pseudorapidity distr. for tracklets
243 TH1F* fhphiTracklets; // Azimuthal (Phi) distr. for tracklets
244 TH1F* fhetaClustersLay1; // Pseudorapidity distr. for Clusters L. 1
245 TH1F* fhphiClustersLay1; // Azimuthal (Phi) distr. for Clusters L. 1
246
f9f90134 247 // temporary stuff for single event trackleting
248 Double_t fDPhiShift; // shift in dphi due to the curvature
249 Double_t fDPhiWindow2; // phi window^2
250 Double_t fDThetaWindow2; // theta window^2
251 Int_t* fPartners; //! L2 partners of L1
252 Int_t* fAssociatedLay1; //! association flag
253 Float_t* fMinDists; //! smallest distances for L2->L1
254 AliRefArray* fBlackList; //! blacklisted cluster references
255 Bool_t fStoreRefs[2][2]; //! which cluster to track refs to store
256 //
257 // this is for the analysis mode only
258 TClonesArray *fClArr[2]; //! original clusters
259 Bool_t fCreateClustersCopy; // read and clone clusters directly from the tree
260 Bool_t fClustersLoaded; // flag of clusters loaded
261 Bool_t fRecoDone; // flag that reconstruction is done
e73fcfbb 262 Bool_t fBuildRefs; // build cluster to tracks references
f9f90134 263 //
264 AliITSsegmentationSPD fSPDSeg; // SPD segmentation model
265 //
266 void LoadClusterArrays(TTree* tree, TTree* treeMix=0);
267 void LoadClusterArrays(TTree* tree,int il);
ac903f1b 268
e73fcfbb 269 ClassDef(AliITSMultReconstructor,11)
ac903f1b 270};
271
f9f90134 272//____________________________________________________________________
b80c197e 273inline void AliITSMultReconstructor::ClusterPos2Angles(Float_t *clPar, const Float_t *vtx) const
f9f90134 274{
275 // convert cluster coordinates to angles wrt vertex
276 Float_t x = clPar[kClTh] - vtx[0];
277 Float_t y = clPar[kClPh] - vtx[1];
278 Float_t z = clPar[kClZ] - vtx[2];
279 Float_t r = TMath::Sqrt(x*x + y*y + z*z);
280 clPar[kClTh] = TMath::ACos(z/r); // Store Theta
281 clPar[kClPh] = TMath::Pi() + TMath::ATan2(-y,-x); // Store Phi
282 //
283}
284
285//____________________________________________________________________
286inline Double_t AliITSMultReconstructor::CalcDist(Double_t dphi, Double_t dtheta, Double_t theta) const
287{
288 // calculate eliptical distance. theta is the angle of cl1, dtheta = tht(cl1)-tht(cl2)
289 dphi = TMath::Abs(dphi) - fDPhiShift;
290 if (fScaleDTBySin2T) {
291 double sinTI = TMath::Sin(theta-dtheta/2);
292 sinTI *= sinTI;
293 dtheta /= sinTI>1.e-6 ? sinTI : 1.e-6;
294 }
295 return dphi*dphi/fDPhiWindow2 + dtheta*dtheta/fDThetaWindow2;
296}
297
298//____________________________________________________________________
299inline void AliITSMultReconstructor::CalcThetaPhi(float x, float y,float z,float &theta,float &phi) const
300{
301 // get theta and phi in tracklet convention
302 theta = TMath::ACos(z/TMath::Sqrt(x*x + y*y + z*z));
303 phi = TMath::Pi() + TMath::ATan2(-y,-x);
304}
305
306
ac903f1b 307#endif