3 #include "EventAlieve.h"
6 #include <AliRunLoader.h>
16 using namespace Alieve;
18 //______________________________________________________________________
24 Event* Alieve::gEvent = 0;
26 Bool_t Alieve::Event::fgUseRunLoader = true;
27 Bool_t Alieve::Event::fgUseESDTree = true;
29 void Event::Initialize(Bool_t use_runloader, Bool_t use_esd)
31 static const Exc_t eH("Event::Initialize ");
33 fgUseRunLoader = use_runloader;
34 fgUseESDTree = use_esd;
37 if(fgUseRunLoader == false && fgUseESDTree == false)
38 throw(eH + "should use at least one data source.");
41 AssertMacro("loadlibs.C");
43 else if(fgUseESDTree) {
44 gSystem->Load("libESD.so");
49 /**************************************************************************/
59 Event::Event() : TNamed(), fEventId(0)
64 Event::Event(TString path, Int_t ev) : fPath(path), fEventId(ev)
70 /**************************************************************************/
74 static const Exc_t eH("Event::Open ");
76 gSystem->ExpandPathName(fPath);
78 fPath = Form("%s/%s", gSystem->WorkingDirectory(), fPath.Data());
81 TString ga_path(Form("%s/galice.root", fPath.Data()));
82 if(gSystem->AccessPathName(ga_path, kReadPermission))
83 throw(eH + "can not read '" + ga_path + "'.");
84 fRunLoader = AliRunLoader::Open(ga_path);
86 throw(eH + "failed opening ALICE run loader from '" + ga_path + "'.");
88 TString alice_path = fPath + "/";
89 fRunLoader->SetDirName(alice_path);
91 if(fRunLoader->LoadgAlice() != 0) {
92 throw(eH + "failed loading gAlice.");
95 if(fRunLoader->GetEvent(fEventId) != 0) {
96 throw(eH + "failed getting required event.");
101 TString p(Form("%s/AliESDs.root", fPath.Data()));
102 fESDFile = new TFile(p);
103 if(fESDFile->IsZombie()) {
104 delete fESDFile; fESDFile = 0;
105 throw(eH + "failed opening ALICE ESD from '" + p + "'.");
108 fESDTree = (TTree*) fESDFile->Get("esdTree");
110 throw(eH + "failed getting the esdTree.");
111 fESDTree->SetBranchAddress("ESD", &fESD);
112 if(fESDTree->GetEntry(fEventId) <= 0)
113 throw(eH + "failed getting required event.");
116 SetName(Form("Event%d", fEventId));
125 /**************************************************************************/
126 /**************************************************************************/
128 // Static convenience functions.
130 AliRunLoader* Event::AssertRunLoader()
132 static const Exc_t eH("Event::AssertRunLoader ");
135 throw(eH + "ALICE event not ready.");
136 if(gEvent->fRunLoader == 0)
137 throw(eH + "AliRunLoader not initialised.");
138 return gEvent->fRunLoader;
141 AliESD* Event::AssertESD()
143 static const Exc_t eH("Event::AssertESD ");
146 throw(eH + "ALICE event not ready.");
147 if(gEvent->fESD == 0)
148 throw(eH + "AliESD not initialised.");