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