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