]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/global/AliFlatESDEvent.h
AliHLTglobal module
[u/mrichter/AliRoot.git] / HLT / global / AliFlatESDEvent.h
CommitLineData
251a2c81 1#ifndef ALIFLATESDEVENT_H
2#define ALIFLATESDEVENT_H
3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice *
6 * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli */
7
8/*
9 * See implementation file for documentation
10 */
11
12#include "Rtypes.h"
1f516476 13#include "AliVMisc.h"
120da37b 14#include "AliVEvent.h"
888585e5 15#include "AliFlatESDTrack.h"
50ff8c36 16#include "AliFlatESDVertex.h"
c6f15692 17#include "AliFlatESDFriend.h"
0912e8dd 18#include "AliESDVertex.h"
6a33e0e9 19
6a33e0e9 20class AliFlatESDV0;
21class AliFlatESDTrigger;
251a2c81 22
23class AliESDEvent;
251a2c81 24class AliESDVertex;
251a2c81 25
120da37b 26class AliFlatESDEvent :public AliVEvent {
251a2c81 27 public:
28 // --------------------------------------------------------------------------------
29 // -- Constructor / Destructors
6a33e0e9 30 AliFlatESDEvent();
888585e5 31 ~AliFlatESDEvent() {}
6a33e0e9 32
c2ea967e 33 // constructor and method for reinitialisation of virtual table
1f516476 34 AliFlatESDEvent( AliVConstructorReinitialisationFlag );
35 void Reinitialize() { new (this) AliFlatESDEvent( AliVReinitialize ); }
c2ea967e 36
888585e5 37 // --------------------------------------------------------------------------------
6a33e0e9 38
6a33e0e9 39 Double_t GetMagneticField() const { return fMagneticField; }
40 UInt_t GetPeriodNumber() const { return fPeriodNumber; }
41 Int_t GetRunNumber() const { return fRunNumber; }
42 UInt_t GetOrbitNumber() const { return fOrbitNumber; }
43 UShort_t GetBunchCrossNumber() const { return fBunchCrossNumber; }
888585e5 44 ULong64_t GetTriggerMask() const { return fTriggerMask; }
45 ULong64_t GetTriggerMaskNext50() const { return fTriggerMaskNext50; }
46 TString GetFiredTriggerClasses() const ;
47
6a33e0e9 48 Int_t GetNumberOfTracks() const { return fNTracks; }
888585e5 49 Int_t GetNumberOfV0s() const { return fNV0s; }
488e1434 50
888585e5 51 void Reset();
6a33e0e9 52 void ConnectTracks(){} // initialisation, needed by the ESD event, part of VVevent interface
251a2c81 53
888585e5 54 UInt_t GetTimeStamp() const { return fTimeStamp; }
55 UInt_t GetEventSpecie() const { return fEventSpecie; }
56 Int_t GetNumberOfKinks() const { return 0; }
57
87f1f6c8 58 AliVTrack *GetVTrack( Int_t i ) const { return GetFlatTrackNonConst(i); }
2cb7e995 59 AliESDkink *GetKink(Int_t /*i*/) const { return NULL;}
888585e5 60
87f1f6c8 61 using AliVEvent::GetPrimaryVertex;
62 using AliVEvent::GetPrimaryVertexTPC;
63 using AliVEvent::GetPrimaryVertexSPD;
64 using AliVEvent::GetPrimaryVertexTracks;
a3da9bda 65 Int_t GetPrimaryVertex( AliESDVertex &v ) const ;
66 Int_t GetPrimaryVertexTPC( AliESDVertex &v ) const ;
0912e8dd 67 Int_t GetPrimaryVertexSPD( AliESDVertex &v ) const ;
68 Int_t GetPrimaryVertexTracks( AliESDVertex &v ) const ;
69
1f516476 70 AliVfriendEvent* FindFriend() const { return fFriendEvent; }
0912e8dd 71
251a2c81 72 // --------------------------------------------------------------------------------
888585e5 73 // Own methods
251a2c81 74
888585e5 75 // -- Set methods
76
77 Int_t SetFromESD( size_t allocatedMemorySize, const AliESDEvent *esd, const Bool_t fillV0s=kTRUE );
251a2c81 78
c6f15692 79 void SetFriendEvent( AliFlatESDFriend *f ) { fFriendEvent=f; }
80
6a33e0e9 81 void SetMagneticField( Double_t mf ){ fMagneticField = mf; }
82 void SetPeriodNumber( Int_t n ) { fPeriodNumber = n; }
83 void SetRunNumber( Int_t n ) { fRunNumber = n; }
84 void SetOrbitNumber( UInt_t n ) { fOrbitNumber = n; }
85 void SetBunchCrossNumber( UShort_t n ) { fBunchCrossNumber = n; }
86 void SetTimeStamp( UInt_t timeStamp ){ fTimeStamp = timeStamp; }
888585e5 87 void SetEventSpecie(UInt_t eventSpecie){ fEventSpecie = eventSpecie; }
6a33e0e9 88 void SetTriggerMask(ULong64_t n) { fTriggerMask = n; }
888585e5 89 void SetTriggerMaskNext50(ULong64_t n) { fTriggerMaskNext50 = n; }
6a33e0e9 90
888585e5 91 Int_t SetPrimaryVertexTracks( const AliESDVertex *v, size_t allocatedVtxMemory );
92 Int_t SetPrimaryVertexSPD( const AliESDVertex *v, size_t allocatedVtxMemory );
6a33e0e9 93
888585e5 94 AliFlatESDTrigger *SetTriggersStart();
95 void SetTriggersEnd( Int_t nTriggerClasses, size_t triggersSize );
6a33e0e9 96
888585e5 97 Int_t SetTracksStart( AliFlatESDTrack* &t, Long64_t* &table, Int_t nTracks, size_t freeMem);
98 void SetTracksEnd( Int_t nTracks, size_t tracksSize );
251a2c81 99
888585e5 100 AliFlatESDV0 *SetV0sStart();
101 void SetV0sEnd( Int_t nV0s, size_t v0sSize );
251a2c81 102
103 // --------------------------------------------------------------------------------
104 // -- Getter methods
105
0912e8dd 106 const AliFlatESDVertex* GetFlatPrimaryVertexSPD() const ;
107 const AliFlatESDVertex* GetFlatPrimaryVertexTracks() const ;
251a2c81 108
6a33e0e9 109 Int_t GetNumberOfTriggerClasses() const { return fNTriggerClasses; }
110
111 const AliFlatESDTrigger *GetTriggerClasses() const { return reinterpret_cast<const AliFlatESDTrigger*>( fContent + fTriggerPointer ); }
112 const AliFlatESDTrack *GetTracks() const { return reinterpret_cast<const AliFlatESDTrack*>( fContent + fTracksPointer ); }
113 const AliFlatESDV0 *GetV0s() const { return reinterpret_cast<const AliFlatESDV0*>( fContent + fV0Pointer ); }
8b15ecc3 114
888585e5 115 const AliFlatESDTrack *GetFlatTrack( Int_t i ) const ;
87f1f6c8 116 AliFlatESDTrack *GetFlatTrackNonConst( Int_t i ) const;
888585e5 117
251a2c81 118 // --------------------------------------------------------------------------------
119 // -- Size methods
488e1434 120
6a33e0e9 121 ULong64_t GetSize() const { return fContent + fContentSize - reinterpret_cast<const Byte_t*>(this); }
488e1434 122
888585e5 123 static ULong64_t EstimateSize(AliESDEvent*esd, Bool_t fillV0s=kTRUE );
488e1434 124
120da37b 125 // --------------------------------------------------------------------------------
126 // AliVEvent interface
5bd31568 127 virtual void Print(Option_t *option="") const {if (option){}; return;}
120da37b 128 virtual void AddObject(TObject* /*obj*/) {}
129 virtual TObject* FindListObject(const char* /*name*/) const {return NULL;}
130 virtual TList* GetList() const {return NULL;}
131 virtual void CreateStdContent() {}
132 virtual void GetStdContent() {}
133 virtual void ReadFromTree(TTree* /*tree*/, Option_t* /*opt*/) {}
134 virtual void WriteToTree(TTree* /*tree*/) const {}
135 virtual void SetStdNames() {}
136 virtual AliVHeader* GetHeader() const {return NULL;}
137 virtual void SetPeriodNumber(UInt_t) {}
138 virtual void SetEventType(UInt_t) {}
139 virtual void SetTriggerCluster(UChar_t) {}
140 virtual UInt_t GetEventType() const {return 0;}
141 virtual UChar_t GetTriggerCluster() const {return 0;}
142 virtual Double_t GetZDCN1Energy() const {return 0.;}
143 virtual Double_t GetZDCP1Energy() const {return 0.;}
144 virtual Double_t GetZDCN2Energy() const {return 0.;}
145 virtual Double_t GetZDCP2Energy() const {return 0.;}
146 virtual Double_t GetZDCEMEnergy(Int_t) const {return 0.;}
c8a50489 147 virtual AliVParticle* GetTrack(Int_t) const;
120da37b 148 virtual Int_t GetNumberOfCascades() const {return 0;}
149 virtual AliCentrality* GetCentrality() {return NULL;}
150 virtual AliEventplane* GetEventplane() {return NULL;}
151 virtual Int_t EventIndex(Int_t) const {return 0;}
152 virtual Int_t EventIndexForCaloCluster(Int_t) const {return 0;}
153 virtual Int_t EventIndexForPHOSCell(Int_t) const {return 0;}
154 virtual Int_t EventIndexForEMCALCell(Int_t) const {return 0;}
155 virtual AliVVZERO* GetVZEROData() const {return NULL;}
156 virtual AliVZDC *GetZDCData() const {return NULL;}
15da855d 157 virtual AliVEvent::EDataLayoutType GetDataLayoutType() const;
120da37b 158
251a2c81 159 private:
251a2c81 160
6a33e0e9 161 AliFlatESDEvent( const AliFlatESDEvent& );
162 AliFlatESDEvent& operator=( const AliFlatESDEvent& );
163
6a33e0e9 164 // --------------------------------------------------------------------------------
251a2c81 165
6a33e0e9 166 // -- Fixed size member objects ( try to align in memory )
167
168 size_t fContentSize; // Size of fContent
169 Double32_t fMagneticField; // Solenoid Magnetic Field in kG : for compatibility with AliMagF
170 UInt_t fPeriodNumber; // PeriodNumber
171 Int_t fRunNumber; // Run Number
172 UInt_t fOrbitNumber; // Orbit Number
173 UInt_t fTimeStamp; // Time stamp
888585e5 174 UInt_t fEventSpecie; // Reconstruction event specie (1-default,2-lowM,4-highM,8-cosmic,16-cal)
6a33e0e9 175 UShort_t fBunchCrossNumber; // Bunch Crossing Number
176 Byte_t fPrimaryVertexMask; // Bit mask specfifying which primary vertices are present
888585e5 177 ULong64_t fTriggerMask; // Trigger mask, first 50 bits
178 ULong64_t fTriggerMaskNext50; // Trigger mask, next 50 bits
6a33e0e9 179
180 UInt_t fNTriggerClasses; // N trigger classes
181 UInt_t fNPrimaryVertices; // Number of primary vertices in array
182 UInt_t fNTracks; // Number of tracks in array
183 UInt_t fNV0s; // Number of v0's
251a2c81 184
6a33e0e9 185 // Pointers to specific data in fContent
186
187 size_t fTriggerPointer; // position of the first trigger description in fContent
888585e5 188 size_t fPrimaryVertexTracksPointer; // position of primary vertex tracks in fContent
189 size_t fPrimaryVertexSPDPointer; // position of primary vertex SPD in fContent
190 size_t fTrackTablePointer; // position of the first track pointer in fContent
6a33e0e9 191 size_t fTracksPointer; // position of the first track in fContent
192 size_t fV0Pointer; // position of the first V0 in fContent
c6f15692 193
194 //
195 AliFlatESDFriend *fFriendEvent;
6a33e0e9 196
251a2c81 197 // --------------------------------------------------------------------------------
6a33e0e9 198
251a2c81 199 // -- Variable Size Object
6a33e0e9 200
251a2c81 201 Byte_t fContent[1]; // Variale size object, which contains all data
e3d1b1e2 202
203 ClassDef(AliFlatESDEvent,0)
251a2c81 204};
6a33e0e9 205
206// Inline implementations
207
87f1f6c8 208inline AliFlatESDTrack *AliFlatESDEvent::GetFlatTrackNonConst( Int_t i ) const
2cb7e995 209{
210 const Long64_t *table = reinterpret_cast<const Long64_t*> (fContent + fTrackTablePointer);
211 if( i<0 || i>(int) fNTracks || table[i]<0 ) return NULL;
87f1f6c8 212 return reinterpret_cast<AliFlatESDTrack*>( const_cast<Byte_t*>(fContent + table[i]) );
2cb7e995 213}
214
888585e5 215inline const AliFlatESDTrack *AliFlatESDEvent::GetFlatTrack( Int_t i ) const
216{
217 const Long64_t *table = reinterpret_cast<const Long64_t*> (fContent + fTrackTablePointer);
218 if( i<0 || i>(int) fNTracks || table[i]<0 ) return NULL;
219 return reinterpret_cast<const AliFlatESDTrack*>( fContent + table[i] );
220}
221
222
223inline Int_t AliFlatESDEvent::SetTracksStart( AliFlatESDTrack* &t, Long64_t* &table, Int_t nTracks, size_t freeMem)
6a33e0e9 224{
225 fNTracks = 0;
888585e5 226 if( nTracks*sizeof(Long64_t) > freeMem ) return -1;
227 fTrackTablePointer = fContentSize;
228 fContentSize += nTracks*sizeof(Long64_t);
6a33e0e9 229 fTracksPointer = fContentSize;
888585e5 230 table = reinterpret_cast< Long64_t* >( fContent + fTrackTablePointer );
231 t = reinterpret_cast< AliFlatESDTrack* >( fContent + fTracksPointer );
232 return 0;
6a33e0e9 233}
234
888585e5 235inline void AliFlatESDEvent::SetTracksEnd( Int_t nTracks, size_t tracksSize )
6a33e0e9 236{
888585e5 237 if( nTracks<0 ) return;
238 Long64_t *table = reinterpret_cast< Long64_t*> (fContent + fTrackTablePointer);
239 for( int i=0; i<nTracks; i++ ) table[i]+=fTracksPointer;
6a33e0e9 240 fNTracks = nTracks;
241 fContentSize += tracksSize;
242}
243
888585e5 244inline AliFlatESDV0 *AliFlatESDEvent::SetV0sStart()
6a33e0e9 245{
246 fNV0s = 0;
247 fV0Pointer = fContentSize;
248 return reinterpret_cast< AliFlatESDV0* >( fContent + fContentSize );
249}
250
888585e5 251inline void AliFlatESDEvent::SetV0sEnd( Int_t nV0s, size_t v0sSize )
6a33e0e9 252{
253 fNV0s = nV0s;
254 fContentSize += v0sSize;
255}
256
888585e5 257inline AliFlatESDTrigger *AliFlatESDEvent::SetTriggersStart()
6a33e0e9 258{
259 fNTriggerClasses = 0;
260 fTriggerPointer = fContentSize;
261 return reinterpret_cast< AliFlatESDTrigger* >( fContent + fContentSize );
262}
263
888585e5 264inline void AliFlatESDEvent::SetTriggersEnd( Int_t nTriggerClasses, size_t triggersSize )
6a33e0e9 265{
266 fNTriggerClasses = nTriggerClasses;
267 fContentSize += triggersSize;
268}
269
0912e8dd 270inline const AliFlatESDVertex* AliFlatESDEvent::GetFlatPrimaryVertexTracks() const
6a33e0e9 271{
ec748c4a 272 return (fPrimaryVertexMask & 0x1) ? (reinterpret_cast<const AliFlatESDVertex*>(fContent + fPrimaryVertexTracksPointer) ) : NULL;
273}
274
275inline const AliFlatESDVertex* AliFlatESDEvent::GetFlatPrimaryVertexSPD() const
276{
277 return (fPrimaryVertexMask & 0x2) ? reinterpret_cast<const AliFlatESDVertex*>(fContent + fPrimaryVertexSPDPointer) : NULL;
6a33e0e9 278}
279
0912e8dd 280inline Int_t AliFlatESDEvent::GetPrimaryVertexSPD( AliESDVertex &v ) const
281{
282 const AliFlatESDVertex* flatVertex = GetFlatPrimaryVertexSPD();
283 if( !flatVertex ) return -1;
284 flatVertex->GetESDVertex( v );
285 return 0;
286}
287
288inline Int_t AliFlatESDEvent::GetPrimaryVertexTracks( AliESDVertex &v ) const
289{
290 const AliFlatESDVertex* flatVertex = GetFlatPrimaryVertexTracks();
291 if( !flatVertex ) return -1;
292 flatVertex->GetESDVertex( v );
293 return 0;
294}
295
a3da9bda 296inline Int_t AliFlatESDEvent::GetPrimaryVertexTPC( AliESDVertex &/*v*/ ) const
297{
298 return -1;
299}
300
301inline Int_t AliFlatESDEvent::GetPrimaryVertex( AliESDVertex &v ) const
302{
303 int ret = GetPrimaryVertexTracks( v );
304 if( ret<0 ) ret = GetPrimaryVertexSPD( v );
305 return ret;
306}
307
308
251a2c81 309#endif