-ClassImp(AliAODExtension)
-
-//-------------------------------------------------------------------------
-// Support class for AOD extensions. This is created by the user analysis
-// that requires a separate file for some AOD branches. The name of the
-// AliAODExtension object is the file name where the AOD branches will be
-// stored.
-//-------------------------------------------------------------------------
-
-//______________________________________________________________________________
-AliAODExtension::~AliAODExtension()
-{
-// Destructor.
- delete fAODEvent;
- if(fFileE){
- // is already handled in TerminateIO
- fFileE->Close();
- delete fFileE;
- }
- delete fTreeE;
-}
-
-//______________________________________________________________________________
-void AliAODExtension::AddBranch(const char* cname, void* addobj)
-{
- // Add a new branch to the aod
- if (!fAODEvent) {
- char type[20];
- gROOT->ProcessLine(Form("TString s_tmp; AliAnalysisManager::GetAnalysisManager()->GetAnalysisTypeString(s_tmp); sprintf((char*)0x%lx, \"%%s\", s_tmp.Data());", type));
- Init(type);
- }
- TDirectory *owd = gDirectory;
- if (fFileE) {
- fFileE->cd();
- }
- char** apointer = (char**) addobj;
- TObject* obj = (TObject*) *apointer;
-
- fAODEvent->AddObject(obj);
-
- const Int_t kSplitlevel = 99; // default value in TTree::Branch()
- const Int_t kBufsize = 32000; // default value in TTree::Branch()
-
- if (!fTreeE->FindBranch(obj->GetName())) {
- // Do the same as if we book via
- // TTree::Branch(TCollection*)
-
- fTreeE->Bronch(obj->GetName(), cname, fAODEvent->GetList()->GetObjectRef(obj),
- kBufsize, kSplitlevel - 1);
- // fTreeA->Branch(obj->GetName(), cname, addobj);
- }
- owd->cd();
-}
-
-//______________________________________________________________________________
-Bool_t AliAODExtension::Init(Option_t *option)
-{
-// Initialize IO.
- if(!fAODEvent) fAODEvent = new AliAODEvent();
- TDirectory *owd = gDirectory;
- TString opt(option);
- opt.ToLower();
- if (opt.Contains("proof")) {
- // proof
- // Merging via files. Need to access analysis manager via interpreter.
- gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->OpenProofFile(\"%s\", \"RECREATE\");", fName.Data()));
- fFileE = gFile;
- } else {
- fFileE = new TFile(GetName(), "RECREATE");
- }
- fTreeE = new TTree("aodTree", "AliAOD tree");
- fTreeE->Branch(fAODEvent->GetList());
- owd->cd();
- return kTRUE;
-}
-
-//______________________________________________________________________________
-Bool_t AliAODExtension::TerminateIO()
-{
- // Terminate IO
- if (fFileE) {
- fFileE->Write();
- fFileE->Close();
- delete fFileE;
- fFileE = 0;
- }
- return kTRUE;
-}