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 "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" |
25 |
|
#include "DataFormats/Common/interface/Handle.h" |
26 |
|
#include "CommonTools/UtilAlgos/interface/TFileService.h" |
27 |
|
#include "FWCore/Framework/interface/MakerMacros.h" |
28 |
+ |
#include "DataFormats/Math/interface/deltaPhi.h" |
29 |
+ |
#include "DataFormats/Math/interface/deltaR.h" |
30 |
|
|
31 |
|
#include "ProductArea/BNcollections/interface/BNbxlumi.h" |
32 |
|
#include "ProductArea/BNcollections/interface/BNelectron.h" |
45 |
|
#include "ProductArea/BNcollections/interface/BNtau.h" |
46 |
|
#include "ProductArea/BNcollections/interface/BNgenjet.h" |
47 |
|
|
40 |
– |
#include "OSUT3Analysis/AnaTools/interface/CutFlow.h" |
41 |
– |
|
42 |
– |
|
48 |
|
|
49 |
+ |
#include "OSUT3Analysis/AnaTools/interface/CutFlow.h" |
50 |
+ |
#include "OSUT3Analysis/AnaTools/interface/PUWeight.h" |
51 |
+ |
#include "OSUT3Analysis/AnaTools/interface/SFWeight.h" |
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 BNelectron* object, string variable, string function = ""); |
72 |
< |
double valueLookup (const BNevent* object, string variable, string function = ""); |
73 |
< |
double valueLookup (const BNtau* object, string variable, string function = ""); |
74 |
< |
double valueLookup (const BNmet* object, string variable, string function = ""); |
75 |
< |
double valueLookup (const BNtrack* object, string variable, string function = ""); |
76 |
< |
double valueLookup (const BNgenjet* object, string variable, string function = ""); |
77 |
< |
double valueLookup (const BNmcparticle* object, string variable, string function = ""); |
78 |
< |
double valueLookup (const BNprimaryvertex* object, string variable, string function = ""); |
79 |
< |
double valueLookup (const BNbxlumi* object, string variable, string function = ""); |
80 |
< |
double valueLookup (const BNphoton* object, string variable, string function = ""); |
81 |
< |
double valueLookup (const BNsupercluster* object, string variable, string function = ""); |
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); |
107 |
> |
double getTrkIsIso (const BNtrack* track1); |
108 |
> |
double getTrkCaloTotRhoCorr(const BNtrack* track); |
109 |
> |
void WriteDeadEcal (); |
110 |
> |
int getTrkIsMatchedDeadEcal (const BNtrack* track1); |
111 |
> |
|
112 |
|
//BNskimbits |
113 |
|
//BNtrigobj |
114 |
|
|
115 |
|
vector<string> splitString (string); |
116 |
< |
|
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; |
127 |
< |
|
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 |
132 |
|
//vector corresponds to each cut |
143 |
|
edm::InputTag tracks_; |
144 |
|
edm::InputTag genjets_; |
145 |
|
edm::InputTag mcparticles_; |
146 |
+ |
edm::InputTag stops_; |
147 |
|
edm::InputTag primaryvertexs_; |
148 |
|
edm::InputTag bxlumis_; |
149 |
|
edm::InputTag photons_; |
150 |
|
edm::InputTag superclusters_; |
151 |
|
edm::InputTag triggers_; |
152 |
< |
|
153 |
< |
BNprimaryvertex *primaryVertex_; |
154 |
< |
|
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 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 |
+ |
bool GetPlotsAfterEachCut_; |
176 |
+ |
|
177 |
+ |
struct DeadEcal { |
178 |
+ |
double etaEcal; |
179 |
+ |
double phiEcal; |
180 |
+ |
}; |
181 |
|
|
182 |
< |
vector<map<string, TH1D*> > oneDHists_; |
183 |
< |
vector<map<string, TH2D*> > twoDHists_; |
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; |
191 |
> |
edm::Handle<BNeventCollection> events; |
192 |
> |
edm::Handle<BNtauCollection> taus; |
193 |
> |
edm::Handle<BNmetCollection> mets; |
194 |
> |
edm::Handle<BNtrackCollection> tracks; |
195 |
> |
edm::Handle<BNgenjetCollection> genjets; |
196 |
> |
edm::Handle<BNmcparticleCollection> mcparticles; |
197 |
> |
edm::Handle<BNprimaryvertexCollection> primaryvertexs; |
198 |
> |
edm::Handle<BNbxlumiCollection> bxlumis; |
199 |
> |
edm::Handle<BNphotonCollection> photons; |
200 |
> |
edm::Handle<BNsuperclusterCollection> superclusters; |
201 |
> |
edm::Handle<BNstopCollection> stops; |
202 |
> |
|
203 |
> |
edm::Handle<double> rhokt6CaloJetsHandle_; |
204 |
> |
|
205 |
> |
flagMap cumulativeFlags; |
206 |
> |
flagMap vetoFlags; |
207 |
> |
|
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 |
|
|
216 |
|
vector<CutFlow *> cutFlows_; |
217 |
|
|
218 |
|
typedef struct { |
219 |
< |
string name; |
220 |
< |
string title; |
221 |
< |
vector<double> bins; |
222 |
< |
string inputCollection; |
223 |
< |
vector<string> inputVariables; |
224 |
< |
string function; |
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 |
< |
string variable; |
238 |
< |
string comparativeOperator; |
239 |
< |
string function; |
240 |
< |
double cutValue; |
241 |
< |
int numberRequired; |
242 |
< |
string eventComparativeOperator; |
243 |
< |
string name; |
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; |
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<cut> cuts; |
251 |
> |
string name; |
252 |
> |
vector<string> triggers; |
253 |
> |
vector<string> triggersToVeto; |
254 |
> |
vector<cut> cuts; |
255 |
|
}; |
256 |
|
|
257 |
+ |
vector<string> objectsToGet; |
258 |
+ |
vector<string> objectsToCut; |
259 |
|
vector<string> objectsToPlot; |
260 |
< |
vector<string> allNecessaryObjects; |
260 |
> |
vector<string> objectsToFlag; |
261 |
> |
|
262 |
|
vector<channel> channels; |
263 |
|
vector<histogram> histograms; |
264 |
+ |
vector<BranchSpecs> treeBranches_; |
265 |
+ |
|
266 |
+ |
PUWeight *puWeight_; |
267 |
+ |
MuonSFWeight *muonSFWeight_; |
268 |
+ |
double muonScaleFactor_; |
269 |
+ |
ElectronSFWeight *electronSFWeight_; |
270 |
+ |
double electronScaleFactor_; |
271 |
+ |
BtagSFWeight *bTagSFWeight_; |
272 |
+ |
double bTagScaleFactor_; |
273 |
+ |
|
274 |
+ |
StopCTauWeight *stopCTauWeight_; |
275 |
+ |
double stopCTauScaleFactor_; |
276 |
|
|
277 |
|
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string); |
278 |
< |
template <class InputCollection> void fillHistogram(TH1*, histogram, InputCollection); |
278 |
> |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, flagPair, flagPair, string); |
279 |
> |
|
280 |
> |
template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, flagPair flags); |
281 |
> |
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, flagPair, double); |
282 |
> |
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double); |
283 |
> |
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, flagPair, double); |
284 |
> |
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, flagPair, flagPair, flagPair, double); |
285 |
> |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType); |
286 |
> |
|
287 |
> |
|
288 |
> |
|
289 |
> |
template <class InputObject> int getGenMatchedParticleIndex(InputObject); |
290 |
> |
int getPdgIdBinValue(int); |
291 |
> |
int findTauMotherIndex(const BNmcparticle*); |
292 |
> |
|
293 |
> |
template <class InputObject> double getGenDeltaRLowest(InputObject); |
294 |
|
|
295 |
|
|
296 |
+ |
const BNprimaryvertex *chosenVertex (); |
297 |
+ |
const BNmet *chosenMET (); |
298 |
+ |
const BNelectron *chosenElectron (); |
299 |
+ |
const BNmuon *chosenMuon (); |
300 |
|
|
301 |
|
}; |
302 |
|
|