31 virtual void endJob()
override;
74 std::map<std::string,TH1D*>
h1_;
99 fastOption_(cfg.getUntrackedParameter<bool> (
"FastOption",
false)),
104 metTag_(cfg.getUntrackedParameter<edm::
InputTag> (
"METTag", edm::
InputTag(
"met"))),
105 metToken_(consumes<
View<
MET> >(metTag_)),
106 metIncludesMuons_(cfg.getUntrackedParameter<bool> (
"METIncludesMuons",
false)),
107 jetTag_(cfg.getUntrackedParameter<edm::
InputTag> (
"JetTag", edm::
InputTag(
"sisCone5CaloJets"))),
108 jetToken_(consumes<
View<
Jet> >(jetTag_)),
112 muonTrig_(cfg.getUntrackedParameter<std::
string> (
"MuonTrig",
"HLT_Mu9")),
113 ptCut_(cfg.getUntrackedParameter<double>(
"PtCut", 25.)),
114 etaCut_(cfg.getUntrackedParameter<double>(
"EtaCut", 2.1)),
115 isRelativeIso_(cfg.getUntrackedParameter<bool>(
"IsRelativeIso",
true)),
116 isCombinedIso_(cfg.getUntrackedParameter<bool>(
"IsCombinedIso",
false)),
117 isoCut03_(cfg.getUntrackedParameter<double>(
"IsoCut03", 0.1)),
118 mtMin_(cfg.getUntrackedParameter<double>(
"MtMin", 50.)),
119 mtMax_(cfg.getUntrackedParameter<double>(
"MtMax", 200.)),
120 metMin_(cfg.getUntrackedParameter<double>(
"MetMin", -999999.)),
121 metMax_(cfg.getUntrackedParameter<double>(
"MetMax", 999999.)),
122 acopCut_(cfg.getUntrackedParameter<double>(
"AcopCut", 2.)),
125 dxyCut_(cfg.getUntrackedParameter<double>(
"DxyCut", 0.2)),
126 normalizedChi2Cut_(cfg.getUntrackedParameter<double>(
"NormalizedChi2Cut", 10.)),
127 trackerHitsCut_(cfg.getUntrackedParameter<int>(
"TrackerHitsCut", 11)),
128 isAlsoTrackerMuon_(cfg.getUntrackedParameter<bool>(
"IsAlsoTrackerMuon",
true)),
131 ptThrForZ1_(cfg.getUntrackedParameter<double>(
"PtThrForZ1", 20.)),
132 ptThrForZ2_(cfg.getUntrackedParameter<double>(
"PtThrForZ2", 10.)),
135 eJetMin_(cfg.getUntrackedParameter<double>(
"EJetMin", 999999.)),
136 nJetMax_(cfg.getUntrackedParameter<int>(
"NJetMax", 999999))
157 TFileDirectory* subDir[2]; subDir[0] = &subDir0; subDir[1] = &subDir1;
159 char chname[256] =
"";
160 char chtitle[256] =
"";
161 std::string chsuffix[2] = {
"_BEFORECUTS",
"_LASTCUT" };
163 for (
int i=0;
i<2; ++
i) {
164 snprintf(chname, 255,
"PT%s", chsuffix[
i].
data());
165 snprintf(chtitle, 255,
"Muon transverse momentum [GeV]");
166 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,100,0.,100.);
168 snprintf(chname, 255,
"ETA%s", chsuffix[
i].
data());
169 snprintf(chtitle, 255,
"Muon pseudo-rapidity");
170 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,50,-2.5,2.5);
172 snprintf(chname, 255,
"DXY%s", chsuffix[
i].
data());
173 snprintf(chtitle, 255,
"Muon transverse distance to beam spot [cm]");
174 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,100,-0.5,0.5);
176 snprintf(chname, 255,
"CHI2%s", chsuffix[
i].
data());
177 snprintf(chtitle, 255,
"Normalized Chi2, inner track fit");
178 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,100,0.,100.);
180 snprintf(chname, 255,
"NHITS%s", chsuffix[
i].
data());
181 snprintf(chtitle, 255,
"Number of hits, inner track");
182 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,40,-0.5,39.5);
184 snprintf(chname, 255,
"ValidMuonHits%s", chsuffix[
i].
data());
185 snprintf(chtitle, 255,
"number Of Valid Muon Hits");
186 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,40,-0.5,39.5);
188 snprintf(chname, 255,
"TKMU%s", chsuffix[
i].
data());
189 snprintf(chtitle, 255,
"Tracker-muon flag (for global muons)");
190 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,2,-0.5,1.5);
192 snprintf(chname, 255,
"ISO%s", chsuffix[
i].
data());
195 snprintf(chtitle, 255,
"Relative (combined) isolation variable");
197 snprintf(chtitle, 255,
"Relative (tracker) isolation variable");
199 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle, 100, 0., 1.);
202 snprintf(chtitle, 255,
"Absolute (combined) isolation variable [GeV]");
204 snprintf(chtitle, 255,
"Absolute (tracker) isolation variable [GeV]");
206 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle, 100, 0., 20.);
209 snprintf(chname, 255,
"TRIG%s", chsuffix[
i].
data());
210 snprintf(chtitle, 255,
"Trigger response (bit %s)",
muonTrig_.data());
211 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,2,-0.5,1.5);
213 snprintf(chname, 255,
"MT%s", chsuffix[
i].
data());
214 snprintf(chtitle, 255,
"Transverse mass (%s) [GeV]",
metTag_.
label().data());
215 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,150,0.,300.);
217 snprintf(chname, 255,
"MET%s", chsuffix[
i].
data());
218 snprintf(chtitle, 255,
"Missing transverse energy (%s) [GeV]",
metTag_.
label().data());
219 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,100,0.,200.);
221 snprintf(chname, 255,
"ACOP%s", chsuffix[
i].
data());
222 snprintf(chtitle, 255,
"MU-MET (%s) acoplanarity",
metTag_.
label().data());
223 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,50,0.,
M_PI);
225 snprintf(chname, 255,
"NZ1%s", chsuffix[
i].
data());
226 snprintf(chtitle, 255,
"Z rejection: number of muons above %.2f GeV",
ptThrForZ1_);
227 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle, 10, -0.5, 9.5);
229 snprintf(chname, 255,
"NZ2%s", chsuffix[
i].
data());
230 snprintf(chtitle, 255,
"Z rejection: number of muons above %.2f GeV",
ptThrForZ2_);
231 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle, 10, -0.5, 9.5);
233 snprintf(chname, 255,
"NJETS%s", chsuffix[
i].
data());
235 h1_[chname] = subDir[
i]->
make<TH1D>(chname,chtitle,10,-0.5,9.5);
248 LogVerbatim(
"") <<
"\n>>>>>> W SELECTION SUMMARY BEGIN >>>>>>>>>>>>>>>";
249 LogVerbatim(
"") <<
"Total numer of events analyzed: " <<
nall <<
" [events]";
250 LogVerbatim(
"") <<
"Total numer of events selected: " <<
nsel <<
" [events]";
251 LogVerbatim(
"") <<
"Overall efficiency: " <<
"(" << setprecision(4) << esel*100. <<
" +/- "<< setprecision(2) <<
sqrt(esel*(1-esel)/all)*100. <<
")%";
261 double err =
sqrt(eff*(1-eff)/all);
262 LogVerbatim(
"") <<
"Passing Pt/Eta/Quality cuts: " << num <<
" [events], (" << setprecision(4) << eff*100. <<
" +/- "<< setprecision(2) << err*100. <<
")%";
266 err =
sqrt(eff*(1-eff)/all);
269 if (
nrec>0) effstep = eiso/erec;
271 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. <<
")%";
275 err =
sqrt(eff*(1-eff)/all);
278 if (
niso>0) effstep = ehlt/eiso;
280 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. <<
")%";
284 err =
sqrt(eff*(1-eff)/all);
287 if (
nhlt>0) effstep = emet/ehlt;
289 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. <<
")%";
293 err =
sqrt(eff*(1-eff)/all);
296 if (
nmet>0) effstep = esel/emet;
298 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. <<
")%";
301 LogVerbatim(
"") <<
">>>>>> W SELECTION SUMMARY END >>>>>>>>>>>>>>>\n";
307 bool rec_sel =
false;
308 bool iso_sel =
false;
309 bool hlt_sel =
false;
310 bool met_sel =
false;
311 bool all_sel =
false;
316 LogError(
"") <<
">>> Muon collection does not exist !!!";
319 unsigned int muonCollectionSize = muonCollection->size();
324 LogTrace(
"") <<
">>> No beam spot found !!!";
333 LogError(
"") <<
">>> MET collection does not exist !!!";
336 const MET&
met = metCollection->at(0);
340 for (
unsigned int i=0;
i<muonCollectionSize;
i++) {
341 const Muon&
mu = muonCollection->at(
i);
347 double met_et =
sqrt(met_px*met_px+met_py*met_py);
348 LogTrace(
"") <<
">>> MET, MET_px, MET_py: " << met_et <<
", " << met_px <<
", " << met_py <<
" [GeV]";
354 LogError(
"") <<
">>> TRIGGER collection does not exist !!!";
365 bool trigger_fired =
false;
367 if (triggerResults->accept(itrig1)) trigger_fired =
true;
368 LogTrace(
"") <<
">>> Trigger bit: " << trigger_fired <<
" (" <<
muonTrig_ <<
")";
372 unsigned int nmuonsForZ1 = 0;
373 unsigned int nmuonsForZ2 = 0;
374 for (
unsigned int i=0;
i<muonCollectionSize;
i++) {
375 const Muon&
mu = muonCollection->at(
i);
389 LogError(
"") <<
">>> JET collection does not exist !!!";
392 unsigned int jetCollectionSize = jetCollection->size();
394 for (
unsigned int i=0;
i<jetCollectionSize;
i++) {
395 const Jet&
jet = jetCollection->at(
i);
398 LogTrace(
"") <<
">>> Total number of jets: " << jetCollectionSize;
399 LogTrace(
"") <<
">>> Number of jets above " <<
eJetMin_ <<
" [GeV]: " << njets;
405 if (
fastOption_ && nmuonsForZ1>=1 && nmuonsForZ2>=2)
return false;
409 bool hlt_hist_done =
false;
410 bool met_hist_done =
false;
411 bool nz1_hist_done =
false;
412 bool nz2_hist_done =
false;
413 bool njets_hist_done =
false;
416 const int NFLAGS = 13;
417 bool muon_sel[NFLAGS];
418 for (
unsigned int i=0;
i<muonCollectionSize;
i++) {
419 for (
int j=0;
j<NFLAGS; ++
j) {
423 const Muon&
mu = muonCollection->at(
i);
428 LogTrace(
"") <<
"> Wsel: processing muon number " <<
i <<
"...";
435 LogTrace(
"") <<
"\t... pt, eta: " << pt <<
" [GeV], " <<
eta;;
436 if (pt>
ptCut_) muon_sel[0] =
true;
438 if (fabs(eta)<
etaCut_) muon_sel[1] =
true;
442 double dxy = gm->dxy(beamSpotHandle->position());
443 double normalizedChi2 = gm->normalizedChi2();
444 double validmuonhits=gm->hitPattern().numberOfValidMuonHits();
446 double trackerHits = gm->hitPattern().numberOfValidTrackerHits();
447 LogTrace(
"") <<
"\t... dxy, normalizedChi2, trackerHits, isTrackerMuon?: " << dxy <<
" [cm], " << normalizedChi2 <<
", " << trackerHits <<
", " << mu.
isTrackerMuon();
448 if (fabs(dxy)<
dxyCut_) muon_sel[2] =
true;
472 if (isovar<
isoCut03_) muon_sel[6] =
true;
474 LogTrace(
"") <<
"\t... isolation value" << isovar <<
", isolated? " << muon_sel[6];
478 if (trigger_fired) muon_sel[7] =
true;
482 double w_et = met_et+ mu.
pt();
483 double w_px = met_px+ mu.
px();
484 double w_py = met_py+mu.
py();
485 double massT = w_et*w_et - w_px*w_px - w_py*w_py;
486 massT = (massT>0) ?
sqrt(massT) : 0;
488 LogTrace(
"") <<
"\t... W mass, W_et, W_px, W_py: " << massT <<
", " << w_et <<
", " << w_px <<
", " << w_py <<
" [GeV]";
497 double acop = deltaphi.
value();
498 if (acop<0) acop = - acop;
500 LogTrace(
"") <<
"\t... acoplanarity: " << acop;
501 if (acop<
acopCut_) muon_sel[10] =
true;
506 if (nmuonsForZ1<1 || nmuonsForZ2<2) muon_sel[11] =
true;
508 if (njets<=
nJetMax_) muon_sel[12] =
true;
516 int flags_passed = 0;
517 bool rec_sel_this =
true;
518 bool iso_sel_this =
true;
519 bool hlt_sel_this =
true;
520 bool met_sel_this =
true;
521 bool all_sel_this =
true;
522 for (
int j=0;
j<NFLAGS; ++
j) {
523 if (muon_sel[
j]) flags_passed += 1;
524 if (j<6 && !muon_sel[j]) rec_sel_this =
false;
525 if (j<7 && !muon_sel[j]) iso_sel_this =
false;
526 if (j<8 && !muon_sel[j]) hlt_sel_this =
false;
527 if (j<11 && !muon_sel[j]) met_sel_this =
false;
528 if (!muon_sel[j]) all_sel_this =
false;
532 if (rec_sel_this) rec_sel =
true;
534 if (iso_sel_this) iso_sel =
true;
536 if (hlt_sel_this) hlt_sel =
true;
538 if (met_sel_this) met_sel =
true;
540 if (all_sel_this) all_sel =
true;
543 if (flags_passed >= (NFLAGS-1)) {
544 if (!muon_sel[0] || flags_passed==NFLAGS)
546 if (!muon_sel[1] || flags_passed==NFLAGS)
548 if (!muon_sel[2] || flags_passed==NFLAGS)
550 if (!muon_sel[3] || flags_passed==NFLAGS)
553 if (!muon_sel[4] || flags_passed==NFLAGS)
555 if (!muon_sel[5] || flags_passed==NFLAGS)
557 if (!muon_sel[6] || flags_passed==NFLAGS)
559 if (!muon_sel[7] || flags_passed==NFLAGS)
561 hlt_hist_done =
true;
562 if (!muon_sel[8] || flags_passed==NFLAGS)
564 if (!muon_sel[9] || flags_passed==NFLAGS)
566 met_hist_done =
true;
567 if (!muon_sel[10] || flags_passed==NFLAGS)
569 if (!muon_sel[11] || flags_passed==NFLAGS)
571 nz1_hist_done =
true;
572 if (!muon_sel[11] || flags_passed==NFLAGS)
574 nz2_hist_done =
true;
575 if (!muon_sel[12] || flags_passed==NFLAGS)
577 njets_hist_done =
true;
593 LogTrace(
"") <<
">>>> Event ACCEPTED";
595 LogTrace(
"") <<
">>>> Event REJECTED";
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
std::map< std::string, TH1D * > h1_
float sumPt
sum-pt of tracks
virtual float pt() const
transverse momentum
virtual double et() const
transverse energy
virtual TrackRef innerTrack() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
virtual float phi() const
momentum azimuthal angle
bool isTrackerMuon() const
Base class for all types of Jets.
bool isGlobalMuon() const
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
unsigned int triggerIndex(std::string const &name) const
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
virtual float eta() const
momentum pseudorapidity
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
virtual void beginJob() override
WMuNuValidator(const edm::ParameterSet &)
double normalizedChi2Cut_
T * make(const Args &...args) const
make new ROOT object
static std::string const triggerResults
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
virtual bool filter(edm::Event &, const edm::EventSetup &) override
bool isNull() const
Checks for null.
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
T value() const
Explicit access to value in case implicit conversion not OK.
edm::EDGetTokenT< edm::TriggerResults > trigToken_
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
virtual double px() const
x coordinate of momentum vector
virtual void endJob() override
char data[epos_bytes_allocation]
void fill_histogram(const char *, const double &)
volatile std::atomic< bool > shutdown_flag false
const std::string muonTrig_
virtual double py() const
y coordinate of momentum vector
const MuonIsolation & isolationR03() const
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector