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 "TTree.h" |
19 |
|
|
20 |
< |
#include "FWCore/Framework/interface/EDAnalyzer.h" |
20 |
> |
#include "FWCore/Framework/interface/EDProducer.h" |
21 |
|
#include "FWCore/Framework/interface/Event.h" |
22 |
|
#include "FWCore/Framework/interface/EventSetup.h" |
23 |
|
#include "FWCore/ParameterSet/interface/ParameterSet.h" |
45 |
|
#include "ProductArea/BNcollections/interface/BNtau.h" |
46 |
|
#include "ProductArea/BNcollections/interface/BNgenjet.h" |
47 |
|
|
48 |
+ |
|
49 |
|
#include "OSUT3Analysis/AnaTools/interface/CutFlow.h" |
50 |
|
#include "OSUT3Analysis/AnaTools/interface/PUWeight.h" |
51 |
|
#include "OSUT3Analysis/AnaTools/interface/SFWeight.h" |
52 |
< |
|
53 |
< |
#ifdef DISPLACED_SUSY |
51 |
< |
#include "DisplacedSUSY/Configuration/interface/CTauWeight.h" |
52 |
< |
#endif |
52 |
> |
#include "OSUT3Analysis/AnaTools/interface/BtagSFWeight.h" |
53 |
> |
#include "OSUT3Analysis/AnaTools/interface/StopCTauWeight.h" |
54 |
|
|
55 |
|
using namespace std; |
56 |
|
|
57 |
< |
class OSUAnalysis : public edm::EDAnalyzer |
57 |
> |
class OSUAnalysis : public edm::EDProducer |
58 |
|
{ |
59 |
|
public: |
60 |
|
OSUAnalysis (const edm::ParameterSet &); |
61 |
|
~OSUAnalysis (); |
62 |
|
|
63 |
< |
void analyze (const edm::Event &, const edm::EventSetup &); |
63 |
> |
void produce (edm::Event &, const edm::EventSetup &); |
64 |
|
bool evaluateComparison (double, string, double); |
65 |
< |
bool evaluateTriggers (vector<string>,const BNtriggerCollection*); |
65 |
> |
bool evaluateComparison (string, string, string); |
66 |
> |
bool evaluateTriggers (vector<string>, vector<string>, const BNtriggerCollection*); |
67 |
|
double applyFunction(string, double); |
68 |
|
|
69 |
< |
double valueLookup (const BNjet* object, string variable, string function = ""); |
70 |
< |
double valueLookup (const BNmuon* object, string variable, string function = ""); |
71 |
< |
double valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function = ""); |
72 |
< |
double valueLookup (const BNelectron* object, string variable, string function = ""); |
73 |
< |
double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function = ""); |
74 |
< |
double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function = ""); |
75 |
< |
double valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function = ""); |
76 |
< |
double valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function = ""); |
77 |
< |
double valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function = ""); |
78 |
< |
double valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function = ""); |
79 |
< |
double valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function); |
80 |
< |
double valueLookup (const BNevent* object, string variable, string function = ""); |
81 |
< |
double valueLookup (const BNtau* object, string variable, string function = ""); |
82 |
< |
double valueLookup (const BNmet* object, string variable, string function = ""); |
83 |
< |
double valueLookup (const BNtrack* object, string variable, string function = ""); |
84 |
< |
double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function = ""); |
85 |
< |
double valueLookup (const BNgenjet* object, string variable, string function = ""); |
86 |
< |
double valueLookup (const BNmcparticle* object, string variable, string function = ""); |
87 |
< |
double valueLookup (const BNprimaryvertex* object, string variable, string function = ""); |
88 |
< |
double valueLookup (const BNbxlumi* object, string variable, string function = ""); |
89 |
< |
double valueLookup (const BNphoton* object, string variable, string function = ""); |
90 |
< |
double valueLookup (const BNsupercluster* object, string variable, string function = ""); |
91 |
< |
|
92 |
< |
#ifdef DISPLACED_SUSY |
93 |
< |
double valueLookup (const BNstop* object, string variable, string function = ""); |
94 |
< |
#endif |
69 |
> |
double valueLookup (const BNjet* object, string variable, string function, string &stringValue); |
70 |
> |
double valueLookup (const BNmuon* object, string variable, string function, string &stringValue); |
71 |
> |
double valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue); |
72 |
> |
double valueLookup (const BNelectron* object, string variable, string function, string &stringValue); |
73 |
> |
double valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue); |
74 |
> |
double valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue); |
75 |
> |
double valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue); |
76 |
> |
double valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue); |
77 |
> |
double valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue); |
78 |
> |
double valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue); |
79 |
> |
double valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue); |
80 |
> |
double valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue); |
81 |
> |
double valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue); |
82 |
> |
double valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue); |
83 |
> |
double valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue); |
84 |
> |
double valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue); |
85 |
> |
double valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue); |
86 |
> |
double valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue); |
87 |
> |
double valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue); |
88 |
> |
double valueLookup (const BNevent* object, string variable, string function, string &stringValue); |
89 |
> |
double valueLookup (const BNtau* object, string variable, string function, string &stringValue); |
90 |
> |
double valueLookup (const BNmet* object, string variable, string function, string &stringValue); |
91 |
> |
double valueLookup (const BNtrack* object, string variable, string function, string &stringValue); |
92 |
> |
double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue); |
93 |
> |
double valueLookup (const BNgenjet* object, string variable, string function, string &stringValue); |
94 |
> |
double valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue); |
95 |
> |
double valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue); |
96 |
> |
double valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue); |
97 |
> |
double valueLookup (const BNphoton* object, string variable, string function, string &stringValue); |
98 |
> |
double valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue); |
99 |
> |
double valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue); |
100 |
> |
double valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue); |
101 |
> |
double valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue); |
102 |
> |
double valueLookup (const BNstop* object, string variable, string function, string &stringValue); |
103 |
> |
|
104 |
|
int getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl); |
105 |
|
double getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl); |
106 |
|
double getTrkPtRes (const BNtrack* track1); |
113 |
|
//BNtrigobj |
114 |
|
|
115 |
|
vector<string> splitString (string); |
116 |
< |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2); |
117 |
< |
string getObjToGet(string obj); |
116 |
> |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2); |
117 |
> |
string getObjToGet(string obj); |
118 |
|
|
119 |
|
private: |
120 |
|
|
122 |
|
//string holds input collection type |
123 |
|
//outer vector corresponds to each cut |
124 |
|
//inner vector corresponds to each object in input collection |
125 |
< |
//bool tells if object passes or fails cuts |
126 |
< |
typedef map<string, vector < vector<bool> > > flagMap; |
125 |
> |
//pair(bool) first bool counts towards the event passing, second bool determines whether to plot the object |
126 |
> |
typedef map<string, vector<vector<pair<bool,bool> > > > flagMap; |
127 |
> |
|
128 |
> |
typedef vector<pair<bool,bool> > flagPair; |
129 |
|
|
130 |
|
//counterMap: |
131 |
|
//string holds input collection type |
149 |
|
edm::InputTag photons_; |
150 |
|
edm::InputTag superclusters_; |
151 |
|
edm::InputTag triggers_; |
152 |
< |
std::string puFile_; |
153 |
< |
std::string deadEcalFile_; |
154 |
< |
std::string muonSFFile_; |
155 |
< |
std::string dataPU_; |
156 |
< |
std::string electronSFID_; |
157 |
< |
std::string muonSF_; |
158 |
< |
std::string dataset_; |
159 |
< |
std::string datasetType_; |
152 |
> |
edm::InputTag trigobjs_; |
153 |
> |
string puFile_; |
154 |
> |
string deadEcalFile_; |
155 |
> |
string muonSFFile_; |
156 |
> |
string dataPU_; |
157 |
> |
string electronSFID_; |
158 |
> |
string muonSF_; |
159 |
> |
string dataset_; |
160 |
> |
string datasetType_; |
161 |
|
vector<edm::ParameterSet> channels_; |
162 |
|
vector<edm::ParameterSet> histogramSets_; |
163 |
+ |
bool useEDMFormat_; |
164 |
+ |
vector<edm::ParameterSet> treeBranchSets_; |
165 |
|
bool plotAllObjectsInPassingEvents_; |
166 |
|
bool doPileupReweighting_; |
167 |
< |
bool printEventInfo_; |
168 |
< |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy |
167 |
> |
bool applyLeptonSF_; |
168 |
> |
bool applyBtagSF_; |
169 |
> |
int minBtag_; |
170 |
> |
int maxBtag_; |
171 |
> |
bool printEventInfo_; |
172 |
> |
bool printAllTriggers_; |
173 |
> |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy |
174 |
|
vector<double> stopCTau_; |
175 |
< |
|
175 |
> |
bool GetPlotsAfterEachCut_; |
176 |
> |
|
177 |
|
struct DeadEcal { |
178 |
|
double etaEcal; |
179 |
|
double phiEcal; |
180 |
|
}; |
181 |
|
|
182 |
< |
std::vector<DeadEcal> DeadEcalVec; |
182 |
> |
vector<DeadEcal> DeadEcalVec; |
183 |
|
|
184 |
|
|
185 |
|
//Collections |
186 |
|
edm::Handle<BNtriggerCollection> triggers; |
187 |
+ |
edm::Handle<BNtrigobjCollection> trigobjs; |
188 |
|
edm::Handle<BNjetCollection> jets; |
189 |
|
edm::Handle<BNmuonCollection> muons; |
190 |
|
edm::Handle<BNelectronCollection> electrons; |
198 |
|
edm::Handle<BNbxlumiCollection> bxlumis; |
199 |
|
edm::Handle<BNphotonCollection> photons; |
200 |
|
edm::Handle<BNsuperclusterCollection> superclusters; |
178 |
– |
#ifdef DISPLACED_SUSY |
201 |
|
edm::Handle<BNstopCollection> stops; |
202 |
< |
#endif |
203 |
< |
edm::Handle<double> rhokt6CaloJetsHandle_; |
202 |
> |
|
203 |
> |
edm::Handle<double> rhokt6CaloJetsHandle_; |
204 |
|
|
205 |
|
flagMap cumulativeFlags; |
206 |
+ |
flagMap vetoFlags; |
207 |
|
|
208 |
< |
vector<map<string, TH1D*> > oneDHists_; |
209 |
< |
vector<map<string, TH2D*> > twoDHists_; |
208 |
> |
vector<vector<map<string, TH1D*>>> oneDHists_; |
209 |
> |
vector<vector<map<string, TH2D*>>> twoDHists_; |
210 |
> |
vector<TTree*> BNTrees_; // one tree per channel |
211 |
> |
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 |
212 |
|
|
213 |
|
edm::Service<TFileService> fs_; |
214 |
|
|
219 |
|
string name; |
220 |
|
string title; |
221 |
|
vector<double> bins; |
222 |
+ |
vector<double> variableBinsX; |
223 |
+ |
vector<double> variableBinsY; |
224 |
|
string inputCollection; |
225 |
|
vector<string> inputVariables; |
226 |
|
} histogram; |
227 |
|
|
228 |
+ |
typedef struct { |
229 |
+ |
string name; |
230 |
+ |
string inputCollection; |
231 |
+ |
string inputVariable; |
232 |
+ |
} BranchSpecs; |
233 |
+ |
|
234 |
+ |
|
235 |
|
struct cut { |
236 |
|
string inputCollection; |
237 |
|
vector<string> functions; |
238 |
|
vector<string> variables; |
239 |
|
vector<string> comparativeOperators;// >, <, =, etc. |
240 |
|
vector<double> cutValues; |
241 |
+ |
vector<string> cutStringValues; |
242 |
|
vector<string> logicalOperators;//and, or |
243 |
< |
int numSubcuts; |
243 |
> |
int numSubcuts; |
244 |
|
int numberRequired; |
245 |
|
string eventComparativeOperator; |
246 |
|
string name; |
247 |
+ |
bool isVeto; |
248 |
|
}; |
249 |
|
|
250 |
|
struct channel { |
251 |
|
string name; |
252 |
|
vector<string> triggers; |
253 |
+ |
vector<string> triggersToVeto; |
254 |
|
vector<cut> cuts; |
255 |
|
}; |
256 |
|
|
259 |
|
vector<string> objectsToPlot; |
260 |
|
vector<channel> channels; |
261 |
|
vector<histogram> histograms; |
262 |
+ |
vector<BranchSpecs> treeBranches_; |
263 |
|
|
264 |
|
PUWeight *puWeight_; |
265 |
|
MuonSFWeight *muonSFWeight_; |
266 |
+ |
double muonScaleFactor_; |
267 |
|
ElectronSFWeight *electronSFWeight_; |
268 |
< |
#ifdef DISPLACED_SUSY |
269 |
< |
CTauWeight *cTauWeight_; |
270 |
< |
#endif |
271 |
< |
double cTauScaleFactor_; |
268 |
> |
double electronScaleFactor_; |
269 |
> |
BtagSFWeight *bTagSFWeight_; |
270 |
> |
double bTagScaleFactor_; |
271 |
> |
|
272 |
> |
StopCTauWeight *stopCTauWeight_; |
273 |
> |
double stopCTauScaleFactor_; |
274 |
|
|
275 |
|
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string); |
276 |
< |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string); |
276 |
> |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, flagPair, flagPair, string); |
277 |
> |
|
278 |
> |
template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, flagPair flags); |
279 |
> |
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, flagPair, double); |
280 |
> |
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double); |
281 |
> |
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, flagPair, double); |
282 |
> |
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double); |
283 |
> |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType); |
284 |
> |
|
285 |
|
|
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); |
286 |
|
|
287 |
|
template <class InputObject> int getGenMatchedParticleIndex(InputObject); |
288 |
|
int getPdgIdBinValue(int); |