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