source: trunk/Mars/hawc/mcmerpp.C@ 19887

Last change on this file since 19887 was 19701, checked in by tbretz, 5 years ago
A macro to get the OriginalMC data into the root file.
File size: 972 bytes
Line 
1int mcmerpp(const char *fin="ceres.root", const char *fout="star.root")
2{
3 TFile filein (fin, "READ");
4 if (!filein)
5 {
6 cerr << "Failed to open '" << fin << "'" << endl;
7 return -1;
8 }
9
10 TFile fileout(fout, "UPDATE");
11 if (!fileout)
12 {
13 cerr << "Failed to open '" << fout << "'" << endl;
14 return -1;
15 }
16
17
18 TTree *tree = dynamic_cast<TTree*>(filein.Get("OriginalMC"));
19 if (!tree)
20 {
21 cerr << "Tree 'OriginalMC' not found in '" << fin << "'" << endl;
22 return -1;
23 }
24
25 //tree->SetBranchStatus("*", 1);
26
27 // Now we clone the tree without unpacking and repacking.
28 // When it has not been moved it will be deleted in the TFile destructor
29
30 TTree *newtree = tree->CloneTree(-1, "fast SortBasketsByEntry");
31 if (!newtree)
32 return -1;
33 newtree->Write();
34 delete newtree;
35
36 cerr << "OriginalMC copied from '" << fin << "' to '" << fout << "'" << endl;
37
38 return 0;
39}
Note: See TracBrowser for help on using the repository browser.