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