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