-
Notifications
You must be signed in to change notification settings - Fork 0
/
SusyMainAna_Higgs.h
263 lines (202 loc) · 7.67 KB
/
SusyMainAna_Higgs.h
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
// -*- C++ -*-
//
// Package: SusyNtuplizer
// Class: SusyMainAna_Higgs.h
//
/*
Description: an analyzer for susy::Event
Implementation:
*/
//
// Original Author: Dongwook Jang
// $Id: SusyMainAna_Higgs.h,v 1.4 2011/06/08 16:28:40 dmason Exp $
//
#ifndef SusyMainAna_Higgs_h
#define SusyMainAna_Higgs_h
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TString.h>
#include <iostream>
#include <fstream>
#include <map>
#include "../src/SusyEvent.h"
class SusyMainAna_Higgs {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain
// Declaration of leaf types
susy::Event *event;
// List of branches
TBranch *b_Event;
SusyMainAna_Higgs(TTree *tree=0);
virtual ~SusyMainAna_Higgs();
virtual Int_t GetEntry(Long64_t entry);
virtual Long64_t LoadTree(Long64_t entry);
virtual void Init(TTree *tree);
virtual void Loop(); // event loop for main analysis
// utility functions
bool isSameObject(TLorentzVector& p1, TLorentzVector& p2);
float d0correction(TVector3& beamSpot, susy::Track& track) const;
void IncludeAJson(std::string jsonfile); // Call to pull in a json file
bool isInJson(Int_t run,Int_t lumi); // JSON based good run list cut...
bool PassTrigger(TString v); // return true if path v is fired
bool PassTriggers(); // return true if any of names in hltNames are fired
//float d0correction_(TVector3& beamSpot, susy::Track& track);
// bool ok_muon(std::vector<susy::Muon>::iterator it,susy::Event* event);
// bool ok_muon_DMoris(std::vector<susy::Muon>::iterator it_Mu,susy::Track& innerTrack,susy::Event* event);
// bool ok_muon_AN_11_409(std::vector<susy::Muon>::iterator it,susy::Track& combinedTrack, susy::Event* event, float pVtx_Z);
bool ok_muon(std::vector<susy::Muon>::iterator it);
bool ok_muon_DMoris(std::vector<susy::Muon>::iterator it_Mu,susy::Track& innerTrack);
bool ok_muon_AN_11_409(std::vector<susy::Muon>::iterator it,susy::Track& combinedTrack, float pVtx_Z);
bool ok_ele(std::vector<susy::Electron>::iterator it_Ele);
bool ok_ele_AN_11_409(std::vector<susy::Electron>::iterator it_Ele, susy::Track& innerTrack, float pVtx_Z);
bool ok_vtx(std::vector<susy::Vertex>::iterator it);
void MakeHistSet(TH1F** h, string prefix, int nbins, float lower, float upper);
// float JEC_MET(susy::MET* pfmet,std::vector<susy::PFJet*> ra3_pfjets, bool Debug_noisily);
float JEC_MET(susy::MET* pfmet,std::vector<susy::PFJet*> ra3_pfjets,float &corrX, float &corrY, bool Debug_noisily);
float PhoEC_MET(float oldcorrmet,std::vector<susy::Photon*> photons, float &corrX, float &corrY, bool Debug_noisily);
// parameter configuration functions
void Initialize(); // global variables needed to be initialized just once
void InitializePerEvent(); // global variables needed to be initialized per event
void SetDataset(TString& v) { ds = v; }
void SetPrintInterval(int v) { printInterval = v; }
void SetPrintLevel(int v) { printLevel = v; }
void SetProcessNEvents(int v) { processNEvents = v; }
void SetUseTrigger(bool v) { useTrigger = v; }
void AddHltName(TString v) { hltNames.push_back(v); }
void SetFilter(bool v) { enableFilter = v; }
void SetFilteredFileName(TString v) { filtered_file_name = v; }
private:
TString ds; // dataset name to be used for output histfile name
// printLevel
// 0 : default - no printout
// 1 : print functional step in every event
// 2 : print values in collections
int printLevel; // print frequency
bool useJSON;
int printInterval; // print level for event content: defined in Event.h
int processNEvents; // number of events to be processed
bool useTrigger; // flag for using trigger bit selection.
std::vector<TString> hltNames; // HLT trigger path names
bool enableFilter; // filter events of interest
TString filtered_file_name; // filtered output file name
typedef std::map<int,std::map<int,bool> > RunLumiFlagHolder; //define map that holds json list
RunLumiFlagHolder goodrunlumilist; // instantiate it
};
#endif
#ifdef SusyMainAna_Higgs_cxx
SusyMainAna_Higgs::SusyMainAna_Higgs(TTree *tree)
{
if (tree == 0) {
std::cout << "Error!!! There is no file containing a tree." << std::endl;
}
Init(tree);
Initialize();
}
SusyMainAna_Higgs::~SusyMainAna_Higgs()
{
if (!fChain) return;
delete fChain->GetCurrentFile();
}
Int_t SusyMainAna_Higgs::GetEntry(Long64_t entry)
{
// Read contents of entry.
if (!fChain) return 0;
return fChain->GetEntry(entry);
}
Long64_t SusyMainAna_Higgs::LoadTree(Long64_t entry)
{
// Set the environment to read one entry
if (!fChain) return -5;
Long64_t centry = fChain->LoadTree(entry);
if (centry < 0) return centry;
if (!fChain->InheritsFrom(TChain::Class())) return centry;
TChain *chain = (TChain*)fChain;
if (chain->GetTreeNumber() != fCurrent) {
fCurrent = chain->GetTreeNumber();
}
return centry;
}
void SusyMainAna_Higgs::Init(TTree *tree)
{
if (!tree) return;
fChain = tree;
fCurrent = -1;
// fChain->SetMakeClass(1);
event = new susy::Event;
fChain->SetBranchAddress("susyEvent", &event, &b_Event);
}
void SusyMainAna_Higgs::Initialize() {
ds = "test";
printLevel = 0;
useJSON = false;
printInterval = 10000;
processNEvents = -1;
useTrigger = true;
enableFilter = true;
//filtered_file_name = "filtered_MC.root";
}
void SusyMainAna_Higgs::IncludeAJson(std::string jsonfile) {
// Fairly primitive brute force json parser -- opens the json file named in the argument
// and adds that to the goodrunlumilist map. Overlapping jsons are merged inclusively.
char thing;
ifstream jsonInput;
std::cout << "Sucking in Json file: " << jsonfile << " which includes: " << std::endl;
jsonInput.open(jsonfile.c_str());
if (!jsonInput.good()) {
std::cout << "Problem reading Json file... Didn't suck anything in... " << std::endl;
return;
}
jsonInput.get(thing);
while (jsonInput.good()) {
if (thing=='{') { // start of list
while (thing != '}') {
int runnum;
if (thing == '"') {
std::string srunnum;
jsonInput.get(thing); // get stuff inside ""
while (thing != '"') {
srunnum+=thing; // get stuff inside ""
jsonInput.get(thing);
}
sscanf(srunnum.c_str(),"%i",&runnum);
std::cout << " runnum: " << runnum << std::endl;
bool newrun=true;
} // inside ""
if (thing == '[') {
jsonInput.get(thing); // get stuff inside []
while (thing != ']') {
if (thing == '[') {
jsonInput.get(thing); // get stuff inside series []
std::string lumiseries;
int firstlumi,lastlumi;
while (thing !=']') {
lumiseries+=thing;
jsonInput.get(thing); // get stuff inside series []
}
sscanf(lumiseries.c_str(),"%i,%i",&firstlumi,&lastlumi);
//std::cout << " lumis " << firstlumi << " to " << lastlumi << std::endl;
// At this point have runnum, first lumi, last lumi -- so can fill map here...
for (int l=firstlumi;l<=lastlumi;l++) {
goodrunlumilist[runnum][l]=true;
}
} // inside actual series []
jsonInput.get(thing); // get stuff inside []
}
} // inside []
jsonInput.get(thing); // get another char looking for "
}
} // inside {}
jsonInput.get(thing); // get another char looking for {
} // EOF
jsonInput.close();
}
bool SusyMainAna_Higgs::isInJson(Int_t run,Int_t lumi) {
//#ifdef MC
// return 1;
//#endif
if (goodrunlumilist[run][lumi]) return true;
return false;
}
#endif // #ifdef SusyMainAna_Higgs_cxx