bug #93685: changes in AliAODTrack/ALiAODEvent - commit to trunk
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODEvent.h
CommitLineData
df9db588 1#ifndef AliAODEvent_H
2#define AliAODEvent_H
3/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/* $Id$ */
7
8//-------------------------------------------------------------------------
9// AOD base class
10// Author: Markus Oldenburg, CERN
11//-------------------------------------------------------------------------
12
13#include <TBuffer.h>
14#include <TClonesArray.h>
15#include <TList.h>
8ff33247 16#include <TTree.h>
df9db588 17#include <TNamed.h>
18
08e4c457 19#include "AliVEvent.h"
20#include "AliVParticle.h"
df9db588 21#include "AliAODHeader.h"
22#include "AliAODTrack.h"
23#include "AliAODVertex.h"
3dd9f9e3 24#include "AliAODv0.h"
9a244178 25#include "AliAODcascade.h"
821f8f1d 26#include "AliAODTracklets.h"
3dd9f9e3 27#include "AliAODJet.h"
28#include "AliAODCaloCells.h"
29#include "AliAODCaloCluster.h"
720f7306 30#include "AliAODCaloTrigger.h"
3dd9f9e3 31#include "AliAODPmdCluster.h"
32#include "AliAODFmdCluster.h"
866d8d78 33#include "AliAODDimuon.h"
a1f96974 34#include "AliAODTZERO.h"
ae2bccf1 35#include "AliAODVZERO.h"
16d867eb 36#include "AliAODZDC.h"
820b4d9e 37#ifdef MFT_UPGRADE
38#include "AliAODMFT.h"
39#endif
df9db588 40
8ff33247 41class TTree;
5c1dc41f 42class TFolder;
befa9db4 43class AliCentrality;
ce7adfe9 44class AliEventplane;
ec4af4c1 45
08e4c457 46class AliAODEvent : public AliVEvent {
df9db588 47
48 public :
08e4c457 49 enum AODListIndex_t {kAODHeader,
50 kAODTracks,
51 kAODVertices,
3dd9f9e3 52 kAODv0,
9a244178 53 kAODcascade,
08e4c457 54 kAODTracklets,
3dd9f9e3 55 kAODJets,
37792174 56 kAODEmcalCells,
57 kAODPhosCells,
3dd9f9e3 58 kAODCaloClusters,
720f7306 59 kAODEMCALTrigger,
60 kAODPHOSTrigger,
3dd9f9e3 61 kAODFmdClusters,
62 kAODPmdClusters,
866d8d78 63 kAODDimuons,
a1f96974 64 kAODTZERO,
ae2bccf1 65 kAODVZERO,
16d867eb 66 kAODZDC,
68919bd9 67 kTOFHeader,
08e4c457 68 kAODListN
820b4d9e 69 #ifdef MFT_UPGRADE
70 ,kAODVZERO
71 #endif
08e4c457 72 };
73
df9db588 74 AliAODEvent();
75 virtual ~AliAODEvent();
76
9a244178 77 AliAODEvent(const AliAODEvent& aodevent);
78 AliAODEvent& operator=(const AliAODEvent& aodevent);
df9db588 79
80 void AddObject(TObject *obj);
4b3de353 81 void RemoveObject(TObject *obj);
2811495d 82 TObject *FindListObject(const char *objName) const;
df9db588 83 TList *GetList() const { return fAODObjects; }
788578f5 84 void SetConnected(Bool_t conn=kTRUE) {fConnected=conn;}
85 Bool_t GetConnected() const {return fConnected;}
df9db588 86
87 // -- Header
08e4c457 88 AliAODHeader *GetHeader() const { return fHeader; }
df9db588 89 void AddHeader(const AliAODHeader* hdx)
635db10f 90 {
91 delete fHeader; fHeader = new AliAODHeader(*hdx);
92 (fAODObjects->FirstLink())->SetObject(fHeader);
93 }
df9db588 94
08e4c457 95 // setters and getters for header information
96 void SetRunNumber(Int_t n) {if (fHeader) fHeader->SetRunNumber(n);}
97 void SetPeriodNumber(UInt_t n){if (fHeader) fHeader->SetPeriodNumber(n);}
98 void SetOrbitNumber(UInt_t n) {if (fHeader) fHeader->SetOrbitNumber(n);}
99 void SetBunchCrossNumber(UShort_t n) {if (fHeader) fHeader->SetBunchCrossNumber(n);}
100 void SetMagneticField(Double_t mf){if (fHeader) fHeader->SetMagneticField(mf);}
33fe5eb1 101 void SetMuonMagFieldScale(Double_t mf){if (fHeader) fHeader->SetMuonMagFieldScale(mf);}
3bfd99da 102 void SetDiamond(Float_t xy[2],Float_t cov[3]){if (fHeader) fHeader->SetDiamond(xy,cov);}
a98c78e5 103 void SetDiamondZ(Float_t z, Float_t sig2z){if (fHeader) fHeader->SetDiamondZ(z,sig2z);}
08e4c457 104 Int_t GetRunNumber() const {return fHeader ? fHeader->GetRunNumber() : -999;}
105 UInt_t GetPeriodNumber() const {return fHeader ? fHeader->GetPeriodNumber() : 0;}
106 UInt_t GetOrbitNumber() const {return fHeader ? fHeader->GetOrbitNumber() : 0;}
107 UShort_t GetBunchCrossNumber() const {return fHeader ? fHeader->GetBunchCrossNumber() : 0;}
108 Double_t GetMagneticField() const {return fHeader ? fHeader->GetMagneticField() : -999.;}
33fe5eb1 109 Double_t GetMuonMagFieldScale() const {return fHeader ? fHeader->GetMuonMagFieldScale() : -999.;}
3bfd99da 110 Double_t GetDiamondX() const {return fHeader ? fHeader->GetDiamondX() : -999.;}
111 Double_t GetDiamondY() const {return fHeader ? fHeader->GetDiamondY() : -999.;}
a98c78e5 112 Double_t GetDiamondZ() const {return fHeader ? fHeader->GetDiamondZ() : -999.;}
3bfd99da 113 void GetDiamondCovXY(Float_t cov[3]) const {cov[0]=-999.; if(fHeader) fHeader->GetDiamondCovXY(cov);}
a98c78e5 114 Double_t GetSigma2DiamondX() const {return fHeader ? fHeader->GetSigma2DiamondX() : -999.;}
115 Double_t GetSigma2DiamondY() const {return fHeader ? fHeader->GetSigma2DiamondY() : -999.;}
116 Double_t GetSigma2DiamondZ() const {return fHeader ? fHeader->GetSigma2DiamondZ() : -999.;}
08e4c457 117
118 void SetEventType(UInt_t eventType){fHeader->SetEventType(eventType);}
119 void SetTriggerMask(ULong64_t n) {fHeader->SetTriggerMask(n);}
120 void SetTriggerCluster(UChar_t n) {fHeader->SetTriggerCluster(n);}
121
27346f69 122 UInt_t GetEventType() const { return fHeader ? fHeader->GetEventType() : 0;}
123 ULong64_t GetTriggerMask() const { return fHeader ? fHeader->GetTriggerMask() : 0;}
124 UChar_t GetTriggerCluster() const { return fHeader ? fHeader->GetTriggerCluster() : 0;}
125 TString GetFiredTriggerClasses()const { return fHeader->GetFiredTriggerClasses();};
08e4c457 126 Double_t GetZDCN1Energy() const { return fHeader ? fHeader->GetZDCN1Energy() : -999.; }
127 Double_t GetZDCP1Energy() const { return fHeader ? fHeader->GetZDCP1Energy() : -999.; }
128 Double_t GetZDCN2Energy() const { return fHeader ? fHeader->GetZDCN2Energy() : -999.; }
129 Double_t GetZDCP2Energy() const { return fHeader ? fHeader->GetZDCP2Energy() : -999.; }
a85132e7 130 Double_t GetZDCEMEnergy(Int_t i) const { return fHeader ? fHeader->GetZDCEMEnergy(i) : -999.; }
08e4c457 131
68919bd9 132 void SetTOFHeader(const AliTOFHeader * tofEventTime);
133 const AliTOFHeader *GetTOFHeader() const {return fTOFHeader;}
134 Float_t GetEventTimeSpread() const {if (fTOFHeader) return fTOFHeader->GetT0spread(); else return 0.;}
135 Float_t GetTOFTimeResolution() const {if (fTOFHeader) return fTOFHeader->GetTOFResolution(); else return 0.;}
136
137
df9db588 138 // -- Tracks
139 TClonesArray *GetTracks() const { return fTracks; }
5d691d96 140 Int_t GetNTracks() const { return fTracks? fTracks->GetEntriesFast() : 0; }
08e4c457 141 Int_t GetNumberOfTracks() const { return GetNTracks(); }
aab77ed0 142 AliAODTrack *GetTrack(Int_t nTrack) const { if(fTracks && fTracks->UncheckedAt(nTrack)) ((AliAODTrack*)fTracks->UncheckedAt(nTrack))->SetAODEvent(this);return fTracks ? (AliAODTrack*)fTracks->UncheckedAt(nTrack):0; }
08e4c457 143 Int_t AddTrack(const AliAODTrack* trk)
144 {new((*fTracks)[fTracks->GetEntriesFast()]) AliAODTrack(*trk); return fTracks->GetEntriesFast()-1;}
fb41236c 145 Int_t GetMuonTracks(TRefArray *muonTracks) const;
fa8b0e56 146 Int_t GetNumberOfMuonTracks() const;
df9db588 147
148 // -- Vertex
149 TClonesArray *GetVertices() const { return fVertices; }
5d691d96 150 Int_t GetNumberOfVertices() const { return fVertices?fVertices->GetEntriesFast():0; }
151 AliAODVertex *GetVertex(Int_t nVertex) const { return fVertices?(AliAODVertex*)fVertices->At(nVertex):0; }
08e4c457 152 Int_t AddVertex(const AliAODVertex* vtx)
153 {new((*fVertices)[fVertices->GetEntriesFast()]) AliAODVertex(*vtx); return fVertices->GetEntriesFast()-1;}
5c2fdfa2 154
3dd9f9e3 155 // primary vertex
156 virtual AliAODVertex *GetPrimaryVertex() const { return GetVertex(0); }
a98c78e5 157 virtual AliAODVertex *GetPrimaryVertexSPD() const;
158
159 // -- Pileup vertices
160 Int_t GetNumberOfPileupVerticesTracks() const;
161 Int_t GetNumberOfPileupVerticesSPD() const;
162 virtual AliAODVertex *GetPileupVertexSPD(Int_t iV=0) const;
163 virtual AliAODVertex *GetPileupVertexTracks(Int_t iV=0) const;
164 virtual Bool_t IsPileupFromSPD(Int_t minContributors=3, Double_t minZdist=0.8, Double_t nSigmaZdist=3., Double_t nSigmaDiamXY=2., Double_t nSigmaDiamZ=5.) const;
b46ff4b0 165 virtual Bool_t IsPileupFromSPDInMultBins() const;
a98c78e5 166
df9db588 167
3dd9f9e3 168 // V0
169 TClonesArray *GetV0s() const { return fV0s; }
c1b93f02 170 Int_t GetNumberOfV0s() const { return fV0s->GetEntriesFast(); }
3dd9f9e3 171 AliAODv0 *GetV0(Int_t nV0) const { return (AliAODv0*)fV0s->UncheckedAt(nV0); }
172 Int_t AddV0(const AliAODv0* v0)
173 {new((*fV0s)[fV0s->GetEntriesFast()]) AliAODv0(*v0); return fV0s->GetEntriesFast()-1;}
174
9a244178 175 // Cascades
176 TClonesArray *GetCascades() const { return fCascades; }
177 Int_t GetNumberOfCascades() const { return fCascades->GetEntriesFast(); }
178 AliAODcascade *GetCascade(Int_t nCasc) const { return (AliAODcascade*)fCascades->UncheckedAt(nCasc); }
179 Int_t AddCascade(const AliAODcascade* cascade)
180 {new((*fCascades)[fCascades->GetEntriesFast()]) AliAODcascade(*cascade); return fCascades->GetEntriesFast()-1;}
181
3dd9f9e3 182 // -- EMCAL and PHOS Cluster
c8fe2783 183 TClonesArray *GetCaloClusters() const { return fCaloClusters; }
184 Int_t GetNumberOfCaloClusters() const { return fCaloClusters->GetEntriesFast(); }
3dd9f9e3 185 AliAODCaloCluster *GetCaloCluster(Int_t nCluster) const { return (AliAODCaloCluster*)fCaloClusters->UncheckedAt(nCluster); }
186 Int_t AddCaloCluster(const AliAODCaloCluster* clus)
187 {new((*fCaloClusters)[fCaloClusters->GetEntriesFast()]) AliAODCaloCluster(*clus); return fCaloClusters->GetEntriesFast()-1;}
720f7306 188 AliAODCaloTrigger *GetCaloTrigger(TString calo) const
189 {
190 if (calo.Contains("EMCAL")) return fEMCALTrigger;
191 else
192 return fPHOSTrigger;
193 }
194
78902954 195 Int_t GetEMCALClusters(TRefArray *clusters) const;
196 Int_t GetPHOSClusters(TRefArray *clusters) const;
197
198
3dd9f9e3 199 // -- FMD Cluster
200 TClonesArray *GetFmdClusters() const { return fFmdClusters; }
201 Int_t GetNFmdClusters() const { return fFmdClusters->GetEntriesFast(); }
202 AliAODFmdCluster *GetFmdCluster(Int_t nCluster) const { return (AliAODFmdCluster*)fFmdClusters->UncheckedAt(nCluster); }
203 Int_t AddFmdCluster(const AliAODFmdCluster* clus)
204 {new((*fFmdClusters)[fFmdClusters->GetEntriesFast()]) AliAODFmdCluster(*clus); return fFmdClusters->GetEntriesFast()-1;}
205
206 // -- PMD Cluster
207 TClonesArray *GetPmdClusters() const { return fPmdClusters; }
208 Int_t GetNPmdClusters() const { return fPmdClusters->GetEntriesFast(); }
209 AliAODPmdCluster *GetPmdCluster(Int_t nCluster) const { return (AliAODPmdCluster*)fPmdClusters->UncheckedAt(nCluster); }
210 Int_t AddPmdCluster(const AliAODPmdCluster* clus)
211 {new((*fPmdClusters)[fPmdClusters->GetEntriesFast()]) AliAODPmdCluster(*clus); return fPmdClusters->GetEntriesFast()-1;}
df9db588 212
213 // -- Jet
214 TClonesArray *GetJets() const { return fJets; }
5d691d96 215 Int_t GetNJets() const { return fJets?fJets->GetEntriesFast():0; }
216 AliAODJet *GetJet(Int_t nJet) const { return fJets?(AliAODJet*)fJets->UncheckedAt(nJet):0; }
08e4c457 217 Int_t AddJet(const AliAODJet* vtx)
218 {new((*fJets)[fJets->GetEntriesFast()]) AliAODJet(*vtx); return fJets->GetEntriesFast()-1;}
df9db588 219
821f8f1d 220 // -- Tracklets
221 AliAODTracklets *GetTracklets() const { return fTracklets; }
222
3dd9f9e3 223 // -- Calorimeter Cells
e649177a 224 AliAODCaloCells *GetEMCALCells() const { return fEmcalCells; }
225 AliAODCaloCells *GetPHOSCells() const { return fPhosCells; }
c8fe2783 226 const TGeoHMatrix* GetPHOSMatrix(Int_t /*i*/) const { return NULL; }
227 const TGeoHMatrix* GetEMCALMatrix(Int_t /*i*/)const { return NULL; }
228
3dd9f9e3 229
866d8d78 230 // -- Dimuons
231 TClonesArray *GetDimuons() const { return fDimuons; }
232 Int_t GetNDimuons() const { return fDimuons->GetEntriesFast(); }
233 Int_t GetNumberOfDimuons() const { return GetNDimuons(); }
234 AliAODDimuon *GetDimuon(Int_t nDimu) const { return (AliAODDimuon*)fDimuons->UncheckedAt(nDimu); }
235 Int_t AddDimuon(const AliAODDimuon* dimu)
236 {new((*fDimuons)[fDimuons->GetEntriesFast()]) AliAODDimuon(*dimu); return fDimuons->GetEntriesFast()-1;}
237
df9db588 238 // -- Services
ec4af4c1 239 void CreateStdContent();
08e4c457 240 void SetStdNames();
ec4af4c1 241 void GetStdContent();
5c1dc41f 242 void CreateStdFolders();
3dd9f9e3 243 void ResetStd(Int_t trkArrSize = 0,
244 Int_t vtxArrSize = 0,
245 Int_t v0ArrSize = 0,
9a244178 246 Int_t cascadeArrSize = 0,
3dd9f9e3 247 Int_t jetSize = 0,
248 Int_t caloClusSize = 0,
249 Int_t fmdClusSize = 0,
866d8d78 250 Int_t pmdClusSize = 0,
251 Int_t dimuonArrsize =0
9a244178 252 );
ec4af4c1 253 void ClearStd();
ec8aded8 254 void Reset() {ClearStd();}
3b93c32a 255 void ReadFromTree(TTree *tree, Option_t* opt = "");
f12d42ce 256 void WriteToTree(TTree* tree) const {tree->Branch(fAODObjects);}
08e4c457 257
258 void Print(Option_t *option="") const;
c8e4f399 259 void MakeEntriesReferencable();
5e6a3170 260 static void AssignIDtoCollection(const TCollection* col);
c8fe2783 261
262 //Following needed only for mixed event
263 virtual Int_t EventIndex(Int_t) const {return 0;}
264 virtual Int_t EventIndexForCaloCluster(Int_t) const {return 0;}
265 virtual Int_t EventIndexForPHOSCell(Int_t) const {return 0;}
266 virtual Int_t EventIndexForEMCALCell(Int_t) const {return 0;}
befa9db4 267 AliCentrality* GetCentrality() {return fHeader->GetCentralityP();}
ce7adfe9 268 AliEventplane* GetEventplane() {return fHeader->GetEventplaneP();}
ae2bccf1 269
a1f96974 270 // TZERO
271 AliAODTZERO *GetTZEROData() const { return fAODTZERO; }
272
ae2bccf1 273 // VZERO
274 AliAODVZERO *GetVZEROData() const { return fAODVZERO; }
5e14e698 275 virtual const Float_t* GetVZEROEqFactors() const {return fHeader?fHeader->GetVZEROEqFactors():0x0;}
276 virtual Float_t GetVZEROEqMultiplicity(Int_t i) const;
cc4d0e9c 277 virtual void SetVZEROEqFactors(Float_t factors[64]) const {
278 SetVZEROEqFactors(&factors[0]);}
5e14e698 279 void SetVZEROEqFactors(const Float_t *factors) const {
280 if(fHeader && factors)
281 fHeader->SetVZEROEqFactors(factors);}
ae2bccf1 282
16d867eb 283 //ZDC
284 AliAODZDC *GetZDCData() const { return fAODZDC; }
285
820b4d9e 286#ifdef MFT_UPGRADE
287 // MFT
288 AliAODMFT *GetMFTData() const { return fAODMFT; }
289#endif
290
c8fe2783 291 private :
df9db588 292
5c1dc41f 293 TList *fAODObjects; // list of AODObjects
294 TFolder *fAODFolder; // folder structure of branches
dd389a30 295 Bool_t fConnected; //! flag if leaves are alreday connected
df9db588 296 // standard content
3dd9f9e3 297 AliAODHeader *fHeader; //! event information
298 TClonesArray *fTracks; //! charged tracks
299 TClonesArray *fVertices; //! vertices
300 TClonesArray *fV0s; //! V0s
9a244178 301 TClonesArray *fCascades; //! Cascades
3dd9f9e3 302 AliAODTracklets *fTracklets; //! SPD tracklets
303 TClonesArray *fJets; //! jets
37792174 304 AliAODCaloCells *fEmcalCells; //! EMCAL calorimenter cells
305 AliAODCaloCells *fPhosCells; //! PHOS calorimenter cells
3dd9f9e3 306 TClonesArray *fCaloClusters; //! calorimeter clusters
720f7306 307 AliAODCaloTrigger *fEMCALTrigger; //! EMCAL Trigger information
308 AliAODCaloTrigger *fPHOSTrigger; //! PHOS Trigger information
3dd9f9e3 309 TClonesArray *fFmdClusters; //! FMDclusters
310 TClonesArray *fPmdClusters; //! PMDclusters
866d8d78 311 TClonesArray *fDimuons; //! dimuons
a1f96974 312 AliAODTZERO *fAODTZERO; //! TZERO AOD
ae2bccf1 313 AliAODVZERO *fAODVZERO; //! VZERO AOD
16d867eb 314 AliAODZDC *fAODZDC; //! ZDC AOD
68919bd9 315 AliTOFHeader *fTOFHeader; //! event times (and sigmas) as estimated by TOF
316 // combinatorial algorithm.
317 // It contains also TOF time resolution
318 // and T0spread as written in OCDB
820b4d9e 319#ifdef MFT_UPGRADE
320 AliAODMFT *fAODMFT; //! VZERO AOD
321#endif
16d867eb 322
08e4c457 323 static const char* fAODListName[kAODListN]; //!
324
68919bd9 325 ClassDef(AliAODEvent,90);
df9db588 326};
327
328#endif