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/EDAnalyzer.h" |
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" |
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 |
< |
|
54 |
< |
|
55 |
< |
|
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::EDAnalyzer |
59 |
> |
class OSUAnalysis : public edm::EDProducer |
60 |
|
{ |
61 |
|
public: |
62 |
|
OSUAnalysis (const edm::ParameterSet &); |
63 |
|
~OSUAnalysis (); |
64 |
|
|
65 |
< |
void analyze (const edm::Event &, const edm::EventSetup &); |
65 |
> |
void produce (edm::Event &, const edm::EventSetup &); |
66 |
|
bool evaluateComparison (double, string, double); |
67 |
< |
bool evaluateTriggers (vector<string>,const BNtriggerCollection*); |
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 = ""); |
72 |
< |
double valueLookup (const BNmuon* object, string variable, string function = ""); |
73 |
< |
double valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function = ""); |
74 |
< |
double valueLookup (const BNelectron* object, string variable, string function = ""); |
75 |
< |
double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function = ""); |
76 |
< |
double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function = ""); |
77 |
< |
double valueLookup (const BNevent* object, string variable, string function = ""); |
78 |
< |
double valueLookup (const BNtau* object, string variable, string function = ""); |
79 |
< |
double valueLookup (const BNmet* object, string variable, string function = ""); |
80 |
< |
double valueLookup (const BNtrack* object, string variable, string function = ""); |
81 |
< |
double valueLookup (const BNgenjet* object, string variable, string function = ""); |
82 |
< |
double valueLookup (const BNmcparticle* object, string variable, string function = ""); |
83 |
< |
double valueLookup (const BNprimaryvertex* object, string variable, string function = ""); |
84 |
< |
double valueLookup (const BNbxlumi* object, string variable, string function = ""); |
85 |
< |
double valueLookup (const BNphoton* object, string variable, string function = ""); |
86 |
< |
double valueLookup (const BNsupercluster* object, string variable, string function = ""); |
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 |
> |
|
75 |
> |
double valueLookup (const BNelectron* object, string variable, string function, string &stringValue); |
76 |
> |
double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue); |
77 |
> |
double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue); |
78 |
> |
double valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue); |
79 |
> |
double valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue); |
80 |
> |
|
81 |
> |
double valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue); |
82 |
> |
double valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue); |
83 |
> |
|
84 |
> |
double valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue); |
85 |
> |
|
86 |
> |
double valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue); |
87 |
> |
double valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue); |
88 |
> |
double valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue); |
89 |
> |
double valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue); |
90 |
> |
double valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue); |
91 |
> |
double valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue); |
92 |
> |
double valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue); |
93 |
> |
double valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue); |
94 |
> |
double valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue); |
95 |
> |
|
96 |
> |
double valueLookup (const BNevent* object, string variable, string function, string &stringValue); |
97 |
> |
double valueLookup (const BNtau* object, string variable, string function, string &stringValue); |
98 |
> |
double valueLookup (const BNmet* object, string variable, string function, string &stringValue); |
99 |
> |
double valueLookup (const BNtrack* object, string variable, string function, string &stringValue); |
100 |
> |
|
101 |
> |
double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue); |
102 |
> |
double valueLookup (const BNgenjet* object, string variable, string function, string &stringValue); |
103 |
> |
double valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue); |
104 |
> |
|
105 |
> |
double valueLookup (const BNelectron* object1, const BNmcparticle* object, string variable, string function, string &stringValue); |
106 |
> |
|
107 |
> |
double valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue); |
108 |
> |
double valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue); |
109 |
> |
double valueLookup (const BNphoton* object, string variable, string function, string &stringValue); |
110 |
> |
double valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue); |
111 |
> |
double valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue); |
112 |
> |
double valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue); |
113 |
> |
double valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue); |
114 |
> |
double valueLookup (const BNstop* object, string variable, string function, string &stringValue); |
115 |
|
|
116 |
|
int getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl); |
117 |
|
double getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl); |
118 |
+ |
double getHt (const BNjetCollection* jetColl); |
119 |
|
double getTrkPtRes (const BNtrack* track1); |
120 |
|
double getTrkIsIso (const BNtrack* track1); |
121 |
+ |
double getTrkCaloTotRhoCorr(const BNtrack* track); |
122 |
+ |
double getTrkDepTrkRp5RhoCorr(const BNtrack* track); |
123 |
+ |
double getTrkDepTrkRp3RhoCorr(const BNtrack* track); |
124 |
|
void WriteDeadEcal (); |
125 |
|
int getTrkIsMatchedDeadEcal (const BNtrack* track1); |
126 |
|
|
128 |
|
//BNtrigobj |
129 |
|
|
130 |
|
vector<string> splitString (string); |
131 |
< |
|
131 |
> |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2); |
132 |
> |
string getObjToGet(string obj); |
133 |
|
|
134 |
|
private: |
135 |
|
|
137 |
|
//string holds input collection type |
138 |
|
//outer vector corresponds to each cut |
139 |
|
//inner vector corresponds to each object in input collection |
140 |
< |
//bool tells if object passes or fails cuts |
141 |
< |
typedef map<string, vector < vector<bool> > > flagMap; |
142 |
< |
|
140 |
> |
//pair(bool) first bool counts towards the event passing, second bool determines whether to plot the object |
141 |
> |
typedef map<string, vector<vector<pair<bool,bool> > > > flagMap; |
142 |
> |
|
143 |
> |
//flagPair (corresponds to flagMap): |
144 |
> |
//vector corresponds to each object in input collection |
145 |
> |
//pair(bool) first bool counts towards the event passing, second bool determines whether to plot the object |
146 |
> |
typedef vector<pair<bool,bool> > flagPair; |
147 |
> |
|
148 |
|
//counterMap: |
149 |
|
//string holds input collection type |
150 |
|
//vector corresponds to each cut |
161 |
|
edm::InputTag tracks_; |
162 |
|
edm::InputTag genjets_; |
163 |
|
edm::InputTag mcparticles_; |
164 |
+ |
edm::InputTag stops_; |
165 |
|
edm::InputTag primaryvertexs_; |
166 |
|
edm::InputTag bxlumis_; |
167 |
|
edm::InputTag photons_; |
168 |
|
edm::InputTag superclusters_; |
169 |
|
edm::InputTag triggers_; |
170 |
< |
std::string puFile_; |
171 |
< |
std::string deadEcalFile_; |
172 |
< |
std::string dataPU_; |
173 |
< |
std::string dataset_; |
174 |
< |
std::string datasetType_; |
170 |
> |
edm::InputTag trigobjs_; |
171 |
> |
string puFile_; |
172 |
> |
string deadEcalFile_; |
173 |
> |
string muonSFFile_; |
174 |
> |
string dataPU_; |
175 |
> |
string electronSFID_; |
176 |
> |
string muonSF_; |
177 |
> |
string dataset_; |
178 |
> |
string datasetType_; |
179 |
|
vector<edm::ParameterSet> channels_; |
180 |
|
vector<edm::ParameterSet> histogramSets_; |
181 |
+ |
bool useEDMFormat_; |
182 |
+ |
vector<edm::ParameterSet> treeBranchSets_; |
183 |
|
bool plotAllObjectsInPassingEvents_; |
184 |
< |
|
184 |
> |
bool doPileupReweighting_; |
185 |
> |
bool applyLeptonSF_; |
186 |
> |
bool applyBtagSF_; |
187 |
> |
int minBtag_; |
188 |
> |
bool printEventInfo_; |
189 |
> |
bool printAllTriggers_; |
190 |
> |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy |
191 |
> |
vector<double> stopCTau_; |
192 |
> |
bool GetPlotsAfterEachCut_; |
193 |
> |
int verbose_; |
194 |
> |
|
195 |
|
struct DeadEcal { |
196 |
< |
double etaEcal; |
197 |
< |
double phiEcal; |
196 |
> |
double etaEcal; |
197 |
> |
double phiEcal; |
198 |
|
}; |
199 |
< |
|
200 |
< |
std::vector<DeadEcal> DeadEcalVec; |
199 |
> |
|
200 |
> |
vector<DeadEcal> DeadEcalVec; |
201 |
|
|
202 |
|
|
203 |
|
//Collections |
204 |
|
edm::Handle<BNtriggerCollection> triggers; |
205 |
+ |
edm::Handle<BNtrigobjCollection> trigobjs; |
206 |
|
edm::Handle<BNjetCollection> jets; |
207 |
|
edm::Handle<BNmuonCollection> muons; |
208 |
|
edm::Handle<BNelectronCollection> electrons; |
216 |
|
edm::Handle<BNbxlumiCollection> bxlumis; |
217 |
|
edm::Handle<BNphotonCollection> photons; |
218 |
|
edm::Handle<BNsuperclusterCollection> superclusters; |
219 |
+ |
edm::Handle<BNstopCollection> stops; |
220 |
|
|
221 |
< |
const BNprimaryvertex *chosenPrimaryVertex; |
221 |
> |
edm::Handle<double> rhokt6CaloJetsHandle_; |
222 |
|
|
223 |
+ |
flagMap cumulativeFlags; |
224 |
+ |
flagMap vetoFlags; |
225 |
|
|
226 |
< |
vector<map<string, TH1D*> > oneDHists_; |
227 |
< |
vector<map<string, TH2D*> > twoDHists_; |
226 |
> |
vector<vector<map<string, TH1D*>>> oneDHists_; |
227 |
> |
vector<vector<map<string, TH2D*>>> twoDHists_; |
228 |
> |
vector<TTree*> BNTrees_; // one tree per channel |
229 |
> |
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 |
230 |
> |
long BNTreeBranchVals_evtLong_; // event number |
231 |
> |
int BNTreeBranchVals_runInt_; // run number |
232 |
> |
int BNTreeBranchVals_lumiInt_; // lumi number |
233 |
|
|
234 |
|
edm::Service<TFileService> fs_; |
235 |
|
|
237 |
|
vector<CutFlow *> cutFlows_; |
238 |
|
|
239 |
|
typedef struct { |
240 |
< |
string name; |
241 |
< |
string title; |
242 |
< |
vector<double> bins; |
243 |
< |
string inputCollection; |
244 |
< |
vector<string> inputVariables; |
240 |
> |
string name; |
241 |
> |
string title; |
242 |
> |
vector<double> bins; |
243 |
> |
vector<double> variableBinsX; |
244 |
> |
vector<double> variableBinsY; |
245 |
> |
string inputCollection; |
246 |
> |
vector<string> inputVariables; |
247 |
|
} histogram; |
248 |
|
|
249 |
+ |
typedef struct { |
250 |
+ |
string name; |
251 |
+ |
string inputCollection; |
252 |
+ |
string inputVariable; |
253 |
+ |
} BranchSpecs; |
254 |
+ |
|
255 |
+ |
|
256 |
|
struct cut { |
257 |
< |
string inputCollection; |
258 |
< |
vector<string> functions; |
259 |
< |
vector<string> variables; |
260 |
< |
vector<string> comparativeOperators;// >, <, =, etc. |
261 |
< |
vector<double> cutValues; |
262 |
< |
vector<string> logicalOperators;//and, or |
263 |
< |
int numSubcuts; |
264 |
< |
int numberRequired; |
265 |
< |
string eventComparativeOperator; |
266 |
< |
string name; |
257 |
> |
string inputCollection; |
258 |
> |
vector<string> functions; |
259 |
> |
vector<string> variables; |
260 |
> |
vector<string> comparativeOperators;// >, <, =, etc. |
261 |
> |
vector<double> cutValues; |
262 |
> |
vector<string> cutStringValues; |
263 |
> |
vector<string> logicalOperators;//and, or |
264 |
> |
int numSubcuts; |
265 |
> |
int numberRequired; |
266 |
> |
string eventComparativeOperator; |
267 |
> |
string name; |
268 |
> |
bool isVeto; |
269 |
|
}; |
270 |
|
|
271 |
|
struct channel { |
272 |
< |
string name; |
273 |
< |
vector<string> triggers; |
274 |
< |
vector<cut> cuts; |
272 |
> |
string name; |
273 |
> |
vector<string> triggers; |
274 |
> |
vector<string> triggersToVeto; |
275 |
> |
vector<cut> cuts; |
276 |
|
}; |
277 |
|
|
278 |
|
vector<string> objectsToGet; |
279 |
|
vector<string> objectsToCut; |
280 |
|
vector<string> objectsToPlot; |
281 |
+ |
vector<string> objectsToFlag; |
282 |
+ |
|
283 |
|
vector<channel> channels; |
284 |
|
vector<histogram> histograms; |
285 |
+ |
vector<BranchSpecs> treeBranches_; |
286 |
|
|
287 |
|
PUWeight *puWeight_; |
288 |
+ |
MuonSFWeight *muonSFWeight_; |
289 |
+ |
double muonScaleFactor_; |
290 |
+ |
ElectronSFWeight *electronSFWeight_; |
291 |
+ |
double electronScaleFactor_; |
292 |
+ |
BtagSFWeight *bTagSFWeight_; |
293 |
+ |
double bTagScaleFactor_; |
294 |
+ |
|
295 |
+ |
StopCTauWeight *stopCTauWeight_; |
296 |
+ |
double stopCTauScaleFactor_; |
297 |
+ |
|
298 |
+ |
ofstream* findEventsLog; |
299 |
+ |
bool isFirstEvent_; |
300 |
|
|
301 |
|
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string); |
302 |
< |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string); |
302 |
> |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, string); |
303 |
> |
|
304 |
> |
template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, flagPair flags); |
305 |
> |
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, flagPair, double); |
306 |
> |
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, flagPair, double); |
307 |
> |
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, flagPair, double); |
308 |
> |
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, flagPair, double); |
309 |
> |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType); |
310 |
> |
|
311 |
|
|
207 |
– |
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double); |
208 |
– |
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
209 |
– |
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double); |
210 |
– |
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
312 |
|
|
313 |
|
template <class InputObject> int getGenMatchedParticleIndex(InputObject); |
314 |
|
int getPdgIdBinValue(int); |
315 |
|
int findTauMotherIndex(const BNmcparticle*); |
316 |
|
|
317 |
+ |
template <class InputObject> double getGenDeltaRLowest(InputObject); |
318 |
+ |
|
319 |
+ |
|
320 |
+ |
const BNprimaryvertex *chosenVertex (); |
321 |
+ |
const BNmet *chosenMET (); |
322 |
+ |
const BNelectron *chosenElectron (); |
323 |
+ |
const BNmuon *chosenMuon (); |
324 |
+ |
double chosenHT (); |
325 |
+ |
pair<const BNmuon *, const BNmuon*> leadMuonPair (); |
326 |
+ |
pair<const BNelectron *, const BNelectron*> leadElectronPair (); |
327 |
|
|
328 |
|
}; |
329 |
|
|