-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_nJets.C
65 lines (48 loc) · 1.6 KB
/
get_nJets.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
#include <vector>
#include <iostream>
#include <fstream>
#include <limits>
#include <math.h>
//Delphes and root stuff
#ifdef __CLING__
R__LOAD_LIBRARY(libDelphes)
#include "classes/DelphesClasses.h"
#include "external/ExRootAnalysis/ExRootTreeReader.h"
#endif
void get_nJets(const char *inputFile, const char *outFileone){
gSystem->Load("libDelphes");
// Create chain of root trees
TChain chain("Delphes");
chain.Add(inputFile);
// Create object of class ExRootTreeReader
ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
Long64_t numberOfEntries = treeReader->GetEntries();
// Get pointers to branches used in this analysis
TClonesArray *branchJet = treeReader->UseBranch("Jet");
// Output file
cout << "Total number of events:" << setw(10) << numberOfEntries << endl;
// numberOfEntries = 10000;
// Loop over all events and write to output file
// Counter for mono-jet events
int monojet_count = 0;
for(Int_t entry = 0; entry < numberOfEntries; ++entry)
{
treeReader->ReadEntry(entry);
// if(branchJet->GetEntriesFast() != 1){continue;}
int jet_count = 0;
for(int i=0; i < branchJet->GetEntriesFast(); i++){
// Jet *candidate = (Jet*)branchJet->At(i);
jet_count += 1;
}
if(jet_count == 1){
monojet_count += 1;
}
}
// Print to the file
cout << "Number of monojet events:" << setw(10) << monojet_count << endl;
ofstream oFile;
oFile.open(outFileone, std::ofstream::out | std::ofstream::trunc); //wipe ouput file clean
oFile << monojet_count << endl;
oFile.close();
return;
}