1 |
lantonel |
1.1 |
#ifndef OSU_ANALYSIS
|
2 |
|
|
|
3 |
|
|
#define OSU_ANALYSIS
|
4 |
|
|
|
5 |
|
|
#include <map>
|
6 |
|
|
#include <string>
|
7 |
|
|
#include <vector>
|
8 |
jbrinson |
1.13 |
|
9 |
|
|
#include <fstream>
|
10 |
|
|
#include <iostream>
|
11 |
lantonel |
1.12 |
#include <algorithm>
|
12 |
ahart |
1.29 |
#include <regex>
|
13 |
lantonel |
1.6 |
#include "TH1.h"
|
14 |
lantonel |
1.9 |
#include "TH2.h"
|
15 |
lantonel |
1.1 |
#include "TH1D.h"
|
16 |
|
|
#include "TH2D.h"
|
17 |
|
|
#include "TLorentzVector.h"
|
18 |
ahart |
1.48 |
#include "TVector3.h"
|
19 |
|
|
#include "TVector2.h"
|
20 |
wulsin |
1.35 |
#include "TTree.h"
|
21 |
lantonel |
1.1 |
|
22 |
ahart |
1.41 |
#include "FWCore/Framework/interface/EDProducer.h"
|
23 |
lantonel |
1.1 |
#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 |
lantonel |
1.10 |
#include "DataFormats/Math/interface/deltaPhi.h"
|
31 |
|
|
#include "DataFormats/Math/interface/deltaR.h"
|
32 |
lantonel |
1.1 |
|
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 |
lantonel |
1.26 |
|
50 |
lantonel |
1.1 |
|
51 |
|
|
#include "OSUT3Analysis/AnaTools/interface/CutFlow.h"
|
52 |
lantonel |
1.9 |
#include "OSUT3Analysis/AnaTools/interface/PUWeight.h"
|
53 |
ahart |
1.16 |
#include "OSUT3Analysis/AnaTools/interface/SFWeight.h"
|
54 |
biliu |
1.40 |
#include "OSUT3Analysis/AnaTools/interface/BtagSFWeight.h"
|
55 |
ahart |
1.29 |
#include "OSUT3Analysis/AnaTools/interface/StopCTauWeight.h"
|
56 |
lantonel |
1.1 |
|
57 |
|
|
using namespace std;
|
58 |
|
|
|
59 |
ahart |
1.41 |
class OSUAnalysis : public edm::EDProducer
|
60 |
lantonel |
1.1 |
{
|
61 |
|
|
public:
|
62 |
|
|
OSUAnalysis (const edm::ParameterSet &);
|
63 |
|
|
~OSUAnalysis ();
|
64 |
|
|
|
65 |
ahart |
1.41 |
void produce (edm::Event &, const edm::EventSetup &);
|
66 |
lantonel |
1.1 |
bool evaluateComparison (double, string, double);
|
67 |
ahart |
1.31 |
bool evaluateComparison (string, string, string);
|
68 |
biliu |
1.34 |
bool evaluateTriggers (vector<string>, vector<string>, const BNtriggerCollection*);
|
69 |
lantonel |
1.3 |
double applyFunction(string, double);
|
70 |
|
|
|
71 |
ahart |
1.31 |
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 |
biliu |
1.43 |
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 |
biliu |
1.47 |
double valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue);
|
81 |
biliu |
1.43 |
double valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue);
|
82 |
ahart |
1.31 |
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 |
wulsin |
1.44 |
double valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue);
|
85 |
jbrinson |
1.45 |
double valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue);
|
86 |
ahart |
1.31 |
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 |
jbrinson |
1.14 |
|
107 |
jbrinson |
1.13 |
int getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl);
|
108 |
jbrinson |
1.14 |
double getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl);
|
109 |
biliu |
1.49 |
double getHt (const BNjetCollection* jetColl);
|
110 |
jbrinson |
1.14 |
double getTrkPtRes (const BNtrack* track1);
|
111 |
|
|
double getTrkIsIso (const BNtrack* track1);
|
112 |
wulsin |
1.20 |
double getTrkCaloTotRhoCorr(const BNtrack* track);
|
113 |
jbrinson |
1.51 |
double getTrkDepTrkRp5RhoCorr(const BNtrack* track);
|
114 |
|
|
double getTrkDepTrkRp3RhoCorr(const BNtrack* track);
|
115 |
jbrinson |
1.13 |
void WriteDeadEcal ();
|
116 |
|
|
int getTrkIsMatchedDeadEcal (const BNtrack* track1);
|
117 |
|
|
|
118 |
lantonel |
1.1 |
//BNskimbits
|
119 |
|
|
//BNtrigobj
|
120 |
|
|
|
121 |
|
|
vector<string> splitString (string);
|
122 |
ahart |
1.31 |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2);
|
123 |
|
|
string getObjToGet(string obj);
|
124 |
lantonel |
1.1 |
|
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 |
lantonel |
1.42 |
//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 |
|
|
typedef vector<pair<bool,bool> > flagPair;
|
135 |
ahart |
1.16 |
|
136 |
lantonel |
1.1 |
//counterMap:
|
137 |
|
|
//string holds input collection type
|
138 |
|
|
//vector corresponds to each cut
|
139 |
|
|
//int holds number of objects passing all cuts up to that point
|
140 |
|
|
typedef map<string ,vector <int> > counterMap;
|
141 |
|
|
|
142 |
|
|
// Remember to define parameters to be retrieved from the configuration file.
|
143 |
|
|
edm::InputTag jets_;
|
144 |
|
|
edm::InputTag muons_;
|
145 |
|
|
edm::InputTag electrons_;
|
146 |
|
|
edm::InputTag events_;
|
147 |
|
|
edm::InputTag taus_;
|
148 |
|
|
edm::InputTag mets_;
|
149 |
|
|
edm::InputTag tracks_;
|
150 |
|
|
edm::InputTag genjets_;
|
151 |
|
|
edm::InputTag mcparticles_;
|
152 |
ahart |
1.21 |
edm::InputTag stops_;
|
153 |
lantonel |
1.1 |
edm::InputTag primaryvertexs_;
|
154 |
|
|
edm::InputTag bxlumis_;
|
155 |
|
|
edm::InputTag photons_;
|
156 |
|
|
edm::InputTag superclusters_;
|
157 |
lantonel |
1.2 |
edm::InputTag triggers_;
|
158 |
ahart |
1.31 |
edm::InputTag trigobjs_;
|
159 |
|
|
string puFile_;
|
160 |
|
|
string deadEcalFile_;
|
161 |
|
|
string muonSFFile_;
|
162 |
|
|
string dataPU_;
|
163 |
|
|
string electronSFID_;
|
164 |
|
|
string muonSF_;
|
165 |
|
|
string dataset_;
|
166 |
|
|
string datasetType_;
|
167 |
lantonel |
1.1 |
vector<edm::ParameterSet> channels_;
|
168 |
lantonel |
1.4 |
vector<edm::ParameterSet> histogramSets_;
|
169 |
ahart |
1.41 |
bool useEDMFormat_;
|
170 |
wulsin |
1.35 |
vector<edm::ParameterSet> treeBranchSets_;
|
171 |
lantonel |
1.9 |
bool plotAllObjectsInPassingEvents_;
|
172 |
lantonel |
1.15 |
bool doPileupReweighting_;
|
173 |
ahart |
1.28 |
bool applyLeptonSF_;
|
174 |
biliu |
1.40 |
bool applyBtagSF_;
|
175 |
|
|
int minBtag_;
|
176 |
ahart |
1.31 |
bool printEventInfo_;
|
177 |
wulsin |
1.39 |
bool printAllTriggers_;
|
178 |
ahart |
1.31 |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy
|
179 |
ahart |
1.21 |
vector<double> stopCTau_;
|
180 |
biliu |
1.33 |
bool GetPlotsAfterEachCut_;
|
181 |
|
|
|
182 |
jbrinson |
1.13 |
struct DeadEcal {
|
183 |
ahart |
1.16 |
double etaEcal;
|
184 |
|
|
double phiEcal;
|
185 |
jbrinson |
1.13 |
};
|
186 |
ahart |
1.16 |
|
187 |
ahart |
1.31 |
vector<DeadEcal> DeadEcalVec;
|
188 |
jbrinson |
1.13 |
|
189 |
jbrinson |
1.14 |
|
190 |
jbrinson |
1.13 |
//Collections
|
191 |
lantonel |
1.11 |
edm::Handle<BNtriggerCollection> triggers;
|
192 |
ahart |
1.31 |
edm::Handle<BNtrigobjCollection> trigobjs;
|
193 |
lantonel |
1.11 |
edm::Handle<BNjetCollection> jets;
|
194 |
|
|
edm::Handle<BNmuonCollection> muons;
|
195 |
|
|
edm::Handle<BNelectronCollection> electrons;
|
196 |
|
|
edm::Handle<BNeventCollection> events;
|
197 |
|
|
edm::Handle<BNtauCollection> taus;
|
198 |
|
|
edm::Handle<BNmetCollection> mets;
|
199 |
|
|
edm::Handle<BNtrackCollection> tracks;
|
200 |
|
|
edm::Handle<BNgenjetCollection> genjets;
|
201 |
|
|
edm::Handle<BNmcparticleCollection> mcparticles;
|
202 |
|
|
edm::Handle<BNprimaryvertexCollection> primaryvertexs;
|
203 |
|
|
edm::Handle<BNbxlumiCollection> bxlumis;
|
204 |
|
|
edm::Handle<BNphotonCollection> photons;
|
205 |
|
|
edm::Handle<BNsuperclusterCollection> superclusters;
|
206 |
lantonel |
1.24 |
edm::Handle<BNstopCollection> stops;
|
207 |
lantonel |
1.26 |
|
208 |
ahart |
1.31 |
edm::Handle<double> rhokt6CaloJetsHandle_;
|
209 |
lantonel |
1.11 |
|
210 |
ahart |
1.16 |
flagMap cumulativeFlags;
|
211 |
lantonel |
1.42 |
flagMap vetoFlags;
|
212 |
lantonel |
1.8 |
|
213 |
biliu |
1.33 |
vector<vector<map<string, TH1D*>>> oneDHists_;
|
214 |
|
|
vector<vector<map<string, TH2D*>>> twoDHists_;
|
215 |
wulsin |
1.35 |
vector<TTree*> BNTrees_; // one tree per channel
|
216 |
|
|
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
|
217 |
lantonel |
1.1 |
|
218 |
|
|
edm::Service<TFileService> fs_;
|
219 |
|
|
|
220 |
|
|
CutFlow *masterCutFlow_;
|
221 |
|
|
vector<CutFlow *> cutFlows_;
|
222 |
|
|
|
223 |
lantonel |
1.4 |
typedef struct {
|
224 |
ahart |
1.16 |
string name;
|
225 |
|
|
string title;
|
226 |
|
|
vector<double> bins;
|
227 |
ahart |
1.30 |
vector<double> variableBinsX;
|
228 |
|
|
vector<double> variableBinsY;
|
229 |
ahart |
1.16 |
string inputCollection;
|
230 |
|
|
vector<string> inputVariables;
|
231 |
lantonel |
1.4 |
} histogram;
|
232 |
lantonel |
1.1 |
|
233 |
wulsin |
1.35 |
typedef struct {
|
234 |
|
|
string name;
|
235 |
|
|
string inputCollection;
|
236 |
|
|
string inputVariable;
|
237 |
|
|
} BranchSpecs;
|
238 |
|
|
|
239 |
|
|
|
240 |
lantonel |
1.1 |
struct cut {
|
241 |
ahart |
1.16 |
string inputCollection;
|
242 |
|
|
vector<string> functions;
|
243 |
|
|
vector<string> variables;
|
244 |
|
|
vector<string> comparativeOperators;// >, <, =, etc.
|
245 |
|
|
vector<double> cutValues;
|
246 |
ahart |
1.31 |
vector<string> cutStringValues;
|
247 |
ahart |
1.16 |
vector<string> logicalOperators;//and, or
|
248 |
lantonel |
1.42 |
int numSubcuts;
|
249 |
ahart |
1.16 |
int numberRequired;
|
250 |
|
|
string eventComparativeOperator;
|
251 |
|
|
string name;
|
252 |
lantonel |
1.42 |
bool isVeto;
|
253 |
lantonel |
1.1 |
};
|
254 |
|
|
|
255 |
|
|
struct channel {
|
256 |
ahart |
1.16 |
string name;
|
257 |
|
|
vector<string> triggers;
|
258 |
biliu |
1.34 |
vector<string> triggersToVeto;
|
259 |
ahart |
1.16 |
vector<cut> cuts;
|
260 |
lantonel |
1.1 |
};
|
261 |
|
|
|
262 |
lantonel |
1.12 |
vector<string> objectsToGet;
|
263 |
|
|
vector<string> objectsToCut;
|
264 |
lantonel |
1.4 |
vector<string> objectsToPlot;
|
265 |
lantonel |
1.46 |
vector<string> objectsToFlag;
|
266 |
|
|
|
267 |
lantonel |
1.1 |
vector<channel> channels;
|
268 |
lantonel |
1.4 |
vector<histogram> histograms;
|
269 |
wulsin |
1.35 |
vector<BranchSpecs> treeBranches_;
|
270 |
lantonel |
1.1 |
|
271 |
lantonel |
1.9 |
PUWeight *puWeight_;
|
272 |
ahart |
1.16 |
MuonSFWeight *muonSFWeight_;
|
273 |
ahart |
1.32 |
double muonScaleFactor_;
|
274 |
ahart |
1.16 |
ElectronSFWeight *electronSFWeight_;
|
275 |
ahart |
1.32 |
double electronScaleFactor_;
|
276 |
biliu |
1.40 |
BtagSFWeight *bTagSFWeight_;
|
277 |
|
|
double bTagScaleFactor_;
|
278 |
ahart |
1.29 |
|
279 |
|
|
StopCTauWeight *stopCTauWeight_;
|
280 |
|
|
double stopCTauScaleFactor_;
|
281 |
lantonel |
1.9 |
|
282 |
wulsin |
1.50 |
ofstream* findEventsLog;
|
283 |
|
|
bool isFirstEvent_;
|
284 |
|
|
|
285 |
lantonel |
1.1 |
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string);
|
286 |
lantonel |
1.42 |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, flagPair, flagPair, string);
|
287 |
|
|
|
288 |
|
|
template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, flagPair flags);
|
289 |
|
|
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, flagPair, double);
|
290 |
|
|
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double);
|
291 |
|
|
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, flagPair, double);
|
292 |
|
|
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double);
|
293 |
|
|
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType);
|
294 |
|
|
|
295 |
lantonel |
1.12 |
|
296 |
lantonel |
1.1 |
|
297 |
lantonel |
1.11 |
template <class InputObject> int getGenMatchedParticleIndex(InputObject);
|
298 |
|
|
int getPdgIdBinValue(int);
|
299 |
|
|
int findTauMotherIndex(const BNmcparticle*);
|
300 |
|
|
|
301 |
jbrinson |
1.17 |
template <class InputObject> double getGenDeltaRLowest(InputObject);
|
302 |
|
|
|
303 |
|
|
|
304 |
ahart |
1.16 |
const BNprimaryvertex *chosenVertex ();
|
305 |
|
|
const BNmet *chosenMET ();
|
306 |
|
|
const BNelectron *chosenElectron ();
|
307 |
|
|
const BNmuon *chosenMuon ();
|
308 |
ahart |
1.48 |
double chosenHT ();
|
309 |
|
|
pair<const BNmuon *, const BNmuon*> leadMuonPair ();
|
310 |
|
|
pair<const BNelectron *, const BNelectron*> leadElectronPair ();
|
311 |
jbrinson |
1.13 |
|
312 |
lantonel |
1.1 |
};
|
313 |
|
|
|
314 |
|
|
#endif
|