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 "TGeometry.h"
39 #include "TObjArray.h"
43 void CopyAli(TString fnOrig="rfio:galice.root", TString fnNew="galice_new.root",Int_t iEvent = 0, Bool_t copygAlice=kTRUE,Bool_t copyTreeK = kFALSE)
46 TFile *fileOrig = TFile::Open(fnOrig);
47 if (!fileOrig->IsOpen()) {
48 cerr<<"Cannot open input file "<<fnOrig.Data()<<endl;
52 if (gAlice) {delete gAlice; gAlice = 0;}
53 gAlice = (AliRun*)(fileOrig->Get("gAlice"));
55 cerr<<"Cannot read gAlice from the input file"<<endl;
59 Int_t nAllTracks = gAlice->GetEvent(iEvent);
60 cout<<"nAllTracks = "<<nAllTracks<<endl;
64 TFile *fileNew = TFile::Open(fnNew,"update");
65 if (!fileNew->IsOpen()) {
66 cerr<<"Cannot open output file "<<fnNew.Data()<<endl;
70 cout<<"Copy gAlice: ";
74 TTree *treeE = gAlice->TreeE();
76 cerr<<"No TreeE found for event "<<iEvent<<endl;
80 AliHeader *header = new AliHeader();
81 treeE->SetBranchAddress("Header", &header);
82 treeE->SetBranchStatus("*",1);
83 TTree *treeENew = treeE->CloneTree();
87 cout<<"Copy AliceGeom: ";
88 TGeometry *AliceGeom = static_cast<TGeometry*>(fileOrig->Get("AliceGeom"));
90 cerr<<"AliceGeom was not found in the input file "<<fnNew.Data()<<endl;
100 TTree *treeK = gAlice->TreeK();
102 cerr<<"No TreeK found for event "<<iEvent<<endl;
105 TParticle *particle = new TParticle();
106 treeK->SetBranchAddress("Particles",&particle);
107 treeK->SetBranchStatus("*",1);
108 TTree *treeKNew = treeK->CloneTree();