6 #include <TObjString.h>
7 #include "TInterpreter.h"
19 #include "classes/DelphesClasses.h"
20 #include "external/ExRootAnalysis/ExRootTreeReader.h"
39 "--input_dir <i>: Directory containing all the ROOT files you want to process\n"
40 "--output_file <o>: Output ROOT file to store results\n"
41 "--module_sequence <s>: A string comma-separated list of modules to load; order is preserved in execution.\n"
42 "--nevents <n>: The total number of events to process, starting from the zeroth event in the input.\n"
43 "--help: Show this helpful message!\n";
47 std::vector<std::string>
fileVector(
const std::string& pattern){
49 glob(pattern.c_str(),GLOB_TILDE,NULL,&glob_result);
50 std::vector<std::string>
files;
51 for(
unsigned int i=0;i<glob_result.gl_pathc;++i){
52 files.push_back(std::string(glob_result.gl_pathv[i]));
54 globfree(&glob_result);
61 int main(
int argc,
char *argv[])
64 "===================== SIMPLEANALYSIS =====================" << std::endl;
68 gInterpreter->GenerateDictionary(
"std::vector<std::vector<float>>",
"vector");
76 const char*
const short_opts =
"i:o:h";
77 const option long_opts[] = {
78 {
"input_dir", required_argument,
nullptr,
'i'},
79 {
"output_file", required_argument,
nullptr,
'o'},
80 {
"module_sequence", required_argument,
nullptr,
's'},
81 {
"nevents", optional_argument,
nullptr,
'n'},
82 {
"help", no_argument,
nullptr,
'h'},
83 {
nullptr, no_argument,
nullptr, 0}
88 const auto opt = getopt_long(argc, argv, short_opts, long_opts,
nullptr);
97 std::cout <<
"Input Directory: " <<
input_dir << std::endl;
102 std::cout <<
"Output File: " <<
output_file << std::endl;
112 std::cout <<
"Number of events to process: " <<
nevents << std::endl;
127 auto data =
new TChain(
"Delphes");
136 ExRootTreeReader *treeReader =
new ExRootTreeReader(
data);
137 int n_entries =
data->GetEntries();
140 <<
"The provided data set contains the following number of events: " << std::endl
145 TClonesArray *branchJet = treeReader->UseBranch(
"Jet");
146 TClonesArray *branchElectron = treeReader->UseBranch(
"Electron");
147 TClonesArray *branchPhoton = treeReader->UseBranch(
"EFlowPhoton");
148 TClonesArray *branchNeutralHadron = treeReader->UseBranch(
"EFlowNeutralHadron");
149 TClonesArray *branchGenJet = treeReader->UseBranch(
"GenJet");
150 TClonesArray *branchGenParticle = treeReader->UseBranch(
"Particle");
151 TClonesArray *branchRawTrack = treeReader->UseBranch(
"Track");
152 TClonesArray *branchEFlowTrack = treeReader->UseBranch(
"EFlowTrack");
153 TClonesArray *branchMET = treeReader->UseBranch(
"MissingET");
164 for (
int i = 0; i < module_list->GetEntries(); i++) {
165 auto name =
static_cast<TObjString*
>(module_list->At(i))->GetString().Data();
166 std::cout <<
" Appending module " <<
name << std::endl;
170 for (
auto module : module_handler->
getModules()) {
171 module->initialize();
176 <<
"Processing all events in the sample..." << std::endl;
179 <<
"Processing "<<
nevents <<
" events in the sample..." << std::endl;
182 for(
int i=0; i < n_entries; ++i) {
185 std::cout <<
"Processing Event " << i << std::endl;
194 treeReader->ReadEntry(i);
196 std::map<std::string, std::any> DataStore;
199 for (
auto module : module_handler->
getModules()) {
200 module->setJets(branchJet);
201 module->setGenJets(branchGenJet);
202 module->setEFlowTracks(branchEFlowTrack);
203 module->setTracks(branchRawTrack);
204 module->setGenParticles(branchGenParticle);
205 module->setPhotons(branchPhoton);
206 module->setElectrons(branchElectron);
207 module->setNeutralHadrons(branchNeutralHadron);
208 module->setMET(branchMET);
210 bool result = module->execute(&DataStore);
224 for (
auto module : module_handler->
getModules()) {
231 "========================== FINIS =========================" << std::endl;