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