]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveEventManager.h
50e1288373f26693e7a6f89a7312da52b65eda80
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveEventManager.h
1 // $Id$
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
17 #include <AliEventInfo.h>
18
19 class AliEveMacroExecutor;
20 class AliEveEventSelector; 
21
22 class AliRunLoader;
23 class AliESDEvent;
24 class AliESDfriend;
25 class AliAODEvent;
26 class AliRawReader;
27
28 class AliGRPObject;
29 class AliRecoParam;
30 class AliMagF;
31
32 class TEveElement;
33 class TFile;
34 class TTree;
35 class TGeoManager;
36 class TString;
37 class TMap;
38
39 //==============================================================================
40 //
41 // AliEveEventManager
42 //
43 // Interface to ALICE event-data (RunLoader, ESD), magnetic field and
44 // geometry.
45 //
46
47
48 class AliEveEventManager : public TEveEventManager,
49                            public TQObject
50 {
51 public:
52   static void SetESDFileName(const TString& esd);
53   static void SetAODFileName(const TString& aod);
54   static void AddAODfriend  (const TString& friendFileName);
55   static void SetRawFileName(const TString& raw);
56   static void SetCdbUri     (const TString& cdb);
57   static void SetAssertElements(Bool_t assertRunloader, Bool_t assertEsd,
58                                 Bool_t assertAod, Bool_t assertRaw);
59   static void SearchRawForCentralReconstruction();
60
61   AliEveEventManager(const TString& name="Event");
62   AliEveEventManager(const TString& name, const TString& path, Int_t ev=0);
63   virtual ~AliEveEventManager();
64
65   virtual void  Open();
66   void          SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd, AliESDfriend *esdf);
67   virtual Int_t GetMaxEventId(Bool_t refreshESD=kFALSE) const;
68   virtual void  GotoEvent(Int_t event);
69   virtual void  NextEvent();
70   virtual void  PrevEvent(); 
71   virtual void  Close();
72   void Timeout(); // * SIGNAL*
73
74   Int_t         GetEventId()         const { return fEventId; }
75   AliRunLoader* GetRunLoader()       const { return fRunLoader; }
76   TFile*        GetESDFile()         const { return fESDFile; }
77   TTree*        GetESDTree()         const { return fESDTree; }
78   AliESDEvent*  GetESD()             const { return fESD;     }
79   AliESDfriend* GetESDfriend()       const { return fESDfriend; }
80   Bool_t        GetESDfriendExists() const { return fESDfriendExists; }
81   TFile*        GetAODFile()         const { return fAODFile; }
82   TTree*        GetAODTree()         const { return fAODTree; }
83   AliAODEvent*  GetAOD()             const { return fAOD;     }
84   virtual const Text_t* GetTitle()   const { return fPath.Data(); }
85   AliEveEventSelector* GetEventSelector() const { return fPEventSelector; }
86   TString       GetEventInfoHorizontal() const;
87   TString       GetEventInfoVertical()   const;
88   const AliEventInfo*   GetEventInfo();
89
90   static Int_t  CurrentEventId();
91
92   static Bool_t HasRunLoader();
93   static Bool_t HasESD();
94   static Bool_t HasESDfriend();
95   static Bool_t HasAOD();
96   static Bool_t HasRawReader();
97
98   static AliRunLoader* AssertRunLoader();
99   static AliESDEvent*  AssertESD();
100   static AliESDfriend* AssertESDfriend();
101   static AliAODEvent*  AssertAOD();
102   static AliRawReader* AssertRawReader();
103
104   static AliMagF*      AssertMagField();
105   static TGeoManager*  AssertGeometry();
106   static AliRecoParam* AssertRecoParams();
107
108   static AliEveEventManager* AddDependentManager(const TString& name, const TString& path);
109   static AliEveEventManager* GetDependentManager(const TString& name);
110
111   static AliEveEventManager* GetMaster();
112   static AliEveEventManager* GetCurrent();
113
114   static void                RegisterTransient    (TEveElement* element);
115   static void                RegisterTransientList(TEveElement* element);
116
117
118   Double_t      GetAutoLoadTime()        const { return fAutoLoadTime; }
119   Bool_t        GetAutoLoad()            const { return fAutoLoad;     }
120   void          SetAutoLoadTime(Float_t time);
121   void          SetAutoLoad(Bool_t autoLoad);
122   void          SetTrigSel(Int_t trig);
123   void          AutoLoadNextEvent();
124
125   Bool_t        AreEventFilesOpened()    const { return fIsOpen;       }
126   Bool_t        IsEventAvailable()       const { return fHasEvent;     }
127   Bool_t        IsUnderExternalControl() const { return fExternalCtrl; }
128   
129   Bool_t        InsertGlobal(const TString& tag, TEveElement* model);
130   Bool_t        InsertGlobal(const TString& tag, TEveElement* model,
131                              Bool_t replace, Bool_t update);
132   TEveElement*  FindGlobal(const TString& tag);
133
134   virtual void  AfterNewEventLoaded();
135   void          NewEventDataLoaded();  // *SIGNAL*
136   void          NewEventLoaded();      // *SIGNAL*
137
138   AliEveMacroExecutor* GetExecutor() const { return fExecutor; }
139
140 protected:
141   TString       fPath;                  // URL to event-data.
142   Int_t         fEventId;               // Id of current event.
143
144   AliRunLoader* fRunLoader;             // Run loader.
145
146   TFile        *fESDFile;               // ESD file.
147   TTree        *fESDTree;               // ESD tree.
148   AliESDEvent  *fESD;                   // ESDEvent object.
149   AliESDfriend *fESDfriend;             // ESDfriend object.
150   Bool_t        fESDfriendExists;       // Flag specifying if ESDfriend was found during opening of the event-data.
151   TFile        *fAODFile;               // AOD file.
152   TTree        *fAODTree;               // AOD tree.
153   AliAODEvent  *fAOD;                   // AODEvent object.
154
155   AliRawReader *fRawReader;             // Raw-data reader.
156   AliEventInfo  fEventInfo;             // Current Event Info
157   
158   Bool_t        fAutoLoad;              // Automatic loading of events (online)
159   Float_t       fAutoLoadTime;          // Auto-load time in seconds
160   TTimer       *fAutoLoadTimer;         // Timer for automatic event loading
161
162   Bool_t        fIsOpen;                // Are event-files opened.
163   Bool_t        fHasEvent;              // Is an event available.
164   Bool_t        fExternalCtrl;          // Are we under external event-loop.
165
166   TMap*         fGlobal;
167   Bool_t        fGlobalReplace;         // Are global replace
168   Bool_t        fGlobalUpdate;          // Are global updates
169
170   AliEveMacroExecutor *fExecutor;       // Executor for std macros
171
172   TEveElementList     *fTransients;     // Container for additional transient (per event) elements.
173   TEveElementList     *fTransientLists; // Container for lists of transient (per event) elements.
174
175   AliEveEventSelector* fPEventSelector; // Event filter
176
177   TList        *fSubManagers;           // Dependent event-managers, used for event embedding.
178
179   static TString  fgGAlice;        // galice.root file
180   static TString  fgESDFileName;        // Name by which to open ESD.
181   static TString  fgESDfriendsFileName;
182   static TString  fgAODFileName;        // Name by which to open AOD.
183   static TString  fgRawFileName;        // Name by which to open raw-data file.
184   static TString  fgCdbUri;             // Global URI to CDB.
185   static Bool_t   fgAssertRunLoader;    // Global flag specifying if AliRunLoader must be asserted during opening of the event-data.
186   static Bool_t   fgAssertESD;          // Global flag specifying if ESDEvent must be asserted during opening of the event-data.
187   static Bool_t   fgAssertAOD;          // Global flag specifying if AODEvent must be asserted during opening of the event-data.
188   static Bool_t   fgAssertRaw;          // Global flag specifying if raw-data presence must be asserted during opening of the event-data.
189
190   static TList   *fgAODfriends;         // Global list of AOD friend names to be attached during opening of the event-data (empty by default).
191
192   static Bool_t   fgRawFromStandardLoc; // Global flag to enable looking for raw data in ../../../raw/, as it is stored for central reco.
193
194   static Bool_t        fgGRPLoaded;     // Global run parameters loaded?
195   static AliMagF      *fgMagField;      // Global pointer to magnetic field.
196   static AliRecoParam* fgRecoParam;
197   static Bool_t        fgUniformField;  // Track with uniform field.
198
199 private:
200   AliEveEventManager(const AliEveEventManager&);            // Not implemented
201   AliEveEventManager& operator=(const AliEveEventManager&); // Not implemented
202
203   void InitInternals();
204   void StartAutoLoadTimer();
205   void StopAutoLoadTimer();
206
207   static Bool_t InitGRP();
208   static Bool_t InitRecoParam();
209
210   Bool_t fAutoLoadTimerRunning; // State of auto-load timer.
211
212   static AliEveEventManager* fgMaster;
213   static AliEveEventManager* fgCurrent;
214
215   ClassDef(AliEveEventManager, 0); // Interface for getting all event components in a uniform way.
216 };
217
218 #endif