CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EwkElecDQM.cc
Go to the documentation of this file.
2 
6 
9 
12 
16 
17 //#include "DataFormats/MuonReco/interface/Muon.h"
18 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" // I guess this is the right one??
19 // also need Fwd.h file ???
22 //#include "DataFormats/JetReco/interface/CaloJet.h"
23 //#include "DataFormats/METReco/interface/CaloMET.h"
24 //#include "DataFormats/METReco/interface/CaloMETCollection.h"
25 //#include "DataFormats/METReco/interface/CaloMETFwd.h"
26 
28 
32 
34 
35 using namespace edm;
36 using namespace std;
37 using namespace reco;
38 
40  // Input collections
41  metTag_(cfg.getUntrackedParameter<edm::InputTag> ("METTag",
42  edm::InputTag("met"))),
43  jetTag_(cfg.getUntrackedParameter<edm::InputTag> ("JetTag",
44  edm::InputTag("sisCone5CaloJets"))),
45  trigTag_(consumes<edm::TriggerResults>(
46  cfg.getUntrackedParameter<edm::InputTag> ("TrigTag",
47  edm::InputTag("TriggerResults::HLT")))),
48  elecTag_(consumes<edm::View<reco::GsfElectron> >(
49  cfg.getUntrackedParameter<edm::InputTag> ("ElecTag",
50  edm::InputTag("gsfElectrons")))),
51  metToken_(consumes<edm::View<reco::MET> >(
52  cfg.getUntrackedParameter<edm::InputTag> ("METTag",
53  edm::InputTag("met")))),
54  jetToken_(consumes<edm::View<reco::Jet> >(
55  cfg.getUntrackedParameter<edm::InputTag> ("JetTag",
56  edm::InputTag("sisCone5CaloJets")))),
57  vertexTag_(consumes<edm::View<reco::Vertex> >(
58  cfg.getUntrackedParameter<edm::InputTag> ("VertexTag",
59  edm::InputTag("offlinePrimaryVertices")))),
60  beamSpotTag_(consumes<reco::BeamSpot>(
61  cfg.getUntrackedParameter<edm::InputTag> ("BeamSpotTag",
62  edm::InputTag("BeamSpot")))),
63 
64  // Main cuts
65  // muonTrig_(cfg.getUntrackedParameter<std::string> ("MuonTrig", "HLT_Mu9")),
66  //elecTrig_(cfg.getUntrackedParameter<std::vector< std::string > >("ElecTrig", "HLT_Ele10_SW_L1R")),
67  elecTrig_(cfg.getUntrackedParameter<std::vector< std::string > >("ElecTrig")),
68  // ptCut_(cfg.getUntrackedParameter<double>("PtCut", 25.)),
69  ptCut_(cfg.getUntrackedParameter<double>("PtCut", 10.)),
70  // etaCut_(cfg.getUntrackedParameter<double>("EtaCut", 2.1)),
71  etaCut_(cfg.getUntrackedParameter<double>("EtaCut", 2.4)),
72  sieieCutBarrel_(cfg.getUntrackedParameter<double>("SieieBarrel", 0.01)),
73  sieieCutEndcap_(cfg.getUntrackedParameter<double>("SieieEndcap", 0.028)),
74  detainCutBarrel_(cfg.getUntrackedParameter<double>("DetainBarrel", 0.0071)),
75  detainCutEndcap_(cfg.getUntrackedParameter<double>("DetainEndcap", 0.0066)),
76  // isRelativeIso_(cfg.getUntrackedParameter<bool>("IsRelativeIso", true)),
77  // isCombinedIso_(cfg.getUntrackedParameter<bool>("IsCombinedIso", false)),
78  // isoCut03_(cfg.getUntrackedParameter<double>("IsoCut03", 0.1)),
79  ecalIsoCutBarrel_(cfg.getUntrackedParameter<double>("EcalIsoCutBarrel", 5.7)),
80  ecalIsoCutEndcap_(cfg.getUntrackedParameter<double>("EcalIsoCutEndcap", 5.0)),
81  hcalIsoCutBarrel_(cfg.getUntrackedParameter<double>("HcalIsoCutBarrel", 8.1)),
82  hcalIsoCutEndcap_(cfg.getUntrackedParameter<double>("HcalIsoCutEndcap", 3.4)),
83  trkIsoCutBarrel_(cfg.getUntrackedParameter<double>("TrkIsoCutBarrel", 7.2)),
84  trkIsoCutEndcap_(cfg.getUntrackedParameter<double>("TrkIsoCutEndcap", 5.1)),
85  mtMin_(cfg.getUntrackedParameter<double>("MtMin", -999999)),
86  mtMax_(cfg.getUntrackedParameter<double>("MtMax", 999999.)),
87  metMin_(cfg.getUntrackedParameter<double>("MetMin", -999999.)),
88  metMax_(cfg.getUntrackedParameter<double>("MetMax", 999999.)),
89  // acopCut_(cfg.getUntrackedParameter<double>("AcopCut", 2.)),
90 
91  // Muon quality cuts
92  // dxyCut_(cfg.getUntrackedParameter<double>("DxyCut", 0.2)),
93  // normalizedChi2Cut_(cfg.getUntrackedParameter<double>("NormalizedChi2Cut", 10.)),
94  // trackerHitsCut_(cfg.getUntrackedParameter<int>("TrackerHitsCut", 11)),
95  // isAlsoTrackerMuon_(cfg.getUntrackedParameter<bool>("IsAlsoTrackerMuon", true)),
96 
97  // Z rejection
98  // ptThrForZ1_(cfg.getUntrackedParameter<double>("PtThrForZ1", 20.)),
99  // ptThrForZ2_(cfg.getUntrackedParameter<double>("PtThrForZ2", 10.)),
100 
101  // Top rejection
102  eJetMin_(cfg.getUntrackedParameter<double>("EJetMin", 999999.)),
103  nJetMax_(cfg.getUntrackedParameter<int>("NJetMax", 999999)),
104  PUMax_(cfg.getUntrackedParameter<unsigned int>("PUMax", 60)),
105  PUBinCount_(cfg.getUntrackedParameter<unsigned int>("PUBinCount", 12))
106 
107 // caloJetCollection_(cfg.getUntrackedParameter<edm:InputTag>("CaloJetCollection","sisCone5CaloJets"))
108 
109 
110 
111 {
112  isValidHltConfig_ = false;
113 
114  // access to dbe
116  theDbe->setCurrentFolder("Physics/EwkElecDQM");
117  init_histograms();
118 
119 }
120 
121 void EwkElecDQM::beginRun(const Run& iRun, const EventSetup& iSet) {
122  nall = 0;
123  nsel = 0;
124 
125  nrec = 0;
126  neid = 0;
127  niso = 0;
128 // nhlt = 0;
129 // nmet = 0;
130 
131  // passed as parameter to HLTConfigProvider::init(), not yet used
132  bool isConfigChanged = false;
133  // isValidHltConfig_ could be used to short-circuit analyze() in case of problems
134  isValidHltConfig_ = hltConfigProvider_.init( iRun, iSet, "HLT", isConfigChanged );
135 
136  LogTrace("") << "isValidHltConfig_=" << isValidHltConfig_ << "\n";
137 }
138 
139 
141 
142 }
143 
145 
146  char chtitle[256] = "";
147  // pt_before_ = theDbe->book1D("PT_BEFORECUTS","Muon transverse momentum (global muon) [GeV],100,0.,100.);
148  // pt_after_ = theDbe->book1D("PT_LASTCUT","Muon transverse momentum (global muon) [GeV],100,0.,100.);
149 
150  pt_before_ = theDbe->book1D("PT_BEFORECUTS","Electron transverse momentum [GeV]",100,0.,100.);
151  pt_after_ = theDbe->book1D("PT_LASTCUT","Electron transverse momentum [GeV]",100,0.,100.);
152 
153  eta_before_ = theDbe->book1D("ETA_BEFORECUTS","Electron pseudo-rapidity",50,-2.5,2.5);
154  eta_after_ = theDbe->book1D("ETA_LASTCUT","Electron pseudo-rapidity",50,-2.5,2.5);
155 
156  sieiebarrel_before_ = theDbe->book1D("SIEIEBARREL_BEFORECUTS","Electron #sigma_{i#etai#eta} (barrel)",70,0.,0.07);
157  sieiebarrel_after_ = theDbe->book1D("SIEIEBARREL_LASTCUT","Electron #sigma_{i#etai#eta} (barrel)",70,0.,0.07);
158 
159  sieieendcap_before_ = theDbe->book1D("SIEIEENDCAP_BEFORECUTS","Electron #sigma_{i#etai#eta} (endcap)",70,0.,0.07);
160  sieieendcap_after_ = theDbe->book1D("SIEIEENDCAP_LASTCUT","Electron #sigma_{i#etai#eta} (endcap)",70,0.,0.07);
161 
162  detainbarrel_before_ = theDbe->book1D("DETAINBARREL_BEFORECUTS","Electron #Delta#eta_{in} (barrel)",40,-0.02,0.02);
163  detainbarrel_after_ = theDbe->book1D("DETAINBARREL_LASTCUT","Electron #Delta#eta_{in} (barrel)",40,-0.02,0.02);
164 
165  detainendcap_before_ = theDbe->book1D("DETAINENDCAP_BEFORECUTS","Electron #Delta#eta_{in} (endcap)",40,-0.02,0.02);
166  detainendcap_after_ = theDbe->book1D("DETAINENDCAP_LASTCUT","Electron #Delta#eta_{in} (endcap)",40,-0.02,0.02);
167 
168  // dxy_before_ = theDbe->book1D("DXY_BEFORECUTS","Muon transverse distance to beam spot [cm]",100,-0.5,0.5);
169  // dxy_after_ = theDbe->book1D("DXY_LASTCUT","Muon transverse distance to beam spot [cm]",100,-0.5,0.5);
170 
171  // chi2_before_ = theDbe->book1D("CHI2_BEFORECUTS","Normalized Chi2, inner track fit",100,0.,100.);
172  // chi2_after_ = theDbe->book1D("CHI2_LASTCUT","Normalized Chi2, inner track fit",100,0.,100.);
173 
174  // nhits_before_ = theDbe->book1D("NHITS_BEFORECUTS","Number of hits, inner track",40,-0.5,39.5);
175  // nhits_after_ = theDbe->book1D("NHITS_LASTCUT","Number of hits, inner track",40,-0.5,39.5);
176 
177  // tkmu_before_ = theDbe->book1D("TKMU_BEFORECUTS","Tracker-muon flag (for global muons)",2,-0.5,1.5);
178  // tkmu_after_ = theDbe->book1D("TKMU_LASTCUT","Tracker-muon flag (for global muons)",2,-0.5,1.5);
179 
180  // if (isRelativeIso_) {
181  // if (isCombinedIso_) {
182  // snprintf(chtitle, 255, "Relative (combined) isolation variable");
183  // iso_before_ = theDbe->book1D("ISO_BEFORECUTS","Relative (combined) isolation variable",100, 0., 1.);
184  // iso_after_ = theDbe->book1D("ISO_LASTCUT","Relative (combined) isolation variable",100, 0., 1.);
185  // } else {
186  // snprintf(chtitle, 255, "Relative (tracker) isolation variable");
187  // iso_before_ = theDbe->book1D("ISO_BEFORECUTS","Relative (tracker) isolation variable",100, 0., 1.);
188  // iso_after_ = theDbe->book1D("ISO_LASTCUT","Relative (tracker) isolation variable",100, 0., 1.);
189  // }
190  // } else {
191  // if (isCombinedIso_) {
192  // iso_before_ = theDbe->book1D("ISO_BEFORECUTS","Absolute (combined) isolation variable [GeV]",100, 0., 20.);
193  // iso_after_ = theDbe->book1D("ISO_LASTCUT","Absolute (combined) isolation variable [GeV]",100, 0., 20.);
194  // } else {
195  // iso_before_ = theDbe->book1D("ISO_BEFORECUTS","Absolute (tracker) isolation variable [GeV]",100, 0., 20.);
196  // iso_after_ = theDbe->book1D("ISO_LASTCUT","Absolute (tracker) isolation variable [GeV]",100, 0., 20.);
197  // }
198  // }
199 
200  ecalisobarrel_before_ = theDbe->book1D("ECALISOBARREL_BEFORECUTS","Absolute electron ECAL isolation variable (barrel) [GeV]",50,0.,50.);
201  ecalisobarrel_after_ = theDbe->book1D("ECALISOBARREL_LASTCUT","Absolute electron ECAL isolation variable (barrel) [GeV]",50,0.,50.);
202 
203  ecalisoendcap_before_ = theDbe->book1D("ECALISOENDCAP_BEFORECUTS","Absolute electron ECAL isolation variable (endcap) [GeV]",50,0.,50.);
204  ecalisoendcap_after_ = theDbe->book1D("ECALISOENDCAP_LASTCUT","Absolute electron ECAL isolation variable (endcap) [GeV]",50,0.,50.);
205 
206  hcalisobarrel_before_ = theDbe->book1D("HCALISOBARREL_BEFORECUTS","Absolute electron HCAL isolation variable (barrel) [GeV]",50,0.,50.);
207  hcalisobarrel_after_ = theDbe->book1D("HCALISOBARREL_LASTCUT","Absolute electron HCAL isolation variable (barrel) [GeV]",50,0.,50.);
208 
209  hcalisoendcap_before_ = theDbe->book1D("HCALISOENDCAP_BEFORECUTS","Absolute electron HCAL isolation variable (endcap) [GeV]",50,0.,50.);
210  hcalisoendcap_after_ = theDbe->book1D("HCALISOENDCAP_LASTCUT","Absolute electron HCAL isolation variable (endcap) [GeV]",50,0.,50.);
211 
212  trkisobarrel_before_ = theDbe->book1D("TRKISOBARREL_BEFORECUTS","Absolute electron track isolation variable (barrel) [GeV]",50,0.,50.);
213  trkisobarrel_after_ = theDbe->book1D("TRKISOBARREL_LASTCUT","Absolute electron track isolation variable (barrel) [GeV]",50,0.,50.);
214 
215  trkisoendcap_before_ = theDbe->book1D("TRKISOENDCAP_BEFORECUTS","Absolute electron track isolation variable (endcap) [GeV]",50,0.,50.);
216  trkisoendcap_after_ = theDbe->book1D("TRKISOENDCAP_LASTCUT","Absolute electron track isolation variable (endcap) [GeV]",50,0.,50.);
217 
218 // snprintf(chtitle, 255, "Trigger response (bit %s)", muonTrig_.data());
219 // trig_before_ = theDbe->book1D("TRIG_BEFORECUTS",chtitle,2,-0.5,1.5);
220 // trig_after_ = theDbe->book1D("TRIG_LASTCUT",chtitle,2,-0.5,1.5);
221 
222  //snprintf(chtitle, 255, "Trigger response (bit %s)", elecTrig_.data());
223  trig_before_ = theDbe->book1D("TRIG_BEFORECUTS","Trigger response",2,-0.5,1.5); // elecTrig_ is now a vector of strings!
224  trig_after_ = theDbe->book1D("TRIG_LASTCUT","Trigger response",2,-0.5,1.5);
225 
226  invmass_before_ = theDbe->book1D("INVMASS_BEFORECUTS","Di-electron invariant mass [GeV]",100,0.,200.);
227  invmass_after_ = theDbe->book1D("INVMASS_AFTERCUTS","Di-electron invariant mass [GeV]",100,0.,200.);
228 
229  invmassPU_before_ = theDbe->book2D("INVMASS_PU_BEFORECUTS","Di-electron invariant mass [GeV] vs PU; mass [GeV]; PU count",100,0.,200., PUBinCount_, -0.5, PUMax_+0.5);
230  invmassPU_afterZ_ = theDbe->book2D("INVMASS_PU_AFTERZCUTS","Di-electron invariant mass [GeV] vs PU; mass [GeV]; PU count",100,0.,200., PUBinCount_, -0.5, PUMax_+0.5);
231 
232  npvs_before_ = theDbe->book1D("NPVs_BEFORECUTS","Number of Valid Primary Vertices; nGoodPVs",PUMax_+1,-0.5,PUMax_+0.5);
233  //npvs_afterW_ = theDbe->book1D("NPVs_AFTERWCUTS","Number of Valid Primary Vertices",PUMax_+1,-0.5,PUMax_+0.5);
234  npvs_afterZ_ = theDbe->book1D("NPVs_AFTERZCUTS","Number of Valid Primary Vertices; nGoodPVs",PUMax_+1,-0.5,PUMax_+0.5);
235 
236 
237  nelectrons_before_ = theDbe->book1D("NELECTRONS_BEFORECUTS","Number of electrons in event",10,-0.5,9.5);
238  nelectrons_after_ = theDbe->book1D("NELECTRONS_AFTERCUTS","Number of electrons in event",10,-0.5,9.5);
239 
240  snprintf(chtitle, 255, "Transverse mass (%s) [GeV]", metTag_.label().data());
241  mt_before_ = theDbe->book1D("MT_BEFORECUTS",chtitle,150,0.,300.);
242  mt_after_ = theDbe->book1D("MT_LASTCUT",chtitle,150,0.,300.);
243 
244 // snprintf(chtitle, 255, "Transverse mass (%s) [GeV]", metTag_.label().data());
245 // mt_before_ = theDbe->book1D("MT_BEFORECUTS",chtitle,150,0.,300.);
246 // mt_after_ = theDbe->book1D("MT_LASTCUT",chtitle,150,0.,300.);
247 
248  snprintf(chtitle, 255, "Missing transverse energy (%s) [GeV]", metTag_.label().data());
249  met_before_ = theDbe->book1D("MET_BEFORECUTS",chtitle,100,0.,200.);
250  met_after_ = theDbe->book1D("MET_LASTCUT",chtitle,100,0.,200.);
251 
252 // snprintf(chtitle, 255, "MU-MET (%s) acoplanarity", metTag_.label().data());
253 // acop_before_ = theDbe->book1D("ACOP_BEFORECUTS",chtitle,50,0.,M_PI);
254 // acop_after_ = theDbe->book1D("ACOP_LASTCUT",chtitle,50,0.,M_PI);
255 
256 // snprintf(chtitle, 255, "Z rejection: number of muons above %.2f GeV", ptThrForZ1_);
257 // nz1_before_ = theDbe->book1D("NZ1_BEFORECUTS",chtitle,10,-0.5,9.5);
258 // nz1_after_ = theDbe->book1D("NZ1_LASTCUT",chtitle,10,-0.5,9.5);
259 
260 // snprintf(chtitle, 255, "Z rejection: number of muons above %.2f GeV", ptThrForZ2_);
261 // nz2_before_ = theDbe->book1D("NZ2_BEFORECUTS",chtitle,10,-0.5,9.5);
262 // nz2_after_ = theDbe->book1D("NZ2_LASTCUT",chtitle,10,-0.5,9.5);
263 
264  snprintf(chtitle, 255, "Number of jets (%s) above %.2f GeV", jetTag_.label().data(), eJetMin_);
265  njets_before_ = theDbe->book1D("NJETS_BEFORECUTS",chtitle,10,-0.5,9.5);
266  njets_after_ = theDbe->book1D("NJETS_LASTCUT",chtitle,10,-0.5,9.5);
267 
268  snprintf(chtitle, 255, "Jet with highest E_{T} (%s)", jetTag_.label().data());
269  jet_et_before_ = theDbe->book1D("JETET1_BEFORECUTS",chtitle, 20, 0., 200.0);
270  jet_et_after_ = theDbe->book1D("JETET1_AFTERCUTS",chtitle, 20, 0., 200.0);
271 
272  snprintf(chtitle, 255, "Eta of Jet with highest E_{T} (%s)", jetTag_.label().data());
273  jet_eta_before_ = theDbe->book1D("JETETA1_BEFORECUTS",chtitle, 20, -5, 5);
274  jet_eta_after_ = theDbe->book1D("JETETA1_AFTERCUTS",chtitle, 20, -5, 5);
275 
276 // snprintf(chtitle, 255, "Jet with 2nd highest E_{T} (%s)", jetTag_.label().data());
277 // jet2_et_before = theDbe->book1D("JETET2_BEFORECUTS",chtitle, 20, 0., 200.0);
278 // jet2_et_after = theDbe->book1D("JETET2_AFTERCUTS",chtitle, 20, 0., 200.0);
279 
280 
281 
282 }
283 
284 
286 }
287 
288 void EwkElecDQM::endRun(const Run& r, const EventSetup&) {
289 
290  // overall
291  double all = nall;
292  double esel = nsel/all;
293  LogVerbatim("") << "\n>>>>>> SELECTION SUMMARY BEGIN >>>>>>>>>>>>>>>";
294  LogVerbatim("") << "Total number of events analyzed: " << nall << " [events]";
295  LogVerbatim("") << "Total number of events selected: " << nsel << " [events]";
296  LogVerbatim("") << "Overall efficiency: " << "(" << setprecision(4) << esel*100. <<" +/- "<< setprecision(2) << sqrt(esel*(1-esel)/all)*100. << ")%";
297 
298  double erec = nrec/all;
299  double eeid = neid/all;
300  double eiso = niso/all;
301 // double ehlt = nhlt/all;
302 // double emet = nmet/all;
303 
304  // general reconstruction step??
305  double num = nrec;
306  double eff = erec;
307  double err = sqrt(eff*(1-eff)/all);
308  LogVerbatim("") << "Passing Pt/Eta/Quality cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%";
309 
310  // electron ID step
311  num = neid;
312  eff = eeid;
313  err = sqrt(eff*(1-eff)/all);
314  double effstep = 0.;
315  double errstep = 0.;
316  if (nrec>0) effstep = eeid/erec;
317  if (nrec>0) errstep = sqrt(effstep*(1-effstep)/nrec);
318  LogVerbatim("") << "Passing eID cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
319 
320  // isolation step
321  num = niso;
322  eff = eiso;
323  err = sqrt(eff*(1-eff)/all);
324  effstep = 0.;
325  errstep = 0.;
326  if (neid>0) effstep = eiso/eeid;
327  if (neid>0) errstep = sqrt(effstep*(1-effstep)/neid);
328  LogVerbatim("") << "Passing isolation cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
329 
330 // // trigger step
331 // num = nhlt;
332 // eff = ehlt;
333 // err = sqrt(eff*(1-eff)/all);
334 // effstep = 0.;
335 // errstep = 0.;
336 // if (niso>0) effstep = ehlt/eiso;
337 // if (niso>0) errstep = sqrt(effstep*(1-effstep)/niso);
338 // LogVerbatim("") << "Passing HLT criteria: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
339 
340  // trigger step
341  num = nsel;
342  eff = esel;
343  err = sqrt(eff*(1-eff)/all);
344  effstep = 0.;
345  errstep = 0.;
346  if (niso>0) effstep = esel/eiso;
347  if (niso>0) errstep = sqrt(effstep*(1-effstep)/niso);
348  LogVerbatim("") << "Passing HLT criteria: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
349 
350 // // met/acoplanarity cuts
351 // num = nmet;
352 // eff = emet;
353 // err = sqrt(eff*(1-eff)/all);
354 // effstep = 0.;
355 // errstep = 0.;
356 // if (nhlt>0) effstep = emet/ehlt;
357 // if (nhlt>0) errstep = sqrt(effstep*(1-effstep)/nhlt);
358 // LogVerbatim("") << "Passing MET/acoplanarity cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
359 
360 // // Z/top selection cuts ALSO LAST STEP so "sel" for "selection"
361 // num = nsel;
362 // eff = esel;
363 // err = sqrt(eff*(1-eff)/all);
364 // effstep = 0.;
365 // errstep = 0.;
366 // if (nmet>0) effstep = esel/emet;
367 // if (nmet>0) errstep = sqrt(effstep*(1-effstep)/nmet);
368 // LogVerbatim("") << "Passing Z/top rejection cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
369 
370  LogVerbatim("") << ">>>>>> SELECTION SUMMARY END >>>>>>>>>>>>>>>\n";
371 }
372 
373 inline void HERE(const char *msg) { std::cout << msg << "\n"; }
374 
375 
376 void EwkElecDQM::analyze (const Event & ev, const EventSetup & iSet) {
377 
378  // Reset global event selection flags
379  bool rec_sel = false;
380  bool eid_sel = false;
381  bool iso_sel = false;
382  bool all_sel = false;
383 
384  // Electron collection
385  Handle<View<GsfElectron> > electronCollection;
386  if (!ev.getByToken(elecTag_, electronCollection)) {
387  //LogWarning("") << ">>> Electron collection does not exist !!!";
388  return;
389  }
390  unsigned int electronCollectionSize = electronCollection->size();
391 
392  // Beam spot
393  Handle<reco::BeamSpot> beamSpotHandle;
394  if (!ev.getByToken(beamSpotTag_, beamSpotHandle)) {
395  //LogWarning("") << ">>> No beam spot found !!!";
396  return;
397  }
398 
399  // MET
400  double met_px = 0.;
401  double met_py = 0.;
402  Handle<View<MET> > metCollection;
403  if (!ev.getByToken(metToken_, metCollection)) {
404  //LogWarning("") << ">>> MET collection does not exist !!!";
405  return;
406  }
407 
408  const MET& met = metCollection->at(0);
409  met_px = met.px();
410  met_py = met.py();
411 // if (!metIncludesMuons_) {
412 // for (unsigned int i=0; i<muonCollectionSize; i++) {
413 // const Muon& mu = muonCollection->at(i);
414 // if (!mu.isGlobalMuon()) continue;
415 // met_px -= mu.px();
416 // met_py -= mu.py();
417 // }
418 // }
419  double met_et = sqrt(met_px*met_px+met_py*met_py);
420  LogTrace("") << ">>> MET, MET_px, MET_py: " << met_et << ", " << met_px << ", " << met_py << " [GeV]";
421  met_before_->Fill(met_et);
422 
423 
424  // Vertices in the event
425  int npvCount = 0;
427  if (!ev.getByToken(vertexTag_, vertexCollection)) {
428  LogError("") << ">>> Vertex collection does not exist !!!";
429  return;
430  }
431 
432  for (unsigned int i=0; i<vertexCollection->size(); i++) {
433  const Vertex& vertex = vertexCollection->at(i);
434  if (vertex.isValid()) npvCount++;
435  }
436  npvs_before_->Fill(npvCount);
437 
438  // Trigger
440  if (!ev.getByToken(trigTag_, triggerResults)) {
441  //LogWarning("") << ">>> TRIGGER collection does not exist !!!";
442  return;
443  }
444  const edm::TriggerNames & trigNames = ev.triggerNames(*triggerResults);
445  bool trigger_fired = false;
446 
447  /* very old code
448  for (unsigned int i=0; i<triggerResults->size(); i++) {
449  if (triggerResults->accept(i)) {
450  LogTrace("") << "Accept by: " << i << ", Trigger: " << trigNames.triggerName(i);
451  }
452  }
453  */
454 
455  // the following gives error on CRAFT08 data where itrig1=19 (vector index out of range)
456  /*
457  int itrig1 = trigNames.triggerIndex(muonTrig_);
458  if (triggerResults->accept(itrig1)) trigger_fired = true;
459  */
460  //suggested replacement: lm250909
461  /* Fix buggy trigger logic
462  for (unsigned int i=0; i<triggerResults->size(); i++)
463  {
464  std::string trigName = trigNames.triggerName(i);
465  bool found=false;
466 
467 // for (unsigned int j = 0; j < elecTrig_.size(); j++)
468 // {
469 // if ( trigName == elecTrig_.at(j) && triggerResults->accept(i))
470 // {
471 // trigger_fired = true;
472 // }
473 // }
474 
475 
476  for(unsigned int index=0; index<elecTrig_.size() && found==false; index++) {
477  size_t trigPath = trigName.find(elecTrig_.at(index)); // 0 if found, pos if not
478  if (trigPath==0) found=true;
479  }
480  if(!found) continue;
481 
482  bool prescaled=false;
483  for (unsigned int ps= 0; ps< hltConfigProvider_.prescaleSize(); ps++){
484  const unsigned int prescaleValue = hltConfigProvider_.prescaleValue(ps, trigName) ;
485  if (prescaleValue != 1) prescaled =true;
486  }
487 
488  if(triggerResults->accept(i) && !prescaled) trigger_fired=true;
489 
490  }
491  */
492 
493  // get the prescale set for this event
494  const int prescaleSet=hltConfigProvider_.prescaleSet(ev,iSet);
495  if (prescaleSet==-1) {
496  LogTrace("") << "Failed to determine prescaleSet\n";
497  //std::cout << "Failed to determine prescaleSet. Check cmsRun GlobalTag\n";
498  return;
499  }
500 
501  for (unsigned int i=0; (i<triggerResults->size()) && (trigger_fired==false); i++) {
502  // skip trigger, if it did not fire
503  if (!triggerResults->accept(i)) continue;
504 
505  // skip trigger, if it is not on our list
506  bool found=false;
507  const std::string trigName = trigNames.triggerName(i);
508  for(unsigned int index=0; index<elecTrig_.size() && found==false; index++) {
509  if ( trigName.find(elecTrig_.at(index)) == 0 ) found=true;
510  }
511  if(!found) continue;
512 
513  // skip trigger, if it is prescaled
514  if (hltConfigProvider_.prescaleValue(prescaleSet,trigName) != 1)
515  continue;
516 
517  //std::cout << "found unprescaled trigger that fired: " << trigName << "\n";
518  trigger_fired=true;
519  }
520 
521  LogTrace("") << ">>> Trigger bit: " << trigger_fired << " for one of ( " ;
522  for (unsigned int k = 0; k < elecTrig_.size(); k++)
523  {
524  LogTrace("") << elecTrig_.at(k) << " ";
525  }
526  LogTrace("") << ")";
527  trig_before_->Fill(trigger_fired);
528 
529  // Jet collection
530  Handle<View<Jet> > jetCollection;
531  if (!ev.getByToken(jetToken_, jetCollection)) {
532  //LogError("") << ">>> JET collection does not exist !!!";
533  return;
534  }
535  float electron_et = -8.0;
536  float electron_eta = -8.0;
537  float electron_phi = -8.0;
538  float electron2_et = -9.0;
539  float electron2_eta = -9.0;
540  float electron2_phi = -9.0;
541  //need to get some electron info so jets can be cleaned of them
542  for (unsigned int i=0; i<electronCollectionSize; i++)
543  {
544  const GsfElectron& elec = electronCollection->at(i);
545 
546  if (i < 1)
547  {
548  electron_et = elec.pt();
549  electron_eta = elec.eta();
550  electron_phi = elec.phi();
551  }
552  if (i == 2)
553  {
554  electron2_et = elec.pt();
555  electron2_eta = elec.eta();
556  electron2_phi = elec.phi();
557  }
558  }
559 
560  float jet_et = -8.0;
561  float jet_eta = -8.0;
562  int jet_count = 0;
563  float jet2_et = -9.0;
564  unsigned int jetCollectionSize = jetCollection->size();
565  int njets = 0;
566  for (unsigned int i=0; i<jetCollectionSize; i++) {
567  const Jet& jet = jetCollection->at(i);
568 
569  float jet_current_et = jet.et();
570 // cout << "jet_current_et " << jet_current_et << endl;
571  // if it overlaps with electron, it is not a jet
572  if ( electron_et>0.0 && fabs(jet.eta()-electron_eta ) < 0.2
573  && calcDeltaPhi(jet.phi(), electron_phi ) < 0.2)
574  continue;
575  if ( electron2_et>0.0&& fabs(jet.eta()-electron2_eta) < 0.2
576  && calcDeltaPhi(jet.phi(), electron2_phi) < 0.2)
577  continue;
578 
579  // if it has too low Et, throw away
580 // if (jet_current_et < eJetMin_) continue; //Keep if only want to plot above jet cut
581 
582  if (jet.et()>eJetMin_)
583  {
584  njets++;
585  jet_count++;
586  }
587  if (jet_current_et > jet_et)
588  {
589  jet2_et = jet_et; // 2nd highest jet get's et from current highest
590  jet_et = jet.et(); // current highest jet gets et from the new highest
591  jet_eta = jet.eta();
592  }
593  else if (jet_current_et > jet2_et)
594  {
595  jet2_et = jet.et();
596  }
597  }
598 
599  //Fill After all electron cuts (or both before and after)
600  if (jet_et>10) //don't want low energy "jets"
601  {
602  jet_et_before_ ->Fill(jet_et);
603 // jet2_et_before_ ->Fill(jet2_et);
604  jet_eta_before_ ->Fill(jet_eta);
605  }
606 
607 
608  LogTrace("") << ">>> Total number of jets: " << jetCollectionSize;
609  LogTrace("") << ">>> Number of jets above " << eJetMin_ << " [GeV]: " << njets;
610  njets_before_->Fill(njets);
611 
612 
613  // Start counting
614  nall++;
615 
616  // Histograms per event should be done only once, so keep track of them
617  bool hlt_hist_done = false;
618  //bool minv_hist_done = false;
619  bool met_hist_done = false;
620 // bool nz1_hist_done = false;
621 // bool nz2_hist_done = false;
622  bool njets_hist_done = false;
623 
624  // Central selection criteria
625  //const int NFLAGS = 13; // number of individual selection criteria
626  const int NFLAGS = 11; // number of individual selection criteria
627  // 0: pt cut | rec
628  // 1: eta cut | rec
629  // 2: sieie | eid
630  // 3: detain | eid
631  // 4: ecal iso | iso
632  // 5: hcal iso | iso
633  // 6: trk iso | iso
634  // 7: trigger fired | hlt/all
635  bool electron_sel[NFLAGS];
636 
637  // for invariant mass calculation
638  // keep track of highest-pt electrons for initial (RECO) electrons
639  // and "good" electrons (passing all cuts)
640  // first array dimension is for first or second good electron
641  // second array dimension is for relevant quantities of good electron
642  // [0]: 1 for electron found or 0 for not found (if 0, no other quantities filled)
643  // [1]: mSqr
644  // [2]: E
645  // [3]: px
646  // [4]: py
647  // [5]: pz
648  // inv mass = sqrt(m_1^2 + m_2^2 + 2*(E_1*E_2 - (px1*px2 + py1*py2 + pz1+pz2) ) )
649  double electron[2][6];
650  double goodElectron[2][6];
651  nGoodElectrons = 0;
652  for (unsigned int i = 0; i < 2; i++)
653  {
654  for (unsigned int j = 0; j < 6; j++)
655  {
656  electron[i][j] = 0.;
657  goodElectron[i][j] = 0.;
658  }
659  }
660 
661  for (unsigned int i=0; i<electronCollectionSize; i++)
662  {
663  for (int j=0; j<NFLAGS; ++j)
664  {
665  electron_sel[j] = false;
666  }
667 
668  const GsfElectron& elec = electronCollection->at(i);
669  //if (!mu.isGlobalMuon()) continue;
670  //if (mu.globalTrack().isNull()) continue;
671  //if (mu.innerTrack().isNull()) continue;
672 
673  LogTrace("") << "> elec: processing electron number " << i << "...";
674  //reco::TrackRef gm = mu.globalTrack();
675  //reco::TrackRef tk = mu.innerTrack();
676  // should have stuff for electron track?
677 
678  if (i < 2)
679  {
680  electron[i][0] = 1.;
681  electron[i][1] = elec.massSqr();
682  electron[i][2] = elec.energy();
683  electron[i][3] = elec.px();
684  electron[i][4] = elec.py();
685  electron[i][5] = elec.pz();
686  }
687 
688  // Pt,eta cuts
689  double pt = elec.pt();
690  double px = elec.px();
691  double py = elec.py();
692  double eta = elec.eta();
693  LogTrace("") << "\t... pt, eta: " << pt << " [GeV], " << eta;;
694  if (pt>ptCut_) electron_sel[0] = true;
695  if (fabs(eta)<etaCut_) electron_sel[1] = true;
696 
697  bool isBarrel = false;
698  bool isEndcap = false;
699  if (eta < 1.4442 && eta > -1.4442)
700  {
701  isBarrel = true;
702  }
703  else if ((eta > 1.56 && eta < 2.4) || (eta < -1.56 && eta > -2.4))
704  {
705  isEndcap = true;
706  }
707 
708  // // d0, chi2, nhits quality cuts
709  // double dxy = tk->dxy(beamSpotHandle->position());
710  // double normalizedChi2 = gm->normalizedChi2();
711  // double trackerHits = tk->numberOfValidHits();
712  // LogTrace("") << "\t... dxy, normalizedChi2, trackerHits, isTrackerMuon?: " << dxy << " [cm], " << normalizedChi2 << ", " << trackerHits << ", " << mu.isTrackerMuon();
713  // if (fabs(dxy)<dxyCut_) muon_sel[2] = true;
714  // if (normalizedChi2<normalizedChi2Cut_) muon_sel[3] = true;
715  // if (trackerHits>=trackerHitsCut_) muon_sel[4] = true;
716  // if (mu.isTrackerMuon()) muon_sel[5] = true;
717 
718  pt_before_->Fill(pt);
719  eta_before_->Fill(eta);
720  // dxy_before_->Fill(dxy);
721  // chi2_before_->Fill(normalizedChi2);
722  // nhits_before_->Fill(trackerHits);
723  // tkmu_before_->Fill(mu.isTrackerMuon());
724 
725 
726  // Electron ID cuts
727  double sieie = (double) elec.sigmaIetaIeta();
728  double detain = (double) elec.deltaEtaSuperClusterTrackAtVtx(); // think this is detain
729  if (sieie < sieieCutBarrel_ && isBarrel) electron_sel[2] = true;
730  if (sieie < sieieCutEndcap_ && isEndcap) electron_sel[2] = true;
731  if (detain < detainCutBarrel_ && isBarrel) electron_sel[3] = true;
732  if (detain < detainCutEndcap_ && isEndcap) electron_sel[3] = true;
733  if (isBarrel)
734  {
735  LogTrace("") << "\t... sieie value " << sieie << " (barrel), pass? " << electron_sel[2];
736  LogTrace("") << "\t... detain value " << detain << " (barrel), pass? " << electron_sel[3];
737  }
738  else if (isEndcap)
739  {
740  LogTrace("") << "\t... sieie value " << sieie << " (endcap), pass? " << electron_sel[2];
741  LogTrace("") << "\t... detain value " << detain << " (endcap), pass? " << electron_sel[2];
742  }
743 
744  if (isBarrel)
745  {
746  sieiebarrel_before_->Fill(sieie);
747  detainbarrel_before_->Fill(detain);
748  }
749  else if (isEndcap)
750  {
751  sieieendcap_before_->Fill(sieie);
752  detainendcap_before_->Fill(detain);
753  }
754 
755 
756 
757  // Isolation cuts
758  //double isovar = mu.isolationR03().sumPt;
759  double ecalisovar = elec.dr03EcalRecHitSumEt(); // picked one set!
760  double hcalisovar = elec.dr03HcalTowerSumEt(); // try others if
761  double trkisovar = elec.dr04TkSumPt(); // doesn't work
762  //if (isCombinedIso_) {
763  //isovar += mu.isolationR03().emEt;
764  //isovar += mu.isolationR03().hadEt;
765  //}
766  //if (isRelativeIso_) isovar /= pt;
767  if (ecalisovar<ecalIsoCutBarrel_ && isBarrel) electron_sel[4] = true;
768  if (ecalisovar<ecalIsoCutEndcap_ && isEndcap) electron_sel[4] = true;
769  if (hcalisovar<hcalIsoCutBarrel_ && isBarrel) electron_sel[5] = true;
770  if (hcalisovar<hcalIsoCutEndcap_ && isEndcap) electron_sel[5] = true;
771  if (trkisovar<trkIsoCutBarrel_ && isBarrel) electron_sel[6] = true;
772  if (trkisovar<trkIsoCutEndcap_ && isEndcap) electron_sel[6] = true;
773  if (isBarrel)
774  {
775  LogTrace("") << "\t... ecal isolation value " << ecalisovar << " (barrel), pass? " << electron_sel[4];
776  LogTrace("") << "\t... hcal isolation value " << hcalisovar << " (barrel), pass? " << electron_sel[5];
777  LogTrace("") << "\t... trk isolation value " << trkisovar << " (barrel), pass? " << electron_sel[6];
778  }
779  else if (isEndcap)
780  {
781  LogTrace("") << "\t... ecal isolation value " << ecalisovar << " (endcap), pass? " << electron_sel[4];
782  LogTrace("") << "\t... hcal isolation value " << hcalisovar << " (endcap), pass? " << electron_sel[5];
783  LogTrace("") << "\t... trk isolation value " << trkisovar << " (endcap), pass? " << electron_sel[6];
784  }
785 
786  //iso_before_->Fill(isovar);
787  if (isBarrel)
788  {
789  ecalisobarrel_before_->Fill(ecalisovar);
790  hcalisobarrel_before_->Fill(hcalisovar);
791  trkisobarrel_before_->Fill(trkisovar);
792  }
793  else if (isEndcap)
794  {
795  ecalisoendcap_before_->Fill(ecalisovar);
796  hcalisoendcap_before_->Fill(hcalisovar);
797  trkisoendcap_before_->Fill(trkisovar);
798  }
799 
800 
801  // HLT
802  if (trigger_fired) electron_sel[7] = true;
803 
804 
805  // // MET/MT cuts
806  double w_et = met_et+pt;
807  double w_px = met_px+px;
808  double w_py = met_py+py;
809 
810  double massT = w_et*w_et - w_px*w_px - w_py*w_py;
811  massT = (massT>0) ? sqrt(massT) : 0;
812 
813  LogTrace("") << "\t... W mass, W_et, W_px, W_py: " << massT << ", " << w_et << ", " << w_px << ", " << w_py << " [GeV]";
814  if (massT>mtMin_ && massT<mtMax_) electron_sel[8] = true;
815  mt_before_->Fill(massT);
816  if (met_et>metMin_ && met_et<metMax_) electron_sel[9] = true;
817 
818  // // Acoplanarity cuts
819  // Geom::Phi<double> deltaphi(mu.phi()-atan2(met_py,met_px));
820  // double acop = deltaphi.value();
821  // if (acop<0) acop = - acop;
822  // acop = M_PI - acop;
823  // LogTrace("") << "\t... acoplanarity: " << acop;
824  // if (acop<acopCut_) muon_sel[10] = true;
825  // acop_before_->Fill(acop);
826 
827  // // Remaining flags (from global event information)
828  // if (nmuonsForZ1<1 || nmuonsForZ2<2) muon_sel[11] = true;
829  if (njets<=nJetMax_) electron_sel[10] = true;
830 
831  // Collect necessary flags "per electron"
832  int flags_passed = 0;
833  bool rec_sel_this = true;
834  bool eid_sel_this = true;
835  bool iso_sel_this = true;
836  bool all_sel_this = true;
837  for (int j=0; j<NFLAGS; ++j)
838  {
839  if (electron_sel[j]) flags_passed += 1;
840  if (j<2 && !electron_sel[j]) rec_sel_this = false;
841  if (j<4 && !electron_sel[j]) eid_sel_this = false;
842  if (j<7 && !electron_sel[j]) iso_sel_this = false;
843  if (!electron_sel[j]) all_sel_this = false;
844  }
845 
846  if (all_sel_this)
847  {
848  if (nGoodElectrons < 2)
849  {
850  goodElectron[nGoodElectrons][0] = 1.;
851  goodElectron[nGoodElectrons][1] = elec.massSqr();
852  goodElectron[nGoodElectrons][2] = elec.energy();
853  goodElectron[nGoodElectrons][3] = elec.px();
854  goodElectron[nGoodElectrons][4] = elec.py();
855  goodElectron[nGoodElectrons][5] = elec.pz();
856  }
857  nGoodElectrons++;
858  }
859 
860  // // "rec" => pt,eta and quality cuts are satisfied
861  // if (rec_sel_this) rec_sel = true;
862  // // "iso" => "rec" AND "muon is isolated"
863  // if (iso_sel_this) iso_sel = true;
864  // // "hlt" => "iso" AND "event is triggered"
865  // if (hlt_sel_this) hlt_sel = true;
866  // // "all" => "met" AND "Z/top rejection cuts"
867  // if (all_sel_this) all_sel = true;
868 
869  // "rec" => pt,eta cuts are satisfied
870  if (rec_sel_this) rec_sel = true;
871  // "eid" => "rec" AND "electron passes ID"
872  if (eid_sel_this) iso_sel = true;
873  // "iso" => "eid" AND "electron is isolated"
874  if (iso_sel_this) iso_sel = true;
875  // "met" => "iso" AND "MET/MT"
876  // "all" => "met" AND "event is triggered"
877  if (all_sel_this) all_sel = true;
878 
879  // Do N-1 histograms now (and only once for global event quantities)
880  if (flags_passed >= (NFLAGS-1))
881  {
882  if (!electron_sel[0] || flags_passed==NFLAGS)
883  {
884  pt_after_->Fill(pt);
885  }
886  if (!electron_sel[1] || flags_passed==NFLAGS)
887  {
888  eta_after_->Fill(eta);
889  }
890  if (!electron_sel[2] || flags_passed==NFLAGS)
891  {
892  if (isBarrel)
893  {
894  sieiebarrel_after_->Fill(sieie);
895  }
896  else if (isEndcap)
897  {
898  sieieendcap_after_->Fill(sieie);
899  }
900  }
901  if (!electron_sel[3] || flags_passed==NFLAGS)
902  {
903  if (isBarrel)
904  {
905  detainbarrel_after_->Fill(detain);
906  }
907  else if (isEndcap)
908  {
909  detainendcap_after_->Fill(detain);
910  }
911  }
912  if (!electron_sel[4] || flags_passed==NFLAGS)
913  {
914  if (isBarrel)
915  {
916  ecalisobarrel_after_->Fill(ecalisovar);
917  }
918  else if (isEndcap)
919  {
920  ecalisoendcap_after_->Fill(ecalisovar);
921  }
922  }
923  if (!electron_sel[5] || flags_passed==NFLAGS)
924  {
925  if (isBarrel)
926  {
927  hcalisobarrel_after_->Fill(hcalisovar);
928  }
929  else if (isEndcap)
930  {
931  hcalisoendcap_after_->Fill(hcalisovar);
932  }
933  }
934  if (!electron_sel[6] || flags_passed==NFLAGS)
935  {
936  if (isBarrel)
937  {
938  trkisobarrel_after_->Fill(trkisovar);
939  }
940  else if (isEndcap)
941  {
942  trkisoendcap_after_->Fill(trkisovar);
943  }
944  }
945  // if (!electron_sel[3] || flags_passed==NFLAGS)
946  // {
947  // detain_after_->Fill(detain);
948  // }
949  // if (!electron_sel[4] || flags_passed==NFLAGS)
950  // {
951  // ecaliso_after_->Fill(trackerHits);
952  // }
953  // if (!electron_sel[5] || flags_passed==NFLAGS)
954  // {
955  // tkelectr_after_->Fill(electr.isTrackerElectron());
956  // }
957  // if (!electron_sel[6] || flags_passed==NFLAGS)
958  // {
959  // iso_after_->Fill(isovar);
960  // }
961  if (!electron_sel[7] || flags_passed==NFLAGS)
962  {
963  if (!hlt_hist_done)
964  {
965  trig_after_->Fill(trigger_fired);
966  }
967  }
968  hlt_hist_done = true;
969  if (!electron_sel[8] || flags_passed==NFLAGS)
970  {
971  mt_after_->Fill(massT);
972  }
973  if (!electron_sel[9] || flags_passed==NFLAGS)
974  {
975  if (!met_hist_done) {
976  met_after_->Fill(met_et);
977  }
978  }
979  met_hist_done = true;
980  // if (!muon_sel[10] || flags_passed==NFLAGS)
981  // acop_after_->Fill(acop);
982  // if (!muon_sel[11] || flags_passed==NFLAGS)
983  // if (!nz1_hist_done) nz1_after_->Fill(nmuonsForZ1);
984  // nz1_hist_done = true;
985  // if (!muon_sel[11] || flags_passed==NFLAGS)
986  // if (!nz2_hist_done) nz2_after_->Fill(nmuonsForZ2);
987  // nz2_hist_done = true;
988  if (!electron_sel[10] || flags_passed==NFLAGS) {
989  if (!njets_hist_done)
990  {
991  njets_after_->Fill(njets);
992  if (jet_et>10) //don't want low energy "jets"
993  {
994  jet_et_after_ ->Fill(jet_et);
995  jet_eta_after_ ->Fill(jet_eta);
996  }
997  }
998  }
999  njets_hist_done = true;
1000 
1001  } // end N-1 histos block
1002 
1003  } // end loop through electrons
1004 
1005  // inv mass = sqrt(m_1^2 + m_2^2 + 2*(E_1*E_2 - (px1*px2 + py1*py2 + pz1+pz2) ) )
1006  double invMass=0;
1007 
1008  nelectrons_before_->Fill(electronCollectionSize);
1009  if (electronCollectionSize > 1)
1010  {
1011  invMass = sqrt(electron[0][1] + electron[1][1] + 2*(electron[0][2]*electron[1][2] - (electron[0][3]*electron[1][3] + electron[0][4]*electron[1][4] + electron[0][5]*electron[1][5]) ) );
1012  invmass_before_->Fill(invMass);
1013  invmassPU_before_->Fill(invMass,npvCount);
1014  }
1015 
1017  if (nGoodElectrons > 1)
1018  {
1019  invMass = sqrt(goodElectron[0][1] + goodElectron[1][1] + 2*(goodElectron[0][2]*goodElectron[1][2] - (goodElectron[0][3]*goodElectron[1][3] + goodElectron[0][4]*goodElectron[1][4] + goodElectron[0][5]*goodElectron[1][5]) ) );
1020  invmass_after_->Fill(invMass);
1021  invmassPU_afterZ_->Fill(invMass,npvCount);
1022  npvs_afterZ_->Fill(npvCount);
1023  }
1024 
1025  // Collect final flags
1026  if (rec_sel) nrec++;
1027  if (eid_sel) neid++;
1028  if (iso_sel) niso++;
1029  // if (hlt_sel) nhlt++;
1030  // if (met_sel) nmet++;
1031 
1032  if (all_sel) {
1033  nsel++;
1034  LogTrace("") << ">>>> Event ACCEPTED";
1035  } else {
1036  LogTrace("") << ">>>> Event REJECTED";
1037  }
1038 
1039 
1040 
1041  return;
1042 
1043 }
1044 
1045 // This always returns only a positive deltaPhi
1046 double EwkElecDQM::calcDeltaPhi(double phi1, double phi2) {
1047 
1048  double deltaPhi = phi1 - phi2;
1049 
1050  if (deltaPhi < 0) deltaPhi = -deltaPhi;
1051 
1052  if (deltaPhi > 3.1415926) {
1053  deltaPhi = 2 * 3.1415926 - deltaPhi;
1054  }
1055 
1056  return deltaPhi;
1057 }
1058 
1059 // Local Variables:
1060 // show-trailing-whitespace: t
1061 // truncate-lines: t
1062 // End:
MonitorElement * ecalisoendcap_after_
Definition: EwkElecDQM.h:139
virtual double energy() const GCC11_FINAL
energy
MonitorElement * jet_et_after_
Definition: EwkElecDQM.h:186
virtual double et() const GCC11_FINAL
transverse energy
int i
Definition: DBlmapReader.cc:9
unsigned int nGoodElectrons
Definition: EwkElecDQM.h:101
MonitorElement * invmass_after_
Definition: EwkElecDQM.h:157
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:204
unsigned int nall
Definition: EwkElecDQM.h:92
MonitorElement * hcalisobarrel_after_
Definition: EwkElecDQM.h:142
DQMStore * theDbe
Definition: EwkElecDQM.h:103
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:4
unsigned int nsel
Definition: EwkElecDQM.h:98
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: EwkElecDQM.cc:376
double metMax_
Definition: EwkElecDQM.h:72
MonitorElement * nelectrons_before_
Definition: EwkElecDQM.h:165
HLTConfigProvider hltConfigProvider_
Definition: EwkElecDQM.h:90
double sieieCutBarrel_
Definition: EwkElecDQM.h:54
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
edm::EDGetTokenT< reco::BeamSpot > beamSpotTag_
Definition: EwkElecDQM.h:46
MonitorElement * sieieendcap_before_
Definition: EwkElecDQM.h:114
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MonitorElement * sieieendcap_after_
Definition: EwkElecDQM.h:115
Base class for all types of Jets.
Definition: Jet.h:20
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:60
MonitorElement * ecalisobarrel_before_
Definition: EwkElecDQM.h:135
edm::InputTag jetTag_
Definition: EwkElecDQM.h:40
virtual void beginJob()
Definition: EwkElecDQM.cc:140
MonitorElement * sieiebarrel_before_
Definition: EwkElecDQM.h:111
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: EwkElecDQM.cc:121
MonitorElement * hcalisobarrel_before_
Definition: EwkElecDQM.h:141
float dr04TkSumPt() const
Definition: GsfElectron.h:485
MonitorElement * detainbarrel_after_
Definition: EwkElecDQM.h:118
MonitorElement * ecalisobarrel_after_
Definition: EwkElecDQM.h:136
MonitorElement * detainendcap_before_
Definition: EwkElecDQM.h:120
T eta() const
MonitorElement * trig_before_
Definition: EwkElecDQM.h:153
MonitorElement * sieiebarrel_after_
Definition: EwkElecDQM.h:112
virtual double pz() const GCC11_FINAL
z coordinate of momentum vector
MonitorElement * detainbarrel_before_
Definition: EwkElecDQM.h:117
tuple vertexCollection
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
MonitorElement * mt_before_
Definition: EwkElecDQM.h:168
MonitorElement * nelectrons_after_
Definition: EwkElecDQM.h:166
MonitorElement * hcalisoendcap_before_
Definition: EwkElecDQM.h:144
MonitorElement * npvs_afterZ_
Definition: EwkElecDQM.h:163
void Fill(long long x)
unsigned int niso
Definition: EwkElecDQM.h:95
double calcDeltaPhi(double phi1, double phi2)
Definition: EwkElecDQM.cc:1046
MonitorElement * mt_after_
Definition: EwkElecDQM.h:169
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:247
unsigned int prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
double ecalIsoCutEndcap_
Definition: EwkElecDQM.h:64
float sigmaIetaIeta() const
Definition: GsfElectron.h:399
MonitorElement * jet_et_before_
Definition: EwkElecDQM.h:185
double detainCutEndcap_
Definition: EwkElecDQM.h:57
MonitorElement * njets_after_
Definition: EwkElecDQM.h:184
MonitorElement * pt_before_
Definition: EwkElecDQM.h:105
MonitorElement * pt_after_
Definition: EwkElecDQM.h:106
edm::EDGetTokenT< edm::View< reco::GsfElectron > > elecTag_
Definition: EwkElecDQM.h:42
double metMin_
Definition: EwkElecDQM.h:71
double trkIsoCutEndcap_
Definition: EwkElecDQM.h:68
unsigned int PUBinCount_
Definition: EwkElecDQM.h:87
Definition: MET.h:39
virtual void endRun(const edm::Run &, const edm::EventSetup &)
Definition: EwkElecDQM.cc:288
T sqrt(T t)
Definition: SSEVec.h:48
unsigned int nrec
Definition: EwkElecDQM.h:93
MonitorElement * hcalisoendcap_after_
Definition: EwkElecDQM.h:145
int nJetMax_
Definition: EwkElecDQM.h:84
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
EwkElecDQM(const edm::ParameterSet &)
Definition: EwkElecDQM.cc:39
int j
Definition: DBlmapReader.cc:9
double ecalIsoCutBarrel_
Definition: EwkElecDQM.h:63
double trkIsoCutBarrel_
Definition: EwkElecDQM.h:67
edm::InputTag metTag_
Definition: EwkElecDQM.h:39
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
Definition: EwkElecDQM.h:44
MonitorElement * invmass_before_
Definition: EwkElecDQM.h:156
MonitorElement * ecalisoendcap_before_
Definition: EwkElecDQM.h:138
unsigned int PUMax_
Definition: EwkElecDQM.h:87
static std::string const triggerResults
Definition: EdmProvDump.cc:41
MonitorElement * jet_eta_after_
Definition: EwkElecDQM.h:188
MonitorElement * trig_after_
Definition: EwkElecDQM.h:154
#define LogTrace(id)
MonitorElement * jet_eta_before_
Definition: EwkElecDQM.h:187
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
int k[5][pyjets_maxn]
unsigned int neid
Definition: EwkElecDQM.h:94
double etaCut_
Definition: EwkElecDQM.h:52
double hcalIsoCutBarrel_
Definition: EwkElecDQM.h:65
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
bool isValidHltConfig_
Definition: EwkElecDQM.h:89
int prescaleSet(const edm::Event &iEvent, const edm::EventSetup &iSetup) const
MonitorElement * detainendcap_after_
Definition: EwkElecDQM.h:121
MonitorElement * njets_before_
Definition: EwkElecDQM.h:183
MonitorElement * invmassPU_afterZ_
Definition: EwkElecDQM.h:159
MonitorElement * trkisobarrel_before_
Definition: EwkElecDQM.h:147
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
double sieieCutEndcap_
Definition: EwkElecDQM.h:55
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
edm::EDGetTokenT< edm::View< reco::Vertex > > vertexTag_
Definition: EwkElecDQM.h:45
MonitorElement * met_before_
Definition: EwkElecDQM.h:171
MonitorElement * trkisoendcap_before_
Definition: EwkElecDQM.h:150
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
Definition: EwkElecDQM.h:43
float dr03EcalRecHitSumEt() const
Definition: GsfElectron.h:475
std::string const & label() const
Definition: InputTag.h:42
edm::EDGetTokenT< edm::TriggerResults > trigTag_
Definition: EwkElecDQM.h:41
virtual float massSqr() const GCC11_FINAL
mass squared
MonitorElement * met_after_
Definition: EwkElecDQM.h:172
double eJetMin_
Definition: EwkElecDQM.h:83
void HERE(const char *msg)
Definition: EwkElecDQM.cc:373
virtual void endJob()
Definition: EwkElecDQM.cc:285
MonitorElement * trkisobarrel_after_
Definition: EwkElecDQM.h:148
void init_histograms()
Definition: EwkElecDQM.cc:144
double mtMax_
Definition: EwkElecDQM.h:70
MonitorElement * eta_after_
Definition: EwkElecDQM.h:109
double detainCutBarrel_
Definition: EwkElecDQM.h:56
const std::vector< std::string > elecTrig_
Definition: EwkElecDQM.h:50
MonitorElement * npvs_before_
Definition: EwkElecDQM.h:161
MonitorElement * trkisoendcap_after_
Definition: EwkElecDQM.h:151
float dr03HcalTowerSumEt() const
Definition: GsfElectron.h:478
tuple cout
Definition: gather_cfg.py:121
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1082
virtual float pt() const GCC11_FINAL
transverse momentum
double hcalIsoCutEndcap_
Definition: EwkElecDQM.h:66
MonitorElement * eta_before_
Definition: EwkElecDQM.h:108
MonitorElement * invmassPU_before_
Definition: EwkElecDQM.h:158
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
Definition: Run.h:41
double mtMin_
Definition: EwkElecDQM.h:69
double ptCut_
Definition: EwkElecDQM.h:51