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