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" |
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 |
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 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 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); |
108 |
|
//BNtrigobj |
109 |
|
|
110 |
|
vector<string> splitString (string); |
111 |
< |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2); |
112 |
< |
string getObjToGet(string obj); |
111 |
> |
void getTwoObjs(string tempInputCollection, string& obj1, string& obj2); |
112 |
> |
string getObjToGet(string obj); |
113 |
|
|
114 |
|
private: |
115 |
|
|
142 |
|
edm::InputTag photons_; |
143 |
|
edm::InputTag superclusters_; |
144 |
|
edm::InputTag triggers_; |
145 |
< |
std::string puFile_; |
146 |
< |
std::string deadEcalFile_; |
147 |
< |
std::string muonSFFile_; |
148 |
< |
std::string dataPU_; |
149 |
< |
std::string electronSFID_; |
150 |
< |
std::string muonSF_; |
151 |
< |
std::string dataset_; |
152 |
< |
std::string datasetType_; |
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 printEventInfo_; |
160 |
< |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy |
159 |
> |
bool fillBNTree_; |
160 |
> |
bool applyLeptonSF_; |
161 |
> |
bool printEventInfo_; |
162 |
> |
bool useTrackCaloRhoCorr_; // to use the calo-based rho correction for the by-hand calculation of the track isolation energy |
163 |
|
vector<double> stopCTau_; |
164 |
< |
|
164 |
> |
bool GetPlotsAfterEachCut_; |
165 |
> |
|
166 |
|
struct DeadEcal { |
167 |
|
double etaEcal; |
168 |
|
double phiEcal; |
169 |
|
}; |
170 |
|
|
171 |
< |
std::vector<DeadEcal> DeadEcalVec; |
171 |
> |
vector<DeadEcal> DeadEcalVec; |
172 |
|
|
173 |
|
|
174 |
|
//Collections |
175 |
|
edm::Handle<BNtriggerCollection> triggers; |
176 |
+ |
edm::Handle<BNtrigobjCollection> trigobjs; |
177 |
|
edm::Handle<BNjetCollection> jets; |
178 |
|
edm::Handle<BNmuonCollection> muons; |
179 |
|
edm::Handle<BNelectronCollection> electrons; |
187 |
|
edm::Handle<BNbxlumiCollection> bxlumis; |
188 |
|
edm::Handle<BNphotonCollection> photons; |
189 |
|
edm::Handle<BNsuperclusterCollection> superclusters; |
178 |
– |
#ifdef DISPLACED_SUSY |
190 |
|
edm::Handle<BNstopCollection> stops; |
191 |
< |
#endif |
192 |
< |
edm::Handle<double> rhokt6CaloJetsHandle_; |
191 |
> |
|
192 |
> |
edm::Handle<double> rhokt6CaloJetsHandle_; |
193 |
|
|
194 |
|
flagMap cumulativeFlags; |
195 |
|
|
196 |
< |
vector<map<string, TH1D*> > oneDHists_; |
197 |
< |
vector<map<string, TH2D*> > twoDHists_; |
196 |
> |
vector<vector<map<string, TH1D*>>> oneDHists_; |
197 |
> |
vector<vector<map<string, TH2D*>>> twoDHists_; |
198 |
> |
vector<TTree*> BNTrees_; // one tree per channel |
199 |
> |
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 |
200 |
|
|
201 |
|
edm::Service<TFileService> fs_; |
202 |
|
|
207 |
|
string name; |
208 |
|
string title; |
209 |
|
vector<double> bins; |
210 |
+ |
vector<double> variableBinsX; |
211 |
+ |
vector<double> variableBinsY; |
212 |
|
string inputCollection; |
213 |
|
vector<string> inputVariables; |
214 |
|
} histogram; |
215 |
|
|
216 |
+ |
typedef struct { |
217 |
+ |
string name; |
218 |
+ |
string inputCollection; |
219 |
+ |
string inputVariable; |
220 |
+ |
} BranchSpecs; |
221 |
+ |
|
222 |
+ |
|
223 |
|
struct cut { |
224 |
|
string inputCollection; |
225 |
|
vector<string> functions; |
226 |
|
vector<string> variables; |
227 |
|
vector<string> comparativeOperators;// >, <, =, etc. |
228 |
|
vector<double> cutValues; |
229 |
+ |
vector<string> cutStringValues; |
230 |
|
vector<string> logicalOperators;//and, or |
231 |
|
int numSubcuts; |
232 |
|
int numberRequired; |
237 |
|
struct channel { |
238 |
|
string name; |
239 |
|
vector<string> triggers; |
240 |
+ |
vector<string> triggersToVeto; |
241 |
|
vector<cut> cuts; |
242 |
|
}; |
243 |
|
|
246 |
|
vector<string> objectsToPlot; |
247 |
|
vector<channel> channels; |
248 |
|
vector<histogram> histograms; |
249 |
+ |
vector<BranchSpecs> treeBranches_; |
250 |
|
|
251 |
|
PUWeight *puWeight_; |
252 |
|
MuonSFWeight *muonSFWeight_; |
253 |
+ |
double muonScaleFactor_; |
254 |
|
ElectronSFWeight *electronSFWeight_; |
255 |
< |
#ifdef DISPLACED_SUSY |
256 |
< |
CTauWeight *cTauWeight_; |
257 |
< |
#endif |
258 |
< |
double cTauScaleFactor_; |
255 |
> |
double electronScaleFactor_; |
256 |
> |
|
257 |
> |
StopCTauWeight *stopCTauWeight_; |
258 |
> |
double stopCTauScaleFactor_; |
259 |
|
|
260 |
|
template <class InputCollection> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection, string); |
261 |
|
template <class InputCollection1, class InputCollection2> void setObjectFlags(cut &, uint, flagMap &, flagMap &, InputCollection1, InputCollection2, vector<bool>, vector<bool>, string); |
262 |
|
|
263 |
+ |
template <class InputCollection> void assignTreeBranch(BranchSpecs brSpecs, InputCollection inputCollection, vector<bool> flags); |
264 |
|
template <class InputCollection> void fill1DHistogram(TH1*, histogram, InputCollection, vector<bool>, double); |
265 |
|
template <class InputCollection1, class InputCollection2> void fill1DHistogram(TH1*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
266 |
|
template <class InputCollection> void fill2DHistogram(TH2*, histogram, InputCollection, vector<bool>, double); |
267 |
|
template <class InputCollection1, class InputCollection2> void fill2DHistogram(TH2*, histogram, InputCollection1, InputCollection2, vector<bool>, vector<bool>, vector<bool>, double); |
268 |
< |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1); |
268 |
> |
bool getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1); |
269 |
|
|
270 |
|
template <class InputObject> int getGenMatchedParticleIndex(InputObject); |
271 |
|
int getPdgIdBinValue(int); |