74 std::map<std::string, TH1D*>
h1_;
99 fastOption_(
cfg.getUntrackedParameter<
bool>(
"FastOption",
false)),
106 metToken_(consumes<
View<
MET> >(metTag_)),
107 metIncludesMuons_(
cfg.getUntrackedParameter<
bool>(
"METIncludesMuons",
false)),
109 jetToken_(consumes<
View<
Jet> >(jetTag_)),
113 muonTrig_(
cfg.getUntrackedParameter<
std::
string>(
"MuonTrig",
"HLT_Mu9")),
114 ptCut_(
cfg.getUntrackedParameter<double>(
"PtCut", 25.)),
115 etaCut_(
cfg.getUntrackedParameter<double>(
"EtaCut", 2.1)),
116 isRelativeIso_(
cfg.getUntrackedParameter<
bool>(
"IsRelativeIso",
true)),
117 isCombinedIso_(
cfg.getUntrackedParameter<
bool>(
"IsCombinedIso",
false)),
118 isoCut03_(
cfg.getUntrackedParameter<double>(
"IsoCut03", 0.1)),
119 mtMin_(
cfg.getUntrackedParameter<double>(
"MtMin", 50.)),
120 mtMax_(
cfg.getUntrackedParameter<double>(
"MtMax", 200.)),
121 metMin_(
cfg.getUntrackedParameter<double>(
"MetMin", -999999.)),
122 metMax_(
cfg.getUntrackedParameter<double>(
"MetMax", 999999.)),
123 acopCut_(
cfg.getUntrackedParameter<double>(
"AcopCut", 2.)),
126 dxyCut_(
cfg.getUntrackedParameter<double>(
"DxyCut", 0.2)),
127 normalizedChi2Cut_(
cfg.getUntrackedParameter<double>(
"NormalizedChi2Cut", 10.)),
128 trackerHitsCut_(
cfg.getUntrackedParameter<
int>(
"TrackerHitsCut", 11)),
129 isAlsoTrackerMuon_(
cfg.getUntrackedParameter<
bool>(
"IsAlsoTrackerMuon",
true)),
132 ptThrForZ1_(
cfg.getUntrackedParameter<double>(
"PtThrForZ1", 20.)),
133 ptThrForZ2_(
cfg.getUntrackedParameter<double>(
"PtThrForZ2", 10.)),
136 eJetMin_(
cfg.getUntrackedParameter<double>(
"EJetMin", 999999.)),
137 nJetMax_(
cfg.getUntrackedParameter<
int>(
"NJetMax", 999999)) {}
160 char chname[256] =
"";
161 char chtitle[256] =
"";
162 std::string chsuffix[2] = {
"_BEFORECUTS",
"_LASTCUT"};
164 for (
int i = 0;
i < 2; ++
i) {
165 snprintf(chname, 255,
"PT%s", chsuffix[
i].
data());
166 snprintf(chtitle, 255,
"Muon transverse momentum [GeV]");
167 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 100, 0., 100.);
169 snprintf(chname, 255,
"ETA%s", chsuffix[
i].
data());
170 snprintf(chtitle, 255,
"Muon pseudo-rapidity");
171 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 50, -2.5, 2.5);
173 snprintf(chname, 255,
"DXY%s", chsuffix[
i].
data());
174 snprintf(chtitle, 255,
"Muon transverse distance to beam spot [cm]");
175 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 100, -0.5, 0.5);
177 snprintf(chname, 255,
"CHI2%s", chsuffix[
i].
data());
178 snprintf(chtitle, 255,
"Normalized Chi2, inner track fit");
179 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 100, 0., 100.);
181 snprintf(chname, 255,
"NHITS%s", chsuffix[
i].
data());
182 snprintf(chtitle, 255,
"Number of hits, inner track");
183 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 40, -0.5, 39.5);
185 snprintf(chname, 255,
"ValidMuonHits%s", chsuffix[
i].
data());
186 snprintf(chtitle, 255,
"number Of Valid Muon Hits");
187 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 40, -0.5, 39.5);
189 snprintf(chname, 255,
"TKMU%s", chsuffix[
i].
data());
190 snprintf(chtitle, 255,
"Tracker-muon flag (for global muons)");
191 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 2, -0.5, 1.5);
193 snprintf(chname, 255,
"ISO%s", chsuffix[
i].
data());
196 snprintf(chtitle, 255,
"Relative (combined) isolation variable");
198 snprintf(chtitle, 255,
"Relative (tracker) isolation variable");
200 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 100, 0., 1.);
203 snprintf(chtitle, 255,
"Absolute (combined) isolation variable [GeV]");
205 snprintf(chtitle, 255,
"Absolute (tracker) isolation variable [GeV]");
207 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 100, 0., 20.);
210 snprintf(chname, 255,
"TRIG%s", chsuffix[
i].
data());
211 snprintf(chtitle, 255,
"Trigger response (bit %s)",
muonTrig_.data());
212 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 2, -0.5, 1.5);
214 snprintf(chname, 255,
"MT%s", chsuffix[
i].
data());
215 snprintf(chtitle, 255,
"Transverse mass (%s) [GeV]",
metTag_.
label().data());
216 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 150, 0., 300.);
218 snprintf(chname, 255,
"MET%s", chsuffix[
i].
data());
219 snprintf(chtitle, 255,
"Missing transverse energy (%s) [GeV]",
metTag_.
label().data());
220 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 100, 0., 200.);
222 snprintf(chname, 255,
"ACOP%s", chsuffix[
i].
data());
223 snprintf(chtitle, 255,
"MU-MET (%s) acoplanarity",
metTag_.
label().data());
224 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 50, 0.,
M_PI);
226 snprintf(chname, 255,
"NZ1%s", chsuffix[
i].
data());
227 snprintf(chtitle, 255,
"Z rejection: number of muons above %.2f GeV",
ptThrForZ1_);
228 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 10, -0.5, 9.5);
230 snprintf(chname, 255,
"NZ2%s", chsuffix[
i].
data());
231 snprintf(chtitle, 255,
"Z rejection: number of muons above %.2f GeV",
ptThrForZ2_);
232 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 10, -0.5, 9.5);
234 snprintf(chname, 255,
"NJETS%s", chsuffix[
i].
data());
236 h1_[chname] =
subDir[
i]->make<TH1D>(chname, chtitle, 10, -0.5, 9.5);
249 LogVerbatim(
"") <<
"\n>>>>>> W SELECTION SUMMARY BEGIN >>>>>>>>>>>>>>>";
250 LogVerbatim(
"") <<
"Total numer of events analyzed: " <<
nall <<
" [events]";
251 LogVerbatim(
"") <<
"Total numer of events selected: " <<
nsel <<
" [events]";
253 <<
"(" << setprecision(4) << esel * 100. <<
" +/- " << setprecision(2)
254 <<
sqrt(esel * (1 - esel) /
all) * 100. <<
")%";
265 LogVerbatim(
"") <<
"Passing Pt/Eta/Quality cuts: " <<
num <<
" [events], (" << setprecision(4) << eff * 100.
266 <<
" +/- " << setprecision(2) <<
err * 100. <<
")%";
274 effstep = eiso / erec;
276 errstep =
sqrt(effstep * (1 - effstep) /
nrec);
277 LogVerbatim(
"") <<
"Passing isolation cuts: " <<
num <<
" [events], (" << setprecision(4) << eff * 100.
278 <<
" +/- " << setprecision(2) <<
err * 100. <<
")%, to previous step: (" << setprecision(4)
279 << effstep * 100. <<
" +/- " << setprecision(2) << errstep * 100. <<
")%";
287 effstep = ehlt / eiso;
289 errstep =
sqrt(effstep * (1 - effstep) /
niso);
290 LogVerbatim(
"") <<
"Passing HLT criteria: " <<
num <<
" [events], (" << setprecision(4) << eff * 100.
291 <<
" +/- " << setprecision(2) <<
err * 100. <<
")%, to previous step: (" << setprecision(4)
292 << effstep * 100. <<
" +/- " << setprecision(2) << errstep * 100. <<
")%";
300 effstep = emet / ehlt;
302 errstep =
sqrt(effstep * (1 - effstep) /
nhlt);
303 LogVerbatim(
"") <<
"Passing MET/acoplanarity cuts: " <<
num <<
" [events], (" << setprecision(4) << eff * 100.
304 <<
" +/- " << setprecision(2) <<
err * 100. <<
")%, to previous step: (" << setprecision(4)
305 << effstep * 100. <<
" +/- " << setprecision(2) << errstep * 100. <<
")%";
313 effstep = esel / emet;
315 errstep =
sqrt(effstep * (1 - effstep) /
nmet);
316 LogVerbatim(
"") <<
"Passing Z/top rejection cuts: " <<
num <<
" [events], (" << setprecision(4) << eff * 100.
317 <<
" +/- " << setprecision(2) <<
err * 100. <<
")%, to previous step: (" << setprecision(4)
318 << effstep * 100. <<
" +/- " << setprecision(2) << errstep * 100. <<
")%";
321 LogVerbatim(
"") <<
">>>>>> W SELECTION SUMMARY END >>>>>>>>>>>>>>>\n";
326 bool rec_sel =
false;
327 bool iso_sel =
false;
328 bool hlt_sel =
false;
329 bool met_sel =
false;
330 bool all_sel =
false;
335 LogError(
"") <<
">>> Muon collection does not exist !!!";
343 LogTrace(
"") <<
">>> No beam spot found !!!";
352 LogError(
"") <<
">>> MET collection does not exist !!!";
359 for (
unsigned int i = 0;
i < muonCollectionSize;
i++) {
361 if (!
mu.isGlobalMuon())
367 double met_et =
sqrt(met_px * met_px + met_py * met_py);
368 LogTrace(
"") <<
">>> MET, MET_px, MET_py: " << met_et <<
", " << met_px <<
", " << met_py <<
" [GeV]";
374 LogError(
"") <<
">>> TRIGGER collection does not exist !!!";
385 bool trigger_fired =
false;
388 trigger_fired =
true;
389 LogTrace(
"") <<
">>> Trigger bit: " << trigger_fired <<
" (" <<
muonTrig_ <<
")";
393 unsigned int nmuonsForZ1 = 0;
394 unsigned int nmuonsForZ2 = 0;
395 for (
unsigned int i = 0;
i < muonCollectionSize;
i++) {
397 if (!
mu.isGlobalMuon())
413 LogError(
"") <<
">>> JET collection does not exist !!!";
418 for (
unsigned int i = 0;
i < jetCollectionSize;
i++) {
423 LogTrace(
"") <<
">>> Total number of jets: " << jetCollectionSize;
431 if (
fastOption_ && nmuonsForZ1 >= 1 && nmuonsForZ2 >= 2)
437 bool hlt_hist_done =
false;
438 bool met_hist_done =
false;
439 bool nz1_hist_done =
false;
440 bool nz2_hist_done =
false;
441 bool njets_hist_done =
false;
444 const int NFLAGS = 13;
445 bool muon_sel[NFLAGS];
446 for (
unsigned int i = 0;
i < muonCollectionSize;
i++) {
447 for (
int j = 0;
j < NFLAGS; ++
j) {
452 if (!
mu.isGlobalMuon())
454 if (
mu.globalTrack().isNull())
456 if (
mu.innerTrack().isNull())
459 LogTrace(
"") <<
"> Wsel: processing muon number " <<
i <<
"...";
465 double eta =
mu.eta();
466 LogTrace(
"") <<
"\t... pt, eta: " <<
pt <<
" [GeV], " <<
eta;
480 double validmuonhits = gm->hitPattern().numberOfValidMuonHits();
482 double trackerHits = gm->hitPattern().numberOfValidTrackerHits();
497 if (
mu.isTrackerMuon())
511 double isovar =
mu.isolationR03().sumPt;
513 isovar +=
mu.isolationR03().emEt;
514 isovar +=
mu.isolationR03().hadEt;
522 LogTrace(
"") <<
"\t... isolation value" << isovar <<
", isolated? " << muon_sel[6];
532 double w_et = met_et +
mu.pt();
533 double w_px = met_px +
mu.px();
534 double w_py = met_py +
mu.py();
535 double massT = w_et * w_et - w_px * w_px - w_py * w_py;
536 massT = (massT > 0) ?
sqrt(massT) : 0;
538 LogTrace(
"") <<
"\t... W mass, W_et, W_px, W_py: " << massT <<
", " << w_et <<
", " << w_px <<
", " << w_py
552 double acop = deltaphi.
value();
556 LogTrace(
"") <<
"\t... acoplanarity: " << acop;
564 if (nmuonsForZ1 < 1 || nmuonsForZ2 < 2)
578 int flags_passed = 0;
579 bool rec_sel_this =
true;
580 bool iso_sel_this =
true;
581 bool hlt_sel_this =
true;
582 bool met_sel_this =
true;
583 bool all_sel_this =
true;
584 for (
int j = 0;
j < NFLAGS; ++
j) {
587 if (
j < 6 && !muon_sel[
j])
588 rec_sel_this =
false;
589 if (
j < 7 && !muon_sel[
j])
590 iso_sel_this =
false;
591 if (
j < 8 && !muon_sel[
j])
592 hlt_sel_this =
false;
593 if (
j < 11 && !muon_sel[
j])
594 met_sel_this =
false;
596 all_sel_this =
false;
616 if (flags_passed >= (NFLAGS - 1)) {
617 if (!muon_sel[0] || flags_passed == NFLAGS)
619 if (!muon_sel[1] || flags_passed == NFLAGS)
621 if (!muon_sel[2] || flags_passed == NFLAGS)
623 if (!muon_sel[3] || flags_passed == NFLAGS) {
627 if (!muon_sel[4] || flags_passed == NFLAGS)
629 if (!muon_sel[5] || flags_passed == NFLAGS)
631 if (!muon_sel[6] || flags_passed == NFLAGS)
633 if (!muon_sel[7] || flags_passed == NFLAGS) {
634 if (!hlt_hist_done) {
636 hlt_hist_done =
true;
639 if (!muon_sel[8] || flags_passed == NFLAGS)
641 if (!muon_sel[9] || flags_passed == NFLAGS) {
642 if (!met_hist_done) {
644 met_hist_done =
true;
647 if (!muon_sel[10] || flags_passed == NFLAGS)
649 if (!muon_sel[11] || flags_passed == NFLAGS) {
650 if (!nz1_hist_done) {
652 nz1_hist_done =
true;
655 if (!muon_sel[11] || flags_passed == NFLAGS) {
656 if (!nz2_hist_done) {
658 nz2_hist_done =
true;
661 if (!muon_sel[12] || flags_passed == NFLAGS) {
662 if (!njets_hist_done) {
664 njets_hist_done =
true;
685 LogTrace(
"") <<
">>>> Event ACCEPTED";
687 LogTrace(
"") <<
">>>> Event REJECTED";