-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRunTest.C
86 lines (61 loc) · 2.33 KB
/
RunTest.C
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "NtupleClass.h"
#include "TH1D.h"
#include "TFile.h"
#include "TSystem.h"
#include <fstream>
#include<iostream>
int main(int argc, char *argv[])
{
char eos_dir_name[1000] ;
if (argc == 1)
{
std::cout << "Please provide a file pattern to run over" << std::endl;
return 0;
}
std::string outfile = "mytest.root";
if (argc > 2)
{
outfile = argv[2];
}
if ( argc > 3 ) {
sprintf( eos_dir_name, "%s", argv[3] ) ;
} else {
sprintf( eos_dir_name, "/store/user/soha/stealth_rpv_ntuples_subjets" ) ;
}
char command[1000] ;
sprintf( command, "eos root://cmseos.fnal.gov ls %s > eos-files.txt", eos_dir_name ) ;
gSystem -> Exec( command ) ;
char file_pattern[1000] ;
sprintf( file_pattern, "%s", argv[1] ) ;
printf("\n\n Will load files that match %s from eos dir %s\n\n", file_pattern, eos_dir_name ) ;
//------- NFG. Can't use wildcard with eos files and TChain::Add apparently.
////////TChain* ch = new TChain( "TreeMaker2/PreSelection" ) ;
////////int nfiles = ch->Add( "root::cmsxrootd.fnal.gov//store/user/soha/stealth_rpv_ntuples_subjets/Summer16_private.rpv_stop_650_t3j_uds_*.root" ) ;
////////printf("\n\n Number of files added to TChain: %d\n\n", nfiles ) ;
////////printf("\n\n Number of entries %lld\n\n", ch->GetEntries() ) ;
TChain* ch = new TChain( "TreeMaker2/PreSelection" ) ;
std::ifstream ifs_files ;
ifs_files.open( "eos-files.txt" ) ;
while ( ifs_files.good() ) {
TString tsline ;
tsline.ReadLine( ifs_files ) ;
if ( !ifs_files.good() ) break ;
if ( tsline.Contains( file_pattern ) ) {
char fname[1000] ;
sscanf( tsline.Data(), "%s", fname ) ;
char fnamewithpath[1000] ;
sprintf( fnamewithpath, "root://cmsxrootd.fnal.gov/%s/%s", eos_dir_name, fname ) ;
printf(" Adding file %s\n", fnamewithpath ) ;
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");
bool isQuiet = true;
NtupleClass t = NtupleClass( ch );
t.Loop("");
myfile->Close();
return 0;
}