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 |
|
#include "OSUT3Analysis/AnaTools/interface/SFWeight.h" |
54 |
< |
|
55 |
< |
#ifdef DISPLACED_SUSY |
51 |
< |
#include "DisplacedSUSY/Configuration/interface/CTauWeight.h" |
52 |
< |
#endif |
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 BNelectron* object1, const BNtrack* object2, string variable, string function = ""); |
78 |
< |
double valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function = ""); |
79 |
< |
double valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function = ""); |
80 |
< |
double valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function = ""); |
81 |
< |
double valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function); |
82 |
< |
double valueLookup (const BNevent* object, string variable, string function = ""); |
83 |
< |
double valueLookup (const BNtau* object, string variable, string function = ""); |
84 |
< |
double valueLookup (const BNmet* object, string variable, string function = ""); |
85 |
< |
double valueLookup (const BNtrack* object, string variable, string function = ""); |
86 |
< |
double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function = ""); |
87 |
< |
double valueLookup (const BNgenjet* object, string variable, string function = ""); |
88 |
< |
double valueLookup (const BNmcparticle* object, string variable, string function = ""); |
89 |
< |
double valueLookup (const BNprimaryvertex* object, string variable, string function = ""); |
90 |
< |
double valueLookup (const BNbxlumi* object, string variable, string function = ""); |
91 |
< |
double valueLookup (const BNphoton* object, string variable, string function = ""); |
92 |
< |
double valueLookup (const BNsupercluster* object, string variable, string function = ""); |
93 |
< |
|
94 |
< |
#ifdef DISPLACED_SUSY |
95 |
< |
double valueLookup (const BNstop* object, string variable, string function = ""); |
96 |
< |
#endif |
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 |
|
|
119 |
|
//BNtrigobj |
120 |
|
|
121 |
|
vector<string> splitString (string); |
122 |
< |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2); |
123 |
< |
string getObjToGet(string obj); |
122 |
> |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2); |
123 |
> |
string getObjToGet(string obj); |
124 |
|
|
125 |
|
private: |
126 |
|
|
128 |
|
//string holds input collection type |
129 |
|
//outer vector corresponds to each cut |
130 |
|
//inner vector corresponds to each object in input collection |
131 |
< |
//bool tells if object passes or fails cuts |
132 |
< |
typedef map<string, vector < vector<bool> > > flagMap; |
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 |
158 |
|
edm::InputTag photons_; |
159 |
|
edm::InputTag superclusters_; |
160 |
|
edm::InputTag triggers_; |
161 |
< |
std::string puFile_; |
162 |
< |
std::string deadEcalFile_; |
163 |
< |
std::string muonSFFile_; |
164 |
< |
std::string dataPU_; |
165 |
< |
std::string electronSFID_; |
166 |
< |
std::string muonSF_; |
167 |
< |
std::string dataset_; |
168 |
< |
std::string datasetType_; |
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 printEventInfo_; |
177 |
< |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy |
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 |
< |
|
183 |
> |
bool GetPlotsAfterEachCut_; |
184 |
> |
int verbose_; |
185 |
> |
|
186 |
|
struct DeadEcal { |
187 |
|
double etaEcal; |
188 |
|
double phiEcal; |
189 |
|
}; |
190 |
|
|
191 |
< |
std::vector<DeadEcal> DeadEcalVec; |
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; |
207 |
|
edm::Handle<BNbxlumiCollection> bxlumis; |
208 |
|
edm::Handle<BNphotonCollection> photons; |
209 |
|
edm::Handle<BNsuperclusterCollection> superclusters; |
178 |
– |
#ifdef DISPLACED_SUSY |
210 |
|
edm::Handle<BNstopCollection> stops; |
211 |
< |
#endif |
212 |
< |
edm::Handle<double> rhokt6CaloJetsHandle_; |
211 |
> |
|
212 |
> |
edm::Handle<double> rhokt6CaloJetsHandle_; |
213 |
|
|
214 |
|
flagMap cumulativeFlags; |
215 |
+ |
flagMap vetoFlags; |
216 |
|
|
217 |
< |
vector<map<string, TH1D*> > oneDHists_; |
218 |
< |
vector<map<string, TH2D*> > twoDHists_; |
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 |
|
|
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; |
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 |
< |
#ifdef DISPLACED_SUSY |
280 |
< |
CTauWeight *cTauWeight_; |
281 |
< |
#endif |
282 |
< |
double cTauScaleFactor_; |
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, vector<bool>, vector<bool>, 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 |
|
|
237 |
– |
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double); |
238 |
– |
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
239 |
– |
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double); |
240 |
– |
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
241 |
– |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1); |
300 |
|
|
301 |
|
template <class InputObject> int getGenMatchedParticleIndex(InputObject); |
302 |
|
int getPdgIdBinValue(int); |
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 |
|
|