Entry with updated list of triggered detectors, number of detectors, LHCperiod
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveEventManager.cxx
CommitLineData
d810d0de 1// $Id$
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"
84aff7a4 11#include <TEveManager.h>
5a5a1232 12
13#include <AliRunLoader.h>
93845f6c 14#include <AliRun.h>
af885e0f 15#include <AliESDEvent.h>
3aecaefc 16#include <AliESDfriend.h>
ec835ab5 17#include <AliDAQ.h>
18#include <AliRawEventHeaderBase.h>
c2c4b7a2 19#include <AliRawReaderRoot.h>
20#include <AliRawReaderFile.h>
21#include <AliRawReaderDate.h>
93845f6c 22#include <AliMagFMaps.h>
632d2b03 23#include <AliCDBManager.h>
24#include <AliHeader.h>
25#include <AliGeomManager.h>
5a5a1232 26
27#include <TFile.h>
28#include <TTree.h>
fbc350a3 29#include <TGeoManager.h>
5a5a1232 30#include <TSystem.h>
d810d0de 31
a15e6d7d 32//==============================================================================
33//==============================================================================
34// AliEveEventManager
35//==============================================================================
5a5a1232 36
57ffa5fb 37//______________________________________________________________________________
5a5a1232 38//
4852ff6f 39// Provide interface for loading and navigating standard AliRoot data
40// (AliRunLoader) and ESDs.
41//
42// Missing support for raw-data. For now this is handled individually
43// by each sub-detector.
51346b82 44//
a15e6d7d 45// Also provides interface to magnetic-field and geometry. Mostly
46// intended as wrappers over standard AliRoot functionality for
47// convenient use from visualizateion macros.
5a5a1232 48
d810d0de 49ClassImp(AliEveEventManager)
5a5a1232 50
a15e6d7d 51AliEveEventManager* gAliEveEvent = 0;
5a5a1232 52
d810d0de 53Bool_t AliEveEventManager::fgAssertRunLoader = kFALSE;
c76ea574 54Bool_t AliEveEventManager::fgAssertESD = kFALSE;
c2c4b7a2 55Bool_t AliEveEventManager::fgAssertRaw = kFALSE;
5a5a1232 56
c2c4b7a2 57TString AliEveEventManager::fgESDFileName("AliESDs.root");
58TString AliEveEventManager::fgRawFileName("raw.root");
d810d0de 59TString AliEveEventManager::fgCdbUri("local://$ALICE_ROOT");
632d2b03 60
d810d0de 61AliMagF* AliEveEventManager::fgMagField = 0;
93845f6c 62
63
d810d0de 64AliEveEventManager::AliEveEventManager() :
84aff7a4 65 TEveEventManager(),
265ecb21 66
c2c4b7a2 67 fPath ( ), fEventId (-1),
265ecb21 68 fRunLoader (0),
90fa773e 69 fESDFile (0), fESDTree (0), fESD (0),
c2c4b7a2 70 fESDfriend (0), fESDfriendExists(kFALSE),
319f3084 71 fRawReader (0),
72 fAutoLoad(kFALSE),
73 fAutoLoadTime(5.),
74 fAutoLoadTimer(0),
75 fIsOnline(kFALSE)
c76ea574 76{
77 // Default constructor.
78}
5a5a1232 79
d810d0de 80AliEveEventManager::AliEveEventManager(TString path, Int_t ev) :
81 TEveEventManager("AliEVE AliEveEventManager"),
265ecb21 82
c76ea574 83 fPath (path), fEventId(-1),
265ecb21 84 fRunLoader (0),
90fa773e 85 fESDFile (0), fESDTree (0), fESD (0),
c2c4b7a2 86 fESDfriend (0), fESDfriendExists(kFALSE),
319f3084 87 fRawReader (0),
88 fAutoLoad(kFALSE),
89 fAutoLoadTime(5.),
90 fAutoLoadTimer(0),
91 fIsOnline(kFALSE)
5a5a1232 92{
c76ea574 93 // Constructor with event-directory URL and event-id.
94
5a5a1232 95 Open();
90fa773e 96 if (ev >= 0) GotoEvent(ev);
5a5a1232 97}
98
a15e6d7d 99AliEveEventManager::~AliEveEventManager()
100{
101 // Destructor.
102
319f3084 103 if (fAutoLoadTimer) delete fAutoLoadTimer;
a15e6d7d 104 // Somewhat unclear what to do here.
105 // In principle should close all data sources and deregister from
106 // TEveManager.
107}
108
57ffa5fb 109/******************************************************************************/
5a5a1232 110
c2c4b7a2 111void AliEveEventManager::SetESDFileName(const Text_t* esd)
112{
113 // Set file-name for opening ESD, default "AliESDs.root".
114
115 if (esd) fgESDFileName = esd;
116}
117
118void AliEveEventManager::SetRawFileName(const Text_t* raw)
119{
120 // Set file-name for opening of raw-data, default "raw.root"
121 if (raw) fgRawFileName = raw;
122}
123
124void AliEveEventManager::SetCdbUri(const Text_t* cdb)
125{
126 // Set path to CDB, default "local://$ALICE_ROOT".
127
128 if (cdb) fgCdbUri = cdb;
129}
130
131void AliEveEventManager::SetAssertElements(Bool_t assertRunloader,
132 Bool_t assertEsd,
133 Bool_t assertRaw)
134{
135 // Set global flags that detrmine which parts of the event-data must
136 // be present when the event is opened.
137
138 fgAssertRunLoader = assertRunloader;
139 fgAssertESD = assertEsd;
140 fgAssertRaw = assertRaw;
141}
142
143/******************************************************************************/
144
d810d0de 145void AliEveEventManager::Open()
5a5a1232 146{
c76ea574 147 // Open event-data from URL specified in fPath.
148 // Attempts to create AliRunLoader() and to open ESD with ESDfriends.
149 // Warning is reported if run-loader or ESD is not found.
150 // Global data-members fgAssertRunLoader and fgAssertESD can be set
151 // to throw exceptions instead.
152
a15e6d7d 153 static const TEveException kEH("AliEveEventManager::Open ");
5a5a1232 154
155 gSystem->ExpandPathName(fPath);
5a58dc18 156 // The following magick is required for ESDriends to be loaded properly
157 // from non-current directory.
158 if (fPath.IsNull() || fPath == ".")
159 {
160 fPath = gSystem->WorkingDirectory();
161 }
162 else if ( ! fPath.BeginsWith("file:/"))
163 {
164 TUrl url(fPath, kTRUE);
165 TString protocol(url.GetProtocol());
166 if (protocol == "file" && fPath[0] != '/')
167 fPath = Form("%s/%s", gSystem->WorkingDirectory(), fPath.Data());
168 }
5a5a1232 169
632d2b03 170 Int_t runNo = -1;
171
db748c38 172 // Open ESD and ESDfriends
173
174 TString esdPath(Form("%s/%s", fPath.Data(), fgESDFileName.Data()));
175 if ((fESDFile = TFile::Open(esdPath)))
176 {
177 fESD = new AliESDEvent();
178 fESDTree = (TTree*) fESDFile->Get("esdTree");
179 if (fESDTree != 0)
180 {
181 fESD->ReadFromTree(fESDTree);
182 fESDTree->GetEntry(0);
183 if (runNo < 0)
184 runNo = fESD->GetESDRun()->GetRunNumber();
185
186 // Check if ESDfriends exists and attach the branch
187 TString p(Form("%s/AliESDfriends.root", fPath.Data()));
188 if (gSystem->AccessPathName(p, kReadPermission) == kFALSE)
189 {
190 fESDfriendExists = kTRUE;
191 fESDTree->SetBranchStatus ("ESDfriend*", 1);
192 fESDTree->SetBranchAddress("ESDfriend.", &fESDfriend);
193 }
194 }
195 else // esdtree == 0
196 {
197 delete fESDFile; fESDFile = 0;
198 Warning(kEH, "failed getting the esdTree.");
199 }
200 }
201 else // esd not readable
202 {
203 Warning(kEH, "can not read ESD file '%s'.", esdPath.Data());
204 }
205 if (fESDTree == 0)
206 {
207 if (fgAssertESD)
208 {
209 throw (kEH + "ESD not initialized. Its precence was requested.");
210 } else {
211 Warning(kEH, "ESD not initialized.");
212 }
213 }
214
215 // Open RunLoader from galice.root
216
a15e6d7d 217 TString gaPath(Form("%s/galice.root", fPath.Data()));
c2c4b7a2 218 // If i use open directly, we get fatal.
db748c38 219 // Is AccessPathName check ok for xrootd / alien? Yes, not for http.
a15e6d7d 220 if (gSystem->AccessPathName(gaPath, kReadPermission) == kFALSE)
90fa773e 221 {
a15e6d7d 222 fRunLoader = AliRunLoader::Open(gaPath);
a1896a82 223 if (fRunLoader)
5a5a1232 224 {
a15e6d7d 225 TString alicePath = fPath + "/";
226 fRunLoader->SetDirName(alicePath);
a1896a82 227
228 if (fRunLoader->LoadgAlice() != 0)
c2c4b7a2 229 Warning(kEH, "failed loading gAlice via run-loader.");
a1896a82 230
231 if (fRunLoader->LoadHeader() == 0)
232 {
db748c38 233 if (runNo < 0)
234 runNo = fRunLoader->GetHeader()->GetRun();
a1896a82 235 }
236 else
237 {
c2c4b7a2 238 Warning(kEH, "failed loading run-loader's header.");
239 delete fRunLoader;
240 fRunLoader = 0;
a1896a82 241 }
242 }
243 else // run-loader open failed
244 {
a15e6d7d 245 Warning(kEH, "failed opening ALICE run-loader from '%s'.", gaPath.Data());
5a5a1232 246 }
5a5a1232 247 }
a1896a82 248 else // galice not readable
249 {
a15e6d7d 250 Warning(kEH, "can not read '%s'.", gaPath.Data());
a1896a82 251 }
252 if (fRunLoader == 0)
253 {
84aff7a4 254 if (fgAssertRunLoader)
c2c4b7a2 255 throw (kEH + "Bootstraping of run-loader failed. Its precence was requested.");
a1896a82 256 else
a15e6d7d 257 Warning(kEH, "Bootstraping of run-loader failed.");
a1896a82 258 }
51346b82 259
db748c38 260 // Open raw-data file
5a5a1232 261
c2c4b7a2 262 TString rawPath(Form("%s/%s", fPath.Data(), fgRawFileName.Data()));
2827badf 263 // If i use open directly, raw-reader reports an error but i have
264 // no way to detect it.
265 // Is this (AccessPathName check) ok for xrootd / alien? Yes, not for http.
266 if (gSystem->AccessPathName(rawPath, kReadPermission) == kFALSE)
267 {
268 fRawReader = AliRawReader::Create(rawPath);
269 }
270 else
271 {
272 fRawReader = AliRawReader::Create(fgRawFileName);
273 }
c2c4b7a2 274 if (fRawReader == 0)
275 {
276 if (fgAssertRaw)
277 {
278 throw (kEH + "raw-data not initialized. Its precence was requested.");
279 } else {
280 Warning(kEH, "raw-data not initialized.");
281 }
282 }
283
632d2b03 284 if (runNo < 0)
c2c4b7a2 285 {
286 if (fRawReader)
287 {
288 fRawReader->NextEvent();
289 runNo = fRawReader->GetRunNumber();
ca49b003 290 Info(kEH, "Determining run-no from raw ... run=%d.", runNo);
c2c4b7a2 291 fRawReader->RewindEvents();
292 } else {
293 throw (kEH + "unknown run number.");
294 }
295 }
632d2b03 296
297 {
298 AliCDBManager* cdb = AliCDBManager::Instance();
299 cdb->SetDefaultStorage(fgCdbUri);
300 if (cdb->IsDefaultStorageSet() == kFALSE)
c2c4b7a2 301 throw (kEH + "CDB initialization failed.");
632d2b03 302 cdb->SetRun(runNo);
303 }
304
73c1c0ec 305 SetName(Form("Event %d", fEventId));
5a5a1232 306 SetTitle(fPath);
307}
308
319f3084 309void AliEveEventManager::SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd)
310{
311 // Set an event from an external source
312 // The method is used in the online visualisation
313 fRunLoader = runLoader;
314 fRawReader = rawReader;
315 fESD = esd;
316 fIsOnline = kTRUE;
317 SetTitle("Online event in memory");
318 SetName("Online Event");
319
320 ElementChanged();
321 AfterNewEventLoaded();
322}
323
f76c9e9b 324Int_t AliEveEventManager::GetMaxEventId(Bool_t /*refreshESD*/) const
516389a2 325{
326 // Returns maximum available event id.
327 // If raw-data is the only data-source this can not be known
328 // and 10,000,000 is returned.
329 // If neither data-source is initialised an exception is thrown.
330 // If refresh_esd is true and ESD is the primary event-data source
331 // its header is re-read from disk.
332
333 static const TEveException kEH("AliEveEventManager::GetMaxEventId ");
334
f76c9e9b 335 if (fESDTree)
516389a2 336 {
f76c9e9b 337 // Refresh crashes with root-5.21.1-alice.
338 // Fixed by Philippe 5.8.2008 r25053, can be reactivated
339 // when we move to a newer root.
340 // if (refreshESD)
341 // fESDTree->Refresh();
342 return fESDTree->GetEntries() - 1;
516389a2 343 }
f76c9e9b 344 else if (fRunLoader)
516389a2 345 {
f76c9e9b 346 return fRunLoader->GetNumberOfEvents() - 1;
516389a2 347 }
348 else if (fRawReader)
349 {
350 return 10000000;
351 }
352 else
353 {
354 throw (kEH + "neither RunLoader, ESD nor Raw loaded.");
355 }
356}
357
d810d0de 358void AliEveEventManager::GotoEvent(Int_t event)
1eaa5849 359{
73c1c0ec 360 // Load data for specified event.
361 // If event is out of range an exception is thrown and old state
362 // is preserved.
363 // After successful loading of event, the virtual function
364 // AfterNewEventLoaded() is called. This executes commands that
365 // were registered via TEveEventManager::AddNewEventCommand().
516389a2 366 //
367 // If event is negative, it is subtracted from the number of
368 // available events, thus passing -1 will load the last event.
369 // This is not supported when raw-data is the only data-source
370 // as the number of events is not known.
73c1c0ec 371
a15e6d7d 372 static const TEveException kEH("AliEveEventManager::GotoEvent ");
1eaa5849 373
1eaa5849 374 Int_t maxEvent = 0;
db748c38 375 if (fESDTree)
516389a2 376 {
ca49b003 377 // Refresh crashes with root-5.21.1-alice.
378 // Fixed by Philippe 5.8.2008 r25053, can be reactivated
379 // when we move to a newer root.
380 // fESDTree->Refresh();
1eaa5849 381 maxEvent = fESDTree->GetEntries() - 1;
516389a2 382 if (event < 0)
383 event = fESDTree->GetEntries() + event;
384 }
db748c38 385 else if (fRunLoader)
386 {
387 maxEvent = fRunLoader->GetNumberOfEvents() - 1;
388 if (event < 0)
389 event = fRunLoader->GetNumberOfEvents() + event;
390 }
516389a2 391 else if (fRawReader)
392 {
c2c4b7a2 393 maxEvent = 10000000;
516389a2 394 if (event < 0) {
395 Error(kEH, "negative event id passed for raw-data as source. Operation not supported.");
396 return;
397 }
c2c4b7a2 398 Info(kEH, "number of events unknown for raw-data, setting max-event id to 10M.");
516389a2 399 }
400 else
401 {
c2c4b7a2 402 throw (kEH + "neither RunLoader, ESD nor Raw loaded.");
403 }
84aff7a4 404 if (event < 0 || event > maxEvent)
516389a2 405 {
c2c4b7a2 406 throw (kEH + Form("event %d not present, available range [%d, %d].",
407 event, 0, maxEvent));
516389a2 408 }
1eaa5849 409
84aff7a4 410 TEveManager::TRedrawDisabler rd(gEve);
411 gEve->Redraw3D(kFALSE, kTRUE); // Enforce drop of all logicals.
d9e0d6c5 412
32e219c2 413 // !!! MT this is somewhat brutal; at least optionally, one could be
414 // a bit gentler, checking for objs owning their external refs and having
415 // additinal parents.
1eaa5849 416 DestroyElements();
1eaa5849 417
84aff7a4 418 if (fESDTree) {
c2c4b7a2 419 if (fESDTree->GetEntry(event) <= 0)
420 throw (kEH + "failed getting required event from ESD.");
1eaa5849 421
2cea771a 422 if (fESDfriendExists)
1eaa5849 423 fESD->SetESDfriend(fESDfriend);
1eaa5849 424 }
90fa773e 425
db748c38 426 if (fRunLoader) {
427 if (fRunLoader->GetEvent(event) != 0)
428 throw (kEH + "failed getting required event.");
429 }
430
c2c4b7a2 431 if (fRawReader)
432 {
ca49b003 433 // AliRawReader::GotoEvent(Int_t) works for AliRawReaderRoot/Chain.
434 if (fRawReader->GotoEvent(event) == kFALSE)
c2c4b7a2 435 {
ca49b003 436 // Use fallback method - iteration with NextEvent().
437 Int_t rawEv = fEventId;
438 if (event < rawEv)
c2c4b7a2 439 {
440 fRawReader->RewindEvents();
ca49b003 441 rawEv = -1;
c2c4b7a2 442 }
c2c4b7a2 443
ca49b003 444 while (rawEv < event)
445 {
446 if ( ! fRawReader->NextEvent())
447 {
448 fRawReader->RewindEvents();
449 fEventId = -1;
450 throw (kEH + Form("Error going to next raw-event from event %d.", rawEv));
451 }
452 ++rawEv;
453 }
454 Warning(kEH, "Loaded raw-event %d with fallback method.\n", rawEv);
455 }
c2c4b7a2 456 }
457
458 fEventId = event;
459 SetName(Form("Event %d", fEventId));
319f3084 460 ElementChanged();
c2c4b7a2 461
90fa773e 462 AfterNewEventLoaded();
f76c9e9b 463 NewEventLoaded();
1eaa5849 464}
465
516389a2 466void AliEveEventManager::NextEvent()
467{
468 // Loads next event
469 // either in automatic (online) or
470 // manual mode
471
472 if (fIsOnline) {
473 if (fAutoLoadTimer) fAutoLoadTimer->Stop();
474
475 DestroyElements();
476
477 gSystem->ExitLoop();
f76c9e9b 478 } else {
516389a2 479 if (fEventId < GetMaxEventId(kTRUE))
480 GotoEvent(fEventId + 1);
481 else
482 GotoEvent(0);
483 StartStopAutoLoadTimer();
484 }
485}
486
487void AliEveEventManager::PrevEvent()
488{
489 // Loads previous event
490 // only in case of manual mode
491 if (!fIsOnline) {
492 GotoEvent(fEventId - 1);
493 StartStopAutoLoadTimer();
494 }
495}
496
d810d0de 497void AliEveEventManager::Close()
5a5a1232 498{
ca49b003 499 // Close the event data-files and delete ESD, ESDfriend, run-loader
500 // and raw-reader.
73c1c0ec 501
2cea771a 502 if (fESDTree) {
503 delete fESD; fESD = 0;
504 delete fESDfriend; fESDfriend = 0;
505
ca49b003 506 delete fESDTree; fESDTree = 0;
507 delete fESDFile; fESDFile = 0;
508 }
509
510 if (fRunLoader) {
511 delete fRunLoader; fRunLoader = 0;
512 }
513
514 if (fRawReader) {
515 delete fRawReader; fRawReader = 0;
2cea771a 516 }
5a5a1232 517}
518
90fa773e 519
57ffa5fb 520/******************************************************************************/
c76ea574 521// Static convenience functions, mainly used from macros.
57ffa5fb 522/******************************************************************************/
5a5a1232 523
d810d0de 524AliRunLoader* AliEveEventManager::AssertRunLoader()
5a5a1232 525{
73c1c0ec 526 // Make sure AliRunLoader is initialized and return it.
527 // Throws exception in case run-loader is not available.
528 // Static utility for macros.
529
a15e6d7d 530 static const TEveException kEH("AliEveEventManager::AssertRunLoader ");
5a5a1232 531
a15e6d7d 532 if (gAliEveEvent == 0)
c2c4b7a2 533 throw (kEH + "ALICE event not ready.");
a15e6d7d 534 if (gAliEveEvent->fRunLoader == 0)
c2c4b7a2 535 throw (kEH + "AliRunLoader not initialised.");
a15e6d7d 536 return gAliEveEvent->fRunLoader;
5a5a1232 537}
538
d810d0de 539AliESDEvent* AliEveEventManager::AssertESD()
5a5a1232 540{
73c1c0ec 541 // Make sure AliESDEvent is initialized and return it.
542 // Throws exception in case ESD is not available.
543 // Static utility for macros.
544
a15e6d7d 545 static const TEveException kEH("AliEveEventManager::AssertESD ");
5a5a1232 546
a15e6d7d 547 if (gAliEveEvent == 0)
c2c4b7a2 548 throw (kEH + "ALICE event not ready.");
a15e6d7d 549 if (gAliEveEvent->fESD == 0)
c2c4b7a2 550 throw (kEH + "AliESD not initialised.");
a15e6d7d 551 return gAliEveEvent->fESD;
5a5a1232 552}
3aecaefc 553
d810d0de 554AliESDfriend* AliEveEventManager::AssertESDfriend()
3aecaefc 555{
73c1c0ec 556 // Make sure AliESDfriend is initialized and return it.
557 // Throws exception in case ESDfriend-loader is not available.
558 // Static utility for macros.
559
a15e6d7d 560 static const TEveException kEH("AliEveEventManager::AssertESDfriend ");
3aecaefc 561
a15e6d7d 562 if (gAliEveEvent == 0)
c2c4b7a2 563 throw (kEH + "ALICE event not ready.");
a15e6d7d 564 if (gAliEveEvent->fESDfriend == 0)
c2c4b7a2 565 throw (kEH + "AliESDfriend not initialised.");
a15e6d7d 566 return gAliEveEvent->fESDfriend;
3aecaefc 567}
93845f6c 568
c2c4b7a2 569AliRawReader* AliEveEventManager::AssertRawReader()
570{
571 // Make sure raw-reader is initialized and return it.
572
573 static const TEveException kEH("AliEveEventManager::AssertRawReader ");
574
575 if (gAliEveEvent == 0)
576 throw (kEH + "ALICE event not ready.");
577 if (gAliEveEvent->fRawReader == 0)
578 throw (kEH + "RawReader not ready.");
579
580 return gAliEveEvent->fRawReader;
581}
582
d810d0de 583AliMagF* AliEveEventManager::AssertMagField()
93845f6c 584{
73c1c0ec 585 // Make sure AliMagF is initialized and return it.
586 // Throws exception in case magnetic field is not available.
587 // Static utility for macros.
588
93845f6c 589 if (fgMagField == 0)
590 {
a15e6d7d 591 if (gAliEveEvent && gAliEveEvent->fRunLoader && gAliEveEvent->fRunLoader->GetAliRun())
592 fgMagField = gAliEveEvent->fRunLoader->GetAliRun()->Field();
93845f6c 593 else
594 fgMagField = new AliMagFMaps("Maps","Maps", 1, 1., 10., AliMagFMaps::k5kG);
595 }
596 return fgMagField;
597}
632d2b03 598
d810d0de 599TGeoManager* AliEveEventManager::AssertGeometry()
632d2b03 600{
73c1c0ec 601 // Make sure AliGeomManager is initialized and returns the
602 // corresponding TGeoManger.
647814a2 603 // gGeoManager is set to the return value.
604 // Throws exception if geometry can not be loaded or if it is not
605 // available and the TGeoManager is locked.
73c1c0ec 606 // Static utility for macros.
607
a15e6d7d 608 static const TEveException kEH("AliEveEventManager::AssertGeometry ");
632d2b03 609
610 if (AliGeomManager::GetGeometry() == 0)
611 {
647814a2 612 if (TGeoManager::IsLocked())
613 throw (kEH + "geometry is not loaded but TGeoManager is locked.");
614
af2e4ef5 615 gGeoManager = 0;
632d2b03 616 AliGeomManager::LoadGeometry();
617 if ( ! AliGeomManager::GetGeometry())
618 {
c2c4b7a2 619 throw (kEH + "can not load geometry.");
632d2b03 620 }
621 if ( ! AliGeomManager::ApplyAlignObjsFromCDB("ITS TPC TRD TOF PHOS HMPID EMCAL MUON FMD ZDC PMD T0 VZERO ACORDE"))
622 {
a15e6d7d 623 ::Warning(kEH, "mismatch of alignable volumes. Proceeding.");
c2c4b7a2 624 // throw (kEH + "could not apply align objs.");
632d2b03 625 }
81515106 626 AliGeomManager::GetGeometry()->DefaultColors();
632d2b03 627 }
628
647814a2 629 gGeoManager = AliGeomManager::GetGeometry();
630 return gGeoManager;
632d2b03 631}
319f3084 632
633void AliEveEventManager::SetAutoLoad(Bool_t autoLoad)
634{
635 // Set the automatic event loading mode
636 fAutoLoad = autoLoad;
637 StartStopAutoLoadTimer();
638}
639
640void AliEveEventManager::SetAutoLoadTime(Double_t time)
641{
642 // Set the auto-load time in seconds
643 fAutoLoadTime = time;
644 StartStopAutoLoadTimer();
645}
646
647void AliEveEventManager::StartStopAutoLoadTimer()
648{
649 // Create if needed and start
650 // the automatic event loading timer
f76c9e9b 651 if (fAutoLoad)
652 {
653 if (!fAutoLoadTimer)
654 {
319f3084 655 fAutoLoadTimer = new TTimer;
656 fAutoLoadTimer->Connect("Timeout()","AliEveEventManager",this,"NextEvent()");
657 }
658 fAutoLoadTimer->Start((Long_t)fAutoLoadTime*1000,kTRUE);
659 }
f76c9e9b 660 else
661 {
319f3084 662 if (fAutoLoadTimer) fAutoLoadTimer->Stop();
663 }
664}
665
f76c9e9b 666void AliEveEventManager::NewEventLoaded()
667{
668 // Emit NewEventLoaded signal.
669
670 Emit("NewEventLoaded()");
671}
672
319f3084 673const char* AliEveEventManager::GetEventInfo() const
674{
675 // Dumps the event-header contents
676
677 static TString eventInfo;
678
ec835ab5 679 if (!fRawReader) {
680 eventInfo.Form("No raw-data event info is available!\n");
681 }
682 else {
683 const UInt_t* attr = fRawReader->GetAttributes();
684 eventInfo.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",
685 fRawReader->GetRunNumber(),fRawReader->GetType(),AliRawEventHeaderBase::GetTypeName(fRawReader->GetType()),
686 fRawReader->GetPeriod(),fRawReader->GetOrbitID(),fRawReader->GetBCID(),
687 fRawReader->GetClassMask(),
688 *fRawReader->GetDetectorPattern(),AliDAQ::ListOfTriggeredDetectors(*fRawReader->GetDetectorPattern()),
689 attr[0],attr[1],attr[2],
690 fRawReader->GetTimestamp());
691 }
692 if (!fESD) {
693 eventInfo.Append(Form("\nNo ESD event info is available!\n"));
694 }
695 else {
696 TString acttrclasses = fESD->GetESDRun()->GetActiveTriggerClasses();
697 TString firedtrclasses = fESD->GetFiredTriggerClasses();
698 eventInfo.Append(Form("\nESD 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",
699 fESD->GetRunNumber(),
700 acttrclasses.Data(),
701 fESD->GetEventType(),AliRawEventHeaderBase::GetTypeName(fESD->GetEventType()),
702 fESD->GetPeriodNumber(),fESD->GetOrbitNumber(),fESD->GetBunchCrossNumber(),
703 fESD->GetTriggerMask(),firedtrclasses.Data(),
704 fESD->GetEventNumberInFile(),
705 fESD->GetTimeStamp()));
706 }
319f3084 707
708 return eventInfo.Data();
709}
710