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