]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveEventManager.h
Resolving all symbols in the library
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveEventManager.h
1 // $Id: AliEveEventManager.h 64557 2013-10-16 20:03:08Z hristov $
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #ifndef AliEveEventManager_H
11 #define AliEveEventManager_H
12
13 #include <TEveEventManager.h>
14 #include <TQObject.h>
15 #include <TObjArray.h>
16 #include <TThread.h>
17
18 #include <AliEventInfo.h>
19 #include <AliESDEvent.h>
20 #include "AliStorageTypes.h"
21
22 class AliEveMacroExecutor;
23 class AliEveEventSelector; 
24
25 class AliRunLoader;
26 class AliESDEvent;
27 class AliESDfriend;
28 class AliAODEvent;
29 class AliRawReader;
30
31 class AliGRPObject;
32 class AliRecoParam;
33 class AliMagF;
34
35 class TEveElement;
36 class TFile;
37 class TTree;
38 class TGeoManager;
39 class TString;
40 class TMap;
41
42 //==============================================================================
43 //
44 // AliEveEventManager
45 //
46 // Interface to ALICE event-data (RunLoader, ESD), magnetic field and
47 // geometry.
48 //
49
50
51 class AliEveEventManager : public TEveEventManager, public TQObject
52 {
53 public:
54     AliEveEventManager(const TString& name="Event", Int_t ev=0);
55     virtual ~AliEveEventManager();
56         
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);
72     static void SetAssertElements(Bool_t assertRunloader, Bool_t assertEsd,
73                                   Bool_t assertAod, Bool_t assertRaw);
74     static void SearchRawForCentralReconstruction();
75
76     virtual void  Open();
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();
81     void MarkCurrentEvent();
82     virtual void  Close();
83
84     void          SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd, AliESDfriend *esdf);
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();
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();
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);
121     static AliEveEventManager* GetMaster();
122     static AliEveEventManager* GetCurrent();
123     static void                RegisterTransient    (TEveElement* element);
124     static void                RegisterTransientList(TEveElement* element);
125
126     Double_t      GetAutoLoadTime()        const { return fAutoLoadTime; }
127     Bool_t        GetAutoLoad()            const { return fAutoLoad;     }
128     Bool_t        GetLoopMarked()            const { return fLoopMarked;     }
129     void          SetAutoLoadTime(Float_t time);
130     void          SetAutoLoad(Bool_t autoLoad);
131     void          SetLoopMarked(Bool_t loopMarked);
132     void          SetTrigSel(Int_t trig);
133     void          AutoLoadNextEvent();
134
135     Bool_t        AreEventFilesOpened()    const { return fIsOpen;       }
136     Bool_t        IsEventAvailable()       const { return fHasEvent;     }
137     Bool_t        IsUnderExternalControl() const { return fExternalCtrl; }
138
139     Bool_t        IsOnlineMode() const { return fOnlineMode; }
140
141     Bool_t        InsertGlobal(const TString& tag, TEveElement* model);
142     Bool_t        InsertGlobal(const TString& tag, TEveElement* model,
143                                Bool_t replace, Bool_t update);
144     TEveElement*  FindGlobal(const TString& tag);
145
146     virtual void  AfterNewEventLoaded();
147     void          NewEventDataLoaded();  // *SIGNAL*
148     void          NewEventLoaded();      // *SIGNAL*
149     void          NoEventLoaded();      // *SIGNAL*
150     void          StorageManagerOk();    // *SIGNAL*
151     void          StorageManagerDown();  // *SIGNAL*
152
153     AliEveMacroExecutor* GetExecutor() const { return fExecutor; }
154     void InitOCDB(int runNo=-1);
155
156     void PrepareForNewEvent(AliESDEvent *event);
157     Int_t NewEventAvailable();
158
159 protected:
160     Int_t         fEventId;             // Id of current event.
161
162     AliRunLoader* fRunLoader;           // Run loader.
163
164     TFile        *fESDFile;             // ESD file.
165     TTree        *fESDTree;             // ESD tree.
166     TTree        *fHLTESDTree;  // HLT ESD tree.
167     AliESDEvent  *fESD;                 // ESDEvent object.
168     AliESDfriend *fESDfriend;           // ESDfriend object.
169     Bool_t        fESDfriendExists;     // Flag specifying if ESDfriend was found during opening of the event-data.
170     TFile        *fAODFile;             // AOD file.
171     TTree        *fAODTree;             // AOD tree.
172     AliAODEvent  *fAOD;                 // AODEvent object.
173
174     AliRawReader *fRawReader;             // Raw-data reader.
175     AliEventInfo        fEventInfo;             // Current Event Info
176
177     Bool_t        fAutoLoad;              // Automatic loading of events (online)
178     Bool_t        fLoopMarked;            // Automatic loading of marked events
179     Float_t       fAutoLoadTime;          // Auto-load time in seconds
180     TTimer       *fAutoLoadTimer;         // Timer for automatic event loading
181
182     Bool_t        fIsOpen;                // Are event-files opened.
183     Bool_t        fHasEvent;              // Is an event available.
184     Bool_t        fExternalCtrl;          // Are we under external event-loop.
185
186     TMap*         fGlobal;
187     Bool_t        fGlobalReplace;         // Are global replace
188     Bool_t        fGlobalUpdate;          // Are global updates
189
190     AliEveMacroExecutor *fExecutor;       // Executor for std macros
191
192     TEveElementList     *fTransients;     // Container for additional transient (per event) elements.
193     TEveElementList     *fTransientLists; // Container for lists of transient (per event) elements.
194
195     AliEveEventSelector* fPEventSelector; // Event filter
196
197     TList        *fSubManagers;           // Dependent event-managers, used for event embedding.
198
199     static TString  fgGAliceFileName;        // galice.root file
200     static TString  fgESDFileName;        // Name by which to open ESD.
201     static EVisibleESDTrees  fgESDvisibleTrees; // trees to open from ESD
202     static TString  fgESDfriendsFileName;
203     static TString  fgAODFileName;        // Name by which to open AOD.
204     static TString  fgRawFileName;        // Name by which to open raw-data file.
205     static TString  fgCdbUri;           // Global URI to CDB.
206     static Bool_t   fgAssertRunLoader;  // Global flag specifying if AliRunLoader must be asserted during opening of the event-data.
207     static Bool_t   fgAssertESD;                // Global flag specifying if ESDEvent must be asserted during opening of the event-data.
208     static Bool_t   fgAssertAOD;                // Global flag specifying if AODEvent must be asserted during opening of the event-data.
209     static Bool_t   fgAssertRaw;                // Global flag specifying if raw-data presence must be asserted during opening of the event-data.
210
211     static TList   *fgAODfriends;         // Global list of AOD friend names to be attached during opening of the event-data (empty by default).
212
213     static Bool_t   fgRawFromStandardLoc; // Global flag to enable looking for raw data in ../../../raw/, as it is stored for central reco.
214
215     static Bool_t        fgGRPLoaded;     // Global run parameters loaded?
216     static AliMagF      *fgMagField;      // Global pointer to magnetic field.
217     static AliRecoParam* fgRecoParam;
218     static Bool_t        fgUniformField;  // Track with uniform field.
219
220
221 private:
222     void InitInternals();
223
224     void StartAutoLoadTimer();
225     void StopAutoLoadTimer();
226     Bool_t fAutoLoadTimerRunning; // State of auto-load timer.
227
228     static Bool_t InitGRP();
229     static Bool_t InitRecoParam();
230     TTree* readESDTree(const char* treeName, int &run);
231
232     static AliEveEventManager* fgMaster;
233     static AliEveEventManager* fgCurrent;
234
235     static void* DispatchEventListener(void *arg){static_cast<AliEveEventManager*>(arg)->GetNextEvent();return nullptr;}
236     static void* DispatchStorageManagerWatcher(void *arg){static_cast<AliEveEventManager*>(arg)->CheckStorageStatus();return nullptr;}
237     void GetNextEvent();
238     void CheckStorageStatus();
239     TThread *fEventListenerThread;
240     TThread *fStorageManagerWatcherThread;
241     TMutex *fMutex;
242     AliESDEvent *fCurrentEvent[2];
243     TTree *fCurrentTree[2];
244     int fEventInUse;
245     int fWritingToEventIndex;
246     bool fIsNewEventAvaliable;
247     storageSockets fgSubSock;
248
249     Bool_t fOnlineMode;
250     Bool_t fStorageDown;
251     Bool_t fFinished;
252
253     AliEveEventManager(const AliEveEventManager&);            // Not implemented
254     AliEveEventManager& operator=(const AliEveEventManager&); // Not implemented
255     
256     ClassDef(AliEveEventManager, 0); // Interface for getting all event components in a uniform way.
257 };
258
259 #endif