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 |
|
|
39 |
– |
#include "OSUT3Analysis/AnaTools/interface/CutFlow.h" |
40 |
– |
|
41 |
– |
|
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 BNtrack* object2, string variable, string function, string &stringValue); |
77 |
> |
double valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue); |
78 |
> |
double valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue); |
79 |
> |
double valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue); |
80 |
> |
double valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue); |
81 |
> |
double valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue); |
82 |
> |
double valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue); |
83 |
> |
double valueLookup (const BNevent* object, string variable, string function, string &stringValue); |
84 |
> |
double valueLookup (const BNtau* object, string variable, string function, string &stringValue); |
85 |
> |
double valueLookup (const BNmet* object, string variable, string function, string &stringValue); |
86 |
> |
double valueLookup (const BNtrack* object, string variable, string function, string &stringValue); |
87 |
> |
double valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue); |
88 |
> |
double valueLookup (const BNgenjet* object, string variable, string function, string &stringValue); |
89 |
> |
double valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue); |
90 |
> |
double valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue); |
91 |
> |
double valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue); |
92 |
> |
double valueLookup (const BNphoton* object, string variable, string function, string &stringValue); |
93 |
> |
double valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue); |
94 |
> |
double valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue); |
95 |
> |
double valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue); |
96 |
> |
double valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue); |
97 |
> |
double valueLookup (const BNstop* object, string variable, string function, string &stringValue); |
98 |
> |
|
99 |
> |
int getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl); |
100 |
> |
double getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl); |
101 |
> |
double getTrkPtRes (const BNtrack* track1); |
102 |
> |
double getTrkIsIso (const BNtrack* track1); |
103 |
> |
double getTrkCaloTotRhoCorr(const BNtrack* track); |
104 |
> |
void WriteDeadEcal (); |
105 |
> |
int getTrkIsMatchedDeadEcal (const BNtrack* track1); |
106 |
> |
|
107 |
|
//BNskimbits |
108 |
|
//BNtrigobj |
109 |
|
|
110 |
|
vector<string> splitString (string); |
111 |
< |
|
111 |
> |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2); |
112 |
> |
string getObjToGet(string obj); |
113 |
|
|
114 |
|
private: |
115 |
|
|
119 |
|
//inner vector corresponds to each object in input collection |
120 |
|
//bool tells if object passes or fails cuts |
121 |
|
typedef map<string, vector < vector<bool> > > flagMap; |
122 |
< |
|
122 |
> |
|
123 |
|
//counterMap: |
124 |
|
//string holds input collection type |
125 |
|
//vector corresponds to each cut |
136 |
|
edm::InputTag tracks_; |
137 |
|
edm::InputTag genjets_; |
138 |
|
edm::InputTag mcparticles_; |
139 |
+ |
edm::InputTag stops_; |
140 |
|
edm::InputTag primaryvertexs_; |
141 |
|
edm::InputTag bxlumis_; |
142 |
|
edm::InputTag photons_; |
143 |
|
edm::InputTag superclusters_; |
144 |
|
edm::InputTag triggers_; |
145 |
< |
|
146 |
< |
|
145 |
> |
edm::InputTag trigobjs_; |
146 |
> |
string puFile_; |
147 |
> |
string deadEcalFile_; |
148 |
> |
string muonSFFile_; |
149 |
> |
string dataPU_; |
150 |
> |
string electronSFID_; |
151 |
> |
string muonSF_; |
152 |
> |
string dataset_; |
153 |
> |
string datasetType_; |
154 |
|
vector<edm::ParameterSet> channels_; |
155 |
|
vector<edm::ParameterSet> histogramSets_; |
156 |
+ |
bool useEDMFormat_; |
157 |
+ |
vector<edm::ParameterSet> treeBranchSets_; |
158 |
+ |
bool plotAllObjectsInPassingEvents_; |
159 |
+ |
bool doPileupReweighting_; |
160 |
+ |
bool applyLeptonSF_; |
161 |
+ |
bool applyBtagSF_; |
162 |
+ |
int minBtag_; |
163 |
+ |
int maxBtag_; |
164 |
+ |
bool printEventInfo_; |
165 |
+ |
bool printAllTriggers_; |
166 |
+ |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy |
167 |
+ |
vector<double> stopCTau_; |
168 |
+ |
bool GetPlotsAfterEachCut_; |
169 |
+ |
|
170 |
+ |
struct DeadEcal { |
171 |
+ |
double etaEcal; |
172 |
+ |
double phiEcal; |
173 |
+ |
}; |
174 |
+ |
|
175 |
+ |
vector<DeadEcal> DeadEcalVec; |
176 |
|
|
177 |
< |
vector<map<string, TH1D*> > oneDHists_; |
177 |
> |
|
178 |
> |
//Collections |
179 |
> |
edm::Handle<BNtriggerCollection> triggers; |
180 |
> |
edm::Handle<BNtrigobjCollection> trigobjs; |
181 |
> |
edm::Handle<BNjetCollection> jets; |
182 |
> |
edm::Handle<BNmuonCollection> muons; |
183 |
> |
edm::Handle<BNelectronCollection> electrons; |
184 |
> |
edm::Handle<BNeventCollection> events; |
185 |
> |
edm::Handle<BNtauCollection> taus; |
186 |
> |
edm::Handle<BNmetCollection> mets; |
187 |
> |
edm::Handle<BNtrackCollection> tracks; |
188 |
> |
edm::Handle<BNgenjetCollection> genjets; |
189 |
> |
edm::Handle<BNmcparticleCollection> mcparticles; |
190 |
> |
edm::Handle<BNprimaryvertexCollection> primaryvertexs; |
191 |
> |
edm::Handle<BNbxlumiCollection> bxlumis; |
192 |
> |
edm::Handle<BNphotonCollection> photons; |
193 |
> |
edm::Handle<BNsuperclusterCollection> superclusters; |
194 |
> |
edm::Handle<BNstopCollection> stops; |
195 |
> |
|
196 |
> |
edm::Handle<double> rhokt6CaloJetsHandle_; |
197 |
> |
|
198 |
> |
flagMap cumulativeFlags; |
199 |
> |
|
200 |
> |
vector<vector<map<string, TH1D*>>> oneDHists_; |
201 |
> |
vector<vector<map<string, TH2D*>>> twoDHists_; |
202 |
> |
vector<TTree*> BNTrees_; // one tree per channel |
203 |
> |
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 |
204 |
|
|
205 |
|
edm::Service<TFileService> fs_; |
206 |
|
|
208 |
|
vector<CutFlow *> cutFlows_; |
209 |
|
|
210 |
|
typedef struct { |
211 |
< |
string name; |
212 |
< |
string title; |
213 |
< |
vector<double> bins; |
214 |
< |
string inputCollection; |
215 |
< |
string inputVariable; |
216 |
< |
string function; |
211 |
> |
string name; |
212 |
> |
string title; |
213 |
> |
vector<double> bins; |
214 |
> |
vector<double> variableBinsX; |
215 |
> |
vector<double> variableBinsY; |
216 |
> |
string inputCollection; |
217 |
> |
vector<string> inputVariables; |
218 |
|
} histogram; |
219 |
|
|
220 |
+ |
typedef struct { |
221 |
+ |
string name; |
222 |
+ |
string inputCollection; |
223 |
+ |
string inputVariable; |
224 |
+ |
} BranchSpecs; |
225 |
+ |
|
226 |
+ |
|
227 |
|
struct cut { |
228 |
< |
string inputCollection; |
229 |
< |
string variable; |
230 |
< |
string comparativeOperator; |
231 |
< |
string function; |
232 |
< |
double cutValue; |
233 |
< |
int numberRequired; |
234 |
< |
string eventComparativeOperator; |
235 |
< |
string name; |
228 |
> |
string inputCollection; |
229 |
> |
vector<string> functions; |
230 |
> |
vector<string> variables; |
231 |
> |
vector<string> comparativeOperators;// >, <, =, etc. |
232 |
> |
vector<double> cutValues; |
233 |
> |
vector<string> cutStringValues; |
234 |
> |
vector<string> logicalOperators;//and, or |
235 |
> |
int numSubcuts; |
236 |
> |
int numberRequired; |
237 |
> |
string eventComparativeOperator; |
238 |
> |
string name; |
239 |
|
}; |
240 |
|
|
241 |
|
struct channel { |
242 |
< |
string name; |
243 |
< |
vector<string> triggers; |
244 |
< |
vector<cut> cuts; |
242 |
> |
string name; |
243 |
> |
vector<string> triggers; |
244 |
> |
vector<string> triggersToVeto; |
245 |
> |
vector<cut> cuts; |
246 |
|
}; |
247 |
|
|
248 |
+ |
vector<string> objectsToGet; |
249 |
+ |
vector<string> objectsToCut; |
250 |
|
vector<string> objectsToPlot; |
145 |
– |
vector<string> allNecessaryObjects; |
251 |
|
vector<channel> channels; |
252 |
|
vector<histogram> histograms; |
253 |
+ |
vector<BranchSpecs> treeBranches_; |
254 |
|
|
255 |
< |
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string); |
256 |
< |
template <class InputCollection> void fillHistogram(TH1D*, histogram, InputCollection); |
255 |
> |
PUWeight *puWeight_; |
256 |
> |
MuonSFWeight *muonSFWeight_; |
257 |
> |
double muonScaleFactor_; |
258 |
> |
ElectronSFWeight *electronSFWeight_; |
259 |
> |
double electronScaleFactor_; |
260 |
> |
BtagSFWeight *bTagSFWeight_; |
261 |
> |
double bTagScaleFactor_; |
262 |
|
|
263 |
+ |
StopCTauWeight *stopCTauWeight_; |
264 |
+ |
double stopCTauScaleFactor_; |
265 |
+ |
|
266 |
+ |
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string); |
267 |
+ |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string); |
268 |
|
|
269 |
+ |
template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, vector<bool> flags); |
270 |
+ |
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double); |
271 |
+ |
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
272 |
+ |
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double); |
273 |
+ |
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
274 |
+ |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1); |
275 |
+ |
|
276 |
+ |
template <class InputObject> int getGenMatchedParticleIndex(InputObject); |
277 |
+ |
int getPdgIdBinValue(int); |
278 |
+ |
int findTauMotherIndex(const BNmcparticle*); |
279 |
+ |
|
280 |
+ |
template <class InputObject> double getGenDeltaRLowest(InputObject); |
281 |
+ |
|
282 |
+ |
|
283 |
+ |
const BNprimaryvertex *chosenVertex (); |
284 |
+ |
const BNmet *chosenMET (); |
285 |
+ |
const BNelectron *chosenElectron (); |
286 |
+ |
const BNmuon *chosenMuon (); |
287 |
|
|
288 |
|
}; |
289 |
|
|