3 #include "EventAlieve.h"
6 #include <AliRunLoader.h>
8 #include <AliESDfriend.h>
17 using namespace Alieve;
19 //______________________________________________________________________
25 Event* Alieve::gEvent = 0;
27 Bool_t Alieve::Event::fgUseRunLoader = true;
28 Bool_t Alieve::Event::fgUseESDTree = true;
30 void Event::Initialize(Bool_t use_runloader, Bool_t use_esd)
32 static const Exc_t eH("Event::Initialize ");
34 fgUseRunLoader = use_runloader;
35 fgUseESDTree = use_esd;
38 if(fgUseRunLoader == false && fgUseESDTree == false)
39 throw(eH + "should use at least one data source.");
42 AssertMacro("loadlibs.C");
44 else if(fgUseESDTree) {
45 gSystem->Load("libESD.so");
50 /**************************************************************************/
64 EventBase(), fEventId(0)
69 Event::Event(TString path, Int_t ev) :
70 EventBase("AliEVE Event"),
71 fPath(path), fEventId(ev)
77 /**************************************************************************/
81 static const Exc_t eH("Event::Open ");
83 gSystem->ExpandPathName(fPath);
85 fPath = Form("%s/%s", gSystem->WorkingDirectory(), fPath.Data());
88 TString ga_path(Form("%s/galice.root", fPath.Data()));
89 if(gSystem->AccessPathName(ga_path, kReadPermission))
90 throw(eH + "can not read '" + ga_path + "'.");
91 fRunLoader = AliRunLoader::Open(ga_path);
93 throw(eH + "failed opening ALICE run loader from '" + ga_path + "'.");
95 TString alice_path = fPath + "/";
96 fRunLoader->SetDirName(alice_path);
98 if(fRunLoader->LoadgAlice() != 0) {
99 throw(eH + "failed loading gAlice.");
102 if(fRunLoader->GetEvent(fEventId) != 0) {
103 throw(eH + "failed getting required event.");
108 TString p(Form("%s/AliESDs.root", fPath.Data()));
109 if(gSystem->AccessPathName(p, kReadPermission))
110 throw(eH + "can not read '" + p + "'.");
111 fESDFile = new TFile(p);
112 if(fESDFile->IsZombie()) {
113 delete fESDFile; fESDFile = 0;
114 throw(eH + "failed opening ALICE ESD from '" + p + "'.");
117 fESDTree = (TTree*) fESDFile->Get("esdTree");
119 throw(eH + "failed getting the esdTree.");
120 fESDTree->SetBranchAddress("ESD", &fESD);
121 if(fESDTree->GetEntry(fEventId) <= 0)
122 throw(eH + "failed getting required event from ESD.");
124 // Check if ESDfriends exists and load it
125 p = Form("%s/AliESDfriends.root", fPath.Data());
126 if(gSystem->AccessPathName(p, kReadPermission) == kFALSE) {
127 fESDfriendFile = new TFile(p);
128 if(fESDfriendFile->IsZombie()) {
129 delete fESDfriendFile; fESDfriendFile = 0;
130 throw(eH + "failed opening ALICE ESDfriend from '" + p + "'.");
133 fESDfriendTree = (TTree*) fESDfriendFile->Get("esdFriendTree");
134 if(fESDfriendTree == 0)
135 throw(eH + "failed getting the esdFriendTree.");
136 fESDfriendTree->SetBranchAddress("ESDfriend", &fESDfriend);
137 if(fESDfriendTree->GetEntry(fEventId) <= 0)
138 throw(eH + "failed getting required event from ESDfriend.");
140 fESD->SetESDfriend(fESDfriend);
144 SetName(Form("Event%d", fEventId));
153 /**************************************************************************/
154 /**************************************************************************/
156 // Static convenience functions.
158 AliRunLoader* Event::AssertRunLoader()
160 static const Exc_t eH("Event::AssertRunLoader ");
163 throw(eH + "ALICE event not ready.");
164 if(gEvent->fRunLoader == 0)
165 throw(eH + "AliRunLoader not initialised.");
166 return gEvent->fRunLoader;
169 AliESD* Event::AssertESD()
171 static const Exc_t eH("Event::AssertESD ");
174 throw(eH + "ALICE event not ready.");
175 if(gEvent->fESD == 0)
176 throw(eH + "AliESD not initialised.");
180 AliESDfriend* Event::AssertESDfriend()
182 static const Exc_t eH("Event::AssertESDfriend ");
185 throw(eH + "ALICE event not ready.");
186 if(gEvent->fESDfriend == 0)
187 throw(eH + "AliESDfriend not initialised.");
188 return gEvent->fESDfriend;