]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/cloneAODTreeAndRemoveObject.C
A new bunch of Global QA histogramms
[u/mrichter/AliRoot.git] / STEER / cloneAODTreeAndRemoveObject.C
CommitLineData
a19c5742 1void cloneAODTreeAndRemoveObject(const char *newFileName = "AliAOD_new.root", const char *orgFileName = "AliAOD.root") {
2 // This little macro takes an already created AOD file and clones it.
3 // After removing an old brach, the new TTree is written to a new file.
4
5 // open input file and get the TTree
6 TFile orgFile(orgFileName, "READ");
7 // get original TTree
8 TTree *orgAodTree = (TTree*)orgFile.Get("aodTree");
9 // do your gymnastics with the old TTree
10 AliAODEvent *evOrg = new AliAODEvent();
11 evOrg->ReadFromTree(orgAodTree);
12
13 // switch off one branch (and its subbranches!)
14 orgAodTree->SetBranchStatus("tracks*", 0);
15 // remove TObject from the list
16 evOrg->RemoveObject(evOrg->GetTracks());
17
18 // open new output file
19 TFile *newFile = new TFile(newFileName, "RECREATE");
20 // clone old TTree (only clones branches that are switched on)
21 TTree *newAodTree = orgAodTree->CloneTree();
22
23 // write new TTree to file
24 newAodTree->Write();
25
26 // close files
27 newFile->Close();
28 delete newFile;
29
30 orgFile.Close();
31}