saveViews extended to print trigger classes, displaying of logo fixed. Cleanup of...
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveEventManager.cxx
CommitLineData
ef795f0b 1// $Id: AliEveEventManager.cxx 64557 2013-10-16 20:03:08Z hristov $
d810d0de 2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
5a5a1232 3
d810d0de 4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
9
10#include "AliEveEventManager.h"
008ac94c 11#include "AliEveEventSelector.h"
f6afd0e1 12#include "AliEveMacroExecutor.h"
0790c3e6 13#include "AliEveConfigManager.h"
14#include "AliEveVSDCreator.h"
f944f125 15
16#include <THashList.h>
3d94b490 17#include <TEveElement.h>
84aff7a4 18#include <TEveManager.h>
b9579f03 19#include <TEveViewer.h>
5a5a1232 20
f944f125 21#include <AliLog.h>
5a5a1232 22#include <AliRunLoader.h>
93845f6c 23#include <AliRun.h>
b3b7b8d3 24#include <AliESDRun.h>
af885e0f 25#include <AliESDEvent.h>
3aecaefc 26#include <AliESDfriend.h>
b3b7b8d3 27#include <AliAODEvent.h>
28
f944f125 29#include <AliRecoParam.h>
30#include <AliCentralTrigger.h>
31#include <AliCDBEntry.h>
32#include <AliTriggerClass.h>
33#include <AliTriggerConfiguration.h>
34#include <AliTriggerCluster.h>
35#include <AliDetectorRecoParam.h>
36
ec835ab5 37#include <AliDAQ.h>
38#include <AliRawEventHeaderBase.h>
c2c4b7a2 39#include <AliRawReaderRoot.h>
40#include <AliRawReaderFile.h>
41#include <AliRawReaderDate.h>
f7a1cc68 42#include <AliMagF.h>
632d2b03 43#include <AliCDBManager.h>
d3ed470c 44#include <AliCDBStorage.h>
8661a211 45#include <AliGRPObject.h>
632d2b03 46#include <AliHeader.h>
47#include <AliGeomManager.h>
55216596 48#include <AliGRPManager.h>
14a4b686 49#include <AliSysInfo.h>
5a5a1232 50
51#include <TFile.h>
52#include <TTree.h>
fbc350a3 53#include <TGeoManager.h>
8661a211 54#include <TGeoGlobalMagField.h>
5a5a1232 55#include <TSystem.h>
12365217 56#include <TTimeStamp.h>
8661a211 57#include <TPRegexp.h>
58#include <TError.h>
ccd2624b 59#include <TEnv.h>
3d94b490 60#include <TString.h>
61#include <TMap.h>
7f97b015 62#include <TROOT.h>
d810d0de 63
ef795f0b 64#ifdef ZMQ
164d3d29 65#include "AliStorageEventManager.h"
7dcdaa40 66#include "AliOnlineReconstructionUtil.h"
67#include "AliGRPPreprocessor.h"
ef795f0b 68#endif
69
6256e5e7 70using std::cout;
71using std::endl;
66f33767 72using std::vector;
a15e6d7d 73//==============================================================================
74//==============================================================================
75// AliEveEventManager
76//==============================================================================
5a5a1232 77
57ffa5fb 78//______________________________________________________________________________
5a5a1232 79//
4d62585e 80// Provides interface for loading and navigating standard AliRoot data
b3b7b8d3 81// (AliRunLoader), ESD, AOD and RAW.
82//
83// ESDfriend is attached automatically, if the file is found.
84//
85// AODfriends are not attached automatically as there are several
86// possible files involved. To have a specific AODfriend attached, call
87// static method
88// AliEveEventManager::AddAODfriend("AliAOD.VertexingHF.root");
89// before initializing the event-manager.
51346b82 90//
a15e6d7d 91// Also provides interface to magnetic-field and geometry. Mostly
92// intended as wrappers over standard AliRoot functionality for
93// convenient use from visualizateion macros.
4d62585e 94//
95// There can be a single main event-manger, it is stored in private
96// data member fgMaster and can be accessed via static member function
97// GetMaster().
98//
99// For event overlaying and embedding one can instantiate additional
100// event-managers via static method AddDependentManager(const TString& path).
101// This interface is under development.
5a5a1232 102
d810d0de 103ClassImp(AliEveEventManager)
5a5a1232 104
d810d0de 105Bool_t AliEveEventManager::fgAssertRunLoader = kFALSE;
c76ea574 106Bool_t AliEveEventManager::fgAssertESD = kFALSE;
b3b7b8d3 107Bool_t AliEveEventManager::fgAssertAOD = kFALSE;
c2c4b7a2 108Bool_t AliEveEventManager::fgAssertRaw = kFALSE;
5a5a1232 109
c2c4b7a2 110TString AliEveEventManager::fgESDFileName("AliESDs.root");
51104899 111AliEveEventManager::EVisibleESDTrees AliEveEventManager::fgESDvisibleTrees(AliEveEventManager::kOfflineTree);
2e29a658 112TString AliEveEventManager::fgESDfriendsFileName("AliESDfriends.root");
b3b7b8d3 113TString AliEveEventManager::fgAODFileName("AliAOD.root");
be736e6d 114TString AliEveEventManager::fgGAliceFileName("galice.root");
c2c4b7a2 115TString AliEveEventManager::fgRawFileName("raw.root");
c63f2997 116TString AliEveEventManager::fgCdbUri;
566ba262 117TString AliEveEventManager::fgSpecificCdbUriValue;
118TString AliEveEventManager::fgSpecificCdbUriPath;
632d2b03 119
b3b7b8d3 120TList* AliEveEventManager::fgAODfriends = 0;
121
25dddcb1 122Bool_t AliEveEventManager::fgRawFromStandardLoc = kFALSE;
123
124Bool_t AliEveEventManager::fgGRPLoaded = kFALSE;
125AliMagF* AliEveEventManager::fgMagField = 0;
f944f125 126AliRecoParam* AliEveEventManager::fgRecoParam = 0;
25dddcb1 127Bool_t AliEveEventManager::fgUniformField = kFALSE;
8661a211 128
4d62585e 129AliEveEventManager* AliEveEventManager::fgMaster = 0;
130AliEveEventManager* AliEveEventManager::fgCurrent = 0;
131
be736e6d 132AliEveEventManager::AliEveEventManager(const TString& name, Int_t ev) :
b686c9db 133TEveEventManager(name, ""),
134fEventId(-1),
135fRunLoader (0),
136fESDFile (0), fESDTree (0), fHLTESDTree(0), fESD (0),
137fESDfriend (0), fESDfriendExists(kFALSE),
138fAODFile (0), fAODTree (0), fAOD (0),
139fRawReader (0), fEventInfo(),
140fAutoLoad (kFALSE),fLoopMarked(kFALSE), fAutoLoadTime (5),fAutoLoadTimer(0),
141fIsOpen (kFALSE), fHasEvent(kFALSE),
142fGlobal (0), fGlobalReplace (kTRUE), fGlobalUpdate (kTRUE),
143fExecutor (0), fTransients(0), fTransientLists(0),
144fPEventSelector(0),
145fSubManagers (0),
146fAutoLoadTimerRunning(kFALSE),
147fMutex(new TMutex()),
148fgSubSock(EVENTS_SERVER_SUB),
149fCurrentRun(-1),
150fEventInUse(1),
151fWritingToEventIndex(0),
152fIsNewEventAvaliable(false),
153fOnlineMode(kFALSE),
154fStorageDown(false),
155fFinished(false)
5a5a1232 156{
be736e6d 157 // Constructor with event-id.
b686c9db 158 if (0 == name.CompareTo("online")) {fOnlineMode = kTRUE;}
159 else{fOnlineMode = kFALSE;}
160
161 InitInternals();
162
163 Open();
164 if (ev >= 0){GotoEvent(ev);}
164d3d29 165
166#ifdef ZMQ
c6229bec 167 if(fOnlineMode)
b686c9db 168 {
169 cout<<"ZMQ FOUND. Starting subscriber thread."<<endl;
170 fEventListenerThread = new TThread("fEventListenerThread",DispatchEventListener,(void*)this);
171 fEventListenerThread->Run();
172
173 // fStorageManagerWatcherThread = new TThread("fStorageManagerWatcherThread",DispatchStorageManagerWatcher,(void*)this);
174 //fStorageManagerWatcherThread->Run();
175 }
164d3d29 176#else
177 cout<<"NO ZMQ FOUND. Online events not avaliable."<<endl;
178#endif
5a5a1232 179}
180
a15e6d7d 181AliEveEventManager::~AliEveEventManager()
182{
2e29a658 183 // Destructor.
7f97b015 184
185 fFinished = true;
7f97b015 186 if(fEventListenerThread)
187 {
d2416c53 188 fEventListenerThread->Join();
7f97b015 189 fEventListenerThread->Kill();
190 delete fEventListenerThread;
572d0620 191 cout<<"listener thread killed and deleted"<<endl;
7f97b015 192 }
193 if(fStorageManagerWatcherThread)
194 {
d2416c53 195 fStorageManagerWatcherThread->Join();
7f97b015 196 fStorageManagerWatcherThread->Kill();
197 delete fStorageManagerWatcherThread;
572d0620 198 cout<<"storage watcher thread killed and deleted"<<endl;
7f97b015 199 }
200
2e29a658 201 fAutoLoadTimer->Stop();
202 fAutoLoadTimer->Disconnect("Timeout");
7f97b015 203 fAutoLoadTimer->Disconnect("AutoLoadNextEvent");
b686c9db 204
be2cafd0 205 if(fSubManagers){delete fSubManagers;}
7f97b015 206 if(fMutex){delete fMutex;}
572d0620 207 if (fIsOpen){Close();}
b686c9db 208
209 // fTransients->DecDenyDestroy();
210 // fTransients->Destroy();
211
212 // fTransientLists->DecDenyDestroy();
213 // fTransientLists->Destroy();
214
2e29a658 215 //delete fExecutor;
a15e6d7d 216}
217
0790c3e6 218void AliEveEventManager::GetNextEvent()
219{
220#ifdef ZMQ
b686c9db 221 if(!fOnlineMode){return;}
222 cout<<"\n\nGet next event called\n\n"<<endl;
223
626a3158 224 AliStorageEventManager *eventManager = AliStorageEventManager::GetEventManagerInstance();
0790c3e6 225 eventManager->CreateSocket(EVENTS_SERVER_SUB);
626a3158 226 eventManager->CreateSocket(SERVER_COMMUNICATION_REQ);
0790c3e6 227
228 fCurrentEvent[0]=0;
229 fCurrentEvent[1]=0;
b686c9db 230
0790c3e6 231 AliESDEvent *tmpEvent = NULL;
0790c3e6 232
626a3158 233 // get list of marked events:
234 struct listRequestStruct list;
b686c9db 235
626a3158 236 list.runNumber[0]=0;
237 list.runNumber[1]=999999;
238 list.eventNumber[0]=0;
239 list.eventNumber[1]=999999;
240 list.marked[0]=1;
241 list.marked[1]=1;
7dcdaa40 242 list.multiplicity[0]=0;
626a3158 243 list.multiplicity[1]=999999;
244 strcpy(list.system[0],"p-p");
7dcdaa40 245 strcpy(list.system[1],"");
626a3158 246
247 struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
248 requestMessage->messageType = REQUEST_LIST_EVENTS;
249 requestMessage->list = list;
250
5c7e574d 251 cout<<"Sending request for marked events list"<<endl;
626a3158 252 eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
5c7e574d 253 cout<<"Waiting for response"<<endl;
61689781 254 vector<serverListStruct> receivedList = eventManager->GetServerListVector(SERVER_COMMUNICATION_REQ,3000);
626a3158 255 cout<<"EVENT DISPLAY -- received list of marked events"<<endl;
256
b686c9db 257 for(int i=0;i<receivedList.size();i++){cout<<"ev:"<<receivedList[i].eventNumber<<endl;}
626a3158 258 int iter=0;
b686c9db 259
5c7e574d 260 cout<<"Starting subscriber's loop"<<endl;
7f97b015 261 while(!fFinished)
0790c3e6 262 {
572d0620 263 if(!fLoopMarked || receivedList.size()<=0)
626a3158 264 {
b686c9db 265 cout<<"Waiting for event from online reconstruction...";
572d0620 266 tmpEvent = eventManager->GetEvent(EVENTS_SERVER_SUB,5000);
b686c9db 267 cout<<"received.";
626a3158 268 if(!tmpEvent){sleep(1);}
269 }
270 else
271 {
626a3158 272 if(iter<receivedList.size())
273 {
efaef546 274 cout<<"i:"<<iter<<endl;
626a3158 275 struct eventStruct mark;
276 mark.runNumber = receivedList[iter].runNumber;
277 mark.eventNumber = receivedList[iter].eventNumber;
b686c9db 278
626a3158 279 requestMessage->messageType = REQUEST_GET_EVENT;
280 requestMessage->event = mark;
b686c9db 281 cout<<"Waiting for event from Storage Manager...";
626a3158 282 eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
283 tmpEvent = eventManager->GetEvent(SERVER_COMMUNICATION_REQ);
b686c9db 284 cout<<"received.";
626a3158 285 iter++;
286 sleep(1);
287 }
288 else{iter=0;}
289 }
290
0790c3e6 291 if(tmpEvent)
7f97b015 292 {
b686c9db 293 cout<<" ("<<tmpEvent->GetRunNumber();
0790c3e6 294 if(tmpEvent->GetRunNumber()>=0)
7f97b015 295 {
296 fMutex->Lock();
0790c3e6 297 if(fEventInUse == 0){fWritingToEventIndex = 1;}
298 else if(fEventInUse == 1){fWritingToEventIndex = 0;}
b686c9db 299 cout<<","<<tmpEvent->GetEventNumberInFile()<<")"<<endl;
0790c3e6 300 if(fCurrentEvent[fWritingToEventIndex])
7f97b015 301 {
0790c3e6 302 delete fCurrentEvent[fWritingToEventIndex];
303 fCurrentEvent[fWritingToEventIndex]=0;
7f97b015 304 }
0790c3e6 305 fCurrentEvent[fWritingToEventIndex] = tmpEvent;
0790c3e6 306 fIsNewEventAvaliable = true;
7f97b015 307 NewEventLoaded();
308 fMutex->UnLock();
309 }
310 }
b686c9db 311 else{cout<<"Did not receive new event."<<endl;}
312
7f97b015 313 }
626a3158 314 delete requestMessage;
315
0790c3e6 316#endif
317}
318
319void AliEveEventManager::CheckStorageStatus()
320{
321#ifdef ZMQ
b686c9db 322 if(!fOnlineMode){return;}
323
0790c3e6 324 AliEveConfigManager *configManager = AliEveConfigManager::GetMaster();
325 configManager->ConnectEventManagerSignals();
326
327 AliStorageEventManager *eventManager = AliStorageEventManager::GetEventManagerInstance();
328 eventManager->CreateSocket(CLIENT_COMMUNICATION_REQ);
329
330 struct clientRequestStruct *request = new struct clientRequestStruct;
331 request->messageType = REQUEST_CONNECTION;
332
7f97b015 333 while (!fFinished)
0790c3e6 334 {
335 if(eventManager->Send(request,CLIENT_COMMUNICATION_REQ,5000))
336 {
337 StorageManagerOk();
0790c3e6 338 long response = eventManager->GetLong(CLIENT_COMMUNICATION_REQ);
b686c9db 339 fStorageDown = kFALSE;
0790c3e6 340 }
341 else
342 {
343 StorageManagerDown();
344 cout<<"WARNING -- Storage Manager is DOWN!!"<<endl;
7f97b015 345 fStorageDown = kTRUE;
0790c3e6 346 }
347 sleep(1);
348 }
572d0620 349
350 AliEveEventManager *manager = AliEveEventManager::GetCurrent();
351 manager->Disconnect("StorageManagerOk");
352 manager->Disconnect("StorageManagerDown");
353
0790c3e6 354#endif
355}
356
357void AliEveEventManager::InitInternals()
358{
359 // Initialize internal members.
360
361 static const TEveException kEH("AliEveEventManager::InitInternals ");
362
b686c9db 363 if (fgCurrent != 0){
0790c3e6 364 throw(kEH + "Dependent event-managers should be created via static method AddDependentManager().");
365 }
366
b686c9db 367 if (fgMaster == 0){fgMaster = this;}
0790c3e6 368 fgCurrent = this;
369
370 fAutoLoadTimer = new TTimer;
371 fAutoLoadTimer->Connect("Timeout()", "AliEveEventManager", this, "AutoLoadNextEvent()");
372 fAutoLoadTimer->Connect("Timeout()", "AliEveEventManager", this, "Timeout()");
373
374 fExecutor = new AliEveMacroExecutor;
375
376 fTransients = new TEveElementList("Transients", "Transient per-event elements.");
377 fTransients->IncDenyDestroy();
378 gEve->AddToListTree(fTransients, kFALSE);
379
380 fTransientLists = new TEveElementList("Transient Lists", "Containers of transient elements.");
381 fTransientLists->IncDenyDestroy();
382 gEve->AddToListTree(fTransientLists, kFALSE);
383
384 fPEventSelector = new AliEveEventSelector(this);
385
386 fGlobal = new TMap; fGlobal->SetOwnerKeyValue();
387}
388
57ffa5fb 389/******************************************************************************/
5a5a1232 390
51104899 391void AliEveEventManager::SetESDFileName(const TString& esd, EVisibleESDTrees shown)
c2c4b7a2 392{
51104899 393 fgESDvisibleTrees = shown;
2e29a658 394 // Set file-name for opening ESD, default "AliESDs.root".
be736e6d 395 if (esd.IsNull()) return;
b686c9db 396
be736e6d 397 fgESDFileName = esd;
398 if (esd.EndsWith(".zip")) fgESDFileName.Form("%s#AliESDs.root",esd.Data());
be736e6d 399}
c2c4b7a2 400
be736e6d 401void AliEveEventManager::SetESDfriendFileName(const TString& esdf)
402{
403 // Set file-name for opening ESD friend, default "AliESDfriends.root".
be736e6d 404 if (esdf.IsNull()) return;
405 fgESDfriendsFileName = esdf;
406
407 if (esdf.EndsWith(".zip")) fgESDfriendsFileName.Form("%s#AliESDfriends.root",esdf.Data());
c2c4b7a2 408}
409
b3b7b8d3 410void AliEveEventManager::SetAODFileName(const TString& aod)
411{
2e29a658 412 // Set file-name for opening AOD, default "AliAOD.root".
be736e6d 413 if (aod.IsNull()) return;
414 fgAODFileName = aod;
415
416 if (aod.EndsWith(".zip")) fgAODFileName.Form("%s#AliAOD.root",aod.Data());
b3b7b8d3 417}
418
419void AliEveEventManager::AddAODfriend(const TString& friendFileName)
420{
2e29a658 421 // Add new AOD friend file-name to be attached when opening AOD.
422 // This should include '.root', as in 'AliAOD.VertexingHF.root'.
b686c9db 423
2e29a658 424 if (fgAODfriends == 0)
425 {
426 fgAODfriends = new TList;
427 fgAODfriends->SetOwner(kTRUE);
428 }
429 if (fgAODfriends->FindObject(friendFileName) == 0)
430 {
431 fgAODfriends->Add(new TObjString(friendFileName));
432 }
b3b7b8d3 433}
434
4d62585e 435void AliEveEventManager::SetRawFileName(const TString& raw)
c2c4b7a2 436{
2e29a658 437 // Set file-name for opening of raw-data, default "raw.root"
be736e6d 438 if (raw.IsNull()) return;
439
440 fgRawFileName = raw;
c2c4b7a2 441}
442
4d62585e 443void AliEveEventManager::SetCdbUri(const TString& cdb)
c2c4b7a2 444{
2e29a658 445 // Set path to CDB, there is no default.
2e29a658 446 if ( ! cdb.IsNull()) fgCdbUri = cdb;
c2c4b7a2 447}
448
566ba262 449void AliEveEventManager::SetSpecificCdbUri(const TString& path,const TString& value)
450{
451 // Set path to specific CDB object, there is no default.
b686c9db 452 if ( ! value.IsNull()) fgSpecificCdbUriValue = value;
453 if ( ! path.IsNull()) fgSpecificCdbUriPath = path;
566ba262 454}
455
be736e6d 456void AliEveEventManager::SetGAliceFileName(const TString& galice)
457{
458 // Set file-name for opening gAlice, default "galice.root".
b686c9db 459
be736e6d 460 if ( galice.IsNull()) return;
51104899 461 fgGAliceFileName = galice;
be736e6d 462
463 if (galice.EndsWith(".zip")) fgGAliceFileName.Form("%s#galice.root",galice.Data());
464}
465
466void AliEveEventManager::SetFilesPath(const TString& urlPath)
467{
51104899 468 TString path = urlPath;
be736e6d 469 gSystem->ExpandPathName(path);
470 if (path.IsNull() || path == ".")
471 {
472 path = gSystem->WorkingDirectory();
473 }
b686c9db 474
51104899 475 TString sep;
476 if(path.EndsWith(".zip")) // if given a path to root_archive.zip
477 sep= "#";
478 else if(!path.EndsWith("/"))
479 sep = "/";
be736e6d 480
481 SetESDFileName( TString(Form("%s%sAliESDs.root", path.Data(), sep.Data())) );
482 SetESDfriendFileName( TString(Form("%s%sAliESDfriends.root", path.Data(), sep.Data())) );
483 SetAODFileName( TString(Form("%s%sAliAOD.root", path.Data(), sep.Data())) );
484 AddAODfriend( TString(Form("%s%sAliAOD.VertexingHF.root", path.Data(), sep.Data())) );
485 SetGAliceFileName( TString(Form("%s%sgalice.root", path.Data(), sep.Data())) );
486 SetRawFileName(TString(Form("%s%sraw.root", path.Data(), sep.Data())));
487}
488
b3b7b8d3 489void AliEveEventManager::SetAssertElements(Bool_t assertRunloader, Bool_t assertEsd,
2e29a658 490 Bool_t assertAod, Bool_t assertRaw)
c2c4b7a2 491{
2e29a658 492 // Set global flags that detrmine which parts of the event-data must
493 // be present when the event is opened.
b686c9db 494
2e29a658 495 fgAssertRunLoader = assertRunloader;
496 fgAssertESD = assertEsd;
497 fgAssertAOD = assertAod;
498 fgAssertRaw = assertRaw;
c2c4b7a2 499}
500
25dddcb1 501void AliEveEventManager::SearchRawForCentralReconstruction()
502{
2e29a658 503 // Enable searching of raw data in standard location. The path passed to
504 // Open() is expected to point to a centrally reconstructed run, e.g.:
505 // "alien:///alice/data/2009/LHC09c/000101134/ESDs/pass1/09000101134018.10".
b686c9db 506
2e29a658 507 fgRawFromStandardLoc = kTRUE;
25dddcb1 508}
509
c2c4b7a2 510/******************************************************************************/
511
d810d0de 512void AliEveEventManager::Open()
5a5a1232 513{
be736e6d 514 // Open event-data from URL specified in path.
2e29a658 515 // Attempts to create AliRunLoader() and to open ESD with ESDfriends.
516 // Warning is reported if run-loader or ESD is not found.
517 // Global data-members fgAssertRunLoader and fgAssertESD can be set
518 // to throw exceptions instead.
b686c9db 519
2e29a658 520 static const TEveException kEH("AliEveEventManager::Open ");
b686c9db 521 if (fIsOpen){throw (kEH + "Event-files already opened.");}
522
523 Int_t runNo = -1;
524
525 // Open ESD and ESDfriends
526 if(fOnlineMode)
2e29a658 527 {
b686c9db 528 InitOCDB(runNo);
529 fIsOpen = kTRUE;
530 return;
ea8fceef 531 }
b686c9db 532
533 if ((fESDFile = TFile::Open(fgESDFileName)))
ea8fceef 534 {
b686c9db 535 fESD = new AliESDEvent();
536
537 switch(fgESDvisibleTrees){
538 case AliEveEventManager::kOfflineTree :
539 fESDTree = readESDTree("esdTree", runNo);
540 break;
541 case AliEveEventManager::kHLTTree :
542 fHLTESDTree = readESDTree("HLTesdTree", runNo);
543 break;
544 default:
545 fESDTree = readESDTree("esdTree", runNo);
546 fHLTESDTree = readESDTree("HLTesdTree", runNo);
547 }
548
549 if(!fESDTree && !fHLTESDTree){
550 // both ESD trees are == 0
551 delete fESDFile; fESDFile = 0;
552 delete fESD; fESD = 0;
553 }
554
555
c2c4b7a2 556 }
b686c9db 557 else{Warning(kEH, "can not read ESD file '%s'.", fgESDFileName.Data());}
558 if (fESDTree == 0 && fHLTESDTree==0)
559 {
560 if (fgAssertESD){throw (kEH + "ESD not initialized. Its precence was requested.");}
561 else {Warning(kEH, "ESD not initialized.");}
562 }
563
564 // Open AOD and registered friends
565 if ( (fAODFile = TFile::Open(fgAODFileName)) )
566 {
567 fAOD = new AliAODEvent();
568 fAODTree = (TTree*) fAODFile->Get("aodTree");
569 if (fAODTree != 0)
570 {
571 // Check if AODfriends exist and attach them.
572 TIter friends(fgAODfriends);
573 TObjString *name;
574 while ((name = (TObjString*) friends()) != 0)
575 {
576 TString p(Form("%s/%s", fgAODFileName.Data(), name->GetName()));
577 if (fgAODFileName.EndsWith(".zip")) p.Form("%s#%s",fgAODFileName.Data(),name->GetName());
578 if (gSystem->AccessPathName(p, kReadPermission) == kFALSE)
579 {
580 fAODTree->AddFriend("aodTree", name->GetName());
581 }
582 }
583
584 fAOD->ReadFromTree(fAODTree);
585
586 if (fAODTree->GetEntry(0) <= 0)
587 {
588 delete fAODFile; fAODFile = 0;
589 delete fAOD; fAOD = 0;
590 Warning(kEH, "failed getting the first entry from addTree.");
591 }
592 else if (runNo < 0){runNo = fAOD->GetRunNumber();}
593 }
594 else // aodtree == 0
595 {
596 delete fAODFile; fAODFile = 0;
597 delete fAOD; fAOD = 0;
598 Warning(kEH, "failed getting the aodTree.");
599 }
600 }
601 else // aod not readable
602 {
603 Warning(kEH, "can not read AOD file '%s'.", fgAODFileName.Data());
604 }
605 if (fAODTree == 0)
606 {
607 if (fgAssertAOD){throw (kEH + "AOD not initialized. Its precence was requested.");}
608 else {Warning(kEH, "AOD not initialized.");}
609 }
610
611 // Open RunLoader from galice.root
612 // fgGAliceFileName = "/Users/Jerus/galice.root"; // temp
613
614 TFile *gafile = TFile::Open(fgGAliceFileName);
615 cout<<"Opening galice"<<endl;
616 if (gafile)
617 {
618 gafile->Close();
619 delete gafile;
620 cout<<"SETTING RUN LOADER in Open()"<<endl;
621 fRunLoader = AliRunLoader::Open(fgGAliceFileName, GetName());
622 if (fRunLoader)
623 {
624 TString alicePath(gSystem->DirName(fgGAliceFileName));
625 alicePath.Append("/");
626 fRunLoader->SetDirName(alicePath);
627
628 if (fRunLoader->LoadgAlice() != 0){Warning(kEH, "failed loading gAlice via run-loader.");}
629
630 if (fRunLoader->LoadHeader() == 0 && runNo < 0){
631 runNo = fRunLoader->GetHeader()->GetRun();
632 }
633 else{
634 Warning(kEH, "failed loading run-loader's header.");
635 delete fRunLoader;
636 fRunLoader = 0;
637 }
638 }
639 else{Warning(kEH, "failed opening ALICE run-loader from '%s'.", fgGAliceFileName.Data());}
640 }
641 else{Warning(kEH, "can not read '%s'.", fgGAliceFileName.Data());}
642
643 if (fRunLoader == 0)
644 {
645 if (fgAssertRunLoader){throw (kEH + "Bootstraping of run-loader failed. Its precence was requested.");}
646 else{Warning(kEH, "Bootstraping of run-loader failed.");}
647 }
648
649 // Open raw-data file
650 TString rawPath;
651 if (fgRawFromStandardLoc)
652 {
653 if (!fgRawFileName.BeginsWith("alien:")){
654 throw kEH + "Standard raw search requested, but the directory is not in AliEn.";
655 }
656 if (!fgRawFileName.Contains("/ESDs/")){
657 throw kEH + "Standard raw search requested, but does not contain 'ESDs' directory.";
658 }
659
660 TPMERegexp chunk("/([\\d\\.])+/?$");
661 Int_t nm = chunk.Match(fgRawFileName);
662 if (nm != 2){
663 throw kEH + "Standard raw search requested, but the path does not end with chunk-id directory.";
664 }
665
666 TPMERegexp esdstrip("/ESDs/.*");
667 rawPath = fgRawFileName;
668 esdstrip.Substitute(rawPath, "/raw/");
669 rawPath += chunk[0];
670 rawPath += ".root";
be736e6d 671
b686c9db 672 Info(kEH, "Standard raw search requested, using the following path:\n %s\n", rawPath.Data());
673 }
674 else
675 {
676 rawPath = fgRawFileName;
677 }
678
679 // If i use open directly, raw-reader reports an error but i have
680 // no way to detect it.
681 // Is this (AccessPathName check) ok for xrootd / alien? Yes, not for http.
682 AliLog::EType_t oldLogLevel = (AliLog::EType_t) AliLog::GetGlobalLogLevel();
683 if (fgAssertRaw == kFALSE){AliLog::SetGlobalLogLevel(AliLog::kFatal);}
684
685 if (gSystem->AccessPathName(rawPath, kReadPermission) == kFALSE){
686 fRawReader = AliRawReader::Create(rawPath);
687 }
688 else{
689 fRawReader = AliRawReader::Create(fgRawFileName);
690 }
691
692 if (fgAssertRaw == kFALSE){AliLog::SetGlobalLogLevel(oldLogLevel);}
693
694 if (fRawReader == 0)
695 {
696 if (fgAssertRaw){throw (kEH + "raw-data not initialized. Its precence was requested.");}
697 else{Warning(kEH, "raw-data not initialized.");}
698 }
699
700 if (runNo < 0)
701 {
702 if (fRawReader)
703 {
704 if (!fRawReader->NextEvent()){throw (kEH + "can not go to first event in raw-reader to determine run-id.");}
705 runNo = fRawReader->GetRunNumber();
706 Info(kEH, "Determining run-no from raw ... run=%d.", runNo);
707 fRawReader->RewindEvents();
708 }
709 else
710 {
711 fEventId = 0;
712 return;
713 }
714 }
715
2e29a658 716 // Initialize OCDB ... only in master event-manager
7dcdaa40 717 InitOCDB(runNo);
ef795f0b 718 fIsOpen = kTRUE;
719}
720
721void AliEveEventManager::InitOCDB(int runNo)
722{
b686c9db 723 TString cdbPath = Form("local://%s/ed_ocdb_objects/",gSystem->Getenv("HOME"));
724 AliCDBManager* cdb = AliCDBManager::Instance();
85506449 725#ifdef ZMQ
b686c9db 726 if(fOnlineMode)
727 {
728 if(runNo != fCurrentRun)
729 {
730 cout<<"Loading OCDB for new run:"<<runNo<<" in online mode."<<endl;
731 TEnv settings;
732 settings.ReadFile(AliOnlineReconstructionUtil::GetPathToServerConf(), kEnvUser);
733 fCurrentRun = runNo;
734 cout<<"config read"<<endl;
735
736 // Retrieve GRP entry for given run from aldaqdb.
737 TString dbHost = settings.GetValue("logbook.host", DEFAULT_LOGBOOK_HOST);
738 Int_t dbPort = settings.GetValue("logbook.port", DEFAULT_LOGBOOK_PORT);
739 TString dbName = settings.GetValue("logbook.db", DEFAULT_LOGBOOK_DB);
740 TString user = settings.GetValue("logbook.user", DEFAULT_LOGBOOK_USER);
741 TString password = settings.GetValue("logbook.pass", DEFAULT_LOGBOOK_PASS);
742
743 gSystem->cd(cdbPath.Data());
744 gSystem->Exec("rm -fr GRP/");
745 cout<<"CDB path for GRP:"<<cdbPath<<endl;
746
747 TString gdc;
748
749 Int_t ret=AliGRPPreprocessor::ReceivePromptRecoParameters(fCurrentRun, dbHost.Data(),
750 dbPort, dbName.Data(),
751 user.Data(), password.Data(),
752 Form("%s",cdbPath.Data()),
753 gdc);
754
755 if(ret>0) Info("RetrieveGRP","Last run of the same type is: %d",ret);
756 else if(ret==0) Warning("RetrieveGRP","No previous run of the same type found");
757 else if(ret<0) Error("Retrieve","Error code while retrieving GRP parameters returned: %d",ret);
758
759
760 cdb->SetDefaultStorage(settings.GetValue("cdb.defaultStorage", DEFAULT_CDB_STORAGE));
761 cdb->SetSpecificStorage("GRP/GRP/Data",cdbPath.Data());
762 cdb->SetRun(fCurrentRun);
763 cdb->Print();
764 }
7dcdaa40 765 }
85506449 766#endif
b686c9db 767
768 static const TEveException kEH("AliEveEventManager::InitOCDB ");
ef795f0b 769 //if (this == fgMaster)
2e29a658 770 {
2e29a658 771 if (cdb->IsDefaultStorageSet() == kTRUE)
772 {
773 Warning(kEH, "CDB already set - using the old storage:\n '%s'",
774 cdb->GetDefaultStorage()->GetURI().Data());
775 }
776 else
777 {
778 if (fgCdbUri.IsNull())
779 {
780 gEnv->SetValue("Root.Stacktrace", "no");
781 Fatal("Open()", "OCDB path was not specified.");
782 }
b686c9db 783 cout<<"Setting default storage:"<<fgCdbUri<<endl;
2e29a658 784 // Handle some special cases for MC (should be in OCDBManager).
785 if (fgCdbUri == "mcideal://")
786 cdb->SetDefaultStorage("MC", "Ideal");
787 else if (fgCdbUri == "mcresidual://")
788 cdb->SetDefaultStorage("MC", "Residual");
789 else if (fgCdbUri == "mcfull://")
790 cdb->SetDefaultStorage("MC", "Full");
566ba262 791 else if (fgCdbUri == "local://"){
b686c9db 792 fgCdbUri = Form("local://%s/OCDB", gSystem->Getenv("ALICE_ROOT"));
793 cdb->SetDefaultStorage(fgCdbUri);
794 }
795 else{
796 cdb->SetDefaultStorage(fgCdbUri);
797 }
2e29a658 798 cdb->SetRun(runNo);
b686c9db 799
800 if (cdb->IsDefaultStorageSet() == kFALSE){throw kEH + "CDB initialization failed for '" + fgCdbUri + "'.";}
801 }
802 /*
2e29a658 803 if (fgCdbUri.BeginsWith("local://"))
804 {
be736e6d 805 TString curPath = gSystem->WorkingDirectory();
2e29a658 806 TString grp = "GRP/GRP/Data";
be736e6d 807 TString grppath = curPath + "/" + grp;
2e29a658 808 if (gSystem->AccessPathName(grppath, kReadPermission) == kFALSE)
809 {
b686c9db 810 if (cdb->GetSpecificStorage(grp)){
2e29a658 811 Warning(kEH, "Local GRP exists, but the specific storage is already set.");
812 }
b686c9db 813 else{
2e29a658 814 Info(kEH, "Setting CDB specific-storage for GRP from event directory.");
815 TString lpath("local://");
be736e6d 816 lpath += curPath;
2e29a658 817 cdb->SetSpecificStorage(grp, lpath);
818 }
819 }
b686c9db 820 }
821 */
2e29a658 822 }
5a5a1232 823}
824
482d0751 825void AliEveEventManager::SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd, AliESDfriend *esdf)
319f3084 826{
2e29a658 827 // Set an event from an external source.
828 // The method is used in the online visualisation.
829 // AOD is not supported.
b686c9db 830
2e29a658 831 static const TEveException kEH("AliEveEventManager::SetEvent ");
b686c9db 832
2e29a658 833 if (fIsOpen)
834 {
835 Warning(kEH, "Event-files were open. Closing and switching to external control.");
836 Close();
837 }
b686c9db 838
839 Info(kEH,"setting it!!! ============================");
840
2e29a658 841 fRunLoader = runLoader;
842 fRawReader = rawReader;
843 fESD = esd;
844 fESDfriend = esdf;
845 fAOD = 0;
b686c9db 846
2e29a658 847 fEventId++;
b686c9db 848 fHasEvent = kTRUE;
849
2e29a658 850 SetTitle("Online event in memory");
851 SetName ("Online Event");
852 ElementChanged();
b686c9db 853
2e29a658 854 AfterNewEventLoaded();
b686c9db 855
626a3158 856 if (fAutoLoad || fLoopMarked) StartAutoLoadTimer();
ef795f0b 857
319f3084 858}
859
96b90c2e 860Int_t AliEveEventManager::GetMaxEventId(Bool_t refreshESD) const
516389a2 861{
2e29a658 862 // Returns maximum available event id.
863 // If under external control or event is not opened -1 is returned.
864 // If raw-data is the only data-source this can not be known
865 // and 10,000,000 is returned.
866 // If neither data-source is initialised an exception is thrown.
867 // If refresh_esd is true and ESD is the primary event-data source
868 // its header is re-read from disk.
b686c9db 869
2e29a658 870 static const TEveException kEH("AliEveEventManager::GetMaxEventId ");
b686c9db 871
872 if (fIsOpen == kFALSE || fOnlineMode)
2e29a658 873 {
874 return -1;
875 }
b686c9db 876
51104899 877 if ((fESDTree!=0) || (fHLTESDTree!=0))
2e29a658 878 {
879 if (refreshESD)
880 {
9a0ed9e2 881 if(fESDTree!=0) fESDTree->Refresh();
882 if(fHLTESDTree!=0) fHLTESDTree->Refresh();
2e29a658 883 fPEventSelector->Update();
884 }
b686c9db 885
51104899 886 Int_t maxEventId=0;
887 switch(fgESDvisibleTrees){
b686c9db 888 default:
889 case AliEveEventManager::kOfflineTree :
890 maxEventId = fESDTree->GetEntries() - 1;
891 break;
892 case AliEveEventManager::kHLTTree :
893 maxEventId = fHLTESDTree->GetEntries() - 1;
894 break;
895 }
896
51104899 897 return maxEventId;
2e29a658 898 }
899 else if (fAODTree)
900 {
901 return fAODTree->GetEntries() - 1;
902 }
903 else if (fRunLoader)
904 {
905 return fRunLoader->GetNumberOfEvents() - 1;
906 }
907 else if (fRawReader)
908 {
909 Int_t n = fRawReader->GetNumberOfEvents() - 1;
910 return n > -1 ? n : 10000000;
911 }
912 else
913 {
914 throw (kEH + "neither ESD, AOD, RunLoader nor Raw loaded.");
915 }
516389a2 916}
917
d810d0de 918void AliEveEventManager::GotoEvent(Int_t event)
1eaa5849 919{
fae81379 920 cout<<"Go to event:"<<event<<endl;
2e29a658 921 // Load data for specified event.
922 // If event is out of range an exception is thrown and old state
923 // is preserved.
924 // After successful loading of event, the virtual function
925 // AfterNewEventLoaded() is called. This executes commands that
926 // were registered via TEveEventManager::AddNewEventCommand().
927 //
928 // If event is negative, it is subtracted from the number of
929 // available events, thus passing -1 will load the last event.
930 // This is not supported when raw-data is the only data-source
931 // as the number of events is not known.
b686c9db 932
2e29a658 933 static const TEveException kEH("AliEveEventManager::GotoEvent ");
b686c9db 934
2e29a658 935 if (fAutoLoadTimerRunning)
936 {
937 throw (kEH + "Event auto-load timer is running.");
938 }
bccf4634 939 else if (!fIsOpen)
940 {
941 throw (kEH + "Event-files not opened.");
942 }
943
a410aca4 944#ifdef ZMQ
b686c9db 945 if(fOnlineMode)
946 {
947 if (fStorageDown && -1 == event)
948 {
949 NextEvent();
950 return;
951 }
952
953 if (fESD)
954 {
955 // create new server request:
956 struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
fae81379 957
b686c9db 958 // set request type:
959 if (event == -1) {requestMessage->messageType = REQUEST_GET_LAST_EVENT;}
960 else if (event == 0) {requestMessage->messageType = REQUEST_GET_FIRST_EVENT;}
961 else if (event == 1) {requestMessage->messageType = REQUEST_GET_PREV_EVENT;}
962 else if (event == 2) {requestMessage->messageType = REQUEST_GET_NEXT_EVENT;}
fae81379 963
b686c9db 964 // set event struct:
965 struct eventStruct eventToLoad;
966 eventToLoad.runNumber = fESD->GetRunNumber();
967 eventToLoad.eventNumber = fESD->GetEventNumberInFile();
968 requestMessage->event = eventToLoad;
fae81379 969
b686c9db 970 // create event manager:
971 AliStorageEventManager *eventManager =
972 AliStorageEventManager::GetEventManagerInstance();
973 AliESDEvent *resultEvent = NULL;
fae81379 974
b686c9db 975 eventManager->CreateSocket(SERVER_COMMUNICATION_REQ);
976 fMutex->Lock();
fae81379 977
b686c9db 978 // send request and receive event:
979 eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
980 resultEvent = eventManager->GetEvent(SERVER_COMMUNICATION_REQ);
fae81379 981
b686c9db 982 if(resultEvent)
983 {
984 DestroyElements();
985 InitOCDB(resultEvent->GetRunNumber());
986 SetEvent(0,0,resultEvent,0);
987 }
988 else
989 {
990 if(event==-1){cout<<"\n\nWARNING -- No last event is avaliable.\n\n"<<endl;}
991 if(event==0){cout<<"\n\nWARNING -- No first event is avaliable.\n\n"<<endl;}
992 if(event==1){cout<<"\n\nWARNING -- No previous event is avaliable.\n\n"<<endl;}
993 if(event==2){cout<<"\n\nWARNING -- No next event is avaliable.\n\n"<<endl;}
994 }
995
996 fMutex->UnLock();
997 }
998 else
999 {
1000 cout<<"\n\nWARNING -- No event has been already loaded. Loading the most recent event...\n\n"<<endl;
fae81379 1001
b686c9db 1002 struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
1003 requestMessage->messageType = REQUEST_GET_LAST_EVENT;
fae81379 1004
b686c9db 1005 AliStorageEventManager *eventManager = AliStorageEventManager::GetEventManagerInstance();
1006 eventManager->CreateSocket(SERVER_COMMUNICATION_REQ);
1007 AliESDEvent *resultEvent = NULL;
fae81379 1008
b686c9db 1009 fMutex->Lock();
1010 eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
1011 resultEvent = eventManager->GetEvent(SERVER_COMMUNICATION_REQ);
fae81379 1012
b686c9db 1013 if(resultEvent)
1014 {
1015 fESD=resultEvent;
1016 DestroyElements();
1017 InitOCDB(resultEvent->GetRunNumber());
1018 SetEvent(0,0,resultEvent,0);
1019 }
1020 else{cout<<"\n\nWARNING -- The most recent event is not avaliable.\n\n"<<endl;}
1021 fMutex->UnLock();
1022 }
1023 }
1024#endif
1025
1026
1027
2e29a658 1028 fEventInfo.Reset();
b686c9db 1029
2e29a658 1030 fHasEvent = kFALSE;
b686c9db 1031
2e29a658 1032 Int_t maxEvent = 0;
51104899 1033 if ((fESDTree!=0) || (fHLTESDTree!=0))
2e29a658 1034 {
51104899 1035 if(fESDTree){
1036 if (event >= fESDTree->GetEntries())
1037 fESDTree->Refresh();
1038 maxEvent = fESDTree->GetEntries() - 1;
1039 if (event < 0)
1040 event = fESDTree->GetEntries() + event;
1041 }
b686c9db 1042
51104899 1043 if(fHLTESDTree){
1044 if (event >= fHLTESDTree->GetEntries())
1045 fHLTESDTree->Refresh();
1046 maxEvent = fHLTESDTree->GetEntries() - 1;
1047 if (event < 0)
1048 event = fHLTESDTree->GetEntries() + event;
b686c9db 1049
51104899 1050 }
2e29a658 1051 }
1052 else if (fAODTree)
1053 {
1054 maxEvent = fAODTree->GetEntries() - 1;
1055 if (event < 0)
1056 event = fAODTree->GetEntries() + event;
1057 }
1058 else if (fRunLoader)
1059 {
1060 maxEvent = fRunLoader->GetNumberOfEvents() - 1;
1061 if (event < 0)
1062 event = fRunLoader->GetNumberOfEvents() + event;
1063 }
1064 else if (fRawReader)
1065 {
1066 maxEvent = fRawReader->GetNumberOfEvents() - 1;
1067 if (maxEvent < 0)
1068 {
1069 maxEvent = 10000000;
1070 if (event < 0) {
1071 Error(kEH, "current raw-data source does not support direct event access.");
1072 return;
1073 }
1074 Info(kEH, "number of events unknown for current raw-data source, setting max-event id to 10M.");
1075 }
1076 else
1077 {
1078 if (event < 0)
1079 event = fRawReader->GetNumberOfEvents() + event;
1080 }
ae1a1b11 1081 }
1082 else
1083 {
2e29a658 1084 throw (kEH + "neither RunLoader, ESD nor Raw loaded.");
1085 }
7dcdaa40 1086 if (event < 0)
2e29a658 1087 {
1088 throw (kEH + Form("event %d not present, available range [%d, %d].",
1089 event, 0, maxEvent));
1090 }
7dcdaa40 1091 if (event > maxEvent)
1092 {
b686c9db 1093 event=0;
1094 cout<<"Event number out of range. Going to event 0"<<endl;
7dcdaa40 1095 }
b686c9db 1096
2e29a658 1097 TString sysInfoHeader;
1098 sysInfoHeader.Form("AliEveEventManager::GotoEvent(%d) - ", event);
1099 AliSysInfo::AddStamp(sysInfoHeader + "Start");
b686c9db 1100
2e29a658 1101 TEveManager::TRedrawDisabler rd(gEve);
1102 gEve->Redraw3D(kFALSE, kTRUE); // Enforce drop of all logicals.
b686c9db 1103
2e29a658 1104 // !!! MT this is somewhat brutal; at least optionally, one could be
1105 // a bit gentler, checking for objs owning their external refs and having
1106 // additinal parents.
1107 gEve->GetViewers()->DeleteAnnotations();
1108 fTransients->DestroyElements();
1109 for (TEveElement::List_i i = fTransientLists->BeginChildren();
1110 i != fTransientLists->EndChildren(); ++i)
1111 {
1112 (*i)->DestroyElements();
1113 }
1114 DestroyElements();
b686c9db 1115
2e29a658 1116 AliSysInfo::AddStamp(sysInfoHeader + "PostDestroy");
b686c9db 1117
2e29a658 1118 if (fESDTree) {
1119 if (fESDTree->GetEntry(event) <= 0)
1120 throw (kEH + "failed getting required event from ESD.");
b686c9db 1121
2e29a658 1122 if (fESDfriendExists)
1123 fESD->SetESDfriend(fESDfriend);
1124 }
b686c9db 1125
51104899 1126 if (fHLTESDTree) {
1127 if (fHLTESDTree->GetEntry(event) <= 0)
1128 throw (kEH + "failed getting required event from HLT ESD.");
b686c9db 1129
51104899 1130 if (fESDfriendExists)
1131 fESD->SetESDfriend(fESDfriend);
1132 }
b686c9db 1133
2e29a658 1134 if (fAODTree) {
1135 if (fAODTree->GetEntry(event) <= 0)
1136 throw (kEH + "failed getting required event from AOD.");
1137 }
b686c9db 1138
2e29a658 1139 if (fRunLoader) {
1140 if (fRunLoader->GetEvent(event) != 0)
1141 throw (kEH + "failed getting required event.");
1142 }
b686c9db 1143
2e29a658 1144 if (fRawReader)
1145 {
1146 // AliRawReader::GotoEvent(Int_t) works for AliRawReaderRoot/Chain.
1147 if (fRawReader->GotoEvent(event) == kFALSE)
ca49b003 1148 {
2e29a658 1149 // Use fallback method - iteration with NextEvent().
1150 Int_t rawEv = fEventId;
1151 if (event < rawEv)
1152 {
1153 fRawReader->RewindEvents();
1154 rawEv = -1;
1155 }
b686c9db 1156
2e29a658 1157 while (rawEv < event)
1158 {
1159 if ( ! fRawReader->NextEvent())
1160 {
1161 fRawReader->RewindEvents();
1162 fEventId = -1;
1163 throw (kEH + Form("Error going to next raw-event from event %d.", rawEv));
1164 }
1165 ++rawEv;
1166 }
1167 Warning(kEH, "Loaded raw-event %d with fallback method.\n", rawEv);
ca49b003 1168 }
ca49b003 1169 }
b686c9db 1170
2e29a658 1171 fHasEvent = kTRUE;
1172 fEventId = event;
1173 if (this == fgMaster)
1174 {
1175 SetName(Form("Event %d", fEventId));
1176 ElementChanged();
1177 }
b686c9db 1178
2e29a658 1179 AliSysInfo::AddStamp(sysInfoHeader + "PostLoadEvent");
b686c9db 1180
2e29a658 1181 AfterNewEventLoaded();
b686c9db 1182
2e29a658 1183 AliSysInfo::AddStamp(sysInfoHeader + "PostUserActions");
1eaa5849 1184}
1185
e10d437c 1186void AliEveEventManager::Timeout()
1187{
2e29a658 1188 Emit("Timeout()");
e10d437c 1189}
1190
164d3d29 1191void AliEveEventManager::PrepareForNewEvent(AliESDEvent *event)
b686c9db 1192{
1193 DestroyElements();
1194 InitOCDB(event->GetRunNumber());
1195 printf("======================= setting event to %d\n", fEventId);
1196 SetEvent(0,0,event,0);
164d3d29 1197}
1198
516389a2 1199void AliEveEventManager::NextEvent()
1200{
2e29a658 1201 // Loads next event.
1202 // Does magick needed for online display when under external event control.
b686c9db 1203
2e29a658 1204 static const TEveException kEH("AliEveEventManager::NextEvent ");
b686c9db 1205
1206 if (fAutoLoadTimerRunning){throw (kEH + "Event auto-load timer is running.");}
fae81379 1207
bccf4634 1208 if(fOnlineMode)
b686c9db 1209 {
164d3d29 1210#ifdef ZMQ
b686c9db 1211
1212 if(fIsNewEventAvaliable)
1213 {
1214 fMutex->Lock();
1215 if(fWritingToEventIndex == 0) fEventInUse = 0;
1216 else if(fWritingToEventIndex == 1) fEventInUse = 1;
fae81379 1217
b686c9db 1218 if(fCurrentEvent[fEventInUse])
1219 {
1220 if(fCurrentEvent[fEventInUse]->GetRunNumber() >= 0)
1221 {
1222 printf("======================= setting event to %d\n", fCurrentEvent[fEventInUse]->GetEventNumberInFile());
fae81379 1223
b686c9db 1224 DestroyElements();
1225 InitOCDB(fCurrentEvent[fEventInUse]->GetRunNumber());
1226 SetEvent(0,0,fCurrentEvent[fEventInUse],0);
7f97b015 1227
b686c9db 1228 }
1229 }
1230 fIsNewEventAvaliable = false;
1231 fMutex->UnLock();
1232 }
1233 else
1234 {
1235 cout<<"No new event is avaliable."<<endl;
1236 NoEventLoaded();
1237 }
fae81379 1238#endif
b686c9db 1239 }
51104899 1240 else if ((fESDTree!=0) || (fHLTESDTree!=0))
ecb84424 1241 {
b686c9db 1242 cout<<"There is ESD or HLTESD tree"<<endl;
1243 Int_t nextevent=0;
1244 if (fPEventSelector->FindNext(nextevent))
1245 {
1246 cout<<"GotoEvent:"<<nextevent<<endl;
1247 GotoEvent(nextevent);
1248 }
2e29a658 1249 }
1250 else if (fEventId < GetMaxEventId(kTRUE))
1251 {
b686c9db 1252 cout<<"GotoEvent:"<<fEventId+1<<endl;
1253 GotoEvent(fEventId + 1);
ecb84424 1254 }
36b10b4d 1255 else
b686c9db 1256 {
1257 cout<<"Going back to event 0"<<endl;
1258 GotoEvent(0);
1259 }
ef795f0b 1260
164d3d29 1261 gSystem->ProcessEvents();
0790c3e6 1262
0790c3e6 1263 //if(fEventListenerThread){delete fEventListenerThread;fEventListenerThread=0;}
516389a2 1264}
1265
1266void AliEveEventManager::PrevEvent()
1267{
2e29a658 1268 // Loads previous event.
b686c9db 1269
2e29a658 1270 static const TEveException kEH("AliEveEventManager::PrevEvent ");
b686c9db 1271
2e29a658 1272 if (fAutoLoadTimerRunning)
1273 {
1274 throw (kEH + "Event auto-load timer is running.");
1275 }
b686c9db 1276
51104899 1277 if ((fESDTree!=0) || (fHLTESDTree!=0))
2e29a658 1278 {
1279 Int_t nextevent=0;
1280 if (fPEventSelector->FindPrev(nextevent))
1281 {
1282 GotoEvent(nextevent);
1283 }
1284 }
1285 else if (fEventId > 0)
1286 {
1287 GotoEvent(fEventId - 1);
1288 }
516389a2 1289}
1290
164d3d29 1291void AliEveEventManager::MarkCurrentEvent()
1292{
1293#ifdef ZMQ
b686c9db 1294 if(!fOnlineMode){return;}
1295
1296 struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
1297 struct eventStruct mark;
1298 mark.runNumber = fESD->GetRunNumber();
1299 mark.eventNumber = fESD->GetEventNumberInFile();
1300 requestMessage->messageType = REQUEST_MARK_EVENT;
1301 requestMessage->event = mark;
1302
1303 AliStorageEventManager *eventManager =
1304 AliStorageEventManager::GetEventManagerInstance();
1305 eventManager->CreateSocket(SERVER_COMMUNICATION_REQ);
1306
1307 /*
1308 std::future<bool> unused = std::async([]()
1309 {
1310 eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
1311 bool response = eventManager->GetBool(SERVER_COMMUNICATION_REQ);
1312
1313 if(response)
1314 {
1315 //fStatusLabel->SetText("Event marked");
1316 cout<<"ADMIN PANEL -- Event marked succesfully"<<endl;
1317 }
1318 else
1319 {
1320 //fStatusLabel->SetText("Couldn't mark this event");
1321 cout<<"ADMIN PANEL -- Could not matk event"<<endl;
1322 }
1323 });
1324 */
1325
1326 eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
1327 bool response = eventManager->GetBool(SERVER_COMMUNICATION_REQ);
1328
1329
1330 if(response)
1331 {
1332 //fStatusLabel->SetText("Event marked");
1333 cout<<"ADMIN PANEL -- Event marked succesfully"<<endl;
1334 }
1335 else
1336 {
1337 //fStatusLabel->SetText("Couldn't mark this event");
1338 cout<<"ADMIN PANEL -- Could not matk event"<<endl;
1339 }
1340 if(requestMessage){delete requestMessage;}
164d3d29 1341#endif
1342}
1343
d810d0de 1344void AliEveEventManager::Close()
5a5a1232 1345{
2e29a658 1346 // Close the event data-files and delete ESD, ESDfriend, run-loader
1347 // and raw-reader.
b686c9db 1348
d2416c53 1349 cout<<"\n\n\nClose() called!!\n\n\n"<<endl;
1350
2e29a658 1351 static const TEveException kEH("AliEveEventManager::Close ");
b686c9db 1352
2e29a658 1353 if (!fIsOpen)
1354 {
1355 throw (kEH + "Event-files not opened.");
1356 }
b686c9db 1357
2e29a658 1358 if (fAutoLoadTimerRunning)
1359 StopAutoLoadTimer();
b686c9db 1360
51104899 1361 if ((fESDTree!=0) || (fHLTESDTree!=0)) {
2e29a658 1362 delete fESD; fESD = 0;
1363 // delete fESDfriend; // friend tree is deleted with the tree
1364 fESDfriend = 0;
1365 fESDfriendExists = kFALSE;
b686c9db 1366
51104899 1367 if(fESDTree) { delete fESDTree; fESDTree = 0; }
1368 if(fHLTESDTree) { delete fHLTESDTree; fHLTESDTree = 0; }
2e29a658 1369 delete fESDFile; fESDFile = 0;
1370 }
b686c9db 1371
2e29a658 1372 if (fAODTree) {
1373 delete fAOD; fAOD = 0;
b686c9db 1374
2e29a658 1375 delete fAODTree; fAODTree = 0;
1376 delete fAODFile; fAODFile = 0;
1377 }
b686c9db 1378
2e29a658 1379 if (fRunLoader) {
1380 delete fRunLoader; fRunLoader = 0;
1381 }
b686c9db 1382
2e29a658 1383 if (fRawReader) {
1384 delete fRawReader; fRawReader = 0;
1385 }
b686c9db 1386
2e29a658 1387 fEventId = -1;
1388 fIsOpen = kFALSE;
1389 fHasEvent = kFALSE;
5a5a1232 1390}
1391
90fa773e 1392
80547f2d 1393//------------------------------------------------------------------------------
c76ea574 1394// Static convenience functions, mainly used from macros.
80547f2d 1395//------------------------------------------------------------------------------
5a5a1232 1396
ba014dea 1397Int_t AliEveEventManager::CurrentEventId()
1398{
2e29a658 1399 // Return current event-id.
b686c9db 1400
2e29a658 1401 static const TEveException kEH("AliEveEventManager::CurrentEventId ");
b686c9db 1402
2e29a658 1403 if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE)
1404 throw (kEH + "ALICE event not ready.");
1405 return fgCurrent->GetEventId();
ba014dea 1406}
1407
f6afd0e1 1408Bool_t AliEveEventManager::HasRunLoader()
1409{
2e29a658 1410 // Check if AliRunLoader is initialized.
b686c9db 1411
2e29a658 1412 return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fRunLoader;
f6afd0e1 1413}
1414
1415Bool_t AliEveEventManager::HasESD()
1416{
2e29a658 1417 // Check if AliESDEvent is initialized.
b686c9db 1418
2e29a658 1419 return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fESD;
f6afd0e1 1420}
1421
1422Bool_t AliEveEventManager::HasESDfriend()
1423{
2e29a658 1424 // Check if AliESDfriend is initialized.
b686c9db 1425
2e29a658 1426 return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fESDfriend;
f6afd0e1 1427}
1428
b3b7b8d3 1429Bool_t AliEveEventManager::HasAOD()
1430{
2e29a658 1431 // Check if AliESDEvent is initialized.
b686c9db 1432
2e29a658 1433 return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fAOD;
b3b7b8d3 1434}
1435
f6afd0e1 1436Bool_t AliEveEventManager::HasRawReader()
1437{
2e29a658 1438 // Check if raw-reader is initialized.
b686c9db 1439
2e29a658 1440 return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fRawReader;
f6afd0e1 1441}
1442
d810d0de 1443AliRunLoader* AliEveEventManager::AssertRunLoader()
5a5a1232 1444{
2e29a658 1445 // Make sure AliRunLoader is initialized and return it.
1446 // Throws exception in case run-loader is not available.
1447 // Static utility for macros.
b686c9db 1448
2e29a658 1449 static const TEveException kEH("AliEveEventManager::AssertRunLoader ");
b686c9db 1450
2e29a658 1451 if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE)
1452 throw (kEH + "ALICE event not ready.");
1453 if (fgCurrent->fRunLoader == 0)
1454 throw (kEH + "AliRunLoader not initialised.");
1455 return fgCurrent->fRunLoader;
5a5a1232 1456}
1457
d810d0de 1458AliESDEvent* AliEveEventManager::AssertESD()
5a5a1232 1459{
2e29a658 1460 // Make sure AliESDEvent is initialized and return it.
1461 // Throws exception in case ESD is not available.
1462 // Static utility for macros.
b686c9db 1463
2e29a658 1464 static const TEveException kEH("AliEveEventManager::AssertESD ");
b686c9db 1465
2e29a658 1466 if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE)
1467 throw (kEH + "ALICE event not ready.");
1468 if (fgCurrent->fESD == 0)
1469 throw (kEH + "AliESD not initialised.");
1470 return fgCurrent->fESD;
5a5a1232 1471}
3aecaefc 1472
d810d0de 1473AliESDfriend* AliEveEventManager::AssertESDfriend()
3aecaefc 1474{
2e29a658 1475 // Make sure AliESDfriend is initialized and return it.
1476 // Throws exception in case ESDfriend-loader is not available.
1477 // Static utility for macros.
b686c9db 1478
2e29a658 1479 static const TEveException kEH("AliEveEventManager::AssertESDfriend ");
b686c9db 1480
2e29a658 1481 if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE)
1482 throw (kEH + "ALICE event not ready.");
1483 if (fgCurrent->fESDfriend == 0)
1484 throw (kEH + "AliESDfriend not initialised.");
1485 return fgCurrent->fESDfriend;
3aecaefc 1486}
93845f6c 1487
b3b7b8d3 1488AliAODEvent* AliEveEventManager::AssertAOD()
1489{
2e29a658 1490 // Make sure AliAODEvent is initialized and return it.
1491 // Throws exception in case AOD is not available.
1492 // Static utility for macros.
b686c9db 1493
2e29a658 1494 static const TEveException kEH("AliEveEventManager::AssertAOD ");
b686c9db 1495
2e29a658 1496 if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE)
1497 throw (kEH + "ALICE event not ready.");
1498 if (fgCurrent->fAOD == 0)
1499 throw (kEH + "AliAOD not initialised.");
1500 return fgCurrent->fAOD;
b3b7b8d3 1501}
1502
c2c4b7a2 1503AliRawReader* AliEveEventManager::AssertRawReader()
1504{
2e29a658 1505 // Make sure raw-reader is initialized and return it.
b686c9db 1506
2e29a658 1507 static const TEveException kEH("AliEveEventManager::AssertRawReader ");
b686c9db 1508
2e29a658 1509 if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE)
1510 throw (kEH + "ALICE event not ready.");
1511 if (fgCurrent->fRawReader == 0)
1512 throw (kEH + "RawReader not ready.");
b686c9db 1513
2e29a658 1514 return fgCurrent->fRawReader;
c2c4b7a2 1515}
1516
8661a211 1517//==============================================================================
1518
b686c9db 1519AliMagF* AliEveEventManager::AssertMagField()
1520{
2e29a658 1521 // Make sure AliMagF is initialized and returns it.
1522 // Throws exception in case magnetic field is not available.
1523 // Static utility for macros.
b686c9db 1524
2e29a658 1525 static const TEveException kEH("AliEveEventManager::AssertMagField ");
b686c9db 1526
2e29a658 1527 if (fgMagField)
1528 return fgMagField;
b686c9db 1529
2e29a658 1530 if (TGeoGlobalMagField::Instance()->GetField())
1531 {
1532 fgMagField = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField());
1533 if (fgMagField == 0)
1534 throw kEH + "Global field set, but it is not AliMagF.";
1535 return fgMagField;
1536 }
b686c9db 1537
2e29a658 1538 if (!fgGRPLoaded)
1539 {
1540 InitGRP();
1541 }
b686c9db 1542
2e29a658 1543 if (TGeoGlobalMagField::Instance()->GetField())
1544 {
1545 fgMagField = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField());
1546 if (fgMagField == 0)
1547 throw kEH + "Global field set, but it is not AliMagF.";
1548 }
1549 else
1550 {
1551 throw kEH + "Could not initialize magnetic field.";
1552 }
b686c9db 1553
911af103 1554 return fgMagField;
8661a211 1555}
632d2b03 1556
d810d0de 1557TGeoManager* AliEveEventManager::AssertGeometry()
632d2b03 1558{
2e29a658 1559 // Make sure AliGeomManager is initialized and returns the
1560 // corresponding TGeoManger.
1561 // gGeoManager is set to the return value.
1562 // Throws exception if geometry can not be loaded or if it is not
1563 // available and the TGeoManager is locked.
1564 // Static utility for macros.
b686c9db 1565
2e29a658 1566 static const TEveException kEH("AliEveEventManager::AssertGeometry ");
b686c9db 1567
2e29a658 1568 if (AliGeomManager::GetGeometry() == 0)
632d2b03 1569 {
2e29a658 1570 if (TGeoManager::IsLocked())
1571 throw (kEH + "geometry is not loaded but TGeoManager is locked.");
b686c9db 1572
2e29a658 1573 gGeoManager = 0;
1574 AliGeomManager::LoadGeometry();
1575 if ( ! AliGeomManager::GetGeometry())
1576 {
1577 throw (kEH + "can not load geometry.");
1578 }
1579 if ( ! AliGeomManager::ApplyAlignObjsFromCDB("ITS TPC TRD TOF PHOS HMPID EMCAL MUON FMD ZDC PMD T0 VZERO ACORDE"))
1580 {
1581 ::Warning(kEH, "mismatch of alignable volumes. Proceeding.");
1582 // throw (kEH + "could not apply align objs.");
1583 }
1584 AliGeomManager::GetGeometry()->DefaultColors();
632d2b03 1585 }
b686c9db 1586
2e29a658 1587 gGeoManager = AliGeomManager::GetGeometry();
1588 return gGeoManager;
632d2b03 1589}
319f3084 1590
f944f125 1591AliRecoParam* AliEveEventManager::AssertRecoParams()
1592{
2e29a658 1593 if(!fgRecoParam)
1594 InitRecoParam();
b686c9db 1595
2e29a658 1596 return fgRecoParam;
f944f125 1597}
1598
1599Bool_t AliEveEventManager::InitRecoParam()
1600{
2e29a658 1601 // This is mostly a reap-off from reconstruction
1602 // The method accesses OCDB and retrieves all
1603 // the available reco-param objects from there.
b686c9db 1604
2e29a658 1605 fgRecoParam = new AliRecoParam;
ef795f0b 1606 const Int_t kNDetectors = 14;
b686c9db 1607
51104899 1608 static const TEveException kEH("AliEveEventManager::InitRecoParam");
b686c9db 1609
2e29a658 1610 Bool_t isOK = kTRUE;
b686c9db 1611
2e29a658 1612 if (fgRecoParam->GetDetRecoParamArray(kNDetectors)) {
1613 ::Info(kEH, "Using custom GRP reconstruction parameters");
f944f125 1614 }
1615 else {
2e29a658 1616 ::Info(kEH, "Loading GRP reconstruction parameter objects");
b686c9db 1617
2e29a658 1618 AliCDBPath path("GRP","Calib","RecoParam");
1619 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
1620 if(!entry){
1621 ::Warning(kEH, "Couldn't find GRP RecoParam entry in OCDB");
1622 isOK = kFALSE;
1623 }
1624 else {
1625 TObject *recoParamObj = entry->GetObject();
1626 if (dynamic_cast<TObjArray*>(recoParamObj)) {
1627 // GRP has a normal TobjArray of AliDetectorRecoParam objects
1628 // Registering them in AliRecoParam
1629 fgRecoParam->AddDetRecoParamArray(kNDetectors,dynamic_cast<TObjArray*>(recoParamObj));
1630 }
1631 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
1632 // GRP has only onse set of reco parameters
1633 // Registering it in AliRecoParam
1634 ::Info(kEH, "Single set of GRP reconstruction parameters found");
1635 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
1636 fgRecoParam->AddDetRecoParam(kNDetectors,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
1637 }
1638 else {
1639 ::Error(kEH, "No valid GRP RecoParam object found in the OCDB");
1640 isOK = kFALSE;
1641 }
1642 entry->SetOwner(0);
1643 }
f944f125 1644 }
b686c9db 1645
ef795f0b 1646 const char* fgkDetectorName[kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE" };
b686c9db 1647
1648
2e29a658 1649 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
b686c9db 1650
2e29a658 1651 if (fgRecoParam->GetDetRecoParamArray(iDet)) {
be736e6d 1652 ::Info(kEH, "Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]);
2e29a658 1653 continue;
1654 }
b686c9db 1655
be736e6d 1656 ::Info(kEH, "Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]);
b686c9db 1657
2e29a658 1658 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
1659 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
1660 if(!entry){
be736e6d 1661 ::Warning(kEH, "Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]);
2e29a658 1662 isOK = kFALSE;
1663 }
1664 else {
1665 TObject *recoParamObj = entry->GetObject();
1666 if (dynamic_cast<TObjArray*>(recoParamObj)) {
1667 // The detector has a normal TobjArray of AliDetectorRecoParam objects
1668 // Registering them in AliRecoParam
1669 fgRecoParam->AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
1670 }
1671 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
1672 // The detector has only onse set of reco parameters
1673 // Registering it in AliRecoParam
be736e6d 1674 ::Info(kEH, "Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]);
2e29a658 1675 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
1676 fgRecoParam->AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
1677 }
1678 else {
be736e6d 1679 ::Error(kEH, "No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]);
2e29a658 1680 isOK = kFALSE;
1681 }
1682 entry->SetOwner(0);
b686c9db 1683
2e29a658 1684 }
1685 }
b686c9db 1686
2e29a658 1687 if(!isOK) {
1688 delete fgRecoParam;
1689 fgRecoParam = 0;
1690 }
b686c9db 1691
2e29a658 1692 return isOK;
f944f125 1693}
1694
51104899 1695TTree *AliEveEventManager::readESDTree(const char *treeName, int &runNo)
1696{
1697 if(!fESDFile && !fESD) return 0;
b686c9db 1698
51104899 1699 static const TEveException kEH("AliEveEventManager::readESDTree ");
b686c9db 1700
51104899 1701 TTree* tempTree = 0;
b686c9db 1702
51104899 1703 tempTree =(TTree*) fESDFile->Get(treeName);
1704 if (tempTree != 0)
1705 {
1706 TFile *esdFriendFile = TFile::Open(fgESDfriendsFileName);
1707 if (esdFriendFile)
1708 {
1709 if (!esdFriendFile->IsZombie())
1710 {
1711 esdFriendFile->Close();
1712 fESDfriendExists = kTRUE;
1713 tempTree->SetBranchStatus ("ESDfriend*", 1);
1714 }
1715 delete esdFriendFile;
1716 }
b686c9db 1717
51104899 1718 fESD->ReadFromTree(tempTree);
1719 if (fESDfriendExists)
1720 {
1721 fESDfriend = (AliESDfriend*) fESD->FindListObject("AliESDfriend");
1722 Info(kEH, "found and attached ESD friend.");
1723 }
1724 else
1725 {
1726 Warning(kEH, "ESDfriend not found.");
1727 }
b686c9db 1728
51104899 1729 if (tempTree->GetEntry(0) <= 0)
1730 {
1731 Warning(kEH, "failed getting the first entry from tree: %s", treeName);
1732 }
1733 else
1734 {
1735 if (runNo < 0)
1736 runNo = fESD->GetESDRun()->GetRunNumber();
1737 }
1738 }
1739 else // tree == 0
1740 {
1741 Warning(kEH, "failed getting the tree:%s", treeName);
1742 }
b686c9db 1743
51104899 1744 return tempTree;
1745}
1746
f944f125 1747
4d62585e 1748//------------------------------------------------------------------------------
1749
ba5d58f2 1750AliEveEventManager* AliEveEventManager::AddDependentManager(const TString& name, const TString& path)
4d62585e 1751{
2e29a658 1752 // Create and attach a dependent event-manager.
1753 // It is not added into eve list tree.
b686c9db 1754
2e29a658 1755 static const TEveException kEH("AliEveEventManager::AddDependentManager ");
b686c9db 1756
2e29a658 1757 if (fgMaster == 0)
1758 throw(kEH + "Master event-manager must be instantiated first.");
b686c9db 1759
2e29a658 1760 if (fgMaster->fSubManagers == 0)
1761 {
1762 fgMaster->fSubManagers = new TList;
1763 fgMaster->fSubManagers->SetOwner(kTRUE);
1764 }
b686c9db 1765
2e29a658 1766 AliEveEventManager* new_mgr = 0;
1767 fgCurrent = 0;
1768 try
1769 {
be736e6d 1770 new_mgr = new AliEveEventManager(name, fgMaster->fEventId);
1771 new_mgr->SetFilesPath(path);
2e29a658 1772 fgMaster->fSubManagers->Add(new_mgr);
1773 }
1774 catch (TEveException& exc)
1775 {
1776 ::Error(kEH, "Creation of new event-manager failed: '%s'.", exc.Data());
1777 }
1778 fgCurrent = fgMaster;
b686c9db 1779
2e29a658 1780 return new_mgr;
ba5d58f2 1781}
1782
1783AliEveEventManager* AliEveEventManager::GetDependentManager(const TString& name)
1784{
2e29a658 1785 // Get a dependant manager by name.
1786 // This will not change the current manager, use helper class
1787 // AliEveEventManager::CurrentChanger for that.
b686c9db 1788
2e29a658 1789 static const TEveException kEH("AliEveEventManager::GetDependentManager ");
b686c9db 1790
2e29a658 1791 if (fgMaster == 0)
1792 throw(kEH + "Master event-manager must be instantiated first.");
b686c9db 1793
2e29a658 1794 if (fgMaster->fSubManagers == 0)
1795 return 0;
b686c9db 1796
2e29a658 1797 return dynamic_cast<AliEveEventManager*>(fgMaster->fSubManagers->FindObject(name));
4d62585e 1798}
1799
1800AliEveEventManager* AliEveEventManager::GetMaster()
1801{
2e29a658 1802 // Get master event-manager.
b686c9db 1803
2e29a658 1804 return fgMaster;
4d62585e 1805}
1806
1807AliEveEventManager* AliEveEventManager::GetCurrent()
1808{
2e29a658 1809 // Get current event-manager.
b686c9db 1810
2e29a658 1811 return fgCurrent;
4d62585e 1812}
80547f2d 1813
08b0f222 1814void AliEveEventManager::RegisterTransient(TEveElement* element)
1815{
2e29a658 1816 GetCurrent()->fTransients->AddElement(element);
08b0f222 1817}
1818
8661a211 1819void AliEveEventManager::RegisterTransientList(TEveElement* element)
1820{
2e29a658 1821 GetCurrent()->fTransientLists->AddElement(element);
8661a211 1822}
1823
80547f2d 1824//------------------------------------------------------------------------------
488869c1 1825// Autoloading of events
80547f2d 1826//------------------------------------------------------------------------------
1827
488869c1 1828void AliEveEventManager::SetAutoLoadTime(Float_t time)
1829{
2e29a658 1830 // Set the auto-load time in seconds
b686c9db 1831
2e29a658 1832 fAutoLoadTime = time;
488869c1 1833}
1834
319f3084 1835void AliEveEventManager::SetAutoLoad(Bool_t autoLoad)
1836{
2e29a658 1837 // Set the automatic event loading mode
b686c9db 1838
2e29a658 1839 static const TEveException kEH("AliEveEventManager::SetAutoLoad ");
b686c9db 1840
2e29a658 1841 if (fAutoLoad == autoLoad)
1842 {
1843 Warning(kEH, "Setting autoload to the same value as before - %s. Ignoring.", fAutoLoad ? "true" : "false");
1844 return;
1845 }
b686c9db 1846
2e29a658 1847 fAutoLoad = autoLoad;
1848 if (fAutoLoad)
1849 {
1850 StartAutoLoadTimer();
1851 }
1852 else
1853 {
1854 StopAutoLoadTimer();
1855 }
319f3084 1856}
1857
626a3158 1858void AliEveEventManager::SetLoopMarked(Bool_t loopMarked)
1859{
1860 // Set the automatic event loading mode
b686c9db 1861 if(fLoopMarked == loopMarked)
7dcdaa40 1862 {
b686c9db 1863 cout<<"loop marked has the same value - ignoring"<<endl;
1864 return;
7dcdaa40 1865 }
b686c9db 1866 else
7dcdaa40 1867 {
b686c9db 1868 cout<<"Setting loof marked to:"<<loopMarked<<endl;
1869 fLoopMarked = loopMarked;
1870 if (fLoopMarked){StartAutoLoadTimer();}
1871 else{StopAutoLoadTimer();}
7dcdaa40 1872 }
626a3158 1873}
1874
969d3431 1875void AliEveEventManager::SetTrigSel(Int_t trig)
1876{
2e29a658 1877 static const TEveException kEH("AliEveEventManager::SetTrigSel ");
b686c9db 1878
2e29a658 1879 if (!fRawReader)
1880 {
1881 Warning(kEH, "No Raw-reader exists. Ignoring the call.");
1882 return;
1883 }
1884 else
1885 {
1886 ULong64_t trigMask = 0;
1887 if (trig >= 0) trigMask = (1ull << trig);
1888 Info(kEH,"Trigger selection: 0x%llx",trigMask);
1889 fRawReader->SelectEvents(-1,trigMask,NULL);
1890 }
969d3431 1891}
1892
488869c1 1893void AliEveEventManager::StartAutoLoadTimer()
319f3084 1894{
2e29a658 1895 // Start the auto-load timer.
b686c9db 1896
2e29a658 1897 fAutoLoadTimer->SetTime((Long_t)(1000*fAutoLoadTime));
1898 fAutoLoadTimer->Reset();
1899 fAutoLoadTimer->TurnOn();
1900 fAutoLoadTimerRunning = kTRUE;
319f3084 1901}
1902
488869c1 1903void AliEveEventManager::StopAutoLoadTimer()
319f3084 1904{
2e29a658 1905 // Stop the auto-load timer.
b686c9db 1906
2e29a658 1907 fAutoLoadTimerRunning = kFALSE;
1908 fAutoLoadTimer->TurnOff();
488869c1 1909}
1910
1911void AliEveEventManager::AutoLoadNextEvent()
1912{
b686c9db 1913 // Called from auto-load timer, so it has to be public.
1914 // Do NOT call it directly.
1915
1916 static const TEveException kEH("AliEveEventManager::AutoLoadNextEvent ");
1917
1918 Info(kEH, "called!");
1919
1920 if ( ! fAutoLoadTimerRunning || ! fAutoLoadTimer->HasTimedOut())
1921 {
1922 Warning(kEH, "Called unexpectedly - ignoring the call. Should ONLY be called from an internal timer.");
1923 return;
1924 }
1925
1926 StopAutoLoadTimer();
1927 NextEvent();
1928 if (fAutoLoad || fLoopMarked){
1929 StartAutoLoadTimer();
1930 }
319f3084 1931}
1932
ecb84424 1933//------------------------------------------------------------------------------
80547f2d 1934// Post event-loading functions
1935//------------------------------------------------------------------------------
1936
f6afd0e1 1937void AliEveEventManager::AfterNewEventLoaded()
1938{
b686c9db 1939 // Execute registered macros and commands.
1940 // At the end emit NewEventLoaded signal.
1941 //
1942 // Virtual from TEveEventManager.
1943
1944 static const TEveException kEH("AliEveEventManager::AfterNewEventLoaded ");
1945
1946 Info(kEH, "------------------!!!------------");
1947
1948 NewEventDataLoaded();
1949 if (fExecutor) fExecutor->ExecMacros();
1950
1951 TEveEventManager::AfterNewEventLoaded();
1952 NewEventLoaded();
1953
1954 if (this == fgMaster && fSubManagers != 0)
1955 {
1956 TIter next(fSubManagers);
1957 while ((fgCurrent = dynamic_cast<AliEveEventManager*>(next())) != 0)
1958 {
1959 gEve->SetCurrentEvent(fgCurrent);
1960 try
1961 {
1962 fgCurrent->GotoEvent(fEventId);
1963 }
1964 catch (TEveException& exc)
1965 {
1966 // !!! Should somehow tag / disable / remove it?
1967 Error(kEH, "Getting event %d for sub-event-manager '%s' failed: '%s'.",
1968 fEventId, fgCurrent->GetName(), exc.Data());
1969 }
1970 Info(kEH, "------------------!!! while() gEve->SetCurrentEvent() ------------");
1971 }
1972 fgCurrent = fgMaster;
1973 Info(kEH, "------------------!!! while() gEve->SetCurrentEvent(MASTER) ------------");
1974 gEve->SetCurrentEvent(fgMaster);
ba5d58f2 1975 }
f6afd0e1 1976}
1977
c12be4d4 1978void AliEveEventManager::NewEventDataLoaded()
1979{
2e29a658 1980 // Emit NewEventDataLoaded signal.
2e29a658 1981 Emit("NewEventDataLoaded()");
c12be4d4 1982}
f76c9e9b 1983void AliEveEventManager::NewEventLoaded()
1984{
2e29a658 1985 // Emit NewEventLoaded signal.
2e29a658 1986 Emit("NewEventLoaded()");
f76c9e9b 1987}
01ca7d6f 1988void AliEveEventManager::NoEventLoaded()
1989{
1990 // Emit NoEventLoaded signal.
1991 Emit("NoEventLoaded()");
1992}
0790c3e6 1993void AliEveEventManager::StorageManagerOk()
1994{
1995 // Emit StorageManagerOk signal.
1996 Emit("StorageManagerOk()");
1997}
1998void AliEveEventManager::StorageManagerDown()
1999{
2000 // Emit StorageManagerOk signal.
2001 Emit("StorageManagerDown()");
2002}
f76c9e9b 2003
80547f2d 2004
2005//------------------------------------------------------------------------------
2006// Event info dumpers
2007//------------------------------------------------------------------------------
12365217 2008
b686c9db 2009const AliEventInfo* AliEveEventManager::GetEventInfo()
f944f125 2010{
2e29a658 2011 // Fill the event info object
b686c9db 2012
2e29a658 2013 AliCentralTrigger *aCTP = NULL;
2014 if (fRawReader) {
2015 fEventInfo.SetEventType(fRawReader->GetType());
b686c9db 2016
2e29a658 2017 ULong64_t mask = fRawReader->GetClassMask();
2018 fEventInfo.SetTriggerMask(mask);
2019 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
2020 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
b686c9db 2021
2e29a658 2022 aCTP = new AliCentralTrigger();
2023 TString configstr("");
2024 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
2025 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
2026 delete aCTP;
2027 return 0;
2028 }
2029 aCTP->SetClassMask(mask);
2030 aCTP->SetClusterMask(clmask);
b686c9db 2031
2e29a658 2032 if (fRunLoader) {
2033 AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
2034 if (rlCTP) {
2035 rlCTP->SetClassMask(mask);
2036 rlCTP->SetClusterMask(clmask);
2037 }
2038 }
2039 }
2040 else {
2041 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
b686c9db 2042
2e29a658 2043 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
2044 aCTP = fRunLoader->GetTrigger();
2045 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
2046 // get inputs from actp - just get
2047 AliESDHeader* esdheader = fESD->GetHeader();
2048 esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs());
2049 esdheader->SetL1TriggerInputs(aCTP->GetL1TriggerInputs());
2050 esdheader->SetL2TriggerInputs(aCTP->GetL2TriggerInputs());
2051 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
2052 }
2053 else {
2054 AliWarning("No trigger can be loaded! The trigger information will not be used!");
2055 return 0;
2056 }
2057 }
b686c9db 2058
2e29a658 2059 AliTriggerConfiguration *config = aCTP->GetConfiguration();
2060 if (!config) {
2061 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
2062 if (fRawReader) delete aCTP;
2063 return 0;
f944f125 2064 }
b686c9db 2065
2e29a658 2066 TString declTriggerClasses;
b686c9db 2067
2e29a658 2068 // Load trigger aliases and declare the trigger classes included in aliases
2069 AliCDBEntry * entry = AliCDBManager::Instance()->Get("GRP/CTP/Aliases");
2070 if (entry) {
2071 THashList * lst = dynamic_cast<THashList*>(entry->GetObject());
2072 if (lst) {
2073 lst->Sort(kSortDescending); // to avoid problems with substrings
2074 if (fRawReader) fRawReader->LoadTriggerAlias(lst);
2075 // Now declare all the triggers present in the aliases
2076 TIter iter(lst);
2077 TNamed *nmd = 0;
2078 while((nmd = dynamic_cast<TNamed*>(iter.Next()))){
2079 declTriggerClasses += " ";
2080 declTriggerClasses += nmd->GetName();
2081 }
2082 }
2083 else {
2084 AliError("Cannot cast the object with trigger aliases to THashList!");
2085 }
f944f125 2086 }
2087 else {
2e29a658 2088 AliError("No OCDB entry for the trigger aliases!");
f944f125 2089 }
b686c9db 2090
2e29a658 2091 // Load trigger classes for this run
2092 UChar_t clustmask = 0;
2093 TString trclasses;
2094 ULong64_t trmask = fEventInfo.GetTriggerMask();
2095 const TObjArray& classesArray = config->GetClasses();
2096 Int_t nclasses = classesArray.GetEntriesFast();
2097 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
2098 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
2099 if (trclass && trclass->GetMask()>0) {
2100 Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
2101 if (fESD) fESD->SetTriggerClass(trclass->GetName(),trindex);
2102 if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
2103 if (trmask & (1ull << trindex)) {
2104 trclasses += " ";
2105 trclasses += trclass->GetName();
2106 trclasses += " ";
2107 clustmask |= trclass->GetCluster()->GetClusterMask();
2108 }
2109 }
2110 }
2111 fEventInfo.SetTriggerClasses(trclasses);
b686c9db 2112
2e29a658 2113 if (!aCTP->CheckTriggeredDetectors()) {
2114 if (fRawReader) delete aCTP;
2115 return 0;
f944f125 2116 }
b686c9db 2117
2e29a658 2118 if (fRawReader) delete aCTP;
b686c9db 2119
2e29a658 2120 // everything went ok, return pointer
2121 return (&fEventInfo);
f944f125 2122}
2123
2124
12365217 2125TString AliEveEventManager::GetEventInfoHorizontal() const
2126{
2e29a658 2127 // Dumps the event-header contents in vertical formatting.
b686c9db 2128
2e29a658 2129 TString rawInfo, esdInfo;
b686c9db 2130
2e29a658 2131 if (!fRawReader)
2132 {
2133 rawInfo = "No raw-data event info is available!\n";
2134 }
2135 else
2136 {
2137 const UInt_t* attr = fRawReader->GetAttributes();
2138 TTimeStamp ts(fRawReader->GetTimestamp());
2139 rawInfo.Form("RAW event info: Run#: %d Event type: %d (%s) Period: %x Orbit: %x BC: %x\n"
2140 "Trigger: %llx\nDetectors: %x (%s)\nAttributes:%x-%x-%x Timestamp: %s\n",
2141 fRawReader->GetRunNumber(),fRawReader->GetType(),AliRawEventHeaderBase::GetTypeName(fRawReader->GetType()),
2142 fRawReader->GetPeriod(),fRawReader->GetOrbitID(),fRawReader->GetBCID(),
2143 fRawReader->GetClassMask(),
2144 *fRawReader->GetDetectorPattern(),AliDAQ::ListOfTriggeredDetectors(*fRawReader->GetDetectorPattern()),
2145 attr[0],attr[1],attr[2], ts.AsString("s"));
2146 }
b686c9db 2147
2e29a658 2148 if (!fESD)
2149 {
2150 esdInfo = "No ESD event info is available!";
2151 }
2152 else
2153 {
2154 TString acttrclasses = fESD->GetESDRun()->GetActiveTriggerClasses();
2155 TString firedtrclasses = fESD->GetFiredTriggerClasses();
2156 TTimeStamp ts(fESD->GetTimeStamp());
2157 esdInfo.Form("ESD event info: Run#: %d Event type: %d (%s) Period: %x Orbit: %x BC: %x\n"
2158 "Active trigger classes: %s\nTrigger: %llx (%s)\nEvent# in file: %d Timestamp: %s, MagField: %.2e",
2159 fESD->GetRunNumber(),
2160 fESD->GetEventType(),AliRawEventHeaderBase::GetTypeName(fESD->GetEventType()),
2161 fESD->GetPeriodNumber(),fESD->GetOrbitNumber(),fESD->GetBunchCrossNumber(),
2162 acttrclasses.Data(),
2163 fESD->GetTriggerMask(),firedtrclasses.Data(),
2164 fESD->GetEventNumberInFile(), ts.AsString("s"), fESD->GetMagneticField());
2165 }
b686c9db 2166
2e29a658 2167 return rawInfo + esdInfo;
12365217 2168}
2169
2170TString AliEveEventManager::GetEventInfoVertical() const
319f3084 2171{
2e29a658 2172 // Dumps the event-header contents in vertical formatting.
b686c9db 2173
2e29a658 2174 TString rawInfo, esdInfo;
b686c9db 2175
2e29a658 2176 if (!fRawReader)
2177 {
2178 rawInfo = "No raw-data event info is available!\n";
2179 }
2180 else
2181 {
2182 const UInt_t* attr = fRawReader->GetAttributes();
2183 rawInfo.Form("Raw-data event info:\nRun#: %d\nEvent type: %d (%s)\nPeriod: %x\nOrbit: %x BC: %x\nTrigger: %llx\nDetectors: %x (%s)\nAttributes:%x-%x-%x\nTimestamp: %x\n",
2184 fRawReader->GetRunNumber(),fRawReader->GetType(),AliRawEventHeaderBase::GetTypeName(fRawReader->GetType()),
2185 fRawReader->GetPeriod(),fRawReader->GetOrbitID(),fRawReader->GetBCID(),
2186 fRawReader->GetClassMask(),
2187 *fRawReader->GetDetectorPattern(),AliDAQ::ListOfTriggeredDetectors(*fRawReader->GetDetectorPattern()),
2188 attr[0],attr[1],attr[2],
2189 fRawReader->GetTimestamp());
2190 }
b686c9db 2191
2e29a658 2192 if (!fESD)
2193 {
2194 esdInfo = "No ESD event info is available!\n";
2195 }
2196 else
2197 {
2198 TString acttrclasses = fESD->GetESDRun()->GetActiveTriggerClasses();
2199 TString firedtrclasses = fESD->GetFiredTriggerClasses();
2200 esdInfo.Form("ESD event info:\nRun#: %d\nActive trigger classes: %s\nEvent type: %d (%s)\nPeriod: %x\nOrbit: %x BC: %x\nTrigger: %llx (%s)\nEvent# in file:%d\nTimestamp: %x\n",
2201 fESD->GetRunNumber(),
2202 acttrclasses.Data(),
2203 fESD->GetEventType(),AliRawEventHeaderBase::GetTypeName(fESD->GetEventType()),
2204 fESD->GetPeriodNumber(),fESD->GetOrbitNumber(),fESD->GetBunchCrossNumber(),
2205 fESD->GetTriggerMask(),firedtrclasses.Data(),
2206 fESD->GetEventNumberInFile(),
2207 fESD->GetTimeStamp());
2208 }
b686c9db 2209
2e29a658 2210 return rawInfo + "\n" + esdInfo;
319f3084 2211}
8661a211 2212
2213
2214//==============================================================================
2215// Reading of GRP and MagneticField.
2216// This is a reap-off from reconstruction ... should really be a common
2217// code to do this somewhere in STEER.
2218//==============================================================================
2219
2220Bool_t AliEveEventManager::InitGRP()
2221{
2e29a658 2222 //------------------------------------
2223 // Initialization of the GRP entry
2224 //------------------------------------
b686c9db 2225
2e29a658 2226 static const TEveException kEH("AliEveEventManager::InitGRP ");
b686c9db 2227
2e29a658 2228 AliGRPManager grpMgr;
2229 if (!grpMgr.ReadGRPEntry()) {
2230 return kFALSE;
2231 }
2232 fgGRPLoaded = kTRUE;
2233 if (!grpMgr.SetMagField()) {
2234 throw kEH + "Setting of field failed!";
2235 }
b686c9db 2236
2e29a658 2237 //*** Get the diamond profiles from OCDB
2238 // Eventually useful.
b686c9db 2239
2e29a658 2240 /*
b686c9db 2241 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
2242 if (entry) {
2243 fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
2244 } else {
2245 ::Error(kEH, "No SPD diamond profile found in OCDB!");
2246 }
2247
2248 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
2249 if (entry) {
2250 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
2251 } else {
2252 ::Error(kEH, "No diamond profile found in OCDB!");
2253 }
2254
2255 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
2256 if (entry) {
2257 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
2258 } else {
2259 ::Error(kEH, "No TPC diamond profile found in OCDB!");
2260 }
2261 */
2262
2e29a658 2263 return kTRUE;
8661a211 2264}
3d94b490 2265
2266//------------------------------------
2267// Global variables management
2268//------------------------------------
2269
2270Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model)
2271{
2e29a658 2272 // Insert a new visualization-parameter database entry with the default
2273 return InsertGlobal(tag, model, fGlobalReplace, fGlobalUpdate);
3d94b490 2274}
2275
2276Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model,
2e29a658 2277 Bool_t replace, Bool_t update)
3d94b490 2278{
2e29a658 2279 TPair* pair = (TPair*) fGlobal->FindObject(tag);
2280 if (pair)
2281 {
2282 if (replace)
2283 {
2284 model->IncDenyDestroy();
2285 model->SetRnrChildren(kFALSE);
b686c9db 2286
2e29a658 2287 TEveElement* old_model = dynamic_cast<TEveElement*>(pair->Value());
2288 if(!old_model) AliFatal("old_model == 0, dynamic cast failed\n");
2289 while (old_model->HasChildren())
3d94b490 2290 {
2e29a658 2291 TEveElement *el = old_model->FirstChild();
2292 el->SetVizModel(model);
2293 if (update)
2294 {
2295 el->CopyVizParams(model);
2296 el->PropagateVizParamsToProjecteds();
2297 }
3d94b490 2298 }
2e29a658 2299 old_model->DecDenyDestroy();
b686c9db 2300
2e29a658 2301 pair->SetValue(dynamic_cast<TObject*>(model));
2302 return kTRUE;
2303 }
2304 else
2305 {
2306 return kFALSE;
2307 }
2308 }
2309 else
2310 {
2311 model->IncDenyDestroy();
2312 model->SetRnrChildren(kFALSE);
2313 fGlobal->Add(new TObjString(tag), dynamic_cast<TObject*>(model));
2314 return kTRUE;
2315 }
3d94b490 2316}
2317
2318TEveElement* AliEveEventManager::FindGlobal(const TString& tag)
2319{
2e29a658 2320 return dynamic_cast<TEveElement*>(fGlobal->GetValue(tag));
3d94b490 2321}
01ca7d6f 2322Int_t AliEveEventManager::NewEventAvailable()
2323{
b686c9db 2324 if (fIsNewEventAvaliable)
2325 {
2326 return 1;
2327 }
2328 else
2329 {
2330 return 0;
2331 }
01ca7d6f 2332}