1 |
#ifndef OSU_ANALYSIS
|
2 |
|
3 |
#define OSU_ANALYSIS
|
4 |
|
5 |
#include <map>
|
6 |
#include <string>
|
7 |
#include <vector>
|
8 |
|
9 |
#include <fstream>
|
10 |
#include <iostream>
|
11 |
#include <algorithm>
|
12 |
#include <regex>
|
13 |
#include "TH1.h"
|
14 |
#include "TH2.h"
|
15 |
#include "TH1D.h"
|
16 |
#include "TH2D.h"
|
17 |
#include "TLorentzVector.h"
|
18 |
#include "TVector3.h"
|
19 |
#include "TVector2.h"
|
20 |
#include "TTree.h"
|
21 |
|
22 |
#include "FWCore/Framework/interface/EDProducer.h"
|
23 |
#include "FWCore/Framework/interface/Event.h"
|
24 |
#include "FWCore/Framework/interface/EventSetup.h"
|
25 |
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
26 |
#include "FWCore/ServiceRegistry/interface/Service.h"
|
27 |
#include "DataFormats/Common/interface/Handle.h"
|
28 |
#include "CommonTools/UtilAlgos/interface/TFileService.h"
|
29 |
#include "FWCore/Framework/interface/MakerMacros.h"
|
30 |
#include "DataFormats/Math/interface/deltaPhi.h"
|
31 |
#include "DataFormats/Math/interface/deltaR.h"
|
32 |
|
33 |
#include "ProductArea/BNcollections/interface/BNbxlumi.h"
|
34 |
#include "ProductArea/BNcollections/interface/BNelectron.h"
|
35 |
#include "ProductArea/BNcollections/interface/BNevent.h"
|
36 |
#include "ProductArea/BNcollections/interface/BNjet.h"
|
37 |
#include "ProductArea/BNcollections/interface/BNmcparticle.h"
|
38 |
#include "ProductArea/BNcollections/interface/BNmet.h"
|
39 |
#include "ProductArea/BNcollections/interface/BNmuon.h"
|
40 |
#include "ProductArea/BNcollections/interface/BNphoton.h"
|
41 |
#include "ProductArea/BNcollections/interface/BNprimaryvertex.h"
|
42 |
#include "ProductArea/BNcollections/interface/BNskimbits.h"
|
43 |
#include "ProductArea/BNcollections/interface/BNsupercluster.h"
|
44 |
#include "ProductArea/BNcollections/interface/BNtrack.h"
|
45 |
#include "ProductArea/BNcollections/interface/BNtrigger.h"
|
46 |
#include "ProductArea/BNcollections/interface/BNtrigobj.h"
|
47 |
#include "ProductArea/BNcollections/interface/BNtau.h"
|
48 |
#include "ProductArea/BNcollections/interface/BNgenjet.h"
|
49 |
|
50 |
|
51 |
#include "OSUT3Analysis/AnaTools/interface/CutFlow.h"
|
52 |
#include "OSUT3Analysis/AnaTools/interface/PUWeight.h"
|
53 |
#include "OSUT3Analysis/AnaTools/interface/SFWeight.h"
|
54 |
#include "OSUT3Analysis/AnaTools/interface/BtagSFWeight.h"
|
55 |
#include "OSUT3Analysis/AnaTools/interface/StopCTauWeight.h"
|
56 |
|
57 |
using namespace std;
|
58 |
|
59 |
class OSUAnalysis : public edm::EDProducer
|
60 |
{
|
61 |
public:
|
62 |
OSUAnalysis (const edm::ParameterSet &);
|
63 |
~OSUAnalysis ();
|
64 |
|
65 |
void produce (edm::Event &, const edm::EventSetup &);
|
66 |
bool evaluateComparison (double, string, double);
|
67 |
bool evaluateComparison (string, string, string);
|
68 |
bool evaluateTriggers (vector<string>, vector<string>, const BNtriggerCollection*);
|
69 |
double applyFunction(string, double);
|
70 |
|
71 |
double valueLookup (const BNjet* object, string variable, string function, string &stringValue);
|
72 |
double valueLookup (const BNmuon* object, string variable, string function, string &stringValue);
|
73 |
double valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue);
|
74 |
double valueLookup (const BNelectron* object, string variable, string function, string &stringValue);
|
75 |
double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue);
|
76 |
double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue);
|
77 |
double valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue);
|
78 |
double valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue);
|
79 |
double valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue);
|
80 |
double valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue);
|
81 |
double valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue);
|
82 |
double valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue);
|
83 |
double valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue);
|
84 |
double valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue);
|
85 |
double valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue);
|
86 |
double valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue);
|
87 |
double valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue);
|
88 |
double valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue);
|
89 |
double valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue);
|
90 |
double valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue);
|
91 |
double valueLookup (const BNevent* object, string variable, string function, string &stringValue);
|
92 |
double valueLookup (const BNtau* object, string variable, string function, string &stringValue);
|
93 |
double valueLookup (const BNmet* object, string variable, string function, string &stringValue);
|
94 |
double valueLookup (const BNtrack* object, string variable, string function, string &stringValue);
|
95 |
double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue);
|
96 |
double valueLookup (const BNgenjet* object, string variable, string function, string &stringValue);
|
97 |
double valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue);
|
98 |
double valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue);
|
99 |
double valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue);
|
100 |
double valueLookup (const BNphoton* object, string variable, string function, string &stringValue);
|
101 |
double valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue);
|
102 |
double valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue);
|
103 |
double valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue);
|
104 |
double valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue);
|
105 |
double valueLookup (const BNstop* object, string variable, string function, string &stringValue);
|
106 |
|
107 |
int getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl);
|
108 |
double getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl);
|
109 |
double getHt (const BNjetCollection* jetColl);
|
110 |
double getTrkPtRes (const BNtrack* track1);
|
111 |
double getTrkIsIso (const BNtrack* track1);
|
112 |
double getTrkCaloTotRhoCorr(const BNtrack* track);
|
113 |
double getTrkDepTrkRp5RhoCorr(const BNtrack* track);
|
114 |
double getTrkDepTrkRp3RhoCorr(const BNtrack* track);
|
115 |
void WriteDeadEcal ();
|
116 |
int getTrkIsMatchedDeadEcal (const BNtrack* track1);
|
117 |
|
118 |
//BNskimbits
|
119 |
//BNtrigobj
|
120 |
|
121 |
vector<string> splitString (string);
|
122 |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2);
|
123 |
string getObjToGet(string obj);
|
124 |
|
125 |
private:
|
126 |
|
127 |
//flagMap:
|
128 |
//string holds input collection type
|
129 |
//outer vector corresponds to each cut
|
130 |
//inner vector corresponds to each object in input collection
|
131 |
//pair(bool) first bool counts towards the event passing, second bool determines whether to plot the object
|
132 |
typedef map<string, vector<vector<pair<bool,bool> > > > flagMap;
|
133 |
|
134 |
//flagPair (corresponds to flagMap):
|
135 |
//vector corresponds to each object in input collection
|
136 |
//pair(bool) first bool counts towards the event passing, second bool determines whether to plot the object
|
137 |
typedef vector<pair<bool,bool> > flagPair;
|
138 |
|
139 |
//counterMap:
|
140 |
//string holds input collection type
|
141 |
//vector corresponds to each cut
|
142 |
//int holds number of objects passing all cuts up to that point
|
143 |
typedef map<string ,vector <int> > counterMap;
|
144 |
|
145 |
// Remember to define parameters to be retrieved from the configuration file.
|
146 |
edm::InputTag jets_;
|
147 |
edm::InputTag muons_;
|
148 |
edm::InputTag electrons_;
|
149 |
edm::InputTag events_;
|
150 |
edm::InputTag taus_;
|
151 |
edm::InputTag mets_;
|
152 |
edm::InputTag tracks_;
|
153 |
edm::InputTag genjets_;
|
154 |
edm::InputTag mcparticles_;
|
155 |
edm::InputTag stops_;
|
156 |
edm::InputTag primaryvertexs_;
|
157 |
edm::InputTag bxlumis_;
|
158 |
edm::InputTag photons_;
|
159 |
edm::InputTag superclusters_;
|
160 |
edm::InputTag triggers_;
|
161 |
edm::InputTag trigobjs_;
|
162 |
string puFile_;
|
163 |
string deadEcalFile_;
|
164 |
string muonSFFile_;
|
165 |
string dataPU_;
|
166 |
string electronSFID_;
|
167 |
string muonSF_;
|
168 |
string dataset_;
|
169 |
string datasetType_;
|
170 |
vector<edm::ParameterSet> channels_;
|
171 |
vector<edm::ParameterSet> histogramSets_;
|
172 |
bool useEDMFormat_;
|
173 |
vector<edm::ParameterSet> treeBranchSets_;
|
174 |
bool plotAllObjectsInPassingEvents_;
|
175 |
bool doPileupReweighting_;
|
176 |
bool applyLeptonSF_;
|
177 |
bool applyBtagSF_;
|
178 |
int minBtag_;
|
179 |
bool printEventInfo_;
|
180 |
bool printAllTriggers_;
|
181 |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy
|
182 |
vector<double> stopCTau_;
|
183 |
bool GetPlotsAfterEachCut_;
|
184 |
int verbose_;
|
185 |
|
186 |
struct DeadEcal {
|
187 |
double etaEcal;
|
188 |
double phiEcal;
|
189 |
};
|
190 |
|
191 |
vector<DeadEcal> DeadEcalVec;
|
192 |
|
193 |
|
194 |
//Collections
|
195 |
edm::Handle<BNtriggerCollection> triggers;
|
196 |
edm::Handle<BNtrigobjCollection> trigobjs;
|
197 |
edm::Handle<BNjetCollection> jets;
|
198 |
edm::Handle<BNmuonCollection> muons;
|
199 |
edm::Handle<BNelectronCollection> electrons;
|
200 |
edm::Handle<BNeventCollection> events;
|
201 |
edm::Handle<BNtauCollection> taus;
|
202 |
edm::Handle<BNmetCollection> mets;
|
203 |
edm::Handle<BNtrackCollection> tracks;
|
204 |
edm::Handle<BNgenjetCollection> genjets;
|
205 |
edm::Handle<BNmcparticleCollection> mcparticles;
|
206 |
edm::Handle<BNprimaryvertexCollection> primaryvertexs;
|
207 |
edm::Handle<BNbxlumiCollection> bxlumis;
|
208 |
edm::Handle<BNphotonCollection> photons;
|
209 |
edm::Handle<BNsuperclusterCollection> superclusters;
|
210 |
edm::Handle<BNstopCollection> stops;
|
211 |
|
212 |
edm::Handle<double> rhokt6CaloJetsHandle_;
|
213 |
|
214 |
flagMap cumulativeFlags;
|
215 |
flagMap vetoFlags;
|
216 |
|
217 |
vector<vector<map<string, TH1D*>>> oneDHists_;
|
218 |
vector<vector<map<string, TH2D*>>> twoDHists_;
|
219 |
vector<TTree*> BNTrees_; // one tree per channel
|
220 |
map<string, vector<float>> BNTreeBranchVals_; // data structure to hold the values of the branches to be stored in the BNTrees_; the string is the name of a variable
|
221 |
|
222 |
edm::Service<TFileService> fs_;
|
223 |
|
224 |
CutFlow *masterCutFlow_;
|
225 |
vector<CutFlow *> cutFlows_;
|
226 |
|
227 |
typedef struct {
|
228 |
string name;
|
229 |
string title;
|
230 |
vector<double> bins;
|
231 |
vector<double> variableBinsX;
|
232 |
vector<double> variableBinsY;
|
233 |
string inputCollection;
|
234 |
vector<string> inputVariables;
|
235 |
} histogram;
|
236 |
|
237 |
typedef struct {
|
238 |
string name;
|
239 |
string inputCollection;
|
240 |
string inputVariable;
|
241 |
} BranchSpecs;
|
242 |
|
243 |
|
244 |
struct cut {
|
245 |
string inputCollection;
|
246 |
vector<string> functions;
|
247 |
vector<string> variables;
|
248 |
vector<string> comparativeOperators;// >, <, =, etc.
|
249 |
vector<double> cutValues;
|
250 |
vector<string> cutStringValues;
|
251 |
vector<string> logicalOperators;//and, or
|
252 |
int numSubcuts;
|
253 |
int numberRequired;
|
254 |
string eventComparativeOperator;
|
255 |
string name;
|
256 |
bool isVeto;
|
257 |
};
|
258 |
|
259 |
struct channel {
|
260 |
string name;
|
261 |
vector<string> triggers;
|
262 |
vector<string> triggersToVeto;
|
263 |
vector<cut> cuts;
|
264 |
};
|
265 |
|
266 |
vector<string> objectsToGet;
|
267 |
vector<string> objectsToCut;
|
268 |
vector<string> objectsToPlot;
|
269 |
vector<string> objectsToFlag;
|
270 |
|
271 |
vector<channel> channels;
|
272 |
vector<histogram> histograms;
|
273 |
vector<BranchSpecs> treeBranches_;
|
274 |
|
275 |
PUWeight *puWeight_;
|
276 |
MuonSFWeight *muonSFWeight_;
|
277 |
double muonScaleFactor_;
|
278 |
ElectronSFWeight *electronSFWeight_;
|
279 |
double electronScaleFactor_;
|
280 |
BtagSFWeight *bTagSFWeight_;
|
281 |
double bTagScaleFactor_;
|
282 |
|
283 |
StopCTauWeight *stopCTauWeight_;
|
284 |
double stopCTauScaleFactor_;
|
285 |
|
286 |
ofstream* findEventsLog;
|
287 |
bool isFirstEvent_;
|
288 |
|
289 |
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string);
|
290 |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, string);
|
291 |
|
292 |
template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, flagPair flags);
|
293 |
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, flagPair, double);
|
294 |
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, flagPair, double);
|
295 |
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, flagPair, double);
|
296 |
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, flagPair, double);
|
297 |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType);
|
298 |
|
299 |
|
300 |
|
301 |
template <class InputObject> int getGenMatchedParticleIndex(InputObject);
|
302 |
int getPdgIdBinValue(int);
|
303 |
int findTauMotherIndex(const BNmcparticle*);
|
304 |
|
305 |
template <class InputObject> double getGenDeltaRLowest(InputObject);
|
306 |
|
307 |
|
308 |
const BNprimaryvertex *chosenVertex ();
|
309 |
const BNmet *chosenMET ();
|
310 |
const BNelectron *chosenElectron ();
|
311 |
const BNmuon *chosenMuon ();
|
312 |
double chosenHT ();
|
313 |
pair<const BNmuon *, const BNmuon*> leadMuonPair ();
|
314 |
pair<const BNelectron *, const BNelectron*> leadElectronPair ();
|
315 |
|
316 |
};
|
317 |
|
318 |
#endif
|