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/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" |
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" |
47 |
|
#include "ProductArea/BNcollections/interface/BNtau.h" |
48 |
|
#include "ProductArea/BNcollections/interface/BNgenjet.h" |
49 |
|
|
39 |
– |
#include "OSUT3Analysis/AnaTools/interface/CutFlow.h" |
40 |
– |
|
41 |
– |
|
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::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 BNelectron* object, string variable, string function = ""); |
74 |
< |
double valueLookup (const BNevent* object, string variable, string function = ""); |
75 |
< |
double valueLookup (const BNtau* object, string variable, string function = ""); |
76 |
< |
double valueLookup (const BNmet* object, string variable, string function = ""); |
77 |
< |
double valueLookup (const BNtrack* object, string variable, string function = ""); |
78 |
< |
double valueLookup (const BNgenjet* object, string variable, string function = ""); |
79 |
< |
double valueLookup (const BNmcparticle* object, string variable, string function = ""); |
80 |
< |
double valueLookup (const BNprimaryvertex* object, string variable, string function = ""); |
81 |
< |
double valueLookup (const BNbxlumi* object, string variable, string function = ""); |
82 |
< |
double valueLookup (const BNphoton* object, string variable, string function = ""); |
83 |
< |
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 |
> |
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 |
> |
void WriteDeadEcal (); |
114 |
> |
int getTrkIsMatchedDeadEcal (const BNtrack* track1); |
115 |
> |
|
116 |
|
//BNskimbits |
117 |
|
//BNtrigobj |
118 |
|
|
119 |
|
vector<string> splitString (string); |
120 |
< |
|
120 |
> |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2); |
121 |
> |
string getObjToGet(string obj); |
122 |
|
|
123 |
|
private: |
124 |
|
|
126 |
|
//string holds input collection type |
127 |
|
//outer vector corresponds to each cut |
128 |
|
//inner vector corresponds to each object in input collection |
129 |
< |
//bool tells if object passes or fails cuts |
130 |
< |
typedef map<string, vector < vector<bool> > > flagMap; |
131 |
< |
|
129 |
> |
//pair(bool) first bool counts towards the event passing, second bool determines whether to plot the object |
130 |
> |
typedef map<string, vector<vector<pair<bool,bool> > > > flagMap; |
131 |
> |
|
132 |
> |
typedef vector<pair<bool,bool> > flagPair; |
133 |
> |
|
134 |
|
//counterMap: |
135 |
|
//string holds input collection type |
136 |
|
//vector corresponds to each cut |
147 |
|
edm::InputTag tracks_; |
148 |
|
edm::InputTag genjets_; |
149 |
|
edm::InputTag mcparticles_; |
150 |
+ |
edm::InputTag stops_; |
151 |
|
edm::InputTag primaryvertexs_; |
152 |
|
edm::InputTag bxlumis_; |
153 |
|
edm::InputTag photons_; |
154 |
|
edm::InputTag superclusters_; |
155 |
|
edm::InputTag triggers_; |
156 |
< |
|
157 |
< |
|
156 |
> |
edm::InputTag trigobjs_; |
157 |
> |
string puFile_; |
158 |
> |
string deadEcalFile_; |
159 |
> |
string muonSFFile_; |
160 |
> |
string dataPU_; |
161 |
> |
string electronSFID_; |
162 |
> |
string muonSF_; |
163 |
> |
string dataset_; |
164 |
> |
string datasetType_; |
165 |
|
vector<edm::ParameterSet> channels_; |
166 |
|
vector<edm::ParameterSet> histogramSets_; |
167 |
+ |
bool useEDMFormat_; |
168 |
+ |
vector<edm::ParameterSet> treeBranchSets_; |
169 |
+ |
bool plotAllObjectsInPassingEvents_; |
170 |
+ |
bool doPileupReweighting_; |
171 |
+ |
bool applyLeptonSF_; |
172 |
+ |
bool applyBtagSF_; |
173 |
+ |
int minBtag_; |
174 |
+ |
bool printEventInfo_; |
175 |
+ |
bool printAllTriggers_; |
176 |
+ |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy |
177 |
+ |
vector<double> stopCTau_; |
178 |
+ |
bool GetPlotsAfterEachCut_; |
179 |
+ |
|
180 |
+ |
struct DeadEcal { |
181 |
+ |
double etaEcal; |
182 |
+ |
double phiEcal; |
183 |
+ |
}; |
184 |
|
|
185 |
< |
vector<map<string, TH1D*> > oneDHists_; |
185 |
> |
vector<DeadEcal> DeadEcalVec; |
186 |
> |
|
187 |
> |
|
188 |
> |
//Collections |
189 |
> |
edm::Handle<BNtriggerCollection> triggers; |
190 |
> |
edm::Handle<BNtrigobjCollection> trigobjs; |
191 |
> |
edm::Handle<BNjetCollection> jets; |
192 |
> |
edm::Handle<BNmuonCollection> muons; |
193 |
> |
edm::Handle<BNelectronCollection> electrons; |
194 |
> |
edm::Handle<BNeventCollection> events; |
195 |
> |
edm::Handle<BNtauCollection> taus; |
196 |
> |
edm::Handle<BNmetCollection> mets; |
197 |
> |
edm::Handle<BNtrackCollection> tracks; |
198 |
> |
edm::Handle<BNgenjetCollection> genjets; |
199 |
> |
edm::Handle<BNmcparticleCollection> mcparticles; |
200 |
> |
edm::Handle<BNprimaryvertexCollection> primaryvertexs; |
201 |
> |
edm::Handle<BNbxlumiCollection> bxlumis; |
202 |
> |
edm::Handle<BNphotonCollection> photons; |
203 |
> |
edm::Handle<BNsuperclusterCollection> superclusters; |
204 |
> |
edm::Handle<BNstopCollection> stops; |
205 |
> |
|
206 |
> |
edm::Handle<double> rhokt6CaloJetsHandle_; |
207 |
> |
|
208 |
> |
flagMap cumulativeFlags; |
209 |
> |
flagMap vetoFlags; |
210 |
> |
|
211 |
> |
vector<vector<map<string, TH1D*>>> oneDHists_; |
212 |
> |
vector<vector<map<string, TH2D*>>> twoDHists_; |
213 |
> |
vector<TTree*> BNTrees_; // one tree per channel |
214 |
> |
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 |
215 |
|
|
216 |
|
edm::Service<TFileService> fs_; |
217 |
|
|
219 |
|
vector<CutFlow *> cutFlows_; |
220 |
|
|
221 |
|
typedef struct { |
222 |
< |
string name; |
223 |
< |
string title; |
224 |
< |
vector<double> bins; |
225 |
< |
string inputCollection; |
226 |
< |
string inputVariable; |
227 |
< |
string function; |
222 |
> |
string name; |
223 |
> |
string title; |
224 |
> |
vector<double> bins; |
225 |
> |
vector<double> variableBinsX; |
226 |
> |
vector<double> variableBinsY; |
227 |
> |
string inputCollection; |
228 |
> |
vector<string> inputVariables; |
229 |
|
} histogram; |
230 |
|
|
231 |
+ |
typedef struct { |
232 |
+ |
string name; |
233 |
+ |
string inputCollection; |
234 |
+ |
string inputVariable; |
235 |
+ |
} BranchSpecs; |
236 |
+ |
|
237 |
+ |
|
238 |
|
struct cut { |
239 |
< |
string inputCollection; |
240 |
< |
string variable; |
241 |
< |
string comparativeOperator; |
242 |
< |
string function; |
243 |
< |
double cutValue; |
244 |
< |
int numberRequired; |
245 |
< |
string eventComparativeOperator; |
246 |
< |
string name; |
239 |
> |
string inputCollection; |
240 |
> |
vector<string> functions; |
241 |
> |
vector<string> variables; |
242 |
> |
vector<string> comparativeOperators;// >, <, =, etc. |
243 |
> |
vector<double> cutValues; |
244 |
> |
vector<string> cutStringValues; |
245 |
> |
vector<string> logicalOperators;//and, or |
246 |
> |
int numSubcuts; |
247 |
> |
int numberRequired; |
248 |
> |
string eventComparativeOperator; |
249 |
> |
string name; |
250 |
> |
bool isVeto; |
251 |
|
}; |
252 |
|
|
253 |
|
struct channel { |
254 |
< |
string name; |
255 |
< |
vector<string> triggers; |
256 |
< |
vector<cut> cuts; |
254 |
> |
string name; |
255 |
> |
vector<string> triggers; |
256 |
> |
vector<string> triggersToVeto; |
257 |
> |
vector<cut> cuts; |
258 |
|
}; |
259 |
|
|
260 |
+ |
vector<string> objectsToGet; |
261 |
+ |
vector<string> objectsToCut; |
262 |
|
vector<string> objectsToPlot; |
263 |
< |
vector<string> allNecessaryObjects; |
263 |
> |
vector<string> objectsToFlag; |
264 |
> |
|
265 |
|
vector<channel> channels; |
266 |
|
vector<histogram> histograms; |
267 |
+ |
vector<BranchSpecs> treeBranches_; |
268 |
+ |
|
269 |
+ |
PUWeight *puWeight_; |
270 |
+ |
MuonSFWeight *muonSFWeight_; |
271 |
+ |
double muonScaleFactor_; |
272 |
+ |
ElectronSFWeight *electronSFWeight_; |
273 |
+ |
double electronScaleFactor_; |
274 |
+ |
BtagSFWeight *bTagSFWeight_; |
275 |
+ |
double bTagScaleFactor_; |
276 |
+ |
|
277 |
+ |
StopCTauWeight *stopCTauWeight_; |
278 |
+ |
double stopCTauScaleFactor_; |
279 |
|
|
280 |
|
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string); |
281 |
< |
template <class InputCollection> void fillHistogram(TH1D*, histogram, InputCollection); |
281 |
> |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, flagPair, flagPair, string); |
282 |
> |
|
283 |
> |
template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, flagPair flags); |
284 |
> |
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, flagPair, double); |
285 |
> |
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double); |
286 |
> |
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, flagPair, double); |
287 |
> |
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double); |
288 |
> |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType); |
289 |
> |
|
290 |
> |
|
291 |
> |
|
292 |
> |
template <class InputObject> int getGenMatchedParticleIndex(InputObject); |
293 |
> |
int getPdgIdBinValue(int); |
294 |
> |
int findTauMotherIndex(const BNmcparticle*); |
295 |
> |
|
296 |
> |
template <class InputObject> double getGenDeltaRLowest(InputObject); |
297 |
|
|
298 |
|
|
299 |
+ |
const BNprimaryvertex *chosenVertex (); |
300 |
+ |
const BNmet *chosenMET (); |
301 |
+ |
const BNelectron *chosenElectron (); |
302 |
+ |
const BNmuon *chosenMuon (); |
303 |
+ |
double chosenHT (); |
304 |
+ |
pair<const BNmuon *, const BNmuon*> leadMuonPair (); |
305 |
+ |
pair<const BNelectron *, const BNelectron*> leadElectronPair (); |
306 |
|
|
307 |
|
}; |
308 |
|
|