-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMicroNtuple.C
More file actions
70 lines (46 loc) · 1.47 KB
/
MicroNtuple.C
File metadata and controls
70 lines (46 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "NtupleClassMicroNtuple.h"
#include "TH1D.h"
#include "TFile.h"
#include "TSystem.h"
#include <fstream>
#include<iostream>
int main(int argc, char *argv[])
{
printf("\n\n argc is %d\n\n", argc ) ;
for ( int i=1; i<argc; i++ ) {
printf(" arg %d : %s\n", i, argv[i] ) ;
}
printf("\n\n") ;
if (argc == 1)
{
std::cout << "Please provide a file to run over" << std::endl;
return 0;
}
char fnamewithpath[10000] ;
sprintf( fnamewithpath, "root://cmsxrootd.fnal.gov/%s", argv[1] ) ;
std::string outfile = "mytest.root";
if (argc > 2)
{
outfile = argv[2];
}
bool do_skim(false) ;
if ( argc > 3 ) {
if ( strcmp( argv[3], "skim" ) == 0 ) {
printf("\n\n Will skim the output.\n\n") ;
do_skim = true ;
}
}
printf(" Adding file %s\n", fnamewithpath ) ;
TChain* ch = new TChain( "TreeMaker2/PreSelection" ) ;
ch -> Add( fnamewithpath ) ;
int nentries = ch->GetEntries() ;
printf("\n\n Number of entries %d\n\n", nentries ) ;
if ( nentries <= 0 ) { printf("\n\n Nothing to do.\n\n") ; gSystem->Exit(-1) ; }
TFile* myfile = TFile::Open(outfile.c_str(), "RECREATE");
//////////TTree* output_tree = ch -> CloneTree( 0 ) ;
TTree* output_tree = new TTree( "micrott", "Micro ttree" ) ;
NtupleClassMicroNtuple t = NtupleClassMicroNtuple( ch, output_tree, do_skim );
t.Loop();
myfile->Close();
return 0;
}