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