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" |
21 |
|
#include "FWCore/Framework/interface/Event.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 |
– |
|
48 |
|
|
49 |
+ |
#include "OSUT3Analysis/AnaTools/interface/CutFlow.h" |
50 |
+ |
#include "OSUT3Analysis/AnaTools/interface/PUWeight.h" |
51 |
+ |
#include "OSUT3Analysis/AnaTools/interface/SFWeight.h" |
52 |
|
|
53 |
+ |
#include "OSUT3Analysis/AnaTools/interface/StopCTauWeight.h" |
54 |
|
|
55 |
|
using namespace std; |
56 |
|
|
62 |
|
|
63 |
|
void analyze (const edm::Event &, const edm::EventSetup &); |
64 |
|
bool evaluateComparison (double, string, double); |
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, 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 |
|
|
55 |
– |
double valueLookup (const BNjet*, string); |
56 |
– |
double valueLookup (const BNmuon*, string); |
57 |
– |
double valueLookup (const BNelectron*, string); |
58 |
– |
double valueLookup (const BNevent*, string); |
59 |
– |
double valueLookup (const BNtau*, string); |
60 |
– |
double valueLookup (const BNmet*, string); |
61 |
– |
double valueLookup (const BNtrack*, string); |
62 |
– |
double valueLookup (const BNgenjet*, string); |
63 |
– |
double valueLookup (const BNmcparticle*, string); |
64 |
– |
double valueLookup (const BNprimaryvertex*, string); |
65 |
– |
double valueLookup (const BNbxlumi*, string); |
66 |
– |
double valueLookup (const BNphoton*, string); |
67 |
– |
double valueLookup (const BNsupercluster*, string); |
107 |
|
//BNskimbits |
69 |
– |
//BNtrigger |
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 |
+ |
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 |
+ |
vector<edm::ParameterSet> treeBranchSets_; |
157 |
+ |
bool plotAllObjectsInPassingEvents_; |
158 |
+ |
bool doPileupReweighting_; |
159 |
+ |
bool applyLeptonSF_; |
160 |
+ |
bool printEventInfo_; |
161 |
+ |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy |
162 |
+ |
vector<double> stopCTau_; |
163 |
+ |
bool GetPlotsAfterEachCut_; |
164 |
+ |
|
165 |
+ |
struct DeadEcal { |
166 |
+ |
double etaEcal; |
167 |
+ |
double phiEcal; |
168 |
+ |
}; |
169 |
|
|
170 |
+ |
vector<DeadEcal> DeadEcalVec; |
171 |
|
|
106 |
– |
vector<edm::ParameterSet> channels_; |
172 |
|
|
173 |
< |
vector<map<string, TH1D*> > oneDHists_; |
173 |
> |
//Collections |
174 |
> |
edm::Handle<BNtriggerCollection> triggers; |
175 |
> |
edm::Handle<BNtrigobjCollection> trigobjs; |
176 |
> |
edm::Handle<BNjetCollection> jets; |
177 |
> |
edm::Handle<BNmuonCollection> muons; |
178 |
> |
edm::Handle<BNelectronCollection> electrons; |
179 |
> |
edm::Handle<BNeventCollection> events; |
180 |
> |
edm::Handle<BNtauCollection> taus; |
181 |
> |
edm::Handle<BNmetCollection> mets; |
182 |
> |
edm::Handle<BNtrackCollection> tracks; |
183 |
> |
edm::Handle<BNgenjetCollection> genjets; |
184 |
> |
edm::Handle<BNmcparticleCollection> mcparticles; |
185 |
> |
edm::Handle<BNprimaryvertexCollection> primaryvertexs; |
186 |
> |
edm::Handle<BNbxlumiCollection> bxlumis; |
187 |
> |
edm::Handle<BNphotonCollection> photons; |
188 |
> |
edm::Handle<BNsuperclusterCollection> superclusters; |
189 |
> |
edm::Handle<BNstopCollection> stops; |
190 |
> |
|
191 |
> |
edm::Handle<double> rhokt6CaloJetsHandle_; |
192 |
> |
|
193 |
> |
flagMap cumulativeFlags; |
194 |
> |
|
195 |
> |
vector<vector<map<string, TH1D*>>> oneDHists_; |
196 |
> |
vector<vector<map<string, TH2D*>>> twoDHists_; |
197 |
> |
vector<TTree*> BNTrees_; // one tree per channel |
198 |
> |
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 |
199 |
|
|
200 |
|
edm::Service<TFileService> fs_; |
201 |
|
|
202 |
|
CutFlow *masterCutFlow_; |
203 |
|
vector<CutFlow *> cutFlows_; |
204 |
|
|
205 |
+ |
typedef struct { |
206 |
+ |
string name; |
207 |
+ |
string title; |
208 |
+ |
vector<double> bins; |
209 |
+ |
vector<double> variableBinsX; |
210 |
+ |
vector<double> variableBinsY; |
211 |
+ |
string inputCollection; |
212 |
+ |
vector<string> inputVariables; |
213 |
+ |
} histogram; |
214 |
+ |
|
215 |
+ |
typedef struct { |
216 |
+ |
string name; |
217 |
+ |
string inputCollection; |
218 |
+ |
string inputVariable; |
219 |
+ |
} BranchSpecs; |
220 |
+ |
|
221 |
|
|
222 |
|
struct cut { |
223 |
< |
string inputCollection; |
224 |
< |
string variable; |
225 |
< |
string comparativeOperator; |
226 |
< |
double cutValue; |
227 |
< |
int numberRequired; |
228 |
< |
string eventComparativeOperator; |
229 |
< |
string name; |
223 |
> |
string inputCollection; |
224 |
> |
vector<string> functions; |
225 |
> |
vector<string> variables; |
226 |
> |
vector<string> comparativeOperators;// >, <, =, etc. |
227 |
> |
vector<double> cutValues; |
228 |
> |
vector<string> cutStringValues; |
229 |
> |
vector<string> logicalOperators;//and, or |
230 |
> |
int numSubcuts; |
231 |
> |
int numberRequired; |
232 |
> |
string eventComparativeOperator; |
233 |
> |
string name; |
234 |
|
}; |
235 |
|
|
236 |
|
struct channel { |
237 |
< |
string name; |
238 |
< |
vector<cut> cuts; |
239 |
< |
vector<string> inputCollections; |
237 |
> |
string name; |
238 |
> |
vector<string> triggers; |
239 |
> |
vector<string> triggersToVeto; |
240 |
> |
vector<cut> cuts; |
241 |
|
}; |
242 |
|
|
243 |
< |
vector<string> allNecessaryObjects; |
243 |
> |
vector<string> objectsToGet; |
244 |
> |
vector<string> objectsToCut; |
245 |
> |
vector<string> objectsToPlot; |
246 |
|
vector<channel> channels; |
247 |
+ |
vector<histogram> histograms; |
248 |
+ |
vector<BranchSpecs> treeBranches_; |
249 |
|
|
250 |
< |
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string); |
250 |
> |
PUWeight *puWeight_; |
251 |
> |
MuonSFWeight *muonSFWeight_; |
252 |
> |
double muonScaleFactor_; |
253 |
> |
ElectronSFWeight *electronSFWeight_; |
254 |
> |
double electronScaleFactor_; |
255 |
> |
|
256 |
> |
StopCTauWeight *stopCTauWeight_; |
257 |
> |
double stopCTauScaleFactor_; |
258 |
|
|
259 |
+ |
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string); |
260 |
+ |
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string); |
261 |
|
|
262 |
+ |
template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, vector<bool> flags); |
263 |
+ |
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double); |
264 |
+ |
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
265 |
+ |
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double); |
266 |
+ |
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
267 |
+ |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1); |
268 |
+ |
|
269 |
+ |
template <class InputObject> int getGenMatchedParticleIndex(InputObject); |
270 |
+ |
int getPdgIdBinValue(int); |
271 |
+ |
int findTauMotherIndex(const BNmcparticle*); |
272 |
+ |
|
273 |
+ |
template <class InputObject> double getGenDeltaRLowest(InputObject); |
274 |
+ |
|
275 |
+ |
|
276 |
+ |
const BNprimaryvertex *chosenVertex (); |
277 |
+ |
const BNmet *chosenMET (); |
278 |
+ |
const BNelectron *chosenElectron (); |
279 |
+ |
const BNmuon *chosenMuon (); |
280 |
|
|
281 |
|
}; |
282 |
|
|