1 ////////////////////////////////////////////////////////////////////////
5 // last update: 21.3.2002
6 // author: Jiri Chudoba
10 // copy some alice objects from 1 file to another
13 // add support for more events in 1 file
17 // copied objects are not deleted, I assume that the root
18 // session is exited after this copy
21 // aliroot -b -q CopyAli.C\("galice.root","TreeK.root",0,1,1,1\)
25 // 21.3.02 - first version
27 ////////////////////////////////////////////////////////////////////////
29 #if !defined(__CINT__) || defined(__MAKECINT__)
33 #include "TDirectory.h"
36 #include "TParticle.h"
37 #include "AliHeader.h"
38 #include "TObjArray.h"
42 void CopyAli(TString fnOrig="rfio:galice.root", TString fnNew="galice_new.root",Int_t iEvent = 0, Bool_t copygAlice=kTRUE,Bool_t copyTreeK = kFALSE)
45 TFile *fileOrig = TFile::Open(fnOrig);
46 if (!fileOrig->IsOpen()) {
47 cerr<<"Cannot open input file "<<fnOrig.Data()<<endl;
51 if (gAlice) {delete gAlice; gAlice = 0;}
52 gAlice = (AliRun*)(fileOrig->Get("gAlice"));
54 cerr<<"Cannot read gAlice from the input file"<<endl;
58 Int_t nAllTracks = gAlice->GetEvent(iEvent);
59 cout<<"nAllTracks = "<<nAllTracks<<endl;
63 TFile *fileNew = TFile::Open(fnNew,"update");
64 if (!fileNew->IsOpen()) {
65 cerr<<"Cannot open output file "<<fnNew.Data()<<endl;
69 cout<<"Copy gAlice: ";
73 TTree *treeE = gAlice->TreeE();
75 cerr<<"No TreeE found for event "<<iEvent<<endl;
79 AliHeader *header = new AliHeader();
80 treeE->SetBranchAddress("Header", &header);
81 treeE->SetBranchStatus("*",1);
82 TTree *treeENew = treeE->CloneTree();
88 TTree *treeK = gAlice->TreeK();
90 cerr<<"No TreeK found for event "<<iEvent<<endl;
93 TParticle *particle = new TParticle();
94 treeK->SetBranchAddress("Particles",&particle);
95 treeK->SetBranchStatus("*",1);
96 TTree *treeKNew = treeK->CloneTree();