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&(1<<0);}
80 Bool_t TestFlag(UShort_t iflag) const {return (iflag<sizeof(UShort_t) ? fFlags&(1<<iflag) : kFALSE);}
81 Bool_t SetFlag(UShort_t iflag) {if (iflag>=sizeof(UShort_t)) return kFALSE; fFlags|=(1<<iflag); return kTRUE;}
82 Bool_t IsGammaLeg() const {return fFlags&(1<<1);}
83 Bool_t IsK0sLeg() const {return fFlags&(1<<2);}
84 Bool_t IsLambdaLeg() const {return fFlags&(1<<3);}
85 Bool_t IsALambdaLeg() const {return fFlags&(1<<4);}
86 Bool_t IsKink(Int_t i=0) const {return (i>=0 && i<3 ? fFlags&(1<<(5+i)) : kFALSE);}
87 Bool_t TestFlagMore(UShort_t iflag) const {return (iflag<sizeof(ULong_t) ? fMoreFlags&(1<<iflag) : kFALSE);}
88 Bool_t SetFlagMore(UShort_t iflag) {if(iflag>=sizeof(ULong_t)) return kFALSE; fMoreFlags|=(1<<iflag); return kTRUE;}
91 UShort_t fTrackId; // track id
92 ULong_t fStatus; // tracking status
93 Float_t fGlobalPhi; // phi at the vertex from global track, in the [0,2pi) interval
94 Float_t fGlobalPt; // pt*charge at the vertex from global track
95 Float_t fGlobalEta; // eta at the vertex from global track
96 Float_t fTPCPhi; // phi at the vertex from TPC alone tracking , in the [0,2pi) interval
97 Float_t fTPCPt; // pt at the vertex from TPC alone tracking
98 Float_t fTPCEta; // eta at the vertex from TPC alone tracking
99 Float_t fMomentumInner; // inner param momentum (only the magnitude)
100 Float_t fDCA[2]; // DCA xy,z
103 UChar_t fITSclusterMap; // ITS cluster map
104 Float_t fITSsignal; // ITS signal
105 Float_t fITSnSig[4]; // 0-electron; 1-pion; 2-kaon; 3-proton
108 UChar_t fTPCNcls; // TPC ncls
109 UChar_t fTPCCrossedRows; // TPC crossed rows
110 UChar_t fTPCNclsF; // TPC findable ncls
111 UChar_t fTPCNclsIter1; // TPC no clusters after first iteration
112 UChar_t fTPCClusterMap; // TPC cluster distribution map
113 Float_t fTPCsignal; // TPC de/dx
114 Float_t fTPCnSig[4]; // 0-electron; 1-pion; 2-kaon; 3-proton
117 Float_t fTOFbeta; // TOF pid info
118 Float_t fTOFnSig[4]; // TOF n-sigma deviation from expected signal
121 UChar_t fTRDntracklets[2]; // 0 - AliESDtrack::GetTRDntracklets(); 1 - AliESDtrack::GetTRDntrackletsPID() TODO: use only 1 char
122 Float_t fTRDpid[2]; // TRD electron probabilities, [0]- 1D likelihood, [1]- 2D likelihood
125 Int_t fCaloClusterId; // ID for the calorimeter cluster (if any)
128 Float_t fBayesPID[3]; // Combined Bayesian PID pi/K/p
130 UShort_t fFlags; // BIT0 toggled if track used for TPC event plane
131 // BIT1 toggled if track belongs to a gamma conversion
132 // BIT2 toggled if track belongs to a K0s
133 // BIT3 toggled if track belongs to a Lambda
134 // BIT4 toggled if track belongs to an Anti-Lambda
135 // BIT5 toggled if the track has kink0 index > 0
136 // BIT6 toggled if the track has kink1 index > 0
137 // BIT7 toggled if the track has kink2 index > 0
138 ULong_t fMoreFlags; // Space reserved for more information which might be needed later for analysis
140 AliReducedTrack(const AliReducedTrack &c);
141 AliReducedTrack& operator= (const AliReducedTrack &c);
143 ClassDef(AliReducedTrack, 3);
147 //_____________________________________________________________________
148 class AliReducedPair : public TObject {
150 friend class AliAnalysisTaskReducedTree; // friend analysis task which fills the object
164 AliReducedPair(const AliReducedPair &c);
168 Char_t CandidateId() const {return fCandidateId;}
169 Char_t PairType() const {return fPairType;}
170 Int_t LegId(Int_t leg) const {return (leg==0 || leg==1 ? fLegIds[leg] : -1);}
171 Float_t Mass(Int_t idx=0) const {return (idx>=0 && idx<4 ? fMass[idx] : -999.);}
172 Float_t Px() const {return fPt*TMath::Cos(fPhi);}
173 Float_t Py() const {return fPt*TMath::Sin(fPhi);}
174 Float_t Pz() const {return fPt*TMath::SinH(fEta);}
175 Float_t P() const {return fPt*TMath::CosH(fEta);}
176 Float_t Phi() const {return fPhi;}
177 Float_t Pt() const {return fPt;}
178 Float_t Eta() const {return fEta;}
179 Float_t Energy() const;
180 Float_t Rapidity() const;
181 Float_t Theta() const {return TMath::ACos(TMath::TanH(fEta));}
182 Float_t Lxy() const {return fLxy;}
183 Float_t LxyErr() const {return fLxyErr;}
184 Float_t PointingAngle() const {return fPointingAngle;}
185 Bool_t IsOnTheFly() const {return fPairType;}
186 UInt_t MCid() const {return fMCid;}
187 Bool_t CheckMC(const Int_t flag) const {return (flag<32 ? (fMCid&(1<<flag)) : kFALSE);}
190 Char_t fCandidateId; // candidate type (K0s, Lambda, J/psi, phi, etc)
191 Char_t fPairType; // 0 ++; 1 +-; 2 -- for dielectron pairs; 0- offline, 1- on the fly for V0 candidates
192 UShort_t fLegIds[2]; // leg ids
193 Float_t fMass[4]; // invariant mass for pairs (3 extra mass values for other V0 pid assumptions)
194 // idx=0 -> K0s assumption; idx=1 -> Lambda; idx=2 -> anti-Lambda; idx=3 -> gamma conversion
195 Float_t fPhi; // pair phi in the [0,2*pi) interval
196 Float_t fPt; // pair pt
197 Float_t fEta; // pair eta
198 Float_t fLxy; // pseudo-proper decay length
199 Float_t fLxyErr; // error on Lxy
200 Float_t fPointingAngle; // angle between the pair momentum vector and the secondary vertex position vector
201 UInt_t fMCid; // Bit map with Monte Carlo info about the pair
203 AliReducedPair& operator= (const AliReducedPair &c);
205 ClassDef(AliReducedPair, 2);
209 //_________________________________________________________________________
210 class AliReducedEventFriend : public TObject {
212 friend class AliAnalysisTaskReducedTree; // friend analysis task which fills the object
215 enum EventPlaneStatus {
222 enum EventPlaneDetector {
235 AliReducedEventFriend();
236 ~AliReducedEventFriend();
238 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.);}
239 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.);}
240 Double_t EventPlane(Int_t det, Int_t h) const;
241 UChar_t GetEventPlaneStatus(Int_t det, Int_t h) const {return (det>=0 && det<kNdetectors && h>0 && h<=fgkNMaxHarmonics ? fEventPlaneStatus[det][h] : 999);}
242 Bool_t CheckEventPlaneStatus(Int_t det, Int_t h, EventPlaneStatus flag) const;
243 void CopyEvent(const AliReducedEventFriend* event);
245 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;}
246 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;}
247 void SetEventPlaneStatus(Int_t det, Int_t harmonic, EventPlaneStatus status) {
248 if(det>=0 && det<kNdetectors && harmonic>0 && harmonic<=fgkNMaxHarmonics)
249 fEventPlaneStatus[det][harmonic-1] |= (1<<status);
253 // Q-vectors for the first 10 harmonics from TPC, VZERO, FMD and ZDC detectors
254 Double_t fQvector[kNdetectors][fgkNMaxHarmonics][2]; // Q vector components for all detectors and 6 harmonics
255 UChar_t fEventPlaneStatus[kNdetectors][fgkNMaxHarmonics]; // Bit maps for the event plane status (1 char per detector and per harmonic)
258 AliReducedEventFriend(const AliReducedEventFriend &c);
259 AliReducedEventFriend& operator= (const AliReducedEventFriend &c);
261 ClassDef(AliReducedEventFriend, 1);
265 //_________________________________________________________________________
266 class AliReducedCaloCluster : public TObject {
268 friend class AliAnalysisTaskReducedTree; // friend analysis task which fills the object
272 kUndefined=0, kEMCAL, kPHOS
275 AliReducedCaloCluster();
276 ~AliReducedCaloCluster();
278 Bool_t IsEMCAL() const {return (fType==kEMCAL ? kTRUE : kFALSE);}
279 Bool_t IsPHOS() const {return (fType==kPHOS ? kTRUE : kFALSE);}
280 Float_t Energy() const {return fEnergy;}
281 Float_t Dx() const {return fTrackDx;}
282 Float_t Dz() const {return fTrackDz;}
285 Char_t fType; // cluster type (EMCAL/PHOS)
286 Float_t fEnergy; // cluster energy
287 Float_t fTrackDx; // distance to closest track in phi
288 Float_t fTrackDz; // distance to closest track in z
290 AliReducedCaloCluster(const AliReducedCaloCluster &c);
291 AliReducedCaloCluster& operator= (const AliReducedCaloCluster &c);
293 ClassDef(AliReducedCaloCluster, 1);
297 //_________________________________________________________________________
298 class AliReducedEvent : public TObject {
300 friend class AliAnalysisTaskReducedTree; // friend analysis task which fills the object
304 AliReducedEvent(const Char_t* name);
308 Int_t RunNo() const {return fRunNo;}
309 UShort_t BC() const {return fBC;}
310 ULong64_t TriggerMask() const {return fTriggerMask;}
311 Bool_t IsPhysicsSelection() const {return fIsPhysicsSelection;}
312 Float_t Vertex(Int_t axis) const {return (axis>=0 && axis<=2 ? fVtx[axis] : 0);}
313 Int_t VertexNContributors() const {return fNVtxContributors;}
314 Float_t VertexTPC(Int_t axis) const {return (axis>=0 && axis<=2 ? fVtxTPC[axis] : 0);}
315 Int_t VertexTPCContributors() const {return fNVtxTPCContributors;}
316 Float_t CentralityVZERO() const {return fCentrality[0];}
317 Float_t CentralitySPD() const {return fCentrality[1];}
318 Float_t CentralityTPC() const {return fCentrality[2];}
319 Float_t CentralityZEMvsZDC() const {return fCentrality[3];}
320 Int_t CentralityQuality() const {return fCentQuality;}
321 Int_t NV0CandidatesTotal() const {return fNV0candidates[0];}
322 Int_t NV0Candidates() const {return fNV0candidates[1];}
323 Int_t NDielectrons() const {return fNDielectronCandidates;}
324 Int_t NTracksTotal() const {return fNtracks[0];}
325 Int_t NTracks() const {return fNtracks[1];}
326 Int_t SPDntracklets() const {return fSPDntracklets;}
328 Float_t MultChannelVZERO(Int_t channel) const {return (channel>=0 && channel<=63 ? fVZEROMult[channel] : -999.);}
329 Float_t MultVZEROA() const;
330 Float_t MultVZEROC() const;
331 Float_t MultVZERO() const;
332 Float_t MultRingVZEROA(Int_t ring) const;
333 Float_t MultRingVZEROC(Int_t ring) const;
335 Float_t EnergyZDC(Int_t channel) const {return (channel>=0 && channel<8 ? fZDCnEnergy[channel] : -999.);}
336 Float_t EnergyZDCnA(Int_t channel) const {return (channel>=0 && channel<4 ? fZDCnEnergy[channel+4] : -999.);}
337 Float_t EnergyZDCnC(Int_t channel) const {return (channel>=0 && channel<4 ? fZDCnEnergy[channel] : -999.);}
339 AliReducedTrack* GetTrack(Int_t i) const
340 {return (i<fNtracks[1] ? (AliReducedTrack*)fTracks->At(i) : 0x0);}
341 AliReducedPair* GetV0Pair(Int_t i) const
342 {return (i>=0 && i<fNV0candidates[1] ? (AliReducedPair*)fCandidates->At(i) : 0x0);}
343 AliReducedPair* GetDielectronPair(Int_t i) const
344 {return (i>=0 && i<fNDielectronCandidates ? (AliReducedPair*)fCandidates->At(i+fNV0candidates[1]) : 0x0);}
345 TClonesArray* GetPairs() const {return fCandidates;}
346 TClonesArray* GetTracks() const {return fTracks;}
348 Int_t GetNCaloClusters() const {return fNCaloClusters;}
349 AliReducedCaloCluster* GetCaloCluster(Int_t i) const
350 {return (i>=0 && i<fNCaloClusters ? (AliReducedCaloCluster*)fCaloClusters->At(i) : 0x0);}
352 void GetQvector(Double_t Qvec[][2], Int_t det, Float_t etaMin=-0.8, Float_t etaMax=+0.8, Bool_t (*IsTrackSelected)(AliReducedTrack*)=NULL);
353 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);
354 void GetVZEROQvector(Double_t Qvec[][2], Int_t det) ;
355 void GetVZEROQvector(Double_t Qvec[][2], Int_t det, Float_t* vzeroMult);
356 void GetZDCQvector(Double_t Qvec[][2], Int_t det) const;
357 void SubtractParticleFromQvector(AliReducedTrack* particle, Double_t Qvec[][2], Int_t det,
358 Float_t etaMin=-0.8, Float_t etaMax=+0.8,
359 Bool_t (*IsTrackSelected)(AliReducedTrack*)=NULL);
362 Int_t fRunNo; // run number
363 UShort_t fBC; // bunch crossing
364 ULong64_t fTriggerMask; // trigger mask
365 Bool_t fIsPhysicsSelection; // PhysicsSelection passed event
366 Float_t fVtx[3]; // global event vertex vector in cm
367 Int_t fNVtxContributors; // global event vertex contributors
368 Float_t fVtxTPC[3]; // TPC only event vertex
369 Int_t fNVtxTPCContributors; // TPC only event vertex contributors
370 Float_t fCentrality[4]; // centrality; 0-VZERO, 1-SPD, 2-TPC, 3-ZEMvsZDC
371 Int_t fCentQuality; // quality flag for the centrality
372 Int_t fNV0candidates[2]; // number of V0 candidates, [0]-total, [1]-selected for the tree
373 Int_t fNDielectronCandidates; // number of pairs selected as dielectrons
374 Int_t fNtracks[2]; // number of tracks, [0]-total, [1]-selected for the tree
375 Int_t fSPDntracklets; // number of SPD tracklets in |eta|<1.0
377 Float_t fVZEROMult[64]; // VZERO multiplicity in all 64 channels
378 Float_t fZDCnEnergy[8]; // neutron ZDC energy in all 8 channels
380 TClonesArray* fTracks; //-> array containing global tracks
381 static TClonesArray* fgTracks; // global tracks
383 TClonesArray* fCandidates; //-> array containing pair candidates
384 static TClonesArray* fgCandidates; // pair candidates
386 Int_t fNCaloClusters; // number of calorimeter clusters
387 TClonesArray* fCaloClusters; //-> array containing calorimeter clusters
388 static TClonesArray* fgCaloClusters; // calorimeter clusters
391 AliReducedEvent(const AliReducedEvent &c);
392 AliReducedEvent& operator= (const AliReducedEvent &c);
394 ClassDef(AliReducedEvent, 2);
397 //_______________________________________________________________________________
398 inline UShort_t AliReducedTrack::ITSncls() const
401 // ITS number of clusters from the cluster map
404 for(Int_t i=0; i<6; ++i) ncls += (ITSLayerHit(i) ? 1 : 0);
409 //_______________________________________________________________________________
410 inline Int_t AliReducedTrack::TPCClusterMapBitsFired() const
413 // Count the number of bits fired in the TPC cluster map
416 for(Int_t i=0; i<8; ++i) nbits += (TPCClusterMapBitFired(i) ? 1 : 0);
421 //_______________________________________________________________________________
422 inline Float_t AliReducedPair::Energy() const
427 Float_t mass=fMass[0];
428 switch (fCandidateId) {
446 return TMath::Sqrt(mass*mass+p*p);
450 //_______________________________________________________________________________
451 inline Float_t AliReducedPair::Rapidity() const
456 Float_t e = Energy();
458 if(e-TMath::Abs(pz)>1.0e-10)
459 return 0.5*TMath::Log((e+pz)/(e-pz));
465 //_______________________________________________________________________________
466 inline Double_t AliReducedEventFriend::EventPlane(Int_t det, Int_t harmonic) const
469 // Event plane from detector "det" and harmonic "harmonic"
471 if(det<0 || det>=kNdetectors || harmonic<1 || harmonic>fgkNMaxHarmonics) return -999.;
472 return TMath::ATan2(fQvector[det][harmonic-1][1], fQvector[det][harmonic-1][0])/Double_t(harmonic);
475 //_______________________________________________________________________________
476 inline Bool_t AliReducedEventFriend::CheckEventPlaneStatus(Int_t det, Int_t h, EventPlaneStatus flag) const {
478 // Check the status of the event plane for a given detector and harmonic
480 if(det<0 || det>=kNdetectors || h<1 || h>fgkNMaxHarmonics) return kFALSE;
481 return (flag<kNMaxFlowFlags ? (fEventPlaneStatus[det][h]&(1<<flag)) : kFALSE);