1 // Classes used for creating a reduced information tree
2 // Author: Ionut-Cristian Arsene (i.c.arsene@gsi.de)
5 // 1. Event wise information
6 // 2. List of tracks in the event
7 // 3. List of resonance candidates
9 #ifndef ALIREDUCEDEVENT_H
10 #define ALIREDUCEDEVENT_H
12 #include <TClonesArray.h>
17 const Int_t fgkNMaxHarmonics = 10;
19 //_____________________________________________________________________
20 class AliReducedTrack : public TObject {
22 friend class AliAnalysisTaskReducedTree; // friend analysis task which fills the object
29 UShort_t TrackId() const {return fTrackId;}
30 ULong_t Status() const {return fStatus;}
31 Bool_t CheckTrackStatus(UInt_t flag) const {return (flag<8*sizeof(ULong_t) ? (fStatus&(1<<flag)) : kFALSE);}
32 Int_t Charge() const {return (fGlobalPt>0.0 ? +1 : -1);}
33 Float_t Px() const {return TMath::Abs(fGlobalPt)*TMath::Cos(fGlobalPhi);}
34 Float_t Py() const {return TMath::Abs(fGlobalPt)*TMath::Sin(fGlobalPhi);}
35 Float_t Pz() const {return TMath::Abs(fGlobalPt)*TMath::SinH(fGlobalEta);}
36 Float_t P() const {return TMath::Abs(fGlobalPt)*TMath::CosH(fGlobalEta);};
37 Float_t Phi() const {return fGlobalPhi;}
38 Float_t Pt() const {return TMath::Abs(fGlobalPt);}
39 Float_t Eta() const {return fGlobalEta;}
40 Float_t Theta() const {return TMath::ACos(TMath::TanH(fGlobalEta));}
41 Float_t PxTPC() const {return fTPCPt*TMath::Cos(fTPCPhi);}
42 Float_t PyTPC() const {return fTPCPt*TMath::Sin(fTPCPhi);}
43 Float_t PzTPC() const {return fTPCPt*TMath::SinH(fTPCEta);}
44 Float_t PTPC() const {return fTPCPt*TMath::CosH(fTPCEta);};
45 Float_t PhiTPC() const {return fTPCPhi;}
46 Float_t PtTPC() const {return fTPCPt;}
47 Float_t EtaTPC() const {return fTPCEta;}
48 Float_t ThetaTPC() const {return TMath::ACos(TMath::TanH(fTPCEta));}
49 Float_t Pin() const {return fMomentumInner;}
50 Float_t DCAxy() const {return fDCA[0];}
51 Float_t DCAz() const {return fDCA[1];}
53 UShort_t ITSncls() const;
54 UChar_t ITSclusterMap() const {return fITSclusterMap;}
55 Bool_t ITSLayerHit(Int_t layer) const {return (layer>=0 && layer<6 ? (fITSclusterMap&(1<<layer)) : kFALSE);};
56 Float_t ITSsignal() const {return fITSsignal;}
57 Float_t ITSnSig(Int_t specie) const {return (specie>=0 && specie<=3 ? fITSnSig[specie] : -999.);}
59 UChar_t TPCncls() const {return fTPCNcls;}
60 UChar_t TPCFindableNcls() const {return fTPCNclsF;}
61 UChar_t TPCCrossedRows() const {return fTPCCrossedRows;}
62 UChar_t TPCnclsIter1() const {return fTPCNclsIter1;}
63 UChar_t TPCClusterMap() const {return fTPCClusterMap;}
64 Int_t TPCClusterMapBitsFired() const;
65 Bool_t TPCClusterMapBitFired(Int_t bit) const {return (bit>=0 && bit<8 ? (fTPCClusterMap&(1<<bit)) : kFALSE);};
66 Float_t TPCsignal() const {return fTPCsignal;}
67 Float_t TPCnSig(Int_t specie) const {return (specie>=0 && specie<=3 ? fTPCnSig[specie] : -999.);}
69 Float_t TOFbeta() const {return fTOFbeta;}
70 Float_t TOFnSig(Int_t specie) const {return (specie>=0 && specie<=3 ? fTOFnSig[specie] : -999.);}
72 Int_t TRDntracklets(Int_t type) const {return (type==0 || type==1 ? fTRDntracklets[type] : -1);}
73 Float_t TRDpid(Int_t specie) const {return (specie>=0 && specie<=1 ? fTRDpid[specie] : -999.);}
75 Int_t CaloClusterId() const {return fCaloClusterId;}
77 Float_t BayesPID(Int_t specie) const {return (specie>=0 && specie<=2 ? fBayesPID[specie] : -999.);}
79 Bool_t UsedForQvector() const {return fFlags&(UShort_t(1)<<0);}
80 Bool_t TestFlag(UShort_t iflag) const {return (iflag<8*sizeof(UShort_t) ? fFlags&(UShort_t(1)<<iflag) : kFALSE);}
81 Bool_t SetFlag(UShort_t iflag) {if (iflag>=8*sizeof(UShort_t)) return kFALSE; fFlags|=(UShort_t(1)<<iflag); return kTRUE;}
82 Bool_t IsGammaLeg() const {return fFlags&(UShort_t(1)<<1);}
83 Bool_t IsK0sLeg() const {return fFlags&(UShort_t(1)<<2);}
84 Bool_t IsLambdaLeg() const {return fFlags&(UShort_t(1)<<3);}
85 Bool_t IsALambdaLeg() const {return fFlags&(UShort_t(1)<<4);}
86 Bool_t IsKink(Int_t i=0) const {return (i>=0 && i<3 ? fFlags&(UShort_t(1)<<(5+i)) : kFALSE);}
87 Bool_t TestFlagMore(UShort_t iflag) const {return (iflag<8*sizeof(ULong_t) ? fMoreFlags&(ULong_t(1)<<iflag) : kFALSE);}
88 Bool_t SetFlagMore(UShort_t iflag) {if(iflag>=8*sizeof(ULong_t)) return kFALSE; fMoreFlags|=(ULong_t(1)<<iflag); return kTRUE;}
89 Bool_t UnsetFlagMore(UShort_t iflag) {if(iflag>=8*sizeof(ULong_t)) return kFALSE; fMoreFlags^=(ULong_t(1)<<iflag); return kTRUE;}
90 ULong_t GetFlagsMore() const {return fMoreFlags;}
93 UShort_t fTrackId; // track id
94 ULong_t fStatus; // tracking status
95 Float_t fGlobalPhi; // phi at the vertex from global track, in the [0,2pi) interval
96 Float_t fGlobalPt; // pt*charge at the vertex from global track
97 Float_t fGlobalEta; // eta at the vertex from global track
98 Float_t fTPCPhi; // phi at the vertex from TPC alone tracking , in the [0,2pi) interval
99 Float_t fTPCPt; // pt at the vertex from TPC alone tracking
100 Float_t fTPCEta; // eta at the vertex from TPC alone tracking
101 Float_t fMomentumInner; // inner param momentum (only the magnitude)
102 Float_t fDCA[2]; // DCA xy,z
105 UChar_t fITSclusterMap; // ITS cluster map
106 Float_t fITSsignal; // ITS signal
107 Float_t fITSnSig[4]; // 0-electron; 1-pion; 2-kaon; 3-proton
110 UChar_t fTPCNcls; // TPC ncls
111 UChar_t fTPCCrossedRows; // TPC crossed rows
112 UChar_t fTPCNclsF; // TPC findable ncls
113 UChar_t fTPCNclsIter1; // TPC no clusters after first iteration
114 UChar_t fTPCClusterMap; // TPC cluster distribution map
115 Float_t fTPCsignal; // TPC de/dx
116 Float_t fTPCnSig[4]; // 0-electron; 1-pion; 2-kaon; 3-proton
119 Float_t fTOFbeta; // TOF pid info
120 Float_t fTOFnSig[4]; // TOF n-sigma deviation from expected signal
123 UChar_t fTRDntracklets[2]; // 0 - AliESDtrack::GetTRDntracklets(); 1 - AliESDtrack::GetTRDntrackletsPID() TODO: use only 1 char
124 Float_t fTRDpid[2]; // TRD electron probabilities, [0]- 1D likelihood, [1]- 2D likelihood
127 Int_t fCaloClusterId; // ID for the calorimeter cluster (if any)
130 Float_t fBayesPID[3]; // Combined Bayesian PID pi/K/p
132 UShort_t fFlags; // BIT0 toggled if track used for TPC event plane
133 // BIT1 toggled if track belongs to a gamma conversion
134 // BIT2 toggled if track belongs to a K0s
135 // BIT3 toggled if track belongs to a Lambda
136 // BIT4 toggled if track belongs to an Anti-Lambda
137 // BIT5 toggled if the track has kink0 index > 0
138 // BIT6 toggled if the track has kink1 index > 0
139 // BIT7 toggled if the track has kink2 index > 0
140 ULong_t fMoreFlags; // Space reserved for more information which might be needed later for analysis
142 AliReducedTrack(const AliReducedTrack &c);
143 AliReducedTrack& operator= (const AliReducedTrack &c);
145 ClassDef(AliReducedTrack, 3);
149 //_____________________________________________________________________
150 class AliReducedPair : public TObject {
152 friend class AliAnalysisTaskReducedTree; // friend analysis task which fills the object
166 AliReducedPair(const AliReducedPair &c);
170 Char_t CandidateId() const {return fCandidateId;}
171 Char_t PairType() const {return fPairType;}
172 Int_t LegId(Int_t leg) const {return (leg==0 || leg==1 ? fLegIds[leg] : -1);}
173 Float_t Mass(Int_t idx=0) const {return (idx>=0 && idx<4 ? fMass[idx] : -999.);}
174 Float_t Px() const {return fPt*TMath::Cos(fPhi);}
175 Float_t Py() const {return fPt*TMath::Sin(fPhi);}
176 Float_t Pz() const {return fPt*TMath::SinH(fEta);}
177 Float_t P() const {return fPt*TMath::CosH(fEta);}
178 Float_t Phi() const {return fPhi;}
179 Float_t Pt() const {return fPt;}
180 Float_t Eta() const {return fEta;}
181 Float_t Energy() const;
182 Float_t Rapidity() const;
183 Float_t Theta() const {return TMath::ACos(TMath::TanH(fEta));}
184 Float_t Lxy() const {return fLxy;}
185 Float_t LxyErr() const {return fLxyErr;}
186 Float_t PointingAngle() const {return fPointingAngle;}
187 Bool_t IsOnTheFly() const {return fPairType;}
188 Bool_t IsPureV0K0s() const {return (fMCid&(UInt_t(1)<<1));}
189 Bool_t IsPureV0Lambda() const {return (fMCid&(UInt_t(1)<<2));}
190 Bool_t IsPureV0ALambda() const {return (fMCid&(UInt_t(1)<<3));}
191 Bool_t IsPureV0Gamma() const {return (fMCid&(UInt_t(1)<<4));}
192 UInt_t MCid() const {return fMCid;}
193 Bool_t CheckMC(const Int_t flag) const {return (flag<32 ? (fMCid&(1<<flag)) : kFALSE);}
196 Char_t fCandidateId; // candidate type (K0s, Lambda, J/psi, phi, etc)
197 Char_t fPairType; // 0 ++; 1 +-; 2 -- for dielectron pairs; 0- offline, 1- on the fly for V0 candidates
198 UShort_t fLegIds[2]; // leg ids
199 Float_t fMass[4]; // invariant mass for pairs (3 extra mass values for other V0 pid assumptions)
200 // idx=0 -> K0s assumption; idx=1 -> Lambda; idx=2 -> anti-Lambda; idx=3 -> gamma conversion
201 Float_t fPhi; // pair phi in the [0,2*pi) interval
202 Float_t fPt; // pair pt
203 Float_t fEta; // pair eta
204 Float_t fLxy; // pseudo-proper decay length
205 Float_t fLxyErr; // error on Lxy
206 Float_t fPointingAngle; // angle between the pair momentum vector and the secondary vertex position vector
207 UInt_t fMCid; // Bit map with Monte Carlo info about the pair
209 AliReducedPair& operator= (const AliReducedPair &c);
211 ClassDef(AliReducedPair, 2);
215 //_________________________________________________________________________
216 class AliReducedEventFriend : public TObject {
218 friend class AliAnalysisTaskReducedTree; // friend analysis task which fills the object
221 enum EventPlaneStatus {
228 enum EventPlaneDetector {
241 AliReducedEventFriend();
242 ~AliReducedEventFriend();
244 Double_t Qx(Int_t det, Int_t harmonic) const {return (det>=0 && det<kNdetectors && harmonic>0 && harmonic<=fgkNMaxHarmonics ? fQvector[det][harmonic-1][0] : -999.);}
245 Double_t Qy(Int_t det, Int_t harmonic) const {return (det>=0 && det<kNdetectors && harmonic>0 && harmonic<=fgkNMaxHarmonics ? fQvector[det][harmonic-1][1] : -999.);}
246 Double_t EventPlane(Int_t det, Int_t h) const;
247 UChar_t GetEventPlaneStatus(Int_t det, Int_t h) const {return (det>=0 && det<kNdetectors && h>0 && h<=fgkNMaxHarmonics ? fEventPlaneStatus[det][h] : 999);}
248 Bool_t CheckEventPlaneStatus(Int_t det, Int_t h, EventPlaneStatus flag) const;
249 void CopyEvent(const AliReducedEventFriend* event);
251 void SetQx(Int_t det, Int_t harmonic, Float_t qx) { if(det>=0 && det<kNdetectors && harmonic>0 && harmonic<=fgkNMaxHarmonics) fQvector[det][harmonic-1][0]=qx;}
252 void SetQy(Int_t det, Int_t harmonic, Float_t qy) { if(det>=0 && det<kNdetectors && harmonic>0 && harmonic<=fgkNMaxHarmonics) fQvector[det][harmonic-1][1]=qy;}
253 void SetEventPlaneStatus(Int_t det, Int_t harmonic, EventPlaneStatus status) {
254 if(det>=0 && det<kNdetectors && harmonic>0 && harmonic<=fgkNMaxHarmonics)
255 fEventPlaneStatus[det][harmonic-1] |= (1<<status);
259 // Q-vectors for the first 10 harmonics from TPC, VZERO, FMD and ZDC detectors
260 Double_t fQvector[kNdetectors][fgkNMaxHarmonics][2]; // Q vector components for all detectors and 6 harmonics
261 UChar_t fEventPlaneStatus[kNdetectors][fgkNMaxHarmonics]; // Bit maps for the event plane status (1 char per detector and per harmonic)
264 AliReducedEventFriend(const AliReducedEventFriend &c);
265 AliReducedEventFriend& operator= (const AliReducedEventFriend &c);
267 ClassDef(AliReducedEventFriend, 1);
271 //_________________________________________________________________________
272 class AliReducedCaloCluster : public TObject {
274 friend class AliAnalysisTaskReducedTree; // friend analysis task which fills the object
278 kUndefined=0, kEMCAL, kPHOS
281 AliReducedCaloCluster();
282 ~AliReducedCaloCluster();
284 Bool_t IsEMCAL() const {return (fType==kEMCAL ? kTRUE : kFALSE);}
285 Bool_t IsPHOS() const {return (fType==kPHOS ? kTRUE : kFALSE);}
286 Float_t Energy() const {return fEnergy;}
287 Float_t Dx() const {return fTrackDx;}
288 Float_t Dz() const {return fTrackDz;}
291 Char_t fType; // cluster type (EMCAL/PHOS)
292 Float_t fEnergy; // cluster energy
293 Float_t fTrackDx; // distance to closest track in phi
294 Float_t fTrackDz; // distance to closest track in z
295 Float_t fM20; // short axis
296 Float_t fM02; // long axis
297 Float_t fDispersion; // dispersion
299 AliReducedCaloCluster(const AliReducedCaloCluster &c);
300 AliReducedCaloCluster& operator= (const AliReducedCaloCluster &c);
302 ClassDef(AliReducedCaloCluster, 2);
306 //_________________________________________________________________________
307 class AliReducedEvent : public TObject {
309 friend class AliAnalysisTaskReducedTree; // friend analysis task which fills the object
313 AliReducedEvent(const Char_t* name);
317 Int_t RunNo() const {return fRunNo;}
318 UShort_t BC() const {return fBC;}
319 ULong64_t TriggerMask() const {return fTriggerMask;}
320 Bool_t IsPhysicsSelection() const {return fIsPhysicsSelection;}
321 Float_t Vertex(Int_t axis) const {return (axis>=0 && axis<=2 ? fVtx[axis] : 0);}
322 Int_t VertexNContributors() const {return fNVtxContributors;}
323 Float_t VertexTPC(Int_t axis) const {return (axis>=0 && axis<=2 ? fVtxTPC[axis] : 0);}
324 Int_t VertexTPCContributors() const {return fNVtxTPCContributors;}
325 Float_t CentralityVZERO() const {return fCentrality[0];}
326 Float_t CentralitySPD() const {return fCentrality[1];}
327 Float_t CentralityTPC() const {return fCentrality[2];}
328 Float_t CentralityZEMvsZDC() const {return fCentrality[3];}
329 Int_t CentralityQuality() const {return fCentQuality;}
330 Int_t NV0CandidatesTotal() const {return fNV0candidates[0];}
331 Int_t NV0Candidates() const {return fNV0candidates[1];}
332 Int_t NDielectrons() const {return fNDielectronCandidates;}
333 Int_t NTracksTotal() const {return fNtracks[0];}
334 Int_t NTracks() const {return fNtracks[1];}
335 Int_t SPDntracklets() const {return fSPDntracklets;}
337 Float_t MultChannelVZERO(Int_t channel) const {return (channel>=0 && channel<=63 ? fVZEROMult[channel] : -999.);}
338 Float_t MultVZEROA() const;
339 Float_t MultVZEROC() const;
340 Float_t MultVZERO() const;
341 Float_t MultRingVZEROA(Int_t ring) const;
342 Float_t MultRingVZEROC(Int_t ring) const;
344 Float_t EnergyZDC(Int_t channel) const {return (channel>=0 && channel<8 ? fZDCnEnergy[channel] : -999.);}
345 Float_t EnergyZDCnA(Int_t channel) const {return (channel>=0 && channel<4 ? fZDCnEnergy[channel+4] : -999.);}
346 Float_t EnergyZDCnC(Int_t channel) const {return (channel>=0 && channel<4 ? fZDCnEnergy[channel] : -999.);}
348 AliReducedTrack* GetTrack(Int_t i) const
349 {return (i<fNtracks[1] ? (AliReducedTrack*)fTracks->At(i) : 0x0);}
350 AliReducedPair* GetV0Pair(Int_t i) const
351 {return (i>=0 && i<fNV0candidates[1] ? (AliReducedPair*)fCandidates->At(i) : 0x0);}
352 AliReducedPair* GetDielectronPair(Int_t i) const
353 {return (i>=0 && i<fNDielectronCandidates ? (AliReducedPair*)fCandidates->At(i+fNV0candidates[1]) : 0x0);}
354 TClonesArray* GetPairs() const {return fCandidates;}
355 TClonesArray* GetTracks() const {return fTracks;}
357 Int_t GetNCaloClusters() const {return fNCaloClusters;}
358 AliReducedCaloCluster* GetCaloCluster(Int_t i) const
359 {return (i>=0 && i<fNCaloClusters ? (AliReducedCaloCluster*)fCaloClusters->At(i) : 0x0);}
361 void GetQvector(Double_t Qvec[][2], Int_t det, Float_t etaMin=-0.8, Float_t etaMax=+0.8, Bool_t (*IsTrackSelected)(AliReducedTrack*)=NULL);
362 Int_t GetTPCQvector(Double_t Qvec[][2], Int_t det, Float_t etaMin=-0.8, Float_t etaMax=+0.8, Bool_t (*IsTrackSelected)(AliReducedTrack*)=NULL);
363 void GetVZEROQvector(Double_t Qvec[][2], Int_t det) ;
364 void GetVZEROQvector(Double_t Qvec[][2], Int_t det, Float_t* vzeroMult);
365 void GetZDCQvector(Double_t Qvec[][2], Int_t det) const;
366 void SubtractParticleFromQvector(AliReducedTrack* particle, Double_t Qvec[][2], Int_t det,
367 Float_t etaMin=-0.8, Float_t etaMax=+0.8,
368 Bool_t (*IsTrackSelected)(AliReducedTrack*)=NULL);
371 Int_t fRunNo; // run number
372 UShort_t fBC; // bunch crossing
373 ULong64_t fTriggerMask; // trigger mask
374 Bool_t fIsPhysicsSelection; // PhysicsSelection passed event
375 Float_t fVtx[3]; // global event vertex vector in cm
376 Int_t fNVtxContributors; // global event vertex contributors
377 Float_t fVtxTPC[3]; // TPC only event vertex
378 Int_t fNVtxTPCContributors; // TPC only event vertex contributors
379 Float_t fCentrality[4]; // centrality; 0-VZERO, 1-SPD, 2-TPC, 3-ZEMvsZDC
380 Int_t fCentQuality; // quality flag for the centrality
381 Int_t fNV0candidates[2]; // number of V0 candidates, [0]-total, [1]-selected for the tree
382 Int_t fNDielectronCandidates; // number of pairs selected as dielectrons
383 Int_t fNtracks[2]; // number of tracks, [0]-total, [1]-selected for the tree
384 Int_t fSPDntracklets; // number of SPD tracklets in |eta|<1.0
386 Float_t fVZEROMult[64]; // VZERO multiplicity in all 64 channels
387 Float_t fZDCnEnergy[8]; // neutron ZDC energy in all 8 channels
389 TClonesArray* fTracks; //-> array containing global tracks
390 static TClonesArray* fgTracks; // global tracks
392 TClonesArray* fCandidates; //-> array containing pair candidates
393 static TClonesArray* fgCandidates; // pair candidates
395 Int_t fNCaloClusters; // number of calorimeter clusters
396 TClonesArray* fCaloClusters; //-> array containing calorimeter clusters
397 static TClonesArray* fgCaloClusters; // calorimeter clusters
400 AliReducedEvent(const AliReducedEvent &c);
401 AliReducedEvent& operator= (const AliReducedEvent &c);
403 ClassDef(AliReducedEvent, 2);
406 //_______________________________________________________________________________
407 inline UShort_t AliReducedTrack::ITSncls() const
410 // ITS number of clusters from the cluster map
413 for(Int_t i=0; i<6; ++i) ncls += (ITSLayerHit(i) ? 1 : 0);
418 //_______________________________________________________________________________
419 inline Int_t AliReducedTrack::TPCClusterMapBitsFired() const
422 // Count the number of bits fired in the TPC cluster map
425 for(Int_t i=0; i<8; ++i) nbits += (TPCClusterMapBitFired(i) ? 1 : 0);
430 //_______________________________________________________________________________
431 inline Float_t AliReducedPair::Energy() const
436 Float_t mass=fMass[0];
437 switch (fCandidateId) {
455 return TMath::Sqrt(mass*mass+p*p);
459 //_______________________________________________________________________________
460 inline Float_t AliReducedPair::Rapidity() const
465 Float_t e = Energy();
467 if(e-TMath::Abs(pz)>1.0e-10)
468 return 0.5*TMath::Log((e+pz)/(e-pz));
474 //_______________________________________________________________________________
475 inline Double_t AliReducedEventFriend::EventPlane(Int_t det, Int_t harmonic) const
478 // Event plane from detector "det" and harmonic "harmonic"
480 if(det<0 || det>=kNdetectors || harmonic<1 || harmonic>fgkNMaxHarmonics) return -999.;
481 return TMath::ATan2(fQvector[det][harmonic-1][1], fQvector[det][harmonic-1][0])/Double_t(harmonic);
484 //_______________________________________________________________________________
485 inline Bool_t AliReducedEventFriend::CheckEventPlaneStatus(Int_t det, Int_t h, EventPlaneStatus flag) const {
487 // Check the status of the event plane for a given detector and harmonic
489 if(det<0 || det>=kNdetectors || h<1 || h>fgkNMaxHarmonics) return kFALSE;
490 return (flag<kNMaxFlowFlags ? (fEventPlaneStatus[det][h]&(1<<flag)) : kFALSE);