67 std::map<std::string,TH1D*>
h1_;
99 fastOption_(cfg.getUntrackedParameter<bool> (
"FastOption",
false)),
102 trigTag_(cfg.getUntrackedParameter<edm::
InputTag> (
"TrigTag", edm::
InputTag(
"TriggerResults::HLT"))),
103 muonTag_(cfg.getUntrackedParameter<edm::
InputTag> (
"MuonTag", edm::
InputTag(
"muons"))),
104 metTag_(cfg.getUntrackedParameter<edm::
InputTag> (
"METTag", edm::
InputTag(
"met"))),
105 metIncludesMuons_(cfg.getUntrackedParameter<bool> (
"METIncludesMuons",
false)),
106 jetTag_(cfg.getUntrackedParameter<edm::
InputTag> (
"JetTag", edm::
InputTag(
"sisCone5CaloJets"))),
109 muonTrig_(cfg.getUntrackedParameter<std::
string> (
"MuonTrig",
"HLT_Mu9")),
110 ptCut_(cfg.getUntrackedParameter<double>(
"PtCut", 25.)),
111 etaCut_(cfg.getUntrackedParameter<double>(
"EtaCut", 2.1)),
112 isRelativeIso_(cfg.getUntrackedParameter<bool>(
"IsRelativeIso",
true)),
113 isCombinedIso_(cfg.getUntrackedParameter<bool>(
"IsCombinedIso",
false)),
114 isoCut03_(cfg.getUntrackedParameter<double>(
"IsoCut03", 0.1)),
115 mtMin_(cfg.getUntrackedParameter<double>(
"MtMin", 50.)),
116 mtMax_(cfg.getUntrackedParameter<double>(
"MtMax", 200.)),
117 metMin_(cfg.getUntrackedParameter<double>(
"MetMin", -999999.)),
118 metMax_(cfg.getUntrackedParameter<double>(
"MetMax", 999999.)),
119 acopCut_(cfg.getUntrackedParameter<double>(
"AcopCut", 2.)),
122 dxyCut_(cfg.getUntrackedParameter<double>(
"DxyCut", 0.2)),
123 normalizedChi2Cut_(cfg.getUntrackedParameter<double>(
"NormalizedChi2Cut", 10.)),
124 trackerHitsCut_(cfg.getUntrackedParameter<int>(
"TrackerHitsCut", 11)),
125 isAlsoTrackerMuon_(cfg.getUntrackedParameter<bool>(
"IsAlsoTrackerMuon",
true)),
128 ptThrForZ1_(cfg.getUntrackedParameter<double>(
"PtThrForZ1", 20.)),
129 ptThrForZ2_(cfg.getUntrackedParameter<double>(
"PtThrForZ2", 10.)),
132 eJetMin_(cfg.getUntrackedParameter<double>(
"EJetMin", 999999.)),
133 nJetMax_(cfg.getUntrackedParameter<int>(
"NJetMax", 999999))
154 TFileDirectory* subDir[2]; subDir[0] = &subDir0; subDir[1] = &subDir1;
156 char chname[256] =
"";
157 char chtitle[256] =
"";
158 std::string chsuffix[2] = {
"_BEFORECUTS",
"_LASTCUT" };
160 for (
int i=0;
i<2; ++
i) {
161 snprintf(chname, 255,
"PT%s", chsuffix[
i].
data());
162 snprintf(chtitle, 255,
"Muon transverse momentum [GeV]");
163 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,100,0.,100.);
165 snprintf(chname, 255,
"ETA%s", chsuffix[
i].
data());
166 snprintf(chtitle, 255,
"Muon pseudo-rapidity");
167 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,50,-2.5,2.5);
169 snprintf(chname, 255,
"DXY%s", chsuffix[
i].
data());
170 snprintf(chtitle, 255,
"Muon transverse distance to beam spot [cm]");
171 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,100,-0.5,0.5);
173 snprintf(chname, 255,
"CHI2%s", chsuffix[
i].
data());
174 snprintf(chtitle, 255,
"Normalized Chi2, inner track fit");
175 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,100,0.,100.);
177 snprintf(chname, 255,
"NHITS%s", chsuffix[
i].
data());
178 snprintf(chtitle, 255,
"Number of hits, inner track");
179 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,40,-0.5,39.5);
181 snprintf(chname, 255,
"ValidMuonHits%s", chsuffix[
i].
data());
182 snprintf(chtitle, 255,
"number Of Valid Muon Hits");
183 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,40,-0.5,39.5);
185 snprintf(chname, 255,
"TKMU%s", chsuffix[
i].
data());
186 snprintf(chtitle, 255,
"Tracker-muon flag (for global muons)");
187 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,2,-0.5,1.5);
189 snprintf(chname, 255,
"ISO%s", chsuffix[
i].
data());
192 snprintf(chtitle, 255,
"Relative (combined) isolation variable");
194 snprintf(chtitle, 255,
"Relative (tracker) isolation variable");
196 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle, 100, 0., 1.);
199 snprintf(chtitle, 255,
"Absolute (combined) isolation variable [GeV]");
201 snprintf(chtitle, 255,
"Absolute (tracker) isolation variable [GeV]");
203 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle, 100, 0., 20.);
206 snprintf(chname, 255,
"TRIG%s", chsuffix[
i].
data());
207 snprintf(chtitle, 255,
"Trigger response (bit %s)",
muonTrig_.data());
208 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,2,-0.5,1.5);
210 snprintf(chname, 255,
"MT%s", chsuffix[
i].
data());
211 snprintf(chtitle, 255,
"Transverse mass (%s) [GeV]",
metTag_.
label().data());
212 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,150,0.,300.);
214 snprintf(chname, 255,
"MET%s", chsuffix[
i].
data());
215 snprintf(chtitle, 255,
"Missing transverse energy (%s) [GeV]",
metTag_.
label().data());
216 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,100,0.,200.);
218 snprintf(chname, 255,
"ACOP%s", chsuffix[
i].
data());
219 snprintf(chtitle, 255,
"MU-MET (%s) acoplanarity",
metTag_.
label().data());
220 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,50,0.,
M_PI);
222 snprintf(chname, 255,
"NZ1%s", chsuffix[
i].
data());
223 snprintf(chtitle, 255,
"Z rejection: number of muons above %.2f GeV",
ptThrForZ1_);
224 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle, 10, -0.5, 9.5);
226 snprintf(chname, 255,
"NZ2%s", chsuffix[
i].
data());
227 snprintf(chtitle, 255,
"Z rejection: number of muons above %.2f GeV",
ptThrForZ2_);
228 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle, 10, -0.5, 9.5);
230 snprintf(chname, 255,
"NJETS%s", chsuffix[
i].
data());
232 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,10,-0.5,9.5);
245 LogVerbatim(
"") <<
"\n>>>>>> W SELECTION SUMMARY BEGIN >>>>>>>>>>>>>>>";
246 LogVerbatim(
"") <<
"Total numer of events analyzed: " <<
nall <<
" [events]";
247 LogVerbatim(
"") <<
"Total numer of events selected: " <<
nsel <<
" [events]";
248 LogVerbatim(
"") <<
"Overall efficiency: " <<
"(" << setprecision(4) << esel*100. <<
" +/- "<< setprecision(2) <<
sqrt(esel*(1-esel)/all)*100. <<
")%";
258 double err =
sqrt(eff*(1-eff)/all);
259 LogVerbatim(
"") <<
"Passing Pt/Eta/Quality cuts: " << num <<
" [events], (" << setprecision(4) << eff*100. <<
" +/- "<< setprecision(2) << err*100. <<
")%";
263 err =
sqrt(eff*(1-eff)/all);
266 if (
nrec>0) effstep = eiso/erec;
268 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. <<
")%";
272 err =
sqrt(eff*(1-eff)/all);
275 if (
niso>0) effstep = ehlt/eiso;
277 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. <<
")%";
281 err =
sqrt(eff*(1-eff)/all);
284 if (
nhlt>0) effstep = emet/ehlt;
286 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. <<
")%";
290 err =
sqrt(eff*(1-eff)/all);
293 if (
nmet>0) effstep = esel/emet;
295 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. <<
")%";
298 LogVerbatim(
"") <<
">>>>>> W SELECTION SUMMARY END >>>>>>>>>>>>>>>\n";
304 bool rec_sel =
false;
305 bool iso_sel =
false;
306 bool hlt_sel =
false;
307 bool met_sel =
false;
308 bool all_sel =
false;
313 LogError(
"") <<
">>> Muon collection does not exist !!!";
316 unsigned int muonCollectionSize = muonCollection->size();
321 LogTrace(
"") <<
">>> No beam spot found !!!";
330 LogError(
"") <<
">>> MET collection does not exist !!!";
333 const MET&
met = metCollection->at(0);
337 for (
unsigned int i=0;
i<muonCollectionSize;
i++) {
338 const Muon&
mu = muonCollection->at(
i);
344 double met_et =
sqrt(met_px*met_px+met_py*met_py);
345 LogTrace(
"") <<
">>> MET, MET_px, MET_py: " << met_et <<
", " << met_px <<
", " << met_py <<
" [GeV]";
351 LogError(
"") <<
">>> TRIGGER collection does not exist !!!";
362 bool trigger_fired =
false;
364 if (triggerResults->accept(itrig1)) trigger_fired =
true;
365 LogTrace(
"") <<
">>> Trigger bit: " << trigger_fired <<
" (" <<
muonTrig_ <<
")";
369 unsigned int nmuonsForZ1 = 0;
370 unsigned int nmuonsForZ2 = 0;
371 for (
unsigned int i=0;
i<muonCollectionSize;
i++) {
372 const Muon&
mu = muonCollection->at(
i);
386 LogError(
"") <<
">>> JET collection does not exist !!!";
389 unsigned int jetCollectionSize = jetCollection->size();
391 for (
unsigned int i=0;
i<jetCollectionSize;
i++) {
392 const Jet&
jet = jetCollection->at(
i);
395 LogTrace(
"") <<
">>> Total number of jets: " << jetCollectionSize;
396 LogTrace(
"") <<
">>> Number of jets above " <<
eJetMin_ <<
" [GeV]: " << njets;
402 if (
fastOption_ && nmuonsForZ1>=1 && nmuonsForZ2>=2)
return false;
406 bool hlt_hist_done =
false;
407 bool met_hist_done =
false;
408 bool nz1_hist_done =
false;
409 bool nz2_hist_done =
false;
410 bool njets_hist_done =
false;
413 const int NFLAGS = 13;
414 bool muon_sel[NFLAGS];
415 for (
unsigned int i=0;
i<muonCollectionSize;
i++) {
416 for (
int j=0;
j<NFLAGS; ++
j) {
420 const Muon&
mu = muonCollection->at(
i);
425 LogTrace(
"") <<
"> Wsel: processing muon number " <<
i <<
"...";
432 LogTrace(
"") <<
"\t... pt, eta: " << pt <<
" [GeV], " <<
eta;;
433 if (pt>
ptCut_) muon_sel[0] =
true;
435 if (fabs(eta)<
etaCut_) muon_sel[1] =
true;
439 double dxy = gm->dxy(beamSpotHandle->position());
440 double normalizedChi2 = gm->normalizedChi2();
441 double validmuonhits=gm->hitPattern().numberOfValidMuonHits();
443 double trackerHits = gm->hitPattern().numberOfValidTrackerHits();
444 LogTrace(
"") <<
"\t... dxy, normalizedChi2, trackerHits, isTrackerMuon?: " << dxy <<
" [cm], " << normalizedChi2 <<
", " << trackerHits <<
", " << mu.
isTrackerMuon();
445 if (fabs(dxy)<
dxyCut_) muon_sel[2] =
true;
469 if (isovar<
isoCut03_) muon_sel[6] =
true;
471 LogTrace(
"") <<
"\t... isolation value" << isovar <<
", isolated? " << muon_sel[6];
475 if (trigger_fired) muon_sel[7] =
true;
479 double w_et = met_et+ mu.
pt();
480 double w_px = met_px+ mu.
px();
481 double w_py = met_py+mu.
py();
482 double massT = w_et*w_et - w_px*w_px - w_py*w_py;
483 massT = (massT>0) ?
sqrt(massT) : 0;
485 LogTrace(
"") <<
"\t... W mass, W_et, W_px, W_py: " << massT <<
", " << w_et <<
", " << w_px <<
", " << w_py <<
" [GeV]";
494 double acop = deltaphi.
value();
495 if (acop<0) acop = - acop;
497 LogTrace(
"") <<
"\t... acoplanarity: " << acop;
498 if (acop<
acopCut_) muon_sel[10] =
true;
503 if (nmuonsForZ1<1 || nmuonsForZ2<2) muon_sel[11] =
true;
505 if (njets<=
nJetMax_) muon_sel[12] =
true;
513 int flags_passed = 0;
514 bool rec_sel_this =
true;
515 bool iso_sel_this =
true;
516 bool hlt_sel_this =
true;
517 bool met_sel_this =
true;
518 bool all_sel_this =
true;
519 for (
int j=0;
j<NFLAGS; ++
j) {
520 if (muon_sel[
j]) flags_passed += 1;
521 if (j<6 && !muon_sel[j]) rec_sel_this =
false;
522 if (j<7 && !muon_sel[j]) iso_sel_this =
false;
523 if (j<8 && !muon_sel[j]) hlt_sel_this =
false;
524 if (j<11 && !muon_sel[j]) met_sel_this =
false;
525 if (!muon_sel[j]) all_sel_this =
false;
529 if (rec_sel_this) rec_sel =
true;
531 if (iso_sel_this) iso_sel =
true;
533 if (hlt_sel_this) hlt_sel =
true;
535 if (met_sel_this) met_sel =
true;
537 if (all_sel_this) all_sel =
true;
540 if (flags_passed >= (NFLAGS-1)) {
541 if (!muon_sel[0] || flags_passed==NFLAGS)
543 if (!muon_sel[1] || flags_passed==NFLAGS)
545 if (!muon_sel[2] || flags_passed==NFLAGS)
547 if (!muon_sel[3] || flags_passed==NFLAGS)
550 if (!muon_sel[4] || flags_passed==NFLAGS)
552 if (!muon_sel[5] || flags_passed==NFLAGS)
554 if (!muon_sel[6] || flags_passed==NFLAGS)
556 if (!muon_sel[7] || flags_passed==NFLAGS)
558 hlt_hist_done =
true;
559 if (!muon_sel[8] || flags_passed==NFLAGS)
561 if (!muon_sel[9] || flags_passed==NFLAGS)
563 met_hist_done =
true;
564 if (!muon_sel[10] || flags_passed==NFLAGS)
566 if (!muon_sel[11] || flags_passed==NFLAGS)
568 nz1_hist_done =
true;
569 if (!muon_sel[11] || flags_passed==NFLAGS)
571 nz2_hist_done =
true;
572 if (!muon_sel[12] || flags_passed==NFLAGS)
574 njets_hist_done =
true;
590 LogTrace(
"") <<
">>>> Event ACCEPTED";
592 LogTrace(
"") <<
">>>> Event REJECTED";
virtual double et() const GCC11_FINAL
transverse energy
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
std::map< std::string, TH1D * > h1_
float sumPt
sum-pt of tracks
virtual TrackRef innerTrack() const
#define DEFINE_FWK_MODULE(type)
bool isTrackerMuon() const
Base class for all types of Jets.
bool isGlobalMuon() const
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
bool isNull() const
Checks for null.
unsigned int triggerIndex(std::string const &name) const
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
WMuNuValidator(const edm::ParameterSet &)
double normalizedChi2Cut_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
T value() const
Explicit access to value in case implicit conversion not OK.
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
char data[epos_bytes_allocation]
T * make() const
make new ROOT object
void fill_histogram(const char *, const double &)
virtual float pt() const GCC11_FINAL
transverse momentum
const std::string muonTrig_
const MuonIsolation & isolationR03() const
virtual bool filter(edm::Event &, const edm::EventSetup &)
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector