+ // Open AOD and registered friends
+
+ TString aodPath(Form("%s/%s", fPath.Data(), fgAODFileName.Data()));
+ if ((fAODFile = TFile::Open(aodPath)))
+ {
+ fAOD = new AliAODEvent();
+ fAODTree = (TTree*) fAODFile->Get("aodTree");
+ if (fAODTree != 0)
+ {
+ // Check if AODfriends exist and attach them.
+ TIter friends(fgAODfriends);
+ TObjString *name;
+ while ((name = (TObjString*) friends()) != 0)
+ {
+ TString p(Form("%s/%s", fPath.Data(), name->GetName()));
+ if (gSystem->AccessPathName(p, kReadPermission) == kFALSE)
+ {
+ fAODTree->AddFriend("aodTree", name->GetName());
+ }
+ }
+
+ fAOD->ReadFromTree(fAODTree);
+
+ if (fAODTree->GetEntry(0) <= 0)
+ {
+ delete fAODFile; fAODFile = 0;
+ delete fAOD; fAOD = 0;
+ Warning(kEH, "failed getting the first entry from addTree.");
+ }
+ else
+ {
+ if (runNo < 0)
+ runNo = fAOD->GetRunNumber();
+ }
+ }
+ else // aodtree == 0
+ {
+ delete fAODFile; fAODFile = 0;
+ delete fAOD; fAOD = 0;
+ Warning(kEH, "failed getting the aodTree.");
+ }
+ }
+ else // aod not readable
+ {
+ Warning(kEH, "can not read AOD file '%s'.", aodPath.Data());
+ }
+ if (fAODTree == 0)
+ {
+ if (fgAssertAOD)
+ {
+ throw (kEH + "AOD not initialized. Its precence was requested.");
+ } else {
+ Warning(kEH, "AOD not initialized.");
+ }
+ }
+