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