Merging STORAGE-dev to master
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveEventManager.h
CommitLineData
ef795f0b 1// $Id: AliEveEventManager.h 64557 2013-10-16 20:03:08Z hristov $
d810d0de 2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
5a5a1232 3
d810d0de 4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
9
ecb84424 10#ifndef AliEveEventManager_H
a15e6d7d 11#define AliEveEventManager_H
5a5a1232 12
84aff7a4 13#include <TEveEventManager.h>
f76c9e9b 14#include <TQObject.h>
ecb84424 15#include <TObjArray.h>
164d3d29 16#include <TThread.h>
5a5a1232 17
f944f125 18#include <AliEventInfo.h>
7e0cf530 19#include <AliESDEvent.h>
164d3d29 20#include "AliStorageTypes.h"
7e0cf530 21
f6afd0e1 22class AliEveMacroExecutor;
3d94b490 23class AliEveEventSelector;
f6afd0e1 24
5a5a1232 25class AliRunLoader;
af885e0f 26class AliESDEvent;
3aecaefc 27class AliESDfriend;
b3b7b8d3 28class AliAODEvent;
c2c4b7a2 29class AliRawReader;
5a5a1232 30
8661a211 31class AliGRPObject;
f944f125 32class AliRecoParam;
93845f6c 33class AliMagF;
34
3d94b490 35class TEveElement;
5a5a1232 36class TFile;
37class TTree;
632d2b03 38class TGeoManager;
3d94b490 39class TString;
40class TMap;
5a5a1232 41
a15e6d7d 42//==============================================================================
43//
44// AliEveEventManager
45//
46// Interface to ALICE event-data (RunLoader, ESD), magnetic field and
47// geometry.
48//
49
5a5a1232 50
164d3d29 51class AliEveEventManager : public TEveEventManager, public TQObject
5a5a1232 52{
5a5a1232 53public:
164d3d29 54 AliEveEventManager(const TString& name="Event", Int_t ev=0);
55 virtual ~AliEveEventManager();
56
51104899 57 enum EVisibleESDTrees{ kOfflineTree, kHLTTree };
58
59 static void SetESDFileName(const TString& esd, EVisibleESDTrees shown=kOfflineTree);
60 static void SetESDfriendFileName(const TString& esdf);
61 static void SetAODFileName(const TString& aod);
62 static void AddAODfriend (const TString& friendFileName);
63 static void SetRawFileName(const TString& raw);
64 static void SetCdbUri (const TString& cdb);
65 static void SetGAliceFileName(const TString& galice);
66
67 // set Local Directory or URL where the files are located
68 // it can also be a path to root_archive.zip
69 // assumes the filenames of ESD, AOD, etc are standard ALICE names
70 // (AliESDs.root, AliESDfriends.root, AliAOD.root, AliAODfriend.root, galice.root,raw.root)
71 static void SetFilesPath(const TString& path);
51104899 72 static void SetAssertElements(Bool_t assertRunloader, Bool_t assertEsd,
73 Bool_t assertAod, Bool_t assertRaw);
74 static void SearchRawForCentralReconstruction();
75
51104899 76 virtual void Open();
51104899 77 virtual Int_t GetMaxEventId(Bool_t refreshESD=kFALSE) const;
78 virtual void GotoEvent(Int_t event);
79 virtual void NextEvent();
80 virtual void PrevEvent();
164d3d29 81 void MarkCurrentEvent();
51104899 82 virtual void Close();
164d3d29 83
84 void SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd, AliESDfriend *esdf);
51104899 85 void Timeout(); // * SIGNAL*
86
87 Int_t GetEventId() const { return fEventId; }
88 AliRunLoader* GetRunLoader() const { return fRunLoader; }
89 TFile* GetESDFile() const { return fESDFile; }
90 TTree* GetESDTree() const { return fESDTree; }
91 TTree* GetHLTESDTree() const { return fHLTESDTree; }
92 AliESDEvent* GetESD() const { return fESD; }
93 AliESDfriend* GetESDfriend() const { return fESDfriend; }
94 Bool_t GetESDfriendExists() const { return fESDfriendExists; }
95 TFile* GetAODFile() const { return fAODFile; }
96 TTree* GetAODTree() const { return fAODTree; }
97 AliAODEvent* GetAOD() const { return fAOD; }
98 AliEveEventSelector* GetEventSelector() const { return fPEventSelector; }
99 TString GetEventInfoHorizontal() const;
100 TString GetEventInfoVertical() const;
101 const AliEventInfo* GetEventInfo();
102
103 static Int_t CurrentEventId();
51104899 104 static Bool_t HasRunLoader();
105 static Bool_t HasESD();
106 static Bool_t HasESDfriend();
107 static Bool_t HasAOD();
108 static Bool_t HasRawReader();
109
110 static AliRunLoader* AssertRunLoader();
111 static AliESDEvent* AssertESD();
112 static AliESDfriend* AssertESDfriend();
113 static AliAODEvent* AssertAOD();
114 static AliRawReader* AssertRawReader();
51104899 115 static AliMagF* AssertMagField();
116 static TGeoManager* AssertGeometry();
117 static AliRecoParam* AssertRecoParams();
118
119 static AliEveEventManager* AddDependentManager(const TString& name, const TString& path);
120 static AliEveEventManager* GetDependentManager(const TString& name);
51104899 121 static AliEveEventManager* GetMaster();
122 static AliEveEventManager* GetCurrent();
51104899 123 static void RegisterTransient (TEveElement* element);
124 static void RegisterTransientList(TEveElement* element);
125
51104899 126 Double_t GetAutoLoadTime() const { return fAutoLoadTime; }
127 Bool_t GetAutoLoad() const { return fAutoLoad; }
128 void SetAutoLoadTime(Float_t time);
129 void SetAutoLoad(Bool_t autoLoad);
130 void SetTrigSel(Int_t trig);
131 void AutoLoadNextEvent();
132
133 Bool_t AreEventFilesOpened() const { return fIsOpen; }
134 Bool_t IsEventAvailable() const { return fHasEvent; }
135 Bool_t IsUnderExternalControl() const { return fExternalCtrl; }
136
137 Bool_t InsertGlobal(const TString& tag, TEveElement* model);
138 Bool_t InsertGlobal(const TString& tag, TEveElement* model,
139 Bool_t replace, Bool_t update);
140 TEveElement* FindGlobal(const TString& tag);
141
142 virtual void AfterNewEventLoaded();
143 void NewEventDataLoaded(); // *SIGNAL*
144 void NewEventLoaded(); // *SIGNAL*
145
146 AliEveMacroExecutor* GetExecutor() const { return fExecutor; }
164d3d29 147 void InitOCDB(int runNo=-1);
148
149 void PrepareForNewEvent(AliESDEvent *event);
4b456ebb 150protected:
51104899 151 Int_t fEventId; // Id of current event.
4b456ebb 152
51104899 153 AliRunLoader* fRunLoader; // Run loader.
4b456ebb 154
51104899 155 TFile *fESDFile; // ESD file.
156 TTree *fESDTree; // ESD tree.
157 TTree *fHLTESDTree; // HLT ESD tree.
158 AliESDEvent *fESD; // ESDEvent object.
159 AliESDfriend *fESDfriend; // ESDfriend object.
160 Bool_t fESDfriendExists; // Flag specifying if ESDfriend was found during opening of the event-data.
161 TFile *fAODFile; // AOD file.
162 TTree *fAODTree; // AOD tree.
163 AliAODEvent *fAOD; // AODEvent object.
4b456ebb 164
51104899 165 AliRawReader *fRawReader; // Raw-data reader.
166 AliEventInfo fEventInfo; // Current Event Info
80547f2d 167
51104899 168 Bool_t fAutoLoad; // Automatic loading of events (online)
169 Float_t fAutoLoadTime; // Auto-load time in seconds
170 TTimer *fAutoLoadTimer; // Timer for automatic event loading
80547f2d 171
51104899 172 Bool_t fIsOpen; // Are event-files opened.
173 Bool_t fHasEvent; // Is an event available.
174 Bool_t fExternalCtrl; // Are we under external event-loop.
3d94b490 175
51104899 176 TMap* fGlobal;
177 Bool_t fGlobalReplace; // Are global replace
178 Bool_t fGlobalUpdate; // Are global updates
f6afd0e1 179
51104899 180 AliEveMacroExecutor *fExecutor; // Executor for std macros
08b0f222 181
51104899 182 TEveElementList *fTransients; // Container for additional transient (per event) elements.
183 TEveElementList *fTransientLists; // Container for lists of transient (per event) elements.
008ac94c 184
51104899 185 AliEveEventSelector* fPEventSelector; // Event filter
4d62585e 186
51104899 187 TList *fSubManagers; // Dependent event-managers, used for event embedding.
4b456ebb 188
51104899 189 static TString fgGAliceFileName; // galice.root file
190 static TString fgESDFileName; // Name by which to open ESD.
191 static EVisibleESDTrees fgESDvisibleTrees; // trees to open from ESD
192 static TString fgESDfriendsFileName;
193 static TString fgAODFileName; // Name by which to open AOD.
194 static TString fgRawFileName; // Name by which to open raw-data file.
195 static TString fgCdbUri; // Global URI to CDB.
196 static Bool_t fgAssertRunLoader; // Global flag specifying if AliRunLoader must be asserted during opening of the event-data.
197 static Bool_t fgAssertESD; // Global flag specifying if ESDEvent must be asserted during opening of the event-data.
198 static Bool_t fgAssertAOD; // Global flag specifying if AODEvent must be asserted during opening of the event-data.
199 static Bool_t fgAssertRaw; // Global flag specifying if raw-data presence must be asserted during opening of the event-data.
4b456ebb 200
51104899 201 static TList *fgAODfriends; // Global list of AOD friend names to be attached during opening of the event-data (empty by default).
25dddcb1 202
51104899 203 static Bool_t fgRawFromStandardLoc; // Global flag to enable looking for raw data in ../../../raw/, as it is stored for central reco.
204
205 static Bool_t fgGRPLoaded; // Global run parameters loaded?
206 static AliMagF *fgMagField; // Global pointer to magnetic field.
207 static AliRecoParam* fgRecoParam;
208 static Bool_t fgUniformField; // Track with uniform field.
8661a211 209
51104899 210
164d3d29 211private:
51104899 212 void InitInternals();
ef795f0b 213
51104899 214 void StartAutoLoadTimer();
215 void StopAutoLoadTimer();
164d3d29 216 Bool_t fAutoLoadTimerRunning; // State of auto-load timer.
4b456ebb 217
51104899 218 static Bool_t InitGRP();
219 static Bool_t InitRecoParam();
51104899 220 TTree* readESDTree(const char* treeName, int &run);
8661a211 221
51104899 222 static AliEveEventManager* fgMaster;
223 static AliEveEventManager* fgCurrent;
4d62585e 224
164d3d29 225
226 static void* Dispatch(void *arg){static_cast<AliEveEventManager*>(arg)->GetNextEvent();}
227 void GetNextEvent();
228 TThread *fGetEventThread;
229 TMutex fMutex;
230 AliESDEvent *fCurrentEvent[2];
231 TTree *fCurrentTree[2];
232 int fEventInUse;
233 int fWritingToEventIndex;
234 bool fIsNewEventAvaliable;
235 storageSockets fgSubSock;
236
237 AliEveEventManager(const AliEveEventManager&); // Not implemented
238 AliEveEventManager& operator=(const AliEveEventManager&); // Not implemented
239
51104899 240 ClassDef(AliEveEventManager, 0); // Interface for getting all event components in a uniform way.
4b456ebb 241};
5a5a1232 242
5a5a1232 243#endif