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