]>
Commit | Line | Data |
---|---|---|
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" | |
008ac94c | 11 | #include "AliEveEventSelector.h" |
f6afd0e1 | 12 | #include "AliEveMacroExecutor.h" |
3d94b490 | 13 | #include <TEveElement.h> |
84aff7a4 | 14 | #include <TEveManager.h> |
b9579f03 | 15 | #include <TEveViewer.h> |
5a5a1232 | 16 | |
17 | #include <AliRunLoader.h> | |
93845f6c | 18 | #include <AliRun.h> |
b3b7b8d3 | 19 | #include <AliESDRun.h> |
af885e0f | 20 | #include <AliESDEvent.h> |
3aecaefc | 21 | #include <AliESDfriend.h> |
b3b7b8d3 | 22 | #include <AliAODEvent.h> |
23 | ||
ec835ab5 | 24 | #include <AliDAQ.h> |
25 | #include <AliRawEventHeaderBase.h> | |
c2c4b7a2 | 26 | #include <AliRawReaderRoot.h> |
27 | #include <AliRawReaderFile.h> | |
28 | #include <AliRawReaderDate.h> | |
f7a1cc68 | 29 | #include <AliMagF.h> |
632d2b03 | 30 | #include <AliCDBManager.h> |
d3ed470c | 31 | #include <AliCDBStorage.h> |
8661a211 | 32 | #include <AliGRPObject.h> |
632d2b03 | 33 | #include <AliHeader.h> |
34 | #include <AliGeomManager.h> | |
55216596 | 35 | #include <AliGRPManager.h> |
14a4b686 | 36 | #include <AliSysInfo.h> |
5a5a1232 | 37 | |
38 | #include <TFile.h> | |
39 | #include <TTree.h> | |
fbc350a3 | 40 | #include <TGeoManager.h> |
8661a211 | 41 | #include <TGeoGlobalMagField.h> |
5a5a1232 | 42 | #include <TSystem.h> |
12365217 | 43 | #include <TTimeStamp.h> |
8661a211 | 44 | #include <TPRegexp.h> |
45 | #include <TError.h> | |
ccd2624b | 46 | #include <TEnv.h> |
3d94b490 | 47 | #include <TString.h> |
48 | #include <TMap.h> | |
d810d0de | 49 | |
a15e6d7d | 50 | //============================================================================== |
51 | //============================================================================== | |
52 | // AliEveEventManager | |
53 | //============================================================================== | |
5a5a1232 | 54 | |
57ffa5fb | 55 | //______________________________________________________________________________ |
5a5a1232 | 56 | // |
4d62585e | 57 | // Provides interface for loading and navigating standard AliRoot data |
b3b7b8d3 | 58 | // (AliRunLoader), ESD, AOD and RAW. |
59 | // | |
60 | // ESDfriend is attached automatically, if the file is found. | |
61 | // | |
62 | // AODfriends are not attached automatically as there are several | |
63 | // possible files involved. To have a specific AODfriend attached, call | |
64 | // static method | |
65 | // AliEveEventManager::AddAODfriend("AliAOD.VertexingHF.root"); | |
66 | // before initializing the event-manager. | |
51346b82 | 67 | // |
a15e6d7d | 68 | // Also provides interface to magnetic-field and geometry. Mostly |
69 | // intended as wrappers over standard AliRoot functionality for | |
70 | // convenient use from visualizateion macros. | |
4d62585e | 71 | // |
72 | // There can be a single main event-manger, it is stored in private | |
73 | // data member fgMaster and can be accessed via static member function | |
74 | // GetMaster(). | |
75 | // | |
76 | // For event overlaying and embedding one can instantiate additional | |
77 | // event-managers via static method AddDependentManager(const TString& path). | |
78 | // This interface is under development. | |
5a5a1232 | 79 | |
d810d0de | 80 | ClassImp(AliEveEventManager) |
5a5a1232 | 81 | |
d810d0de | 82 | Bool_t AliEveEventManager::fgAssertRunLoader = kFALSE; |
c76ea574 | 83 | Bool_t AliEveEventManager::fgAssertESD = kFALSE; |
b3b7b8d3 | 84 | Bool_t AliEveEventManager::fgAssertAOD = kFALSE; |
c2c4b7a2 | 85 | Bool_t AliEveEventManager::fgAssertRaw = kFALSE; |
5a5a1232 | 86 | |
c2c4b7a2 | 87 | TString AliEveEventManager::fgESDFileName("AliESDs.root"); |
b3b7b8d3 | 88 | TString AliEveEventManager::fgAODFileName("AliAOD.root"); |
c2c4b7a2 | 89 | TString AliEveEventManager::fgRawFileName("raw.root"); |
c63f2997 | 90 | TString AliEveEventManager::fgCdbUri; |
632d2b03 | 91 | |
b3b7b8d3 | 92 | TList* AliEveEventManager::fgAODfriends = 0; |
93 | ||
25dddcb1 | 94 | Bool_t AliEveEventManager::fgRawFromStandardLoc = kFALSE; |
95 | ||
96 | Bool_t AliEveEventManager::fgGRPLoaded = kFALSE; | |
97 | AliMagF* AliEveEventManager::fgMagField = 0; | |
98 | Bool_t AliEveEventManager::fgUniformField = kFALSE; | |
8661a211 | 99 | |
4d62585e | 100 | AliEveEventManager* AliEveEventManager::fgMaster = 0; |
101 | AliEveEventManager* AliEveEventManager::fgCurrent = 0; | |
102 | ||
488869c1 | 103 | void AliEveEventManager::InitInternals() |
104 | { | |
105 | // Initialize internal members. | |
106 | ||
4d62585e | 107 | static const TEveException kEH("AliEveEventManager::InitInternals "); |
108 | ||
109 | if (fgCurrent != 0) | |
110 | { | |
111 | throw(kEH + "Dependent event-managers should be created via static method AddDependentManager()."); | |
112 | } | |
113 | ||
114 | if (fgMaster == 0) | |
115 | { | |
116 | fgMaster = this; | |
117 | } | |
118 | ||
119 | fgCurrent = this; | |
120 | ||
488869c1 | 121 | fAutoLoadTimer = new TTimer; |
122 | fAutoLoadTimer->Connect("Timeout()", "AliEveEventManager", this, "AutoLoadNextEvent()"); | |
e10d437c | 123 | fAutoLoadTimer->Connect("Timeout()", "AliEveEventManager", this, "Timeout()"); |
488869c1 | 124 | |
125 | fExecutor = new AliEveMacroExecutor; | |
08b0f222 | 126 | |
127 | fTransients = new TEveElementList("Transients", "Transient per-event elements."); | |
128 | fTransients->IncDenyDestroy(); | |
8661a211 | 129 | gEve->AddToListTree(fTransients, kFALSE); |
130 | ||
131 | fTransientLists = new TEveElementList("Transient Lists", "Containers of transient elements."); | |
132 | fTransientLists->IncDenyDestroy(); | |
133 | gEve->AddToListTree(fTransientLists, kFALSE); | |
008ac94c | 134 | |
135 | fPEventSelector = new AliEveEventSelector(this); | |
3d94b490 | 136 | |
137 | fGlobal = new TMap; fGlobal->SetOwnerKeyValue(); | |
488869c1 | 138 | } |
93845f6c | 139 | |
ba5d58f2 | 140 | AliEveEventManager::AliEveEventManager(const TString& name) : |
141 | TEveEventManager(name), | |
265ecb21 | 142 | |
c2c4b7a2 | 143 | fPath ( ), fEventId (-1), |
265ecb21 | 144 | fRunLoader (0), |
90fa773e | 145 | fESDFile (0), fESDTree (0), fESD (0), |
c2c4b7a2 | 146 | fESDfriend (0), fESDfriendExists(kFALSE), |
b3b7b8d3 | 147 | fAODFile (0), fAODTree (0), fAOD (0), |
319f3084 | 148 | fRawReader (0), |
80547f2d | 149 | fAutoLoad (kFALSE), fAutoLoadTime (5.), fAutoLoadTimer(0), |
150 | fIsOpen (kFALSE), fHasEvent (kFALSE), fExternalCtrl (kFALSE), | |
3d94b490 | 151 | fGlobal (0), fGlobalReplace (kTRUE), fGlobalUpdate (kTRUE), |
8661a211 | 152 | fExecutor (0), fTransients(0), fTransientLists(0), |
008ac94c | 153 | fPEventSelector(0), |
4d62585e | 154 | fSubManagers (0), |
488869c1 | 155 | fAutoLoadTimerRunning(kFALSE) |
c76ea574 | 156 | { |
157 | // Default constructor. | |
488869c1 | 158 | |
159 | InitInternals(); | |
c76ea574 | 160 | } |
5a5a1232 | 161 | |
ba5d58f2 | 162 | AliEveEventManager::AliEveEventManager(const TString& name, const TString& path, Int_t ev) : |
163 | TEveEventManager(name, path), | |
265ecb21 | 164 | |
c76ea574 | 165 | fPath (path), fEventId(-1), |
265ecb21 | 166 | fRunLoader (0), |
90fa773e | 167 | fESDFile (0), fESDTree (0), fESD (0), |
c2c4b7a2 | 168 | fESDfriend (0), fESDfriendExists(kFALSE), |
b3b7b8d3 | 169 | fAODFile (0), fAODTree (0), fAOD (0), |
319f3084 | 170 | fRawReader (0), |
488869c1 | 171 | fAutoLoad (kFALSE), fAutoLoadTime (5), fAutoLoadTimer(0), |
80547f2d | 172 | fIsOpen (kFALSE), fHasEvent (kFALSE), fExternalCtrl (kFALSE), |
3d94b490 | 173 | fGlobal (0), fGlobalReplace (kTRUE), fGlobalUpdate (kTRUE), |
8661a211 | 174 | fExecutor (0), fTransients(0), fTransientLists(0), |
008ac94c | 175 | fPEventSelector(0), |
4d62585e | 176 | fSubManagers (0), |
488869c1 | 177 | fAutoLoadTimerRunning(kFALSE) |
5a5a1232 | 178 | { |
c76ea574 | 179 | // Constructor with event-directory URL and event-id. |
180 | ||
488869c1 | 181 | InitInternals(); |
182 | ||
5a5a1232 | 183 | Open(); |
488869c1 | 184 | if (ev >= 0) |
185 | { | |
186 | GotoEvent(ev); | |
187 | } | |
5a5a1232 | 188 | } |
189 | ||
a15e6d7d | 190 | AliEveEventManager::~AliEveEventManager() |
191 | { | |
192 | // Destructor. | |
e10d437c | 193 | fAutoLoadTimer->Stop(); |
194 | fAutoLoadTimer->Disconnect("Timeout"); | |
a15e6d7d | 195 | |
ba5d58f2 | 196 | delete fSubManagers; |
197 | ||
80547f2d | 198 | if (fIsOpen) |
199 | { | |
200 | Close(); | |
201 | } | |
08b0f222 | 202 | |
203 | fTransients->DecDenyDestroy(); | |
204 | fTransients->Destroy(); | |
8661a211 | 205 | |
206 | fTransientLists->DecDenyDestroy(); | |
207 | fTransientLists->Destroy(); | |
e10d437c | 208 | |
209 | //delete fExecutor; | |
a15e6d7d | 210 | } |
211 | ||
57ffa5fb | 212 | /******************************************************************************/ |
5a5a1232 | 213 | |
4d62585e | 214 | void AliEveEventManager::SetESDFileName(const TString& esd) |
c2c4b7a2 | 215 | { |
216 | // Set file-name for opening ESD, default "AliESDs.root". | |
217 | ||
4d62585e | 218 | if ( ! esd.IsNull()) fgESDFileName = esd; |
c2c4b7a2 | 219 | } |
220 | ||
b3b7b8d3 | 221 | void AliEveEventManager::SetAODFileName(const TString& aod) |
222 | { | |
223 | // Set file-name for opening AOD, default "AliAOD.root". | |
224 | ||
225 | if ( ! aod.IsNull()) fgAODFileName = aod; | |
226 | } | |
227 | ||
228 | void AliEveEventManager::AddAODfriend(const TString& friendFileName) | |
229 | { | |
230 | // Add new AOD friend file-name to be attached when opening AOD. | |
231 | // This should include '.root', as in 'AliAOD.VertexingHF.root'. | |
232 | ||
233 | if (fgAODfriends == 0) | |
234 | { | |
235 | fgAODfriends = new TList; | |
236 | fgAODfriends->SetOwner(kTRUE); | |
237 | } | |
f8d5a389 | 238 | if (fgAODfriends->FindObject(friendFileName) == 0) |
239 | { | |
240 | fgAODfriends->Add(new TObjString(friendFileName)); | |
241 | } | |
b3b7b8d3 | 242 | } |
243 | ||
4d62585e | 244 | void AliEveEventManager::SetRawFileName(const TString& raw) |
c2c4b7a2 | 245 | { |
246 | // Set file-name for opening of raw-data, default "raw.root" | |
4d62585e | 247 | if ( ! raw.IsNull()) fgRawFileName = raw; |
c2c4b7a2 | 248 | } |
249 | ||
4d62585e | 250 | void AliEveEventManager::SetCdbUri(const TString& cdb) |
c2c4b7a2 | 251 | { |
c63f2997 | 252 | // Set path to CDB, there is no default. |
c2c4b7a2 | 253 | |
4d62585e | 254 | if ( ! cdb.IsNull()) fgCdbUri = cdb; |
c2c4b7a2 | 255 | } |
256 | ||
b3b7b8d3 | 257 | void AliEveEventManager::SetAssertElements(Bool_t assertRunloader, Bool_t assertEsd, |
258 | Bool_t assertAod, Bool_t assertRaw) | |
c2c4b7a2 | 259 | { |
260 | // Set global flags that detrmine which parts of the event-data must | |
261 | // be present when the event is opened. | |
262 | ||
263 | fgAssertRunLoader = assertRunloader; | |
264 | fgAssertESD = assertEsd; | |
b3b7b8d3 | 265 | fgAssertAOD = assertAod; |
c2c4b7a2 | 266 | fgAssertRaw = assertRaw; |
267 | } | |
268 | ||
25dddcb1 | 269 | void AliEveEventManager::SearchRawForCentralReconstruction() |
270 | { | |
271 | // Enable searching of raw data in standard location. The path passed to | |
272 | // Open() is expected to point to a centrally reconstructed run, e.g.: | |
273 | // "alien:///alice/data/2009/LHC09c/000101134/ESDs/pass1/09000101134018.10". | |
274 | ||
275 | fgRawFromStandardLoc = kTRUE; | |
276 | } | |
277 | ||
c2c4b7a2 | 278 | /******************************************************************************/ |
279 | ||
d810d0de | 280 | void AliEveEventManager::Open() |
5a5a1232 | 281 | { |
c76ea574 | 282 | // Open event-data from URL specified in fPath. |
283 | // Attempts to create AliRunLoader() and to open ESD with ESDfriends. | |
284 | // Warning is reported if run-loader or ESD is not found. | |
285 | // Global data-members fgAssertRunLoader and fgAssertESD can be set | |
286 | // to throw exceptions instead. | |
287 | ||
a15e6d7d | 288 | static const TEveException kEH("AliEveEventManager::Open "); |
5a5a1232 | 289 | |
80547f2d | 290 | if (fExternalCtrl) |
291 | { | |
292 | throw (kEH + "Event-loop is under external control."); | |
293 | } | |
294 | if (fIsOpen) | |
295 | { | |
296 | throw (kEH + "Event-files already opened."); | |
297 | } | |
298 | ||
5a5a1232 | 299 | gSystem->ExpandPathName(fPath); |
ba5d58f2 | 300 | // The following magick is required for ESDfriends to be loaded properly |
5a58dc18 | 301 | // from non-current directory. |
302 | if (fPath.IsNull() || fPath == ".") | |
303 | { | |
304 | fPath = gSystem->WorkingDirectory(); | |
305 | } | |
306 | else if ( ! fPath.BeginsWith("file:/")) | |
307 | { | |
308 | TUrl url(fPath, kTRUE); | |
309 | TString protocol(url.GetProtocol()); | |
310 | if (protocol == "file" && fPath[0] != '/') | |
311 | fPath = Form("%s/%s", gSystem->WorkingDirectory(), fPath.Data()); | |
312 | } | |
5a5a1232 | 313 | |
632d2b03 | 314 | Int_t runNo = -1; |
315 | ||
db748c38 | 316 | // Open ESD and ESDfriends |
317 | ||
318 | TString esdPath(Form("%s/%s", fPath.Data(), fgESDFileName.Data())); | |
1ac92ea8 | 319 | if (fPath.EndsWith(".zip")) esdPath.Form("%s#%s",fPath.Data(),fgESDFileName.Data()); |
db748c38 | 320 | if ((fESDFile = TFile::Open(esdPath))) |
321 | { | |
322 | fESD = new AliESDEvent(); | |
323 | fESDTree = (TTree*) fESDFile->Get("esdTree"); | |
324 | if (fESDTree != 0) | |
325 | { | |
73267f50 | 326 | // Check if ESDfriends exists and attach the branch. |
327 | // We use TFile::Open() instead of gSystem->AccessPathName | |
328 | // as it seems to work better when attachine alieve to a | |
329 | // running reconstruction process with auto-save on. | |
db748c38 | 330 | TString p(Form("%s/AliESDfriends.root", fPath.Data())); |
1ac92ea8 | 331 | if (fPath.EndsWith(".zip")) p.Form("%s#AliESDfriends.root",fPath.Data()); |
fa46c586 | 332 | TFile *esdFriendFile = TFile::Open(p); |
73267f50 | 333 | if (esdFriendFile) |
334 | { | |
fa46c586 | 335 | if (!esdFriendFile->IsZombie()) |
73267f50 | 336 | { |
337 | esdFriendFile->Close(); | |
338 | fESDfriendExists = kTRUE; | |
339 | fESDTree->SetBranchStatus ("ESDfriend*", 1); | |
340 | } | |
341 | delete esdFriendFile; | |
db748c38 | 342 | } |
fa46c586 | 343 | |
344 | fESD->ReadFromTree(fESDTree); | |
73267f50 | 345 | if (fESDfriendExists) |
346 | { | |
347 | fESDfriend = (AliESDfriend*) fESD->FindListObject("AliESDfriend"); | |
348 | Info(kEH, "found and attached ESD friend."); | |
349 | } | |
350 | else | |
351 | { | |
352 | Warning(kEH, "ESDfriend not found."); | |
353 | } | |
354 | ||
fa46c586 | 355 | if (fESDTree->GetEntry(0) <= 0) |
73267f50 | 356 | { |
357 | delete fESDFile; fESDFile = 0; | |
358 | delete fESD; fESD = 0; | |
359 | Warning(kEH, "failed getting the first entry from esdTree."); | |
360 | } | |
fa46c586 | 361 | else |
73267f50 | 362 | { |
363 | if (runNo < 0) | |
364 | runNo = fESD->GetESDRun()->GetRunNumber(); | |
365 | } | |
db748c38 | 366 | } |
367 | else // esdtree == 0 | |
368 | { | |
369 | delete fESDFile; fESDFile = 0; | |
fa46c586 | 370 | delete fESD; fESD = 0; |
db748c38 | 371 | Warning(kEH, "failed getting the esdTree."); |
372 | } | |
373 | } | |
374 | else // esd not readable | |
375 | { | |
376 | Warning(kEH, "can not read ESD file '%s'.", esdPath.Data()); | |
377 | } | |
378 | if (fESDTree == 0) | |
379 | { | |
380 | if (fgAssertESD) | |
381 | { | |
382 | throw (kEH + "ESD not initialized. Its precence was requested."); | |
383 | } else { | |
384 | Warning(kEH, "ESD not initialized."); | |
385 | } | |
386 | } | |
387 | ||
b3b7b8d3 | 388 | // Open AOD and registered friends |
389 | ||
390 | TString aodPath(Form("%s/%s", fPath.Data(), fgAODFileName.Data())); | |
1ac92ea8 | 391 | if (fPath.EndsWith(".zip")) aodPath.Form("%s#%s",fPath.Data(),fgAODFileName.Data()); |
b3b7b8d3 | 392 | if ((fAODFile = TFile::Open(aodPath))) |
393 | { | |
394 | fAOD = new AliAODEvent(); | |
395 | fAODTree = (TTree*) fAODFile->Get("aodTree"); | |
396 | if (fAODTree != 0) | |
397 | { | |
398 | // Check if AODfriends exist and attach them. | |
399 | TIter friends(fgAODfriends); | |
400 | TObjString *name; | |
401 | while ((name = (TObjString*) friends()) != 0) | |
402 | { | |
403 | TString p(Form("%s/%s", fPath.Data(), name->GetName())); | |
1ac92ea8 | 404 | if (fPath.EndsWith(".zip")) p.Form("%s#%s",fPath.Data(),name->GetName()); |
b3b7b8d3 | 405 | if (gSystem->AccessPathName(p, kReadPermission) == kFALSE) |
406 | { | |
407 | fAODTree->AddFriend("aodTree", name->GetName()); | |
408 | } | |
409 | } | |
410 | ||
411 | fAOD->ReadFromTree(fAODTree); | |
412 | ||
413 | if (fAODTree->GetEntry(0) <= 0) | |
414 | { | |
415 | delete fAODFile; fAODFile = 0; | |
416 | delete fAOD; fAOD = 0; | |
417 | Warning(kEH, "failed getting the first entry from addTree."); | |
418 | } | |
419 | else | |
420 | { | |
421 | if (runNo < 0) | |
422 | runNo = fAOD->GetRunNumber(); | |
423 | } | |
424 | } | |
425 | else // aodtree == 0 | |
426 | { | |
427 | delete fAODFile; fAODFile = 0; | |
428 | delete fAOD; fAOD = 0; | |
429 | Warning(kEH, "failed getting the aodTree."); | |
430 | } | |
431 | } | |
432 | else // aod not readable | |
433 | { | |
434 | Warning(kEH, "can not read AOD file '%s'.", aodPath.Data()); | |
435 | } | |
436 | if (fAODTree == 0) | |
437 | { | |
438 | if (fgAssertAOD) | |
439 | { | |
440 | throw (kEH + "AOD not initialized. Its precence was requested."); | |
441 | } else { | |
442 | Warning(kEH, "AOD not initialized."); | |
443 | } | |
444 | } | |
445 | ||
db748c38 | 446 | // Open RunLoader from galice.root |
447 | ||
a15e6d7d | 448 | TString gaPath(Form("%s/galice.root", fPath.Data())); |
1ac92ea8 | 449 | if (fPath.EndsWith(".zip")) gaPath.Form("%s#%s",fPath.Data(),"galice.root"); |
c2c4b7a2 | 450 | // If i use open directly, we get fatal. |
db748c38 | 451 | // Is AccessPathName check ok for xrootd / alien? Yes, not for http. |
3766697a | 452 | // Seems not to work for alien anymore. |
67d3e221 | 453 | // Fixed in ROOT on 27.10.2009, rev 30888. |
454 | // To revert after we move to root-5.26. | |
3766697a | 455 | TFile *gafile = TFile::Open(gaPath); |
456 | if (gafile) | |
90fa773e | 457 | { |
3766697a | 458 | gafile->Close(); |
459 | delete gafile; | |
460 | // if (gSystem->AccessPathName(gaPath, kReadPermission) == kFALSE) | |
461 | // { | |
ba5d58f2 | 462 | fRunLoader = AliRunLoader::Open(gaPath, GetName()); |
a1896a82 | 463 | if (fRunLoader) |
5a5a1232 | 464 | { |
a15e6d7d | 465 | TString alicePath = fPath + "/"; |
466 | fRunLoader->SetDirName(alicePath); | |
a1896a82 | 467 | |
468 | if (fRunLoader->LoadgAlice() != 0) | |
c2c4b7a2 | 469 | Warning(kEH, "failed loading gAlice via run-loader."); |
a1896a82 | 470 | |
471 | if (fRunLoader->LoadHeader() == 0) | |
472 | { | |
db748c38 | 473 | if (runNo < 0) |
474 | runNo = fRunLoader->GetHeader()->GetRun(); | |
a1896a82 | 475 | } |
476 | else | |
477 | { | |
c2c4b7a2 | 478 | Warning(kEH, "failed loading run-loader's header."); |
479 | delete fRunLoader; | |
480 | fRunLoader = 0; | |
a1896a82 | 481 | } |
482 | } | |
483 | else // run-loader open failed | |
484 | { | |
a15e6d7d | 485 | Warning(kEH, "failed opening ALICE run-loader from '%s'.", gaPath.Data()); |
5a5a1232 | 486 | } |
5a5a1232 | 487 | } |
a1896a82 | 488 | else // galice not readable |
489 | { | |
a15e6d7d | 490 | Warning(kEH, "can not read '%s'.", gaPath.Data()); |
a1896a82 | 491 | } |
492 | if (fRunLoader == 0) | |
493 | { | |
84aff7a4 | 494 | if (fgAssertRunLoader) |
c2c4b7a2 | 495 | throw (kEH + "Bootstraping of run-loader failed. Its precence was requested."); |
a1896a82 | 496 | else |
a15e6d7d | 497 | Warning(kEH, "Bootstraping of run-loader failed."); |
a1896a82 | 498 | } |
51346b82 | 499 | |
db748c38 | 500 | // Open raw-data file |
5a5a1232 | 501 | |
25dddcb1 | 502 | TString rawPath; |
503 | if (fgRawFromStandardLoc) | |
504 | { | |
505 | if (!fPath.BeginsWith("alien:")) | |
506 | throw kEH + "Standard raw search requested, but the directory is not in AliEn."; | |
507 | if (!fPath.Contains("/ESDs/")) | |
508 | throw kEH + "Standard raw search requested, but does not contain 'ESDs' directory."; | |
509 | ||
510 | TPMERegexp chunk("/([\\d\\.])+/?$"); | |
511 | Int_t nm = chunk.Match(fPath); | |
512 | if (nm != 2) | |
513 | throw kEH + "Standard raw search requested, but the path does not end with chunk-id directory."; | |
514 | ||
515 | TPMERegexp esdstrip("/ESDs/.*"); | |
516 | rawPath = fPath; | |
517 | esdstrip.Substitute(rawPath, "/raw/"); | |
518 | rawPath += chunk[0]; | |
519 | rawPath += ".root"; | |
520 | ||
521 | Info(kEH, "Standard raw search requested, using the following path:\n %s\n", rawPath.Data()); | |
522 | } | |
523 | else | |
524 | { | |
525 | rawPath.Form("%s/%s", fPath.Data(), fgRawFileName.Data()); | |
526 | } | |
ecb84424 | 527 | // If i use open directly, raw-reader reports an error but i have |
528 | // no way to detect it. | |
529 | // Is this (AccessPathName check) ok for xrootd / alien? Yes, not for http. | |
f337c1d6 | 530 | AliLog::EType_t oldLogLevel = (AliLog::EType_t) AliLog::GetGlobalLogLevel(); |
531 | if (fgAssertRaw == kFALSE) | |
532 | { | |
533 | AliLog::SetGlobalLogLevel(AliLog::kFatal); | |
534 | } | |
ecb84424 | 535 | if (gSystem->AccessPathName(rawPath, kReadPermission) == kFALSE) |
2827badf | 536 | { |
537 | fRawReader = AliRawReader::Create(rawPath); | |
538 | } | |
539 | else | |
540 | { | |
541 | fRawReader = AliRawReader::Create(fgRawFileName); | |
542 | } | |
f337c1d6 | 543 | if (fgAssertRaw == kFALSE) |
544 | { | |
545 | AliLog::SetGlobalLogLevel(oldLogLevel); | |
546 | } | |
547 | ||
c2c4b7a2 | 548 | if (fRawReader == 0) |
549 | { | |
550 | if (fgAssertRaw) | |
551 | { | |
552 | throw (kEH + "raw-data not initialized. Its precence was requested."); | |
ea8fceef | 553 | } |
554 | else | |
555 | { | |
c2c4b7a2 | 556 | Warning(kEH, "raw-data not initialized."); |
557 | } | |
558 | } | |
559 | ||
632d2b03 | 560 | if (runNo < 0) |
c2c4b7a2 | 561 | { |
562 | if (fRawReader) | |
563 | { | |
ea8fceef | 564 | if ( ! fRawReader->NextEvent()) |
565 | { | |
566 | throw (kEH + "can not go to first event in raw-reader to determine run-id."); | |
567 | } | |
c2c4b7a2 | 568 | runNo = fRawReader->GetRunNumber(); |
ca49b003 | 569 | Info(kEH, "Determining run-no from raw ... run=%d.", runNo); |
c2c4b7a2 | 570 | fRawReader->RewindEvents(); |
ea8fceef | 571 | } |
572 | else | |
573 | { | |
c2c4b7a2 | 574 | throw (kEH + "unknown run number."); |
575 | } | |
576 | } | |
632d2b03 | 577 | |
b3b7b8d3 | 578 | // Initialize OCDB ... only in master event-manager |
579 | ||
ba5d58f2 | 580 | if (this == fgMaster) |
632d2b03 | 581 | { |
582 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
d3ed470c | 583 | if (cdb->IsDefaultStorageSet() == kTRUE) |
584 | { | |
585 | Warning(kEH, "CDB already set - using the old storage:\n '%s'", | |
586 | cdb->GetDefaultStorage()->GetURI().Data()); | |
587 | } | |
588 | else | |
589 | { | |
c63f2997 | 590 | if (fgCdbUri.IsNull()) |
591 | { | |
592 | gEnv->SetValue("Root.Stacktrace", "no"); | |
593 | Fatal("Open()", "OCDB path was not specified."); | |
594 | } | |
595 | ||
596 | // Handle some special cases for MC (should be in OCDBManager). | |
597 | if (fgCdbUri == "mcideal://") | |
598 | cdb->SetDefaultStorage("MC", "Ideal"); | |
599 | else if (fgCdbUri == "mcresidual://") | |
600 | cdb->SetDefaultStorage("MC", "Residual"); | |
601 | else if (fgCdbUri == "mcfull://") | |
602 | cdb->SetDefaultStorage("MC", "Full"); | |
603 | else if (fgCdbUri == "local://") { | |
604 | fgCdbUri = "local://$ALICE_ROOT/OCDB"; | |
605 | cdb->SetDefaultStorage(fgCdbUri); | |
606 | } else | |
607 | cdb->SetDefaultStorage(fgCdbUri); | |
d33bb434 | 608 | |
609 | cdb->SetRun(runNo); | |
610 | ||
d3ed470c | 611 | if (cdb->IsDefaultStorageSet() == kFALSE) |
106b85e3 | 612 | throw kEH + "CDB initialization failed for '" + fgCdbUri + "'."; |
d3ed470c | 613 | } |
047cb6f4 | 614 | |
c63f2997 | 615 | if (fgCdbUri.BeginsWith("local://")) |
047cb6f4 | 616 | { |
617 | TString grp = "GRP/GRP/Data"; | |
618 | TString grppath = fPath + "/" + grp; | |
619 | if (gSystem->AccessPathName(grppath, kReadPermission) == kFALSE) | |
620 | { | |
621 | if (cdb->GetSpecificStorage(grp)) | |
622 | { | |
623 | Warning(kEH, "Local GRP exists, but the specific storage is already set."); | |
624 | } | |
625 | else | |
626 | { | |
627 | Info(kEH, "Setting CDB specific-storage for GRP from event directory."); | |
628 | TString lpath("local://"); | |
629 | lpath += fPath; | |
630 | cdb->SetSpecificStorage(grp, lpath); | |
631 | } | |
632 | } | |
633 | } | |
632d2b03 | 634 | } |
635 | ||
80547f2d | 636 | fIsOpen = kTRUE; |
5a5a1232 | 637 | } |
638 | ||
482d0751 | 639 | void AliEveEventManager::SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd, AliESDfriend *esdf) |
319f3084 | 640 | { |
b3b7b8d3 | 641 | // Set an event from an external source. |
642 | // The method is used in the online visualisation. | |
643 | // AOD is not supported. | |
80547f2d | 644 | |
645 | static const TEveException kEH("AliEveEventManager::SetEvent "); | |
646 | ||
647 | if (fIsOpen) | |
648 | { | |
649 | Warning(kEH, "Event-files were open. Closing and switching to external control."); | |
650 | Close(); | |
651 | } | |
652 | ||
319f3084 | 653 | fRunLoader = runLoader; |
654 | fRawReader = rawReader; | |
80547f2d | 655 | fESD = esd; |
482d0751 | 656 | fESDfriend = esdf; |
b3b7b8d3 | 657 | fAOD = 0; |
80547f2d | 658 | |
659 | fEventId++; | |
660 | fHasEvent = kTRUE; | |
661 | fExternalCtrl = kTRUE; | |
662 | ||
319f3084 | 663 | SetTitle("Online event in memory"); |
80547f2d | 664 | SetName ("Online Event"); |
319f3084 | 665 | ElementChanged(); |
ba5d58f2 | 666 | |
319f3084 | 667 | AfterNewEventLoaded(); |
47aab29b | 668 | |
ecb84424 | 669 | if (fAutoLoad) StartAutoLoadTimer(); |
319f3084 | 670 | } |
671 | ||
96b90c2e | 672 | Int_t AliEveEventManager::GetMaxEventId(Bool_t refreshESD) const |
516389a2 | 673 | { |
674 | // Returns maximum available event id. | |
80547f2d | 675 | // If under external control or event is not opened -1 is returned. |
516389a2 | 676 | // If raw-data is the only data-source this can not be known |
677 | // and 10,000,000 is returned. | |
678 | // If neither data-source is initialised an exception is thrown. | |
679 | // If refresh_esd is true and ESD is the primary event-data source | |
680 | // its header is re-read from disk. | |
681 | ||
682 | static const TEveException kEH("AliEveEventManager::GetMaxEventId "); | |
683 | ||
80547f2d | 684 | if (fExternalCtrl || fIsOpen == kFALSE) |
685 | { | |
686 | return -1; | |
687 | } | |
688 | ||
f76c9e9b | 689 | if (fESDTree) |
516389a2 | 690 | { |
96b90c2e | 691 | if (refreshESD) |
692 | { | |
693 | fESDTree->Refresh(); | |
694 | fPEventSelector->Update(); | |
695 | } | |
f76c9e9b | 696 | return fESDTree->GetEntries() - 1; |
516389a2 | 697 | } |
b3b7b8d3 | 698 | else if (fAODTree) |
699 | { | |
700 | return fAODTree->GetEntries() - 1; | |
701 | } | |
f76c9e9b | 702 | else if (fRunLoader) |
516389a2 | 703 | { |
f76c9e9b | 704 | return fRunLoader->GetNumberOfEvents() - 1; |
516389a2 | 705 | } |
706 | else if (fRawReader) | |
707 | { | |
ae1a1b11 | 708 | Int_t n = fRawReader->GetNumberOfEvents() - 1; |
709 | return n > -1 ? n : 10000000; | |
516389a2 | 710 | } |
711 | else | |
712 | { | |
b3b7b8d3 | 713 | throw (kEH + "neither ESD, AOD, RunLoader nor Raw loaded."); |
516389a2 | 714 | } |
715 | } | |
716 | ||
d810d0de | 717 | void AliEveEventManager::GotoEvent(Int_t event) |
1eaa5849 | 718 | { |
73c1c0ec | 719 | // Load data for specified event. |
720 | // If event is out of range an exception is thrown and old state | |
721 | // is preserved. | |
722 | // After successful loading of event, the virtual function | |
723 | // AfterNewEventLoaded() is called. This executes commands that | |
724 | // were registered via TEveEventManager::AddNewEventCommand(). | |
516389a2 | 725 | // |
726 | // If event is negative, it is subtracted from the number of | |
727 | // available events, thus passing -1 will load the last event. | |
728 | // This is not supported when raw-data is the only data-source | |
729 | // as the number of events is not known. | |
73c1c0ec | 730 | |
a15e6d7d | 731 | static const TEveException kEH("AliEveEventManager::GotoEvent "); |
1eaa5849 | 732 | |
488869c1 | 733 | if (fAutoLoadTimerRunning) |
734 | { | |
735 | throw (kEH + "Event auto-load timer is running."); | |
736 | } | |
80547f2d | 737 | if (fExternalCtrl) |
738 | { | |
739 | throw (kEH + "Event-loop is under external control."); | |
740 | } | |
488869c1 | 741 | else if (!fIsOpen) |
80547f2d | 742 | { |
743 | throw (kEH + "Event-files not opened."); | |
744 | } | |
745 | ||
746 | fHasEvent = kFALSE; | |
747 | ||
1eaa5849 | 748 | Int_t maxEvent = 0; |
db748c38 | 749 | if (fESDTree) |
516389a2 | 750 | { |
fe98ffed | 751 | if (event >= fESDTree->GetEntries()) |
752 | fESDTree->Refresh(); | |
1eaa5849 | 753 | maxEvent = fESDTree->GetEntries() - 1; |
516389a2 | 754 | if (event < 0) |
755 | event = fESDTree->GetEntries() + event; | |
756 | } | |
b3b7b8d3 | 757 | else if (fAODTree) |
758 | { | |
759 | maxEvent = fAODTree->GetEntries() - 1; | |
760 | if (event < 0) | |
761 | event = fAODTree->GetEntries() + event; | |
762 | } | |
db748c38 | 763 | else if (fRunLoader) |
764 | { | |
765 | maxEvent = fRunLoader->GetNumberOfEvents() - 1; | |
766 | if (event < 0) | |
767 | event = fRunLoader->GetNumberOfEvents() + event; | |
768 | } | |
516389a2 | 769 | else if (fRawReader) |
770 | { | |
ae1a1b11 | 771 | maxEvent = fRawReader->GetNumberOfEvents() - 1; |
772 | if (maxEvent < 0) | |
773 | { | |
774 | maxEvent = 10000000; | |
775 | if (event < 0) { | |
776 | Error(kEH, "current raw-data source does not support direct event access."); | |
777 | return; | |
778 | } | |
779 | Info(kEH, "number of events unknown for current raw-data source, setting max-event id to 10M."); | |
780 | } | |
781 | else | |
782 | { | |
783 | if (event < 0) | |
784 | event = fRawReader->GetNumberOfEvents() + event; | |
516389a2 | 785 | } |
516389a2 | 786 | } |
787 | else | |
788 | { | |
c2c4b7a2 | 789 | throw (kEH + "neither RunLoader, ESD nor Raw loaded."); |
790 | } | |
84aff7a4 | 791 | if (event < 0 || event > maxEvent) |
516389a2 | 792 | { |
c2c4b7a2 | 793 | throw (kEH + Form("event %d not present, available range [%d, %d].", |
794 | event, 0, maxEvent)); | |
516389a2 | 795 | } |
1eaa5849 | 796 | |
14a4b686 | 797 | TString sysInfoHeader; |
798 | sysInfoHeader.Form("AliEveEventManager::GotoEvent(%d) - ", event); | |
799 | AliSysInfo::AddStamp(sysInfoHeader + "Start"); | |
800 | ||
84aff7a4 | 801 | TEveManager::TRedrawDisabler rd(gEve); |
802 | gEve->Redraw3D(kFALSE, kTRUE); // Enforce drop of all logicals. | |
d9e0d6c5 | 803 | |
32e219c2 | 804 | // !!! MT this is somewhat brutal; at least optionally, one could be |
805 | // a bit gentler, checking for objs owning their external refs and having | |
806 | // additinal parents. | |
b9579f03 | 807 | gEve->GetViewers()->DeleteAnnotations(); |
08b0f222 | 808 | fTransients->DestroyElements(); |
8661a211 | 809 | for (TEveElement::List_i i = fTransientLists->BeginChildren(); |
810 | i != fTransientLists->EndChildren(); ++i) | |
811 | { | |
812 | (*i)->DestroyElements(); | |
813 | } | |
1eaa5849 | 814 | DestroyElements(); |
1eaa5849 | 815 | |
14a4b686 | 816 | AliSysInfo::AddStamp(sysInfoHeader + "PostDestroy"); |
817 | ||
84aff7a4 | 818 | if (fESDTree) { |
c2c4b7a2 | 819 | if (fESDTree->GetEntry(event) <= 0) |
820 | throw (kEH + "failed getting required event from ESD."); | |
1eaa5849 | 821 | |
2cea771a | 822 | if (fESDfriendExists) |
1eaa5849 | 823 | fESD->SetESDfriend(fESDfriend); |
1eaa5849 | 824 | } |
90fa773e | 825 | |
b3b7b8d3 | 826 | if (fAODTree) { |
827 | if (fAODTree->GetEntry(event) <= 0) | |
828 | throw (kEH + "failed getting required event from AOD."); | |
829 | } | |
830 | ||
db748c38 | 831 | if (fRunLoader) { |
832 | if (fRunLoader->GetEvent(event) != 0) | |
833 | throw (kEH + "failed getting required event."); | |
834 | } | |
835 | ||
c2c4b7a2 | 836 | if (fRawReader) |
837 | { | |
ca49b003 | 838 | // AliRawReader::GotoEvent(Int_t) works for AliRawReaderRoot/Chain. |
839 | if (fRawReader->GotoEvent(event) == kFALSE) | |
c2c4b7a2 | 840 | { |
ca49b003 | 841 | // Use fallback method - iteration with NextEvent(). |
842 | Int_t rawEv = fEventId; | |
843 | if (event < rawEv) | |
c2c4b7a2 | 844 | { |
845 | fRawReader->RewindEvents(); | |
ca49b003 | 846 | rawEv = -1; |
c2c4b7a2 | 847 | } |
c2c4b7a2 | 848 | |
ca49b003 | 849 | while (rawEv < event) |
850 | { | |
851 | if ( ! fRawReader->NextEvent()) | |
852 | { | |
853 | fRawReader->RewindEvents(); | |
854 | fEventId = -1; | |
855 | throw (kEH + Form("Error going to next raw-event from event %d.", rawEv)); | |
856 | } | |
857 | ++rawEv; | |
858 | } | |
859 | Warning(kEH, "Loaded raw-event %d with fallback method.\n", rawEv); | |
860 | } | |
c2c4b7a2 | 861 | } |
862 | ||
80547f2d | 863 | fHasEvent = kTRUE; |
864 | fEventId = event; | |
ba5d58f2 | 865 | if (this == fgMaster) |
866 | { | |
867 | SetName(Form("Event %d", fEventId)); | |
868 | ElementChanged(); | |
869 | } | |
c2c4b7a2 | 870 | |
14a4b686 | 871 | AliSysInfo::AddStamp(sysInfoHeader + "PostLoadEvent"); |
872 | ||
90fa773e | 873 | AfterNewEventLoaded(); |
14a4b686 | 874 | |
875 | AliSysInfo::AddStamp(sysInfoHeader + "PostUserActions"); | |
1eaa5849 | 876 | } |
877 | ||
e10d437c | 878 | void AliEveEventManager::Timeout() |
879 | { | |
880 | Emit("Timeout()"); | |
881 | } | |
882 | ||
516389a2 | 883 | void AliEveEventManager::NextEvent() |
884 | { | |
80547f2d | 885 | // Loads next event. |
886 | // Does magick needed for online display when under external event control. | |
ecb84424 | 887 | |
488869c1 | 888 | static const TEveException kEH("AliEveEventManager::NextEvent "); |
889 | ||
890 | if (fAutoLoadTimerRunning) | |
ae1a1b11 | 891 | { |
488869c1 | 892 | throw (kEH + "Event auto-load timer is running."); |
893 | } | |
516389a2 | 894 | |
488869c1 | 895 | if (fExternalCtrl) |
896 | { | |
897 | // !!! This should really go somewhere else. It is done in GotoEvent(), | |
898 | // so here we should do it in SetEvent(). | |
516389a2 | 899 | DestroyElements(); |
96d621f6 | 900 | gSystem->ExitLoop(); |
e10d437c | 901 | |
ae1a1b11 | 902 | } |
96b90c2e | 903 | else if (fESDTree) |
ae1a1b11 | 904 | { |
008ac94c | 905 | Int_t nextevent=0; |
906 | if (fPEventSelector->FindNext(nextevent)) | |
ecb84424 | 907 | { |
008ac94c | 908 | GotoEvent(nextevent); |
ecb84424 | 909 | } |
516389a2 | 910 | } |
96b90c2e | 911 | else if (fEventId < GetMaxEventId(kTRUE)) |
912 | { | |
913 | GotoEvent(fEventId + 1); | |
914 | } | |
516389a2 | 915 | } |
916 | ||
917 | void AliEveEventManager::PrevEvent() | |
918 | { | |
80547f2d | 919 | // Loads previous event. |
e10d437c | 920 | |
80547f2d | 921 | static const TEveException kEH("AliEveEventManager::PrevEvent "); |
922 | ||
488869c1 | 923 | if (fAutoLoadTimerRunning) |
80547f2d | 924 | { |
488869c1 | 925 | throw (kEH + "Event auto-load timer is running."); |
516389a2 | 926 | } |
488869c1 | 927 | if (fExternalCtrl) |
80547f2d | 928 | { |
488869c1 | 929 | throw (kEH + "Event-loop is under external control."); |
80547f2d | 930 | } |
96b90c2e | 931 | |
932 | if (fESDTree) | |
933 | { | |
934 | Int_t nextevent=0; | |
935 | if (fPEventSelector->FindPrev(nextevent)) | |
936 | { | |
937 | GotoEvent(nextevent); | |
938 | } | |
939 | } | |
940 | else if (fEventId > 0) | |
ecb84424 | 941 | { |
96b90c2e | 942 | GotoEvent(fEventId - 1); |
ecb84424 | 943 | } |
516389a2 | 944 | } |
945 | ||
d810d0de | 946 | void AliEveEventManager::Close() |
5a5a1232 | 947 | { |
ca49b003 | 948 | // Close the event data-files and delete ESD, ESDfriend, run-loader |
949 | // and raw-reader. | |
73c1c0ec | 950 | |
80547f2d | 951 | static const TEveException kEH("AliEveEventManager::Close "); |
952 | ||
953 | if (!fIsOpen) | |
954 | { | |
955 | throw (kEH + "Event-files not opened."); | |
956 | } | |
957 | ||
488869c1 | 958 | if (fAutoLoadTimerRunning) |
959 | StopAutoLoadTimer(); | |
960 | ||
2cea771a | 961 | if (fESDTree) { |
962 | delete fESD; fESD = 0; | |
1367b606 | 963 | // delete fESDfriend; // friend tree is deleted with the tree |
964 | fESDfriend = 0; | |
73267f50 | 965 | fESDfriendExists = kFALSE; |
2cea771a | 966 | |
ca49b003 | 967 | delete fESDTree; fESDTree = 0; |
968 | delete fESDFile; fESDFile = 0; | |
969 | } | |
970 | ||
b3b7b8d3 | 971 | if (fAODTree) { |
972 | delete fAOD; fAOD = 0; | |
973 | ||
974 | delete fAODTree; fAODTree = 0; | |
975 | delete fAODFile; fAODFile = 0; | |
976 | } | |
977 | ||
ca49b003 | 978 | if (fRunLoader) { |
979 | delete fRunLoader; fRunLoader = 0; | |
980 | } | |
981 | ||
982 | if (fRawReader) { | |
983 | delete fRawReader; fRawReader = 0; | |
2cea771a | 984 | } |
80547f2d | 985 | |
986 | fEventId = -1; | |
987 | fIsOpen = kFALSE; | |
988 | fHasEvent = kFALSE; | |
5a5a1232 | 989 | } |
990 | ||
90fa773e | 991 | |
80547f2d | 992 | //------------------------------------------------------------------------------ |
c76ea574 | 993 | // Static convenience functions, mainly used from macros. |
80547f2d | 994 | //------------------------------------------------------------------------------ |
5a5a1232 | 995 | |
ba014dea | 996 | Int_t AliEveEventManager::CurrentEventId() |
997 | { | |
998 | // Return current event-id. | |
999 | ||
1000 | static const TEveException kEH("AliEveEventManager::CurrentEventId "); | |
1001 | ||
1002 | if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE) | |
1003 | throw (kEH + "ALICE event not ready."); | |
1004 | return fgCurrent->GetEventId(); | |
1005 | } | |
1006 | ||
f6afd0e1 | 1007 | Bool_t AliEveEventManager::HasRunLoader() |
1008 | { | |
1009 | // Check if AliRunLoader is initialized. | |
1010 | ||
4d62585e | 1011 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fRunLoader; |
f6afd0e1 | 1012 | } |
1013 | ||
1014 | Bool_t AliEveEventManager::HasESD() | |
1015 | { | |
1016 | // Check if AliESDEvent is initialized. | |
1017 | ||
4d62585e | 1018 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fESD; |
f6afd0e1 | 1019 | } |
1020 | ||
1021 | Bool_t AliEveEventManager::HasESDfriend() | |
1022 | { | |
1023 | // Check if AliESDfriend is initialized. | |
1024 | ||
4d62585e | 1025 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fESDfriend; |
f6afd0e1 | 1026 | } |
1027 | ||
b3b7b8d3 | 1028 | Bool_t AliEveEventManager::HasAOD() |
1029 | { | |
1030 | // Check if AliESDEvent is initialized. | |
1031 | ||
1032 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fAOD; | |
1033 | } | |
1034 | ||
f6afd0e1 | 1035 | Bool_t AliEveEventManager::HasRawReader() |
1036 | { | |
1037 | // Check if raw-reader is initialized. | |
1038 | ||
4d62585e | 1039 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fRawReader; |
f6afd0e1 | 1040 | } |
1041 | ||
d810d0de | 1042 | AliRunLoader* AliEveEventManager::AssertRunLoader() |
5a5a1232 | 1043 | { |
73c1c0ec | 1044 | // Make sure AliRunLoader is initialized and return it. |
1045 | // Throws exception in case run-loader is not available. | |
1046 | // Static utility for macros. | |
1047 | ||
a15e6d7d | 1048 | static const TEveException kEH("AliEveEventManager::AssertRunLoader "); |
5a5a1232 | 1049 | |
4d62585e | 1050 | if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE) |
c2c4b7a2 | 1051 | throw (kEH + "ALICE event not ready."); |
4d62585e | 1052 | if (fgCurrent->fRunLoader == 0) |
c2c4b7a2 | 1053 | throw (kEH + "AliRunLoader not initialised."); |
4d62585e | 1054 | return fgCurrent->fRunLoader; |
5a5a1232 | 1055 | } |
1056 | ||
d810d0de | 1057 | AliESDEvent* AliEveEventManager::AssertESD() |
5a5a1232 | 1058 | { |
73c1c0ec | 1059 | // Make sure AliESDEvent is initialized and return it. |
1060 | // Throws exception in case ESD is not available. | |
1061 | // Static utility for macros. | |
1062 | ||
a15e6d7d | 1063 | static const TEveException kEH("AliEveEventManager::AssertESD "); |
5a5a1232 | 1064 | |
4d62585e | 1065 | if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE) |
c2c4b7a2 | 1066 | throw (kEH + "ALICE event not ready."); |
4d62585e | 1067 | if (fgCurrent->fESD == 0) |
c2c4b7a2 | 1068 | throw (kEH + "AliESD not initialised."); |
4d62585e | 1069 | return fgCurrent->fESD; |
5a5a1232 | 1070 | } |
3aecaefc | 1071 | |
d810d0de | 1072 | AliESDfriend* AliEveEventManager::AssertESDfriend() |
3aecaefc | 1073 | { |
73c1c0ec | 1074 | // Make sure AliESDfriend is initialized and return it. |
1075 | // Throws exception in case ESDfriend-loader is not available. | |
1076 | // Static utility for macros. | |
1077 | ||
a15e6d7d | 1078 | static const TEveException kEH("AliEveEventManager::AssertESDfriend "); |
3aecaefc | 1079 | |
4d62585e | 1080 | if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE) |
c2c4b7a2 | 1081 | throw (kEH + "ALICE event not ready."); |
4d62585e | 1082 | if (fgCurrent->fESDfriend == 0) |
c2c4b7a2 | 1083 | throw (kEH + "AliESDfriend not initialised."); |
4d62585e | 1084 | return fgCurrent->fESDfriend; |
3aecaefc | 1085 | } |
93845f6c | 1086 | |
b3b7b8d3 | 1087 | AliAODEvent* AliEveEventManager::AssertAOD() |
1088 | { | |
1089 | // Make sure AliAODEvent is initialized and return it. | |
1090 | // Throws exception in case AOD is not available. | |
1091 | // Static utility for macros. | |
1092 | ||
1093 | static const TEveException kEH("AliEveEventManager::AssertAOD "); | |
1094 | ||
1095 | if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE) | |
1096 | throw (kEH + "ALICE event not ready."); | |
1097 | if (fgCurrent->fAOD == 0) | |
1098 | throw (kEH + "AliAOD not initialised."); | |
1099 | return fgCurrent->fAOD; | |
1100 | } | |
1101 | ||
c2c4b7a2 | 1102 | AliRawReader* AliEveEventManager::AssertRawReader() |
1103 | { | |
1104 | // Make sure raw-reader is initialized and return it. | |
1105 | ||
1106 | static const TEveException kEH("AliEveEventManager::AssertRawReader "); | |
1107 | ||
4d62585e | 1108 | if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE) |
c2c4b7a2 | 1109 | throw (kEH + "ALICE event not ready."); |
4d62585e | 1110 | if (fgCurrent->fRawReader == 0) |
c2c4b7a2 | 1111 | throw (kEH + "RawReader not ready."); |
1112 | ||
4d62585e | 1113 | return fgCurrent->fRawReader; |
c2c4b7a2 | 1114 | } |
1115 | ||
8661a211 | 1116 | //============================================================================== |
1117 | ||
1118 | AliMagF* AliEveEventManager::AssertMagField() | |
1119 | { | |
1120 | // Make sure AliMagF is initialized and returns it. | |
1121 | // Throws exception in case magnetic field is not available. | |
1122 | // Static utility for macros. | |
1123 | ||
1124 | static const TEveException kEH("AliEveEventManager::AssertMagField "); | |
1125 | ||
1126 | if (fgMagField) | |
1127 | return fgMagField; | |
1128 | ||
911af103 | 1129 | if (TGeoGlobalMagField::Instance()->GetField()) |
1130 | { | |
1131 | fgMagField = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField()); | |
1132 | if (fgMagField == 0) | |
1133 | throw kEH + "Global field set, but it is not AliMagF."; | |
1134 | return fgMagField; | |
1135 | } | |
1136 | ||
55216596 | 1137 | if (!fgGRPLoaded) |
8661a211 | 1138 | { |
1139 | InitGRP(); | |
1140 | } | |
1141 | ||
047cb6f4 | 1142 | if (TGeoGlobalMagField::Instance()->GetField()) |
8661a211 | 1143 | { |
1144 | fgMagField = dynamic_cast<AliMagF*>(TGeoGlobalMagField::Instance()->GetField()); | |
1145 | if (fgMagField == 0) | |
1146 | throw kEH + "Global field set, but it is not AliMagF."; | |
1147 | } | |
1148 | else | |
1149 | { | |
1150 | throw kEH + "Could not initialize magnetic field."; | |
1151 | } | |
1152 | ||
1153 | return fgMagField; | |
1154 | } | |
632d2b03 | 1155 | |
d810d0de | 1156 | TGeoManager* AliEveEventManager::AssertGeometry() |
632d2b03 | 1157 | { |
73c1c0ec | 1158 | // Make sure AliGeomManager is initialized and returns the |
1159 | // corresponding TGeoManger. | |
647814a2 | 1160 | // gGeoManager is set to the return value. |
1161 | // Throws exception if geometry can not be loaded or if it is not | |
1162 | // available and the TGeoManager is locked. | |
73c1c0ec | 1163 | // Static utility for macros. |
1164 | ||
a15e6d7d | 1165 | static const TEveException kEH("AliEveEventManager::AssertGeometry "); |
632d2b03 | 1166 | |
1167 | if (AliGeomManager::GetGeometry() == 0) | |
1168 | { | |
647814a2 | 1169 | if (TGeoManager::IsLocked()) |
1170 | throw (kEH + "geometry is not loaded but TGeoManager is locked."); | |
1171 | ||
af2e4ef5 | 1172 | gGeoManager = 0; |
632d2b03 | 1173 | AliGeomManager::LoadGeometry(); |
1174 | if ( ! AliGeomManager::GetGeometry()) | |
1175 | { | |
c2c4b7a2 | 1176 | throw (kEH + "can not load geometry."); |
632d2b03 | 1177 | } |
1178 | if ( ! AliGeomManager::ApplyAlignObjsFromCDB("ITS TPC TRD TOF PHOS HMPID EMCAL MUON FMD ZDC PMD T0 VZERO ACORDE")) | |
1179 | { | |
a15e6d7d | 1180 | ::Warning(kEH, "mismatch of alignable volumes. Proceeding."); |
c2c4b7a2 | 1181 | // throw (kEH + "could not apply align objs."); |
632d2b03 | 1182 | } |
81515106 | 1183 | AliGeomManager::GetGeometry()->DefaultColors(); |
632d2b03 | 1184 | } |
1185 | ||
647814a2 | 1186 | gGeoManager = AliGeomManager::GetGeometry(); |
1187 | return gGeoManager; | |
632d2b03 | 1188 | } |
319f3084 | 1189 | |
4d62585e | 1190 | //------------------------------------------------------------------------------ |
1191 | ||
ba5d58f2 | 1192 | AliEveEventManager* AliEveEventManager::AddDependentManager(const TString& name, const TString& path) |
4d62585e | 1193 | { |
1194 | // Create and attach a dependent event-manager. | |
ba5d58f2 | 1195 | // It is not added into eve list tree. |
4d62585e | 1196 | |
1197 | static const TEveException kEH("AliEveEventManager::AddDependentManager "); | |
1198 | ||
4d62585e | 1199 | if (fgMaster == 0) |
1200 | throw(kEH + "Master event-manager must be instantiated first."); | |
1201 | ||
1202 | if (fgMaster->fSubManagers == 0) | |
ba5d58f2 | 1203 | { |
4d62585e | 1204 | fgMaster->fSubManagers = new TList; |
ba5d58f2 | 1205 | fgMaster->fSubManagers->SetOwner(kTRUE); |
1206 | } | |
4d62585e | 1207 | |
ba5d58f2 | 1208 | AliEveEventManager* new_mgr = 0; |
1209 | fgCurrent = 0; | |
1210 | try | |
1211 | { | |
1212 | new_mgr = new AliEveEventManager(name, path, fgMaster->fEventId); | |
1213 | fgMaster->fSubManagers->Add(new_mgr); | |
1214 | } | |
1215 | catch (TEveException& exc) | |
1216 | { | |
1217 | ::Error(kEH, "Creation of new event-manager failed: '%s'.", exc.Data()); | |
1218 | } | |
1219 | fgCurrent = fgMaster; | |
1220 | ||
1221 | return new_mgr; | |
1222 | } | |
1223 | ||
1224 | AliEveEventManager* AliEveEventManager::GetDependentManager(const TString& name) | |
1225 | { | |
1226 | // Get a dependant manager by name. | |
1227 | // This will not change the current manager, use helper class | |
1228 | // AliEveEventManager::CurrentChanger for that. | |
1229 | ||
1230 | static const TEveException kEH("AliEveEventManager::GetDependentManager "); | |
1231 | ||
1232 | if (fgMaster == 0) | |
1233 | throw(kEH + "Master event-manager must be instantiated first."); | |
1234 | ||
1235 | if (fgMaster->fSubManagers == 0) | |
1236 | return 0; | |
1237 | ||
1238 | return dynamic_cast<AliEveEventManager*>(fgMaster->fSubManagers->FindObject(name)); | |
4d62585e | 1239 | } |
1240 | ||
1241 | AliEveEventManager* AliEveEventManager::GetMaster() | |
1242 | { | |
1243 | // Get master event-manager. | |
1244 | ||
1245 | return fgMaster; | |
1246 | } | |
1247 | ||
1248 | AliEveEventManager* AliEveEventManager::GetCurrent() | |
1249 | { | |
1250 | // Get current event-manager. | |
1251 | ||
1252 | return fgCurrent; | |
1253 | } | |
80547f2d | 1254 | |
08b0f222 | 1255 | void AliEveEventManager::RegisterTransient(TEveElement* element) |
1256 | { | |
1257 | GetCurrent()->fTransients->AddElement(element); | |
1258 | } | |
1259 | ||
8661a211 | 1260 | void AliEveEventManager::RegisterTransientList(TEveElement* element) |
1261 | { | |
1262 | GetCurrent()->fTransientLists->AddElement(element); | |
1263 | } | |
1264 | ||
80547f2d | 1265 | //------------------------------------------------------------------------------ |
488869c1 | 1266 | // Autoloading of events |
80547f2d | 1267 | //------------------------------------------------------------------------------ |
1268 | ||
488869c1 | 1269 | void AliEveEventManager::SetAutoLoadTime(Float_t time) |
1270 | { | |
1271 | // Set the auto-load time in seconds | |
1272 | ||
1273 | fAutoLoadTime = time; | |
1274 | } | |
1275 | ||
319f3084 | 1276 | void AliEveEventManager::SetAutoLoad(Bool_t autoLoad) |
1277 | { | |
1278 | // Set the automatic event loading mode | |
80547f2d | 1279 | |
488869c1 | 1280 | static const TEveException kEH("AliEveEventManager::SetAutoLoad "); |
1281 | ||
1282 | if (fAutoLoad == autoLoad) | |
1283 | { | |
1284 | Warning(kEH, "Setting autoload to the same value as before - %s. Ignoring.", fAutoLoad ? "true" : "false"); | |
1285 | return; | |
1286 | } | |
1287 | ||
319f3084 | 1288 | fAutoLoad = autoLoad; |
488869c1 | 1289 | if (fAutoLoad) |
1290 | { | |
1291 | StartAutoLoadTimer(); | |
1292 | } | |
1293 | else | |
1294 | { | |
1295 | StopAutoLoadTimer(); | |
1296 | } | |
319f3084 | 1297 | } |
1298 | ||
969d3431 | 1299 | void AliEveEventManager::SetTrigSel(Int_t trig) |
1300 | { | |
1301 | static const TEveException kEH("AliEveEventManager::SetTrigSel "); | |
1302 | ||
1303 | if (!fRawReader) | |
1304 | { | |
1305 | Warning(kEH, "No Raw-reader exists. Ignoring the call."); | |
1306 | return; | |
1307 | } | |
1308 | else | |
1309 | { | |
1310 | ULong64_t trigMask = 0; | |
1311 | if (trig >= 0) trigMask = (1ull << trig); | |
1312 | Info(kEH,"Trigger selection: 0x%llx",trigMask); | |
1313 | fRawReader->SelectEvents(-1,trigMask,NULL); | |
1314 | } | |
1315 | } | |
1316 | ||
488869c1 | 1317 | void AliEveEventManager::StartAutoLoadTimer() |
319f3084 | 1318 | { |
488869c1 | 1319 | // Start the auto-load timer. |
80547f2d | 1320 | |
488869c1 | 1321 | fAutoLoadTimer->SetTime((Long_t)(1000*fAutoLoadTime)); |
1322 | fAutoLoadTimer->Reset(); | |
1323 | fAutoLoadTimer->TurnOn(); | |
1324 | fAutoLoadTimerRunning = kTRUE; | |
319f3084 | 1325 | } |
1326 | ||
488869c1 | 1327 | void AliEveEventManager::StopAutoLoadTimer() |
319f3084 | 1328 | { |
488869c1 | 1329 | // Stop the auto-load timer. |
80547f2d | 1330 | |
488869c1 | 1331 | fAutoLoadTimerRunning = kFALSE; |
1332 | fAutoLoadTimer->TurnOff(); | |
1333 | } | |
1334 | ||
1335 | void AliEveEventManager::AutoLoadNextEvent() | |
1336 | { | |
1337 | // Called from auto-load timer, so it has to be public. | |
1338 | // Do NOT call it directly. | |
1339 | ||
1340 | static const TEveException kEH("AliEveEventManager::AutoLoadNextEvent "); | |
1341 | ||
1342 | if ( ! fAutoLoadTimerRunning || ! fAutoLoadTimer->HasTimedOut()) | |
f76c9e9b | 1343 | { |
488869c1 | 1344 | Warning(kEH, "Called unexpectedly - ignoring the call. Should ONLY be called from an internal timer."); |
1345 | return; | |
319f3084 | 1346 | } |
488869c1 | 1347 | |
1348 | StopAutoLoadTimer(); | |
1349 | NextEvent(); | |
47aab29b | 1350 | if (fAutoLoad && !fExternalCtrl) |
488869c1 | 1351 | StartAutoLoadTimer(); |
319f3084 | 1352 | } |
1353 | ||
80547f2d | 1354 | //------------------------------------------------------------------------------ |
1355 | // Post event-loading functions | |
1356 | //------------------------------------------------------------------------------ | |
1357 | ||
f6afd0e1 | 1358 | void AliEveEventManager::AfterNewEventLoaded() |
1359 | { | |
1360 | // Execute registered macros and commands. | |
1361 | // At the end emit NewEventLoaded signal. | |
1362 | // | |
1363 | // Virtual from TEveEventManager. | |
1364 | ||
ba5d58f2 | 1365 | static const TEveException kEH("AliEveEventManager::AfterNewEventLoaded "); |
1366 | ||
c12be4d4 | 1367 | NewEventDataLoaded(); |
1368 | ||
f6afd0e1 | 1369 | if (fExecutor) |
1370 | fExecutor->ExecMacros(); | |
1371 | ||
1372 | TEveEventManager::AfterNewEventLoaded(); | |
1373 | ||
1374 | NewEventLoaded(); | |
ba5d58f2 | 1375 | |
1376 | if (this == fgMaster && fSubManagers != 0) | |
1377 | { | |
1378 | TIter next(fSubManagers); | |
1379 | while ((fgCurrent = dynamic_cast<AliEveEventManager*>(next())) != 0) | |
1380 | { | |
68ca2fe7 | 1381 | gEve->SetCurrentEvent(fgCurrent); |
ba5d58f2 | 1382 | try |
1383 | { | |
1384 | fgCurrent->GotoEvent(fEventId); | |
1385 | } | |
1386 | catch (TEveException& exc) | |
1387 | { | |
1388 | // !!! Should somehow tag / disable / remove it? | |
1389 | Error(kEH, "Getting event %d for sub-event-manager '%s' failed: '%s'.", | |
1390 | fEventId, fgCurrent->GetName(), exc.Data()); | |
1391 | } | |
1392 | } | |
1393 | fgCurrent = fgMaster; | |
68ca2fe7 | 1394 | gEve->SetCurrentEvent(fgMaster); |
ba5d58f2 | 1395 | } |
f6afd0e1 | 1396 | } |
1397 | ||
c12be4d4 | 1398 | void AliEveEventManager::NewEventDataLoaded() |
1399 | { | |
1400 | // Emit NewEventDataLoaded signal. | |
1401 | ||
1402 | Emit("NewEventDataLoaded()"); | |
1403 | } | |
1404 | ||
f76c9e9b | 1405 | void AliEveEventManager::NewEventLoaded() |
1406 | { | |
1407 | // Emit NewEventLoaded signal. | |
1408 | ||
1409 | Emit("NewEventLoaded()"); | |
1410 | } | |
1411 | ||
80547f2d | 1412 | |
1413 | //------------------------------------------------------------------------------ | |
1414 | // Event info dumpers | |
1415 | //------------------------------------------------------------------------------ | |
12365217 | 1416 | |
1417 | TString AliEveEventManager::GetEventInfoHorizontal() const | |
1418 | { | |
1419 | // Dumps the event-header contents in vertical formatting. | |
1420 | ||
1421 | TString rawInfo, esdInfo; | |
1422 | ||
1423 | if (!fRawReader) | |
1424 | { | |
1425 | rawInfo = "No raw-data event info is available!\n"; | |
1426 | } | |
1427 | else | |
1428 | { | |
1429 | const UInt_t* attr = fRawReader->GetAttributes(); | |
1430 | TTimeStamp ts(fRawReader->GetTimestamp()); | |
1431 | rawInfo.Form("RAW event info: Run#: %d Event type: %d (%s) Period: %x Orbit: %x BC: %x\n" | |
1432 | "Trigger: %llx\nDetectors: %x (%s)\nAttributes:%x-%x-%x Timestamp: %s\n", | |
1433 | fRawReader->GetRunNumber(),fRawReader->GetType(),AliRawEventHeaderBase::GetTypeName(fRawReader->GetType()), | |
1434 | fRawReader->GetPeriod(),fRawReader->GetOrbitID(),fRawReader->GetBCID(), | |
1435 | fRawReader->GetClassMask(), | |
1436 | *fRawReader->GetDetectorPattern(),AliDAQ::ListOfTriggeredDetectors(*fRawReader->GetDetectorPattern()), | |
1437 | attr[0],attr[1],attr[2], ts.AsString("s")); | |
1438 | } | |
1439 | ||
1440 | if (!fESD) | |
1441 | { | |
1442 | esdInfo = "No ESD event info is available!"; | |
1443 | } | |
1444 | else | |
1445 | { | |
1446 | TString acttrclasses = fESD->GetESDRun()->GetActiveTriggerClasses(); | |
1447 | TString firedtrclasses = fESD->GetFiredTriggerClasses(); | |
1448 | TTimeStamp ts(fESD->GetTimeStamp()); | |
1449 | esdInfo.Form("ESD event info: Run#: %d Event type: %d (%s) Period: %x Orbit: %x BC: %x\n" | |
ecb84424 | 1450 | "Active trigger classes: %s\nTrigger: %llx (%s)\nEvent# in file: %d Timestamp: %s, MagField: %.2e", |
12365217 | 1451 | fESD->GetRunNumber(), |
1452 | fESD->GetEventType(),AliRawEventHeaderBase::GetTypeName(fESD->GetEventType()), | |
1453 | fESD->GetPeriodNumber(),fESD->GetOrbitNumber(),fESD->GetBunchCrossNumber(), | |
1454 | acttrclasses.Data(), | |
1455 | fESD->GetTriggerMask(),firedtrclasses.Data(), | |
ecb84424 | 1456 | fESD->GetEventNumberInFile(), ts.AsString("s"), fESD->GetMagneticField()); |
12365217 | 1457 | } |
1458 | ||
1459 | return rawInfo + esdInfo; | |
1460 | } | |
1461 | ||
1462 | TString AliEveEventManager::GetEventInfoVertical() const | |
319f3084 | 1463 | { |
12365217 | 1464 | // Dumps the event-header contents in vertical formatting. |
319f3084 | 1465 | |
12365217 | 1466 | TString rawInfo, esdInfo; |
319f3084 | 1467 | |
12365217 | 1468 | if (!fRawReader) |
1469 | { | |
1470 | rawInfo = "No raw-data event info is available!\n"; | |
ec835ab5 | 1471 | } |
12365217 | 1472 | else |
1473 | { | |
ec835ab5 | 1474 | const UInt_t* attr = fRawReader->GetAttributes(); |
12365217 | 1475 | 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", |
1476 | fRawReader->GetRunNumber(),fRawReader->GetType(),AliRawEventHeaderBase::GetTypeName(fRawReader->GetType()), | |
1477 | fRawReader->GetPeriod(),fRawReader->GetOrbitID(),fRawReader->GetBCID(), | |
1478 | fRawReader->GetClassMask(), | |
1479 | *fRawReader->GetDetectorPattern(),AliDAQ::ListOfTriggeredDetectors(*fRawReader->GetDetectorPattern()), | |
1480 | attr[0],attr[1],attr[2], | |
1481 | fRawReader->GetTimestamp()); | |
1482 | } | |
1483 | ||
1484 | if (!fESD) | |
1485 | { | |
1486 | esdInfo = "No ESD event info is available!\n"; | |
1487 | } | |
1488 | else | |
1489 | { | |
1490 | TString acttrclasses = fESD->GetESDRun()->GetActiveTriggerClasses(); | |
ec835ab5 | 1491 | TString firedtrclasses = fESD->GetFiredTriggerClasses(); |
12365217 | 1492 | 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", |
1493 | fESD->GetRunNumber(), | |
1494 | acttrclasses.Data(), | |
1495 | fESD->GetEventType(),AliRawEventHeaderBase::GetTypeName(fESD->GetEventType()), | |
1496 | fESD->GetPeriodNumber(),fESD->GetOrbitNumber(),fESD->GetBunchCrossNumber(), | |
1497 | fESD->GetTriggerMask(),firedtrclasses.Data(), | |
1498 | fESD->GetEventNumberInFile(), | |
1499 | fESD->GetTimeStamp()); | |
ec835ab5 | 1500 | } |
319f3084 | 1501 | |
12365217 | 1502 | return rawInfo + "\n" + esdInfo; |
319f3084 | 1503 | } |
8661a211 | 1504 | |
1505 | ||
1506 | //============================================================================== | |
1507 | // Reading of GRP and MagneticField. | |
1508 | // This is a reap-off from reconstruction ... should really be a common | |
1509 | // code to do this somewhere in STEER. | |
1510 | //============================================================================== | |
1511 | ||
1512 | Bool_t AliEveEventManager::InitGRP() | |
1513 | { | |
1514 | //------------------------------------ | |
1515 | // Initialization of the GRP entry | |
1516 | //------------------------------------ | |
1517 | ||
1518 | static const TEveException kEH("AliEveEventManager::InitGRP "); | |
1519 | ||
55216596 | 1520 | AliGRPManager grpMgr; |
1521 | if (!grpMgr.ReadGRPEntry()) { | |
8661a211 | 1522 | return kFALSE; |
1523 | } | |
55216596 | 1524 | fgGRPLoaded = kTRUE; |
1525 | if (!grpMgr.SetMagField()) { | |
1526 | throw kEH + "Setting of field failed!"; | |
8661a211 | 1527 | } |
1528 | ||
8661a211 | 1529 | //*** Get the diamond profiles from OCDB |
1530 | // Eventually useful. | |
1531 | ||
1532 | /* | |
1533 | entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD"); | |
1534 | if (entry) { | |
1535 | fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
1536 | } else { | |
1537 | ::Error(kEH, "No SPD diamond profile found in OCDB!"); | |
1538 | } | |
1539 | ||
1540 | entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex"); | |
1541 | if (entry) { | |
1542 | fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
1543 | } else { | |
1544 | ::Error(kEH, "No diamond profile found in OCDB!"); | |
1545 | } | |
1546 | ||
1547 | entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC"); | |
1548 | if (entry) { | |
1549 | fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
1550 | } else { | |
1551 | ::Error(kEH, "No TPC diamond profile found in OCDB!"); | |
1552 | } | |
1553 | */ | |
1554 | ||
1555 | return kTRUE; | |
1556 | } | |
3d94b490 | 1557 | |
1558 | //------------------------------------ | |
1559 | // Global variables management | |
1560 | //------------------------------------ | |
1561 | ||
1562 | Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model) | |
1563 | { | |
1564 | // Insert a new visualization-parameter database entry with the default | |
1565 | return InsertGlobal(tag, model, fGlobalReplace, fGlobalUpdate); | |
1566 | } | |
1567 | ||
1568 | Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model, | |
1569 | Bool_t replace, Bool_t update) | |
1570 | { | |
1571 | TPair* pair = (TPair*) fGlobal->FindObject(tag); | |
1572 | if (pair) | |
1573 | { | |
1574 | if (replace) | |
1575 | { | |
1576 | model->IncDenyDestroy(); | |
1577 | model->SetRnrChildren(kFALSE); | |
1578 | ||
1579 | TEveElement* old_model = dynamic_cast<TEveElement*>(pair->Value()); | |
04a6d27f | 1580 | if(!old_model) AliFatal("old_model == 0, dynamic cast failed\n"); |
3d94b490 | 1581 | while (old_model->HasChildren()) |
1582 | { | |
1583 | TEveElement *el = old_model->FirstChild(); | |
1584 | el->SetVizModel(model); | |
1585 | if (update) | |
1586 | { | |
1587 | el->CopyVizParams(model); | |
1588 | el->PropagateVizParamsToProjecteds(); | |
1589 | } | |
1590 | } | |
1591 | old_model->DecDenyDestroy(); | |
1592 | ||
1593 | pair->SetValue(dynamic_cast<TObject*>(model)); | |
1594 | return kTRUE; | |
1595 | } | |
1596 | else | |
1597 | { | |
1598 | return kFALSE; | |
1599 | } | |
1600 | } | |
1601 | else | |
1602 | { | |
1603 | model->IncDenyDestroy(); | |
1604 | model->SetRnrChildren(kFALSE); | |
1605 | fGlobal->Add(new TObjString(tag), dynamic_cast<TObject*>(model)); | |
1606 | return kTRUE; | |
1607 | } | |
1608 | } | |
1609 | ||
1610 | TEveElement* AliEveEventManager::FindGlobal(const TString& tag) | |
1611 | { | |
1612 | return dynamic_cast<TEveElement*>(fGlobal->GetValue(tag)); | |
1613 | } |