]>
Commit | Line | Data |
---|---|---|
1 | // $Id: AliEveEventManager.cxx 64557 2013-10-16 20:03:08Z hristov $ | |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
3 | ||
4 | /************************************************************************** | |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
7 | * full copyright notice. * | |
8 | **************************************************************************/ | |
9 | ||
10 | #include "AliEveEventManager.h" | |
11 | #include "AliEveEventSelector.h" | |
12 | #include "AliEveMacroExecutor.h" | |
13 | #include "AliEveConfigManager.h" | |
14 | #include "AliEveVSDCreator.h" | |
15 | ||
16 | #include <THashList.h> | |
17 | #include <TEveElement.h> | |
18 | #include <TEveManager.h> | |
19 | #include <TEveViewer.h> | |
20 | ||
21 | #include <AliLog.h> | |
22 | #include <AliRunLoader.h> | |
23 | #include <AliRun.h> | |
24 | #include <AliESDRun.h> | |
25 | #include <AliESDEvent.h> | |
26 | #include <AliESDfriend.h> | |
27 | #include <AliAODEvent.h> | |
28 | ||
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 | ||
37 | #include <AliDAQ.h> | |
38 | #include <AliRawEventHeaderBase.h> | |
39 | #include <AliRawReaderRoot.h> | |
40 | #include <AliRawReaderFile.h> | |
41 | #include <AliRawReaderDate.h> | |
42 | #include <AliMagF.h> | |
43 | #include <AliCDBManager.h> | |
44 | #include <AliCDBStorage.h> | |
45 | #include <AliGRPObject.h> | |
46 | #include <AliHeader.h> | |
47 | #include <AliGeomManager.h> | |
48 | #include <AliGRPManager.h> | |
49 | #include <AliSysInfo.h> | |
50 | ||
51 | #include <TFile.h> | |
52 | #include <TTree.h> | |
53 | #include <TGeoManager.h> | |
54 | #include <TGeoGlobalMagField.h> | |
55 | #include <TSystem.h> | |
56 | #include <TTimeStamp.h> | |
57 | #include <TPRegexp.h> | |
58 | #include <TError.h> | |
59 | #include <TEnv.h> | |
60 | #include <TString.h> | |
61 | #include <TMap.h> | |
62 | #include <TROOT.h> | |
63 | ||
64 | #ifdef ZMQ | |
65 | #include "AliStorageEventManager.h" | |
66 | #endif | |
67 | ||
68 | using std::cout; | |
69 | using std::endl; | |
70 | using std::vector; | |
71 | //============================================================================== | |
72 | //============================================================================== | |
73 | // AliEveEventManager | |
74 | //============================================================================== | |
75 | ||
76 | //______________________________________________________________________________ | |
77 | // | |
78 | // Provides interface for loading and navigating standard AliRoot data | |
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. | |
88 | // | |
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. | |
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. | |
100 | ||
101 | ClassImp(AliEveEventManager) | |
102 | ||
103 | Bool_t AliEveEventManager::fgAssertRunLoader = kFALSE; | |
104 | Bool_t AliEveEventManager::fgAssertESD = kFALSE; | |
105 | Bool_t AliEveEventManager::fgAssertAOD = kFALSE; | |
106 | Bool_t AliEveEventManager::fgAssertRaw = kFALSE; | |
107 | ||
108 | TString AliEveEventManager::fgESDFileName("AliESDs.root"); | |
109 | AliEveEventManager::EVisibleESDTrees AliEveEventManager::fgESDvisibleTrees(AliEveEventManager::kOfflineTree); | |
110 | TString AliEveEventManager::fgESDfriendsFileName("AliESDfriends.root"); | |
111 | TString AliEveEventManager::fgAODFileName("AliAOD.root"); | |
112 | TString AliEveEventManager::fgGAliceFileName("galice.root"); | |
113 | TString AliEveEventManager::fgRawFileName("raw.root"); | |
114 | TString AliEveEventManager::fgCdbUri; | |
115 | ||
116 | TList* AliEveEventManager::fgAODfriends = 0; | |
117 | ||
118 | Bool_t AliEveEventManager::fgRawFromStandardLoc = kFALSE; | |
119 | ||
120 | Bool_t AliEveEventManager::fgGRPLoaded = kFALSE; | |
121 | AliMagF* AliEveEventManager::fgMagField = 0; | |
122 | AliRecoParam* AliEveEventManager::fgRecoParam = 0; | |
123 | Bool_t AliEveEventManager::fgUniformField = kFALSE; | |
124 | ||
125 | AliEveEventManager* AliEveEventManager::fgMaster = 0; | |
126 | AliEveEventManager* AliEveEventManager::fgCurrent = 0; | |
127 | ||
128 | AliEveEventManager::AliEveEventManager(const TString& name, Int_t ev) : | |
129 | TEveEventManager(name, ""), | |
130 | fEventId(-1), | |
131 | fRunLoader (0), | |
132 | fESDFile (0), fESDTree (0), fHLTESDTree(0), fESD (0), | |
133 | fESDfriend (0), fESDfriendExists(kFALSE), | |
134 | fAODFile (0), fAODTree (0), fAOD (0), | |
135 | fRawReader (0), fEventInfo(), | |
136 | fAutoLoad (kFALSE),fLoopMarked(kFALSE), fAutoLoadTime (5), fAutoLoadTimer(0), | |
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), | |
142 | fAutoLoadTimerRunning(kFALSE), | |
143 | fMutex(new TMutex()), | |
144 | fgSubSock(EVENTS_SERVER_SUB), | |
145 | fEventInUse(1), | |
146 | fWritingToEventIndex(0), | |
147 | fIsNewEventAvaliable(false), | |
148 | fOnlineMode(kFALSE), | |
149 | fStorageDown(false), | |
150 | fFinished(false) | |
151 | { | |
152 | // Constructor with event-id. | |
153 | ||
154 | InitInternals(); | |
155 | ||
156 | Open(); | |
157 | if (ev >= 0) | |
158 | { | |
159 | GotoEvent(ev); | |
160 | } | |
161 | ||
162 | if (0 == name.CompareTo("online")) { | |
163 | fOnlineMode = kTRUE; | |
164 | } | |
165 | else{ | |
166 | fOnlineMode = kFALSE; | |
167 | } | |
168 | ||
169 | ||
170 | #ifdef ZMQ | |
171 | cout<<"ZMQ FOUND. Starting subscriber thread."<<endl; | |
172 | fEventListenerThread = new TThread("fEventListenerThread",DispatchEventListener,(void*)this); | |
173 | fEventListenerThread->Run(); | |
174 | ||
175 | fStorageManagerWatcherThread = new TThread("fStorageManagerWatcherThread",DispatchStorageManagerWatcher,(void*)this); | |
176 | fStorageManagerWatcherThread->Run(); | |
177 | #else | |
178 | cout<<"NO ZMQ FOUND. Online events not avaliable."<<endl; | |
179 | #endif | |
180 | } | |
181 | ||
182 | AliEveEventManager::~AliEveEventManager() | |
183 | { | |
184 | // Destructor. | |
185 | ||
186 | fFinished = true; | |
187 | if(fEventListenerThread) | |
188 | { | |
189 | fEventListenerThread->Join(); | |
190 | fEventListenerThread->Kill(); | |
191 | delete fEventListenerThread; | |
192 | cout<<"listener thread killed and deleted"<<endl; | |
193 | } | |
194 | if(fStorageManagerWatcherThread) | |
195 | { | |
196 | fStorageManagerWatcherThread->Join(); | |
197 | fStorageManagerWatcherThread->Kill(); | |
198 | delete fStorageManagerWatcherThread; | |
199 | cout<<"storage watcher thread killed and deleted"<<endl; | |
200 | } | |
201 | ||
202 | fAutoLoadTimer->Stop(); | |
203 | fAutoLoadTimer->Disconnect("Timeout"); | |
204 | fAutoLoadTimer->Disconnect("AutoLoadNextEvent"); | |
205 | ||
206 | if(fSubManagers){delete fSubManagers;} | |
207 | if(fMutex){delete fMutex;} | |
208 | if (fIsOpen){Close();} | |
209 | ||
210 | // fTransients->DecDenyDestroy(); | |
211 | // fTransients->Destroy(); | |
212 | ||
213 | // fTransientLists->DecDenyDestroy(); | |
214 | // fTransientLists->Destroy(); | |
215 | ||
216 | //delete fExecutor; | |
217 | } | |
218 | ||
219 | void AliEveEventManager::GetNextEvent() | |
220 | { | |
221 | #ifdef ZMQ | |
222 | cout<<"\n\nGet next event called\n\n"<<endl; | |
223 | ||
224 | AliStorageEventManager *eventManager = AliStorageEventManager::GetEventManagerInstance(); | |
225 | eventManager->CreateSocket(EVENTS_SERVER_SUB); | |
226 | eventManager->CreateSocket(SERVER_COMMUNICATION_REQ); | |
227 | ||
228 | fCurrentEvent[0]=0; | |
229 | fCurrentEvent[1]=0; | |
230 | ||
231 | AliESDEvent *tmpEvent = NULL; | |
232 | ||
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); | |
252 | vector<serverListStruct> receivedList = eventManager->GetServerListVector(SERVER_COMMUNICATION_REQ,3000); | |
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; | |
262 | while(!fFinished) | |
263 | { | |
264 | if(!fLoopMarked || receivedList.size()<=0) | |
265 | { | |
266 | cout<<"taking event from reco server"<<endl; | |
267 | tmpEvent = eventManager->GetEvent(EVENTS_SERVER_SUB,5000); | |
268 | if(!tmpEvent){sleep(1);} | |
269 | } | |
270 | else | |
271 | { | |
272 | cout<<"taking event from storage manager"<<endl; | |
273 | if(iter<receivedList.size()) | |
274 | { | |
275 | cout<<"i:"<<iter<<endl; | |
276 | struct eventStruct mark; | |
277 | mark.runNumber = receivedList[iter].runNumber; | |
278 | mark.eventNumber = receivedList[iter].eventNumber; | |
279 | ||
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); | |
285 | ||
286 | iter++; | |
287 | sleep(1); | |
288 | } | |
289 | else{iter=0;} | |
290 | } | |
291 | ||
292 | if(tmpEvent) | |
293 | { | |
294 | cout<<"tmpEvent:"<<tmpEvent->GetRunNumber()<<endl; | |
295 | if(tmpEvent->GetRunNumber()>=0) | |
296 | { | |
297 | fMutex->Lock(); | |
298 | if(fEventInUse == 0){fWritingToEventIndex = 1;} | |
299 | else if(fEventInUse == 1){fWritingToEventIndex = 0;} | |
300 | cout<<"Received new event:"<<tmpEvent->GetEventNumberInFile()<<endl; | |
301 | if(fCurrentEvent[fWritingToEventIndex]) | |
302 | { | |
303 | delete fCurrentEvent[fWritingToEventIndex]; | |
304 | fCurrentEvent[fWritingToEventIndex]=0; | |
305 | } | |
306 | fCurrentEvent[fWritingToEventIndex] = tmpEvent; | |
307 | fIsNewEventAvaliable = true; | |
308 | NewEventLoaded(); | |
309 | fMutex->UnLock(); | |
310 | } | |
311 | } | |
312 | else{cout<<"didn't receive new event"<<endl;} | |
313 | } | |
314 | delete requestMessage; | |
315 | ||
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 | ||
331 | while (!fFinished) | |
332 | { | |
333 | if(eventManager->Send(request,CLIENT_COMMUNICATION_REQ,5000)) | |
334 | { | |
335 | StorageManagerOk(); | |
336 | long response = eventManager->GetLong(CLIENT_COMMUNICATION_REQ); | |
337 | fStorageDown = kFALSE; | |
338 | } | |
339 | else | |
340 | { | |
341 | StorageManagerDown(); | |
342 | cout<<"WARNING -- Storage Manager is DOWN!!"<<endl; | |
343 | fStorageDown = kTRUE; | |
344 | } | |
345 | sleep(1); | |
346 | } | |
347 | ||
348 | AliEveEventManager *manager = AliEveEventManager::GetCurrent(); | |
349 | manager->Disconnect("StorageManagerOk"); | |
350 | manager->Disconnect("StorageManagerDown"); | |
351 | ||
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 | ||
392 | /******************************************************************************/ | |
393 | ||
394 | void AliEveEventManager::SetESDFileName(const TString& esd, EVisibleESDTrees shown) | |
395 | { | |
396 | fgESDvisibleTrees = shown; | |
397 | // Set file-name for opening ESD, default "AliESDs.root". | |
398 | if (esd.IsNull()) return; | |
399 | ||
400 | fgESDFileName = esd; | |
401 | if (esd.EndsWith(".zip")) fgESDFileName.Form("%s#AliESDs.root",esd.Data()); | |
402 | ||
403 | } | |
404 | ||
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()); | |
413 | } | |
414 | ||
415 | void AliEveEventManager::SetAODFileName(const TString& aod) | |
416 | { | |
417 | // Set file-name for opening AOD, default "AliAOD.root". | |
418 | ||
419 | if (aod.IsNull()) return; | |
420 | fgAODFileName = aod; | |
421 | ||
422 | if (aod.EndsWith(".zip")) fgAODFileName.Form("%s#AliAOD.root",aod.Data()); | |
423 | ||
424 | } | |
425 | ||
426 | void AliEveEventManager::AddAODfriend(const TString& friendFileName) | |
427 | { | |
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 | } | |
440 | } | |
441 | ||
442 | void AliEveEventManager::SetRawFileName(const TString& raw) | |
443 | { | |
444 | // Set file-name for opening of raw-data, default "raw.root" | |
445 | if (raw.IsNull()) return; | |
446 | ||
447 | fgRawFileName = raw; | |
448 | } | |
449 | ||
450 | void AliEveEventManager::SetCdbUri(const TString& cdb) | |
451 | { | |
452 | // Set path to CDB, there is no default. | |
453 | if ( ! cdb.IsNull()) fgCdbUri = cdb; | |
454 | } | |
455 | ||
456 | void AliEveEventManager::SetGAliceFileName(const TString& galice) | |
457 | { | |
458 | // Set file-name for opening gAlice, default "galice.root". | |
459 | ||
460 | if ( galice.IsNull()) return; | |
461 | fgGAliceFileName = galice; | |
462 | ||
463 | if (galice.EndsWith(".zip")) fgGAliceFileName.Form("%s#galice.root",galice.Data()); | |
464 | } | |
465 | ||
466 | void AliEveEventManager::SetFilesPath(const TString& urlPath) | |
467 | { | |
468 | TString path = urlPath; | |
469 | gSystem->ExpandPathName(path); | |
470 | if (path.IsNull() || path == ".") | |
471 | { | |
472 | path = gSystem->WorkingDirectory(); | |
473 | } | |
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 = "/"; | |
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 | ||
489 | void AliEveEventManager::SetAssertElements(Bool_t assertRunloader, Bool_t assertEsd, | |
490 | Bool_t assertAod, Bool_t assertRaw) | |
491 | { | |
492 | // Set global flags that detrmine which parts of the event-data must | |
493 | // be present when the event is opened. | |
494 | ||
495 | fgAssertRunLoader = assertRunloader; | |
496 | fgAssertESD = assertEsd; | |
497 | fgAssertAOD = assertAod; | |
498 | fgAssertRaw = assertRaw; | |
499 | } | |
500 | ||
501 | void AliEveEventManager::SearchRawForCentralReconstruction() | |
502 | { | |
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". | |
506 | ||
507 | fgRawFromStandardLoc = kTRUE; | |
508 | } | |
509 | ||
510 | /******************************************************************************/ | |
511 | ||
512 | void AliEveEventManager::Open() | |
513 | { | |
514 | // Open event-data from URL specified in path. | |
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."); | |
525 | } | |
526 | if (fIsOpen) | |
527 | { | |
528 | throw (kEH + "Event-files already opened."); | |
529 | } | |
530 | ||
531 | Int_t runNo = -1; | |
532 | ||
533 | // Open ESD and ESDfriends | |
534 | ||
535 | if ((fESDFile = TFile::Open(fgESDFileName))) | |
536 | { | |
537 | fESD = new AliESDEvent(); | |
538 | ||
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); | |
549 | } | |
550 | ||
551 | if(!fESDTree && !fHLTESDTree){ | |
552 | // both ESD trees are == 0 | |
553 | delete fESDFile; fESDFile = 0; | |
554 | delete fESD; fESD = 0; | |
555 | } | |
556 | ||
557 | ||
558 | } | |
559 | else // esd file not readable | |
560 | { | |
561 | Warning(kEH, "can not read ESD file '%s'.", fgESDFileName.Data()); | |
562 | } | |
563 | if (fESDTree == 0 && fHLTESDTree==0) | |
564 | { | |
565 | if (fgAssertESD) | |
566 | { | |
567 | throw (kEH + "ESD not initialized. Its precence was requested."); | |
568 | } else { | |
569 | Warning(kEH, "ESD not initialized."); | |
570 | } | |
571 | } | |
572 | ||
573 | // Open AOD and registered friends | |
574 | if ( (fAODFile = TFile::Open(fgAODFileName)) ) | |
575 | { | |
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 | { | |
616 | Warning(kEH, "can not read AOD file '%s'.", fgAODFileName.Data()); | |
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 | } | |
626 | } | |
627 | ||
628 | // Open RunLoader from galice.root | |
629 | // fgGAliceFileName = "/Users/Jerus/galice.root"; // temp | |
630 | ||
631 | TFile *gafile = TFile::Open(fgGAliceFileName); | |
632 | cout<<"Opening galice"<<endl; | |
633 | if (gafile) | |
634 | { | |
635 | gafile->Close(); | |
636 | delete gafile; | |
637 | cout<<"SETTING RUN LOADER in Open()"<<endl; | |
638 | fRunLoader = AliRunLoader::Open(fgGAliceFileName, GetName()); | |
639 | if (fRunLoader) | |
640 | { | |
641 | TString alicePath(gSystem->DirName(fgGAliceFileName)); | |
642 | alicePath.Append("/"); | |
643 | fRunLoader->SetDirName(alicePath); | |
644 | ||
645 | if (fRunLoader->LoadgAlice() != 0) | |
646 | Warning(kEH, "failed loading gAlice via run-loader."); | |
647 | ||
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 | { | |
662 | Warning(kEH, "failed opening ALICE run-loader from '%s'.", fgGAliceFileName.Data()); | |
663 | } | |
664 | ||
665 | } | |
666 | else // galice not readable | |
667 | { | |
668 | Warning(kEH, "can not read '%s'.", fgGAliceFileName.Data()); | |
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 | { | |
683 | if (!fgRawFileName.BeginsWith("alien:")) | |
684 | throw kEH + "Standard raw search requested, but the directory is not in AliEn."; | |
685 | if (!fgRawFileName.Contains("/ESDs/")) | |
686 | throw kEH + "Standard raw search requested, but does not contain 'ESDs' directory."; | |
687 | ||
688 | TPMERegexp chunk("/([\\d\\.])+/?$"); | |
689 | Int_t nm = chunk.Match(fgRawFileName); | |
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/.*"); | |
694 | rawPath = fgRawFileName; | |
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 | { | |
703 | rawPath = fgRawFileName; | |
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) | |
714 | { | |
715 | fRawReader = AliRawReader::Create(rawPath); | |
716 | } | |
717 | else | |
718 | { | |
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 | { | |
752 | fExternalCtrl = kTRUE; | |
753 | fEventId = 0; | |
754 | return; | |
755 | } | |
756 | } | |
757 | ||
758 | // Initialize OCDB ... only in master event-manager | |
759 | ||
760 | InitOCDB(runNo); | |
761 | ||
762 | ||
763 | fIsOpen = kTRUE; | |
764 | } | |
765 | ||
766 | void AliEveEventManager::InitOCDB(int runNo) | |
767 | { | |
768 | static const TEveException kEH("AliEveEventManager::InitOCDB "); | |
769 | //if (this == fgMaster) | |
770 | { | |
771 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
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://") { | |
793 | fgCdbUri = Form("local://%s/OCDB", gSystem->Getenv("ALICE_ROOT")); | |
794 | cdb->SetDefaultStorage(fgCdbUri); | |
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 | } | |
803 | if (fgCdbUri.BeginsWith("local://")) | |
804 | { | |
805 | TString curPath = gSystem->WorkingDirectory(); | |
806 | TString grp = "GRP/GRP/Data"; | |
807 | TString grppath = curPath + "/" + grp; | |
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://"); | |
818 | lpath += curPath; | |
819 | cdb->SetSpecificStorage(grp, lpath); | |
820 | } | |
821 | } | |
822 | } | |
823 | } | |
824 | } | |
825 | ||
826 | void AliEveEventManager::SetEvent(AliRunLoader *runLoader, AliRawReader *rawReader, AliESDEvent *esd, AliESDfriend *esdf) | |
827 | { | |
828 | // Set an event from an external source. | |
829 | // The method is used in the online visualisation. | |
830 | // AOD is not supported. | |
831 | ||
832 | static const TEveException kEH("AliEveEventManager::SetEvent "); | |
833 | ||
834 | if (fIsOpen) | |
835 | { | |
836 | Warning(kEH, "Event-files were open. Closing and switching to external control."); | |
837 | Close(); | |
838 | } | |
839 | ||
840 | Info(kEH,"setting it!!! ============================"); | |
841 | ||
842 | fRunLoader = runLoader; | |
843 | fRawReader = rawReader; | |
844 | fESD = esd; | |
845 | fESDfriend = esdf; | |
846 | fAOD = 0; | |
847 | ||
848 | fEventId++; | |
849 | fHasEvent = kTRUE; | |
850 | fExternalCtrl = kTRUE; | |
851 | ||
852 | SetTitle("Online event in memory"); | |
853 | SetName ("Online Event"); | |
854 | ElementChanged(); | |
855 | ||
856 | AfterNewEventLoaded(); | |
857 | ||
858 | if (fAutoLoad || fLoopMarked) StartAutoLoadTimer(); | |
859 | ||
860 | } | |
861 | ||
862 | Int_t AliEveEventManager::GetMaxEventId(Bool_t refreshESD) const | |
863 | { | |
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 | ||
879 | if ((fESDTree!=0) || (fHLTESDTree!=0)) | |
880 | { | |
881 | if (refreshESD) | |
882 | { | |
883 | if(fESDTree!=0) fESDTree->Refresh(); | |
884 | if(fHLTESDTree!=0) fHLTESDTree->Refresh(); | |
885 | fPEventSelector->Update(); | |
886 | } | |
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; | |
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 | } | |
918 | } | |
919 | ||
920 | void AliEveEventManager::GotoEvent(Int_t event) | |
921 | { | |
922 | cout<<"Go to event:"<<event<<endl; | |
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 | { | |
943 | // throw (kEH + "Event-loop is under external control."); | |
944 | #ifdef ZMQ | |
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; | |
955 | ||
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;} | |
961 | ||
962 | // set event struct: | |
963 | struct eventStruct eventToLoad; | |
964 | eventToLoad.runNumber = fESD->GetRunNumber(); | |
965 | eventToLoad.eventNumber = fESD->GetEventNumberInFile(); | |
966 | requestMessage->event = eventToLoad; | |
967 | ||
968 | // create event manager: | |
969 | AliStorageEventManager *eventManager = | |
970 | AliStorageEventManager::GetEventManagerInstance(); | |
971 | AliESDEvent *resultEvent = NULL; | |
972 | ||
973 | eventManager->CreateSocket(SERVER_COMMUNICATION_REQ); | |
974 | fMutex->Lock(); | |
975 | ||
976 | // send request and receive event: | |
977 | eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ); | |
978 | resultEvent = eventManager->GetEvent(SERVER_COMMUNICATION_REQ); | |
979 | ||
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 | } | |
993 | ||
994 | fMutex->UnLock(); | |
995 | } | |
996 | else | |
997 | { | |
998 | cout<<"\n\nWARNING -- No event has been already loaded. Loading the most recent event...\n\n"<<endl; | |
999 | ||
1000 | struct serverRequestStruct *requestMessage = new struct serverRequestStruct; | |
1001 | requestMessage->messageType = REQUEST_GET_LAST_EVENT; | |
1002 | ||
1003 | AliStorageEventManager *eventManager = AliStorageEventManager::GetEventManagerInstance(); | |
1004 | eventManager->CreateSocket(SERVER_COMMUNICATION_REQ); | |
1005 | AliESDEvent *resultEvent = NULL; | |
1006 | ||
1007 | fMutex->Lock(); | |
1008 | eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ); | |
1009 | resultEvent = eventManager->GetEvent(SERVER_COMMUNICATION_REQ); | |
1010 | ||
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;} | |
1019 | fMutex->UnLock(); | |
1020 | } | |
1021 | #endif | |
1022 | ||
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; | |
1034 | if ((fESDTree!=0) || (fHLTESDTree!=0)) | |
1035 | { | |
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 | } | |
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 | } | |
1082 | } | |
1083 | else | |
1084 | { | |
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 | ||
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 | ||
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) | |
1144 | { | |
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); | |
1164 | } | |
1165 | } | |
1166 | ||
1167 | fHasEvent = kTRUE; | |
1168 | fEventId = event; | |
1169 | if (this == fgMaster) | |
1170 | { | |
1171 | SetName(Form("Event %d", fEventId)); | |
1172 | ElementChanged(); | |
1173 | } | |
1174 | ||
1175 | AliSysInfo::AddStamp(sysInfoHeader + "PostLoadEvent"); | |
1176 | ||
1177 | AfterNewEventLoaded(); | |
1178 | ||
1179 | AliSysInfo::AddStamp(sysInfoHeader + "PostUserActions"); | |
1180 | } | |
1181 | ||
1182 | void AliEveEventManager::Timeout() | |
1183 | { | |
1184 | Emit("Timeout()"); | |
1185 | } | |
1186 | ||
1187 | void AliEveEventManager::PrepareForNewEvent(AliESDEvent *event) | |
1188 | { | |
1189 | DestroyElements(); | |
1190 | InitOCDB(event->GetRunNumber()); | |
1191 | printf("======================= setting event to %d\n", fEventId); | |
1192 | SetEvent(0,0,event,0); | |
1193 | } | |
1194 | ||
1195 | void AliEveEventManager::NextEvent() | |
1196 | { | |
1197 | // Loads next event. | |
1198 | // Does magick needed for online display when under external event control. | |
1199 | ||
1200 | static const TEveException kEH("AliEveEventManager::NextEvent "); | |
1201 | ||
1202 | if (fAutoLoadTimerRunning){throw (kEH + "Event auto-load timer is running.");} | |
1203 | ||
1204 | if (fExternalCtrl) | |
1205 | { | |
1206 | #ifdef ZMQ | |
1207 | if(fIsNewEventAvaliable) | |
1208 | { | |
1209 | fMutex->Lock(); | |
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 | { | |
1217 | printf("======================= setting event to %d\n", fCurrentEvent[fEventInUse]->GetEventNumberInFile()); | |
1218 | ||
1219 | DestroyElements(); | |
1220 | InitOCDB(fCurrentEvent[fEventInUse]->GetRunNumber()); | |
1221 | SetEvent(0,0,fCurrentEvent[fEventInUse],0); | |
1222 | ||
1223 | } | |
1224 | } | |
1225 | fIsNewEventAvaliable = false; | |
1226 | fMutex->UnLock(); | |
1227 | } | |
1228 | else | |
1229 | { | |
1230 | cout<<"No new event is avaliable."<<endl; | |
1231 | NoEventLoaded(); | |
1232 | } | |
1233 | #endif | |
1234 | } | |
1235 | else if ((fESDTree!=0) || (fHLTESDTree!=0)) | |
1236 | { | |
1237 | Int_t nextevent=0; | |
1238 | if (fPEventSelector->FindNext(nextevent)) | |
1239 | { | |
1240 | GotoEvent(nextevent); | |
1241 | } | |
1242 | } | |
1243 | else if (fEventId < GetMaxEventId(kTRUE)) | |
1244 | { | |
1245 | GotoEvent(fEventId + 1); | |
1246 | } | |
1247 | ||
1248 | gSystem->ProcessEvents(); | |
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;} | |
1258 | } | |
1259 | ||
1260 | void AliEveEventManager::PrevEvent() | |
1261 | { | |
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 | ||
1275 | if ((fESDTree!=0) || (fHLTESDTree!=0)) | |
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 | } | |
1287 | } | |
1288 | ||
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 | ||
1340 | void AliEveEventManager::Close() | |
1341 | { | |
1342 | // Close the event data-files and delete ESD, ESDfriend, run-loader | |
1343 | // and raw-reader. | |
1344 | ||
1345 | cout<<"\n\n\nClose() called!!\n\n\n"<<endl; | |
1346 | ||
1347 | static const TEveException kEH("AliEveEventManager::Close "); | |
1348 | ||
1349 | if (!fIsOpen) | |
1350 | { | |
1351 | throw (kEH + "Event-files not opened."); | |
1352 | } | |
1353 | ||
1354 | if (fAutoLoadTimerRunning) | |
1355 | StopAutoLoadTimer(); | |
1356 | ||
1357 | if ((fESDTree!=0) || (fHLTESDTree!=0)) { | |
1358 | delete fESD; fESD = 0; | |
1359 | // delete fESDfriend; // friend tree is deleted with the tree | |
1360 | fESDfriend = 0; | |
1361 | fESDfriendExists = kFALSE; | |
1362 | ||
1363 | if(fESDTree) { delete fESDTree; fESDTree = 0; } | |
1364 | if(fHLTESDTree) { delete fHLTESDTree; fHLTESDTree = 0; } | |
1365 | delete fESDFile; fESDFile = 0; | |
1366 | } | |
1367 | ||
1368 | if (fAODTree) { | |
1369 | delete fAOD; fAOD = 0; | |
1370 | ||
1371 | delete fAODTree; fAODTree = 0; | |
1372 | delete fAODFile; fAODFile = 0; | |
1373 | } | |
1374 | ||
1375 | if (fRunLoader) { | |
1376 | delete fRunLoader; fRunLoader = 0; | |
1377 | } | |
1378 | ||
1379 | if (fRawReader) { | |
1380 | delete fRawReader; fRawReader = 0; | |
1381 | } | |
1382 | ||
1383 | fEventId = -1; | |
1384 | fIsOpen = kFALSE; | |
1385 | fHasEvent = kFALSE; | |
1386 | } | |
1387 | ||
1388 | ||
1389 | //------------------------------------------------------------------------------ | |
1390 | // Static convenience functions, mainly used from macros. | |
1391 | //------------------------------------------------------------------------------ | |
1392 | ||
1393 | Int_t AliEveEventManager::CurrentEventId() | |
1394 | { | |
1395 | // Return current event-id. | |
1396 | ||
1397 | static const TEveException kEH("AliEveEventManager::CurrentEventId "); | |
1398 | ||
1399 | if (fgCurrent == 0 || fgCurrent->fHasEvent == kFALSE) | |
1400 | throw (kEH + "ALICE event not ready."); | |
1401 | return fgCurrent->GetEventId(); | |
1402 | } | |
1403 | ||
1404 | Bool_t AliEveEventManager::HasRunLoader() | |
1405 | { | |
1406 | // Check if AliRunLoader is initialized. | |
1407 | ||
1408 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fRunLoader; | |
1409 | } | |
1410 | ||
1411 | Bool_t AliEveEventManager::HasESD() | |
1412 | { | |
1413 | // Check if AliESDEvent is initialized. | |
1414 | ||
1415 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fESD; | |
1416 | } | |
1417 | ||
1418 | Bool_t AliEveEventManager::HasESDfriend() | |
1419 | { | |
1420 | // Check if AliESDfriend is initialized. | |
1421 | ||
1422 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fESDfriend; | |
1423 | } | |
1424 | ||
1425 | Bool_t AliEveEventManager::HasAOD() | |
1426 | { | |
1427 | // Check if AliESDEvent is initialized. | |
1428 | ||
1429 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fAOD; | |
1430 | } | |
1431 | ||
1432 | Bool_t AliEveEventManager::HasRawReader() | |
1433 | { | |
1434 | // Check if raw-reader is initialized. | |
1435 | ||
1436 | return fgCurrent && fgCurrent->fHasEvent && fgCurrent->fRawReader; | |
1437 | } | |
1438 | ||
1439 | AliRunLoader* AliEveEventManager::AssertRunLoader() | |
1440 | { | |
1441 | // Make sure AliRunLoader is initialized and return it. | |
1442 | // Throws exception in case run-loader is not available. | |
1443 | // Static utility for macros. | |
1444 | ||
1445 | static const TEveException kEH("AliEveEventManager::AssertRunLoader "); | |
1446 | ||
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; | |
1452 | } | |
1453 | ||
1454 | AliESDEvent* AliEveEventManager::AssertESD() | |
1455 | { | |
1456 | // Make sure AliESDEvent is initialized and return it. | |
1457 | // Throws exception in case ESD is not available. | |
1458 | // Static utility for macros. | |
1459 | ||
1460 | static const TEveException kEH("AliEveEventManager::AssertESD "); | |
1461 | ||
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; | |
1467 | } | |
1468 | ||
1469 | AliESDfriend* AliEveEventManager::AssertESDfriend() | |
1470 | { | |
1471 | // Make sure AliESDfriend is initialized and return it. | |
1472 | // Throws exception in case ESDfriend-loader is not available. | |
1473 | // Static utility for macros. | |
1474 | ||
1475 | static const TEveException kEH("AliEveEventManager::AssertESDfriend "); | |
1476 | ||
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; | |
1482 | } | |
1483 | ||
1484 | AliAODEvent* AliEveEventManager::AssertAOD() | |
1485 | { | |
1486 | // Make sure AliAODEvent is initialized and return it. | |
1487 | // Throws exception in case AOD is not available. | |
1488 | // Static utility for macros. | |
1489 | ||
1490 | static const TEveException kEH("AliEveEventManager::AssertAOD "); | |
1491 | ||
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; | |
1497 | } | |
1498 | ||
1499 | AliRawReader* AliEveEventManager::AssertRawReader() | |
1500 | { | |
1501 | // Make sure raw-reader is initialized and return it. | |
1502 | ||
1503 | static const TEveException kEH("AliEveEventManager::AssertRawReader "); | |
1504 | ||
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."); | |
1509 | ||
1510 | return fgCurrent->fRawReader; | |
1511 | } | |
1512 | ||
1513 | //============================================================================== | |
1514 | ||
1515 | AliMagF* AliEveEventManager::AssertMagField() | |
1516 | { | |
1517 | // Make sure AliMagF is initialized and returns it. | |
1518 | // Throws exception in case magnetic field is not available. | |
1519 | // Static utility for macros. | |
1520 | ||
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 | } | |
1549 | ||
1550 | return fgMagField; | |
1551 | } | |
1552 | ||
1553 | TGeoManager* AliEveEventManager::AssertGeometry() | |
1554 | { | |
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. | |
1561 | ||
1562 | static const TEveException kEH("AliEveEventManager::AssertGeometry "); | |
1563 | ||
1564 | if (AliGeomManager::GetGeometry() == 0) | |
1565 | { | |
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(); | |
1581 | } | |
1582 | ||
1583 | gGeoManager = AliGeomManager::GetGeometry(); | |
1584 | return gGeoManager; | |
1585 | } | |
1586 | ||
1587 | AliRecoParam* AliEveEventManager::AssertRecoParams() | |
1588 | { | |
1589 | if(!fgRecoParam) | |
1590 | InitRecoParam(); | |
1591 | ||
1592 | return fgRecoParam; | |
1593 | } | |
1594 | ||
1595 | Bool_t AliEveEventManager::InitRecoParam() | |
1596 | { | |
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; | |
1602 | const Int_t kNDetectors = 14; | |
1603 | ||
1604 | static const TEveException kEH("AliEveEventManager::InitRecoParam"); | |
1605 | ||
1606 | Bool_t isOK = kTRUE; | |
1607 | ||
1608 | if (fgRecoParam->GetDetRecoParamArray(kNDetectors)) { | |
1609 | ::Info(kEH, "Using custom GRP reconstruction parameters"); | |
1610 | } | |
1611 | else { | |
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 | } | |
1640 | } | |
1641 | ||
1642 | const char* fgkDetectorName[kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE" }; | |
1643 | ||
1644 | ||
1645 | for (Int_t iDet = 0; iDet < kNDetectors; iDet++) { | |
1646 | ||
1647 | if (fgRecoParam->GetDetRecoParamArray(iDet)) { | |
1648 | ::Info(kEH, "Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]); | |
1649 | continue; | |
1650 | } | |
1651 | ||
1652 | ::Info(kEH, "Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]); | |
1653 | ||
1654 | AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam"); | |
1655 | AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath()); | |
1656 | if(!entry){ | |
1657 | ::Warning(kEH, "Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]); | |
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 | |
1670 | ::Info(kEH, "Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]); | |
1671 | dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault(); | |
1672 | fgRecoParam->AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj)); | |
1673 | } | |
1674 | else { | |
1675 | ::Error(kEH, "No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]); | |
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; | |
1689 | } | |
1690 | ||
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 | ||
1743 | ||
1744 | //------------------------------------------------------------------------------ | |
1745 | ||
1746 | AliEveEventManager* AliEveEventManager::AddDependentManager(const TString& name, const TString& path) | |
1747 | { | |
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 | { | |
1766 | new_mgr = new AliEveEventManager(name, fgMaster->fEventId); | |
1767 | new_mgr->SetFilesPath(path); | |
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; | |
1777 | } | |
1778 | ||
1779 | AliEveEventManager* AliEveEventManager::GetDependentManager(const TString& name) | |
1780 | { | |
1781 | // Get a dependant manager by name. | |
1782 | // This will not change the current manager, use helper class | |
1783 | // AliEveEventManager::CurrentChanger for that. | |
1784 | ||
1785 | static const TEveException kEH("AliEveEventManager::GetDependentManager "); | |
1786 | ||
1787 | if (fgMaster == 0) | |
1788 | throw(kEH + "Master event-manager must be instantiated first."); | |
1789 | ||
1790 | if (fgMaster->fSubManagers == 0) | |
1791 | return 0; | |
1792 | ||
1793 | return dynamic_cast<AliEveEventManager*>(fgMaster->fSubManagers->FindObject(name)); | |
1794 | } | |
1795 | ||
1796 | AliEveEventManager* AliEveEventManager::GetMaster() | |
1797 | { | |
1798 | // Get master event-manager. | |
1799 | ||
1800 | return fgMaster; | |
1801 | } | |
1802 | ||
1803 | AliEveEventManager* AliEveEventManager::GetCurrent() | |
1804 | { | |
1805 | // Get current event-manager. | |
1806 | ||
1807 | return fgCurrent; | |
1808 | } | |
1809 | ||
1810 | void AliEveEventManager::RegisterTransient(TEveElement* element) | |
1811 | { | |
1812 | GetCurrent()->fTransients->AddElement(element); | |
1813 | } | |
1814 | ||
1815 | void AliEveEventManager::RegisterTransientList(TEveElement* element) | |
1816 | { | |
1817 | GetCurrent()->fTransientLists->AddElement(element); | |
1818 | } | |
1819 | ||
1820 | //------------------------------------------------------------------------------ | |
1821 | // Autoloading of events | |
1822 | //------------------------------------------------------------------------------ | |
1823 | ||
1824 | void AliEveEventManager::SetAutoLoadTime(Float_t time) | |
1825 | { | |
1826 | // Set the auto-load time in seconds | |
1827 | ||
1828 | fAutoLoadTime = time; | |
1829 | } | |
1830 | ||
1831 | void AliEveEventManager::SetAutoLoad(Bool_t autoLoad) | |
1832 | { | |
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 | } | |
1852 | } | |
1853 | ||
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 | ||
1862 | void AliEveEventManager::SetTrigSel(Int_t trig) | |
1863 | { | |
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 | } | |
1878 | } | |
1879 | ||
1880 | void AliEveEventManager::StartAutoLoadTimer() | |
1881 | { | |
1882 | // Start the auto-load timer. | |
1883 | ||
1884 | fAutoLoadTimer->SetTime((Long_t)(1000*fAutoLoadTime)); | |
1885 | fAutoLoadTimer->Reset(); | |
1886 | fAutoLoadTimer->TurnOn(); | |
1887 | fAutoLoadTimerRunning = kTRUE; | |
1888 | } | |
1889 | ||
1890 | void AliEveEventManager::StopAutoLoadTimer() | |
1891 | { | |
1892 | // Stop the auto-load timer. | |
1893 | ||
1894 | fAutoLoadTimerRunning = kFALSE; | |
1895 | fAutoLoadTimer->TurnOff(); | |
1896 | } | |
1897 | ||
1898 | void AliEveEventManager::AutoLoadNextEvent() | |
1899 | { | |
1900 | // Called from auto-load timer, so it has to be public. | |
1901 | // Do NOT call it directly. | |
1902 | ||
1903 | static const TEveException kEH("AliEveEventManager::AutoLoadNextEvent "); | |
1904 | ||
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(); | |
1915 | if (fAutoLoad || fLoopMarked) | |
1916 | StartAutoLoadTimer(); | |
1917 | } | |
1918 | ||
1919 | //------------------------------------------------------------------------------ | |
1920 | // Post event-loading functions | |
1921 | //------------------------------------------------------------------------------ | |
1922 | ||
1923 | void AliEveEventManager::AfterNewEventLoaded() | |
1924 | { | |
1925 | // Execute registered macros and commands. | |
1926 | // At the end emit NewEventLoaded signal. | |
1927 | // | |
1928 | // Virtual from TEveEventManager. | |
1929 | ||
1930 | static const TEveException kEH("AliEveEventManager::AfterNewEventLoaded "); | |
1931 | ||
1932 | Info(kEH, "------------------!!!------------"); | |
1933 | ||
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() ------------"); | |
1957 | } | |
1958 | fgCurrent = fgMaster; | |
1959 | Info(kEH, "------------------!!! while() gEve->SetCurrentEvent(MASTER) ------------"); | |
1960 | gEve->SetCurrentEvent(fgMaster); | |
1961 | } | |
1962 | } | |
1963 | ||
1964 | void AliEveEventManager::NewEventDataLoaded() | |
1965 | { | |
1966 | // Emit NewEventDataLoaded signal. | |
1967 | Emit("NewEventDataLoaded()"); | |
1968 | } | |
1969 | void AliEveEventManager::NewEventLoaded() | |
1970 | { | |
1971 | // Emit NewEventLoaded signal. | |
1972 | Emit("NewEventLoaded()"); | |
1973 | } | |
1974 | void AliEveEventManager::NoEventLoaded() | |
1975 | { | |
1976 | // Emit NoEventLoaded signal. | |
1977 | Emit("NoEventLoaded()"); | |
1978 | } | |
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 | } | |
1989 | ||
1990 | ||
1991 | //------------------------------------------------------------------------------ | |
1992 | // Event info dumpers | |
1993 | //------------------------------------------------------------------------------ | |
1994 | ||
1995 | const AliEventInfo* AliEveEventManager::GetEventInfo() | |
1996 | { | |
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 | } | |
2044 | ||
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; | |
2050 | } | |
2051 | ||
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 | } | |
2072 | } | |
2073 | else { | |
2074 | AliError("No OCDB entry for the trigger aliases!"); | |
2075 | } | |
2076 | ||
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; | |
2102 | } | |
2103 | ||
2104 | if (fRawReader) delete aCTP; | |
2105 | ||
2106 | // everything went ok, return pointer | |
2107 | return (&fEventInfo); | |
2108 | } | |
2109 | ||
2110 | ||
2111 | TString AliEveEventManager::GetEventInfoHorizontal() const | |
2112 | { | |
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; | |
2154 | } | |
2155 | ||
2156 | TString AliEveEventManager::GetEventInfoVertical() const | |
2157 | { | |
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; | |
2197 | } | |
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 | { | |
2208 | //------------------------------------ | |
2209 | // Initialization of the GRP entry | |
2210 | //------------------------------------ | |
2211 | ||
2212 | static const TEveException kEH("AliEveEventManager::InitGRP "); | |
2213 | ||
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 | } | |
2222 | ||
2223 | //*** Get the diamond profiles from OCDB | |
2224 | // Eventually useful. | |
2225 | ||
2226 | /* | |
2227 | entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD"); | |
2228 | if (entry) { | |
2229 | fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
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) { | |
2236 | fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
2237 | } else { | |
2238 | ::Error(kEH, "No diamond profile found in OCDB!"); | |
2239 | } | |
2240 | ||
2241 | entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC"); | |
2242 | if (entry) { | |
2243 | fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject()); | |
2244 | } else { | |
2245 | ::Error(kEH, "No TPC diamond profile found in OCDB!"); | |
2246 | } | |
2247 | */ | |
2248 | ||
2249 | return kTRUE; | |
2250 | } | |
2251 | ||
2252 | //------------------------------------ | |
2253 | // Global variables management | |
2254 | //------------------------------------ | |
2255 | ||
2256 | Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model) | |
2257 | { | |
2258 | // Insert a new visualization-parameter database entry with the default | |
2259 | return InsertGlobal(tag, model, fGlobalReplace, fGlobalUpdate); | |
2260 | } | |
2261 | ||
2262 | Bool_t AliEveEventManager::InsertGlobal(const TString& tag, TEveElement* model, | |
2263 | Bool_t replace, Bool_t update) | |
2264 | { | |
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()) | |
2276 | { | |
2277 | TEveElement *el = old_model->FirstChild(); | |
2278 | el->SetVizModel(model); | |
2279 | if (update) | |
2280 | { | |
2281 | el->CopyVizParams(model); | |
2282 | el->PropagateVizParamsToProjecteds(); | |
2283 | } | |
2284 | } | |
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 | } | |
2302 | } | |
2303 | ||
2304 | TEveElement* AliEveEventManager::FindGlobal(const TString& tag) | |
2305 | { | |
2306 | return dynamic_cast<TEveElement*>(fGlobal->GetValue(tag)); | |
2307 | } | |
2308 | Int_t AliEveEventManager::NewEventAvailable() | |
2309 | { | |
2310 | if (fIsNewEventAvaliable) | |
2311 | { | |
2312 | return 1; | |
2313 | } | |
2314 | else | |
2315 | { | |
2316 | return 0; | |
2317 | } | |
2318 | } |