CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
WMuNuValidator Class Reference
Inheritance diagram for WMuNuValidator:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginJob () override
 
void endJob () override
 
void fill_histogram (const char *, const double &)
 
bool filter (edm::Event &, const edm::EventSetup &) override
 
void init_histograms ()
 
 WMuNuValidator (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

double acopCut_
 
edm::EDGetTokenT< reco::BeamSpotbeamSpotToken_
 
double dxyCut_
 
double eJetMin_
 
double etaCut_
 
bool fastOption_
 
std::map< std::string, TH1D * > h1_
 
bool isAlsoTrackerMuon_
 
bool isCombinedIso_
 
double isoCut03_
 
bool isRelativeIso_
 
edm::InputTag jetTag_
 
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
 
bool metIncludesMuons_
 
double metMax_
 
double metMin_
 
edm::InputTag metTag_
 
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
 
double mtMax_
 
double mtMin_
 
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
 
const std::string muonTrig_
 
unsigned int nall
 
unsigned int nhlt
 
unsigned int niso
 
int nJetMax_
 
unsigned int nmet
 
double normalizedChi2Cut_
 
unsigned int nrec
 
unsigned int nsel
 
double ptCut_
 
double ptThrForZ1_
 
double ptThrForZ2_
 
int trackerHitsCut_
 
edm::EDGetTokenT< edm::TriggerResultstrigToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 26 of file WMuNuValidator.cc.

Constructor & Destructor Documentation

WMuNuValidator::WMuNuValidator ( const edm::ParameterSet cfg)

Definition at line 97 of file WMuNuValidator.cc.

97  :
98  // Fast selection (no histograms or book-keeping)
99  fastOption_(cfg.getUntrackedParameter<bool> ("FastOption", false)),
100 
101  // Input collections
102  trigToken_(consumes<TriggerResults>(cfg.getUntrackedParameter<edm::InputTag> ("TrigTag", edm::InputTag("TriggerResults::HLT")))),
104  metTag_(cfg.getUntrackedParameter<edm::InputTag> ("METTag", edm::InputTag("met"))),
106  metIncludesMuons_(cfg.getUntrackedParameter<bool> ("METIncludesMuons", false)),
107  jetTag_(cfg.getUntrackedParameter<edm::InputTag> ("JetTag", edm::InputTag("sisCone5CaloJets"))),
109  beamSpotToken_(consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))),
110 
111  // Main cuts
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.)),
123 
124  // Muon quality cuts
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)),
129 
130  // Z rejection
131  ptThrForZ1_(cfg.getUntrackedParameter<double>("PtThrForZ1", 20.)),
132  ptThrForZ2_(cfg.getUntrackedParameter<double>("PtThrForZ2", 10.)),
133 
134  // Top rejection
135  eJetMin_(cfg.getUntrackedParameter<double>("EJetMin", 999999.)),
136  nJetMax_(cfg.getUntrackedParameter<int>("NJetMax", 999999))
137 {
138 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
edm::InputTag metTag_
double normalizedChi2Cut_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
edm::EDGetTokenT< edm::TriggerResults > trigToken_
edm::InputTag jetTag_
const std::string muonTrig_

Member Function Documentation

void WMuNuValidator::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 140 of file WMuNuValidator.cc.

References fastOption_, init_histograms(), nall, nhlt, niso, nmet, nrec, and nsel.

140  {
141  nall = 0;
142  nsel = 0;
143 
144  if (!fastOption_) {
145  nrec = 0;
146  niso = 0;
147  nhlt = 0;
148  nmet = 0;
149  init_histograms();
150  }
151 }
unsigned int nsel
unsigned int niso
unsigned int nrec
unsigned int nhlt
unsigned int nmet
unsigned int nall
void WMuNuValidator::endJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 245 of file WMuNuValidator.cc.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor::all(), fastOption_, nall, nhlt, niso, nmet, nrec, nsel, pileupDistInMC::num, and mathSSE::sqrt().

245  {
246  double all = nall;
247  double esel = nsel/all;
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. << ")%";
252 
253  if (!fastOption_) {
254  double erec = nrec/all;
255  double eiso = niso/all;
256  double ehlt = nhlt/all;
257  double emet = nmet/all;
258 
259  double num = nrec;
260  double eff = erec;
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. << ")%";
263 
264  num = niso;
265  eff = eiso;
266  err = sqrt(eff*(1-eff)/all);
267  double effstep = 0.;
268  double errstep = 0.;
269  if (nrec>0) effstep = eiso/erec;
270  if (nrec>0) errstep = sqrt(effstep*(1-effstep)/nrec);
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. <<")%";
272 
273  num = nhlt;
274  eff = ehlt;
275  err = sqrt(eff*(1-eff)/all);
276  effstep = 0.;
277  errstep = 0.;
278  if (niso>0) effstep = ehlt/eiso;
279  if (niso>0) errstep = sqrt(effstep*(1-effstep)/niso);
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. <<")%";
281 
282  num = nmet;
283  eff = emet;
284  err = sqrt(eff*(1-eff)/all);
285  effstep = 0.;
286  errstep = 0.;
287  if (nhlt>0) effstep = emet/ehlt;
288  if (nhlt>0) errstep = sqrt(effstep*(1-effstep)/nhlt);
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. <<")%";
290 
291  num = nsel;
292  eff = esel;
293  err = sqrt(eff*(1-eff)/all);
294  effstep = 0.;
295  errstep = 0.;
296  if (nmet>0) effstep = esel/emet;
297  if (nmet>0) errstep = sqrt(effstep*(1-effstep)/nmet);
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. <<")%";
299  }
300 
301  LogVerbatim("") << ">>>>>> W SELECTION SUMMARY END >>>>>>>>>>>>>>>\n";
302 }
unsigned int nsel
unsigned int niso
unsigned int nrec
T sqrt(T t)
Definition: SSEVec.h:18
unsigned int nhlt
unsigned int nmet
unsigned int nall
void WMuNuValidator::fill_histogram ( const char *  name,
const double &  var 
)

Definition at line 240 of file WMuNuValidator.cc.

References fastOption_, h1_, and dataset::name.

Referenced by filter().

240  {
241  if (fastOption_) return;
242  h1_[name]->Fill(var);
243 }
std::map< std::string, TH1D * > h1_
bool WMuNuValidator::filter ( edm::Event ev,
const edm::EventSetup  
)
override

Definition at line 304 of file WMuNuValidator.cc.

References edm::HLTGlobalStatus::accept(), acopCut_, beamSpotToken_, DEFINE_FWK_MODULE, PVValHelper::dxy, dxyCut_, eJetMin_, reco::MuonIsolation::emEt, reco::LeafCandidate::et(), PVValHelper::eta, reco::LeafCandidate::eta(), etaCut_, fastOption_, fill_histogram(), edm::Event::getByToken(), muon::GlobalMuonPromptTight, reco::Muon::globalTrack(), reco::MuonIsolation::hadEt, mps_fire::i, reco::Muon::innerTrack(), isCombinedIso_, reco::Muon::isGlobalMuon(), muon::isGoodMuon(), edm::Ref< C, T, F >::isNull(), isoCut03_, reco::Muon::isolationR03(), isRelativeIso_, reco::Muon::isTrackerMuon(), metsig::jet, jetToken_, LogTrace, M_PI, RazorAnalyzer::met, MT2Analyzer::metCollection, metIncludesMuons_, metMax_, metMin_, metToken_, mtMax_, mtMin_, RPCpg::mu, HiRecoMuon_cff::muonCollection, muonToken_, muonTrig_, nall, nhlt, niso, nJetMax_, nmet, nrec, nsel, reco::LeafCandidate::phi(), reco::BeamSpot::position(), EnergyCorrector::pt, reco::LeafCandidate::pt(), ptCut_, ptThrForZ1_, ptThrForZ2_, reco::LeafCandidate::px(), reco::LeafCandidate::py(), mathSSE::sqrt(), reco::MuonIsolation::sumPt, trackerHitsCut_, edm::TriggerNames::triggerIndex(), edm::Event::triggerNames(), triggerResults, trigToken_, and Geom::Phi< T >::value().

Referenced by Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filter(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setDataAccessor(), and Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView().

304  {
305 
306  // Reset global event selection flags
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;
312 
313  // Muon collection
315  if (!ev.getByToken(muonToken_, muonCollection)) {
316  LogError("") << ">>> Muon collection does not exist !!!";
317  return false;
318  }
319  unsigned int muonCollectionSize = muonCollection->size();
320 
321  // Beam spot
322  Handle<reco::BeamSpot> beamSpotHandle;
323  if (!ev.getByToken(beamSpotToken_, beamSpotHandle)) {
324  LogTrace("") << ">>> No beam spot found !!!";
325  return false;
326  }
327 
328  // MET
329  double met_px = 0.;
330  double met_py = 0.;
332  if (!ev.getByToken(metToken_, metCollection)) {
333  LogError("") << ">>> MET collection does not exist !!!";
334  return false;
335  }
336  const MET& met = metCollection->at(0);
337  met_px = met.px();
338  met_py = met.py();
339  if (!metIncludesMuons_) {
340  for (unsigned int i=0; i<muonCollectionSize; i++) {
341  const Muon& mu = muonCollection->at(i);
342  if (!mu.isGlobalMuon()) continue;
343  met_px -= mu.px();
344  met_py -= mu.py();
345  }
346  }
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]";
349  fill_histogram("MET_BEFORECUTS",met_et);
350 
351  // Trigger
353  if (!ev.getByToken(trigToken_, triggerResults)) {
354  LogError("") << ">>> TRIGGER collection does not exist !!!";
355  return false;
356  }
357  const edm::TriggerNames & triggerNames = ev.triggerNames(*triggerResults);
358  /*
359  for (unsigned int i=0; i<triggerResults->size(); i++) {
360  if (triggerResults->accept(i)) {
361  LogTrace("") << "Accept by: " << i << ", Trigger: " << triggerNames.triggerName(i);
362  }
363  }
364  */
365  bool trigger_fired = false;
366  int itrig1 = triggerNames.triggerIndex(muonTrig_);
367  if (triggerResults->accept(itrig1)) trigger_fired = true;
368  LogTrace("") << ">>> Trigger bit: " << trigger_fired << " (" << muonTrig_ << ")";
369  fill_histogram("TRIG_BEFORECUTS",trigger_fired);
370 
371  // Loop to reject/control Z->mumu is done separately
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);
376  if (!mu.isGlobalMuon()) continue;
377  double pt = mu.pt();
378  if (pt>ptThrForZ1_) nmuonsForZ1++;
379  if (pt>ptThrForZ2_) nmuonsForZ2++;
380  }
381  LogTrace("") << "> Z rejection: muons above " << ptThrForZ1_ << " [GeV]: " << nmuonsForZ1;
382  LogTrace("") << "> Z rejection: muons above " << ptThrForZ2_ << " [GeV]: " << nmuonsForZ2;
383  fill_histogram("NZ1_BEFORECUTS",nmuonsForZ1);
384  fill_histogram("NZ2_BEFORECUTS",nmuonsForZ2);
385 
386  // Jet collection
387  Handle<View<Jet> > jetCollection;
388  if (!ev.getByToken(jetToken_, jetCollection)) {
389  LogError("") << ">>> JET collection does not exist !!!";
390  return false;
391  }
392  unsigned int jetCollectionSize = jetCollection->size();
393  int njets = 0;
394  for (unsigned int i=0; i<jetCollectionSize; i++) {
395  const Jet& jet = jetCollection->at(i);
396  if (jet.et()>eJetMin_) njets++;
397  }
398  LogTrace("") << ">>> Total number of jets: " << jetCollectionSize;
399  LogTrace("") << ">>> Number of jets above " << eJetMin_ << " [GeV]: " << njets;
400  fill_histogram("NJETS_BEFORECUTS",njets);
401 
402  // Start counting, reject already events if possible (under FastOption flag)
403  nall++;
404  if (fastOption_ && !trigger_fired) return false;
405  if (fastOption_ && nmuonsForZ1>=1 && nmuonsForZ2>=2) return false;
406  if (fastOption_ && njets>nJetMax_) return false;
407 
408  // Histograms per event shouldbe done only once, so keep track of them
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;
414 
415  // Central W->mu nu selection criteria
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) {
420  muon_sel[j] = false;
421  }
422 
423  const Muon& mu = muonCollection->at(i);
424  if (!mu.isGlobalMuon()) continue;
425  if (mu.globalTrack().isNull()) continue;
426  if (mu.innerTrack().isNull()) continue;
427 
428  LogTrace("") << "> Wsel: processing muon number " << i << "...";
429  reco::TrackRef gm = mu.globalTrack();
430  //reco::TrackRef tk = mu.innerTrack();
431 
432  // Pt,eta cuts
433  double pt = mu.pt();
434  double eta = mu.eta();
435  LogTrace("") << "\t... pt, eta: " << pt << " [GeV], " << eta;;
436  if (pt>ptCut_) muon_sel[0] = true;
437  else if (fastOption_) continue;
438  if (fabs(eta)<etaCut_) muon_sel[1] = true;
439  else if (fastOption_) continue;
440 
441  // d0, chi2, nhits quality cuts
442  double dxy = gm->dxy(beamSpotHandle->position());
443  double normalizedChi2 = gm->normalizedChi2();
444  double validmuonhits=gm->hitPattern().numberOfValidMuonHits();
445  //double standalonehits=mu.outerTrack()->numberOfValidHits();
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;
449  else if (fastOption_) continue;
450  if (muon::isGoodMuon(mu,muon::GlobalMuonPromptTight)) muon_sel[3] = true;
451  else if (fastOption_) continue;
452  if (trackerHits>=trackerHitsCut_) muon_sel[4] = true;
453  else if (fastOption_) continue;
454  if (mu.isTrackerMuon()) muon_sel[5] = true;
455  else if (fastOption_) continue;
456 
457  fill_histogram("PT_BEFORECUTS",pt);
458  fill_histogram("ETA_BEFORECUTS",eta);
459  fill_histogram("DXY_BEFORECUTS",dxy);
460  fill_histogram("CHI2_BEFORECUTS",normalizedChi2);
461  fill_histogram("NHITS_BEFORECUTS",trackerHits);
462  fill_histogram("ValidMuonHits_BEFORECUTS",validmuonhits);
463  fill_histogram("TKMU_BEFORECUTS",mu.isTrackerMuon());
464 
465  // Isolation cuts
466  double isovar = mu.isolationR03().sumPt;
467  if (isCombinedIso_) {
468  isovar += mu.isolationR03().emEt;
469  isovar += mu.isolationR03().hadEt;
470  }
471  if (isRelativeIso_) isovar /= pt;
472  if (isovar<isoCut03_) muon_sel[6] = true;
473  else if (fastOption_) continue;
474  LogTrace("") << "\t... isolation value" << isovar <<", isolated? " << muon_sel[6];
475  fill_histogram("ISO_BEFORECUTS",isovar);
476 
477  // HLT (not mtched to muon for the time being)
478  if (trigger_fired) muon_sel[7] = true;
479  else if (fastOption_) continue;
480 
481  // MET/MT cuts
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;
487 
488  LogTrace("") << "\t... W mass, W_et, W_px, W_py: " << massT << ", " << w_et << ", " << w_px << ", " << w_py << " [GeV]";
489  if (massT>mtMin_ && massT<mtMax_) muon_sel[8] = true;
490  else if (fastOption_) continue;
491  fill_histogram("MT_BEFORECUTS",massT);
492  if (met_et>metMin_ && met_et<metMax_) muon_sel[9] = true;
493  else if (fastOption_) continue;
494 
495  // Acoplanarity cuts
496  Geom::Phi<double> deltaphi(mu.phi()-atan2(met_py,met_px));
497  double acop = deltaphi.value();
498  if (acop<0) acop = - acop;
499  acop = M_PI - acop;
500  LogTrace("") << "\t... acoplanarity: " << acop;
501  if (acop<acopCut_) muon_sel[10] = true;
502  else if (fastOption_) continue;
503  fill_histogram("ACOP_BEFORECUTS",acop);
504 
505  // Remaining flags (from global event information)
506  if (nmuonsForZ1<1 || nmuonsForZ2<2) muon_sel[11] = true;
507  else if (fastOption_) continue;
508  if (njets<=nJetMax_) muon_sel[12] = true;
509  else if (fastOption_) continue;
510 
511  if (fastOption_) {
512  all_sel = true;
513  break;
514  } else {
515  // Collect necessary flags "per muon"
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;
529  }
530 
531  // "rec" => pt,eta and quality cuts are satisfied
532  if (rec_sel_this) rec_sel = true;
533  // "iso" => "rec" AND "muon is isolated"
534  if (iso_sel_this) iso_sel = true;
535  // "hlt" => "iso" AND "event is triggered"
536  if (hlt_sel_this) hlt_sel = true;
537  // "met" => "hlt" AND "MET/MT and acoplanarity cuts"
538  if (met_sel_this) met_sel = true;
539  // "all" => "met" AND "Z/top rejection cuts"
540  if (all_sel_this) all_sel = true;
541 
542  // Do N-1 histograms now (and only once for global event quantities)
543  if (flags_passed >= (NFLAGS-1)) {
544  if (!muon_sel[0] || flags_passed==NFLAGS)
545  fill_histogram("PT_LASTCUT",pt);
546  if (!muon_sel[1] || flags_passed==NFLAGS)
547  fill_histogram("ETA_LASTCUT",eta);
548  if (!muon_sel[2] || flags_passed==NFLAGS)
549  fill_histogram("DXY_LASTCUT",dxy);
550  if (!muon_sel[3] || flags_passed==NFLAGS) {
551  fill_histogram("CHI2_LASTCUT",normalizedChi2);
552  fill_histogram("ValidMuonHits_LASTCUT",validmuonhits); }
553  if (!muon_sel[4] || flags_passed==NFLAGS)
554  fill_histogram("NHITS_LASTCUT",trackerHits);
555  if (!muon_sel[5] || flags_passed==NFLAGS)
556  fill_histogram("TKMU_LASTCUT",mu.isTrackerMuon());
557  if (!muon_sel[6] || flags_passed==NFLAGS)
558  fill_histogram("ISO_LASTCUT",isovar);
559  if (!muon_sel[7] || flags_passed==NFLAGS) {
560  if (!hlt_hist_done) { fill_histogram("TRIG_LASTCUT",trigger_fired);
561  hlt_hist_done = true;}
562  }
563  if (!muon_sel[8] || flags_passed==NFLAGS)
564  fill_histogram("MT_LASTCUT",massT);
565  if (!muon_sel[9] || flags_passed==NFLAGS) {
566  if (!met_hist_done) { fill_histogram("MET_LASTCUT",met_et);
567  met_hist_done = true;}
568  }
569  if (!muon_sel[10] || flags_passed==NFLAGS)
570  fill_histogram("ACOP_LASTCUT",acop);
571  if (!muon_sel[11] || flags_passed==NFLAGS) {
572  if (!nz1_hist_done) { fill_histogram("NZ1_LASTCUT",nmuonsForZ1);
573  nz1_hist_done = true;}
574  }
575  if (!muon_sel[11] || flags_passed==NFLAGS) {
576  if (!nz2_hist_done) { fill_histogram("NZ2_LASTCUT",nmuonsForZ2);
577  nz2_hist_done = true; }
578  }
579  if (!muon_sel[12] || flags_passed==NFLAGS) {
580  if (!njets_hist_done) { fill_histogram("NJETS_LASTCUT",njets);
581  njets_hist_done = true;}
582  }
583  }
584  }
585 
586  }
587 
588  // Collect final flags
589  if (!fastOption_) {
590  if (rec_sel) nrec++;
591  if (iso_sel) niso++;
592  if (hlt_sel) nhlt++;
593  if (met_sel) nmet++;
594  }
595 
596  if (all_sel) {
597  nsel++;
598  LogTrace("") << ">>>> Event ACCEPTED";
599  } else {
600  LogTrace("") << ">>>> Event REJECTED";
601  }
602 
603  return all_sel;
604 
605 }
unsigned int nsel
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:9
double eta() const final
momentum pseudorapidity
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:7
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
double px() const final
x coordinate of momentum vector
bool accept() const
Has at least one path accepted the event?
double pt() const final
transverse momentum
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
unsigned int niso
bool isTrackerMuon() const override
Definition: Muon.h:269
unsigned int nrec
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
Definition: Muon.py:1
Definition: Jet.py:1
double et() const final
transverse energy
bool isGlobalMuon() const override
Definition: Muon.h:268
Definition: MET.h:42
T sqrt(T t)
Definition: SSEVec.h:18
float emEt
ecal sum-Et
Definition: MuonIsolation.h:8
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
const int mu
Definition: Constants.h:22
unsigned int nhlt
static std::string const triggerResults
Definition: EdmProvDump.cc:41
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
bool isNull() const
Checks for null.
Definition: Ref.h:250
#define LogTrace(id)
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
#define M_PI
T value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:38
edm::EDGetTokenT< edm::TriggerResults > trigToken_
met
===> hadronic RAZOR
double py() const final
y coordinate of momentum vector
unsigned int nmet
void fill_histogram(const char *, const double &)
const Point & position() const
position
Definition: BeamSpot.h:62
const std::string muonTrig_
double phi() const final
momentum azimuthal angle
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:301
unsigned int nall
const MuonIsolation & isolationR03() const
Definition: Muon.h:162
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:54
void WMuNuValidator::init_histograms ( )

Definition at line 153 of file WMuNuValidator.cc.

References data, eJetMin_, h1_, mps_fire::i, isCombinedIso_, isRelativeIso_, jetTag_, edm::InputTag::label(), M_PI, TFileDirectory::make(), metTag_, TFileService::mkdir(), muonTrig_, ptThrForZ1_, ptThrForZ2_, AlCaHLTBitMon_QueryRunRegistry::string, and muonValidation_cff::subDir.

Referenced by beginJob().

153  {
155  TFileDirectory subDir0 = fs->mkdir("BeforeCuts");
156  TFileDirectory subDir1 = fs->mkdir("LastCut");
157  TFileDirectory* subDir[2]; subDir[0] = &subDir0; subDir[1] = &subDir1;
158 
159  char chname[256] = "";
160  char chtitle[256] = "";
161  std::string chsuffix[2] = { "_BEFORECUTS", "_LASTCUT" };
162 
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.);
167 
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);
171 
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);
175 
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.);
179 
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);
183 
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);
187 
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);
191 
192  snprintf(chname, 255, "ISO%s", chsuffix[i].data());
193  if (isRelativeIso_) {
194  if (isCombinedIso_) {
195  snprintf(chtitle, 255, "Relative (combined) isolation variable");
196  } else {
197  snprintf(chtitle, 255, "Relative (tracker) isolation variable");
198  }
199  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle, 100, 0., 1.);
200  } else {
201  if (isCombinedIso_) {
202  snprintf(chtitle, 255, "Absolute (combined) isolation variable [GeV]");
203  } else {
204  snprintf(chtitle, 255, "Absolute (tracker) isolation variable [GeV]");
205  }
206  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle, 100, 0., 20.);
207  }
208 
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);
212 
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.);
216 
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.);
220 
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);
224 
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);
228 
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);
232 
233  snprintf(chname, 255, "NJETS%s", chsuffix[i].data());
234  snprintf(chtitle, 255, "Number of jets (%s) above %.2f GeV", jetTag_.label().data(), eJetMin_);
235  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,10,-0.5,9.5);
236 
237  }
238 }
std::map< std::string, TH1D * > h1_
edm::InputTag metTag_
T * make(const Args &...args) const
make new ROOT object
#define M_PI
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
edm::InputTag jetTag_
std::string const & label() const
Definition: InputTag.h:36
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const std::string muonTrig_

Member Data Documentation

double WMuNuValidator::acopCut_
private

Definition at line 54 of file WMuNuValidator.cc.

Referenced by filter().

edm::EDGetTokenT<reco::BeamSpot> WMuNuValidator::beamSpotToken_
private

Definition at line 43 of file WMuNuValidator.cc.

Referenced by filter().

double WMuNuValidator::dxyCut_
private

Definition at line 56 of file WMuNuValidator.cc.

Referenced by filter().

double WMuNuValidator::eJetMin_
private

Definition at line 64 of file WMuNuValidator.cc.

Referenced by filter(), and init_histograms().

double WMuNuValidator::etaCut_
private

Definition at line 46 of file WMuNuValidator.cc.

Referenced by filter().

bool WMuNuValidator::fastOption_
private

Definition at line 35 of file WMuNuValidator.cc.

Referenced by beginJob(), endJob(), fill_histogram(), and filter().

std::map<std::string,TH1D*> WMuNuValidator::h1_
private

Definition at line 74 of file WMuNuValidator.cc.

Referenced by fill_histogram(), and init_histograms().

bool WMuNuValidator::isAlsoTrackerMuon_
private

Definition at line 59 of file WMuNuValidator.cc.

bool WMuNuValidator::isCombinedIso_
private

Definition at line 48 of file WMuNuValidator.cc.

Referenced by filter(), and init_histograms().

double WMuNuValidator::isoCut03_
private

Definition at line 49 of file WMuNuValidator.cc.

Referenced by filter().

bool WMuNuValidator::isRelativeIso_
private

Definition at line 47 of file WMuNuValidator.cc.

Referenced by filter(), and init_histograms().

edm::InputTag WMuNuValidator::jetTag_
private

Definition at line 41 of file WMuNuValidator.cc.

Referenced by init_histograms().

edm::EDGetTokenT<edm::View<reco::Jet> > WMuNuValidator::jetToken_
private

Definition at line 42 of file WMuNuValidator.cc.

Referenced by filter().

bool WMuNuValidator::metIncludesMuons_
private

Definition at line 40 of file WMuNuValidator.cc.

Referenced by filter().

double WMuNuValidator::metMax_
private

Definition at line 53 of file WMuNuValidator.cc.

Referenced by filter().

double WMuNuValidator::metMin_
private

Definition at line 52 of file WMuNuValidator.cc.

Referenced by filter().

edm::InputTag WMuNuValidator::metTag_
private

Definition at line 38 of file WMuNuValidator.cc.

Referenced by init_histograms().

edm::EDGetTokenT<edm::View<reco::MET> > WMuNuValidator::metToken_
private

Definition at line 39 of file WMuNuValidator.cc.

Referenced by filter().

double WMuNuValidator::mtMax_
private

Definition at line 51 of file WMuNuValidator.cc.

Referenced by filter().

double WMuNuValidator::mtMin_
private

Definition at line 50 of file WMuNuValidator.cc.

Referenced by filter().

edm::EDGetTokenT<edm::View<reco::Muon> > WMuNuValidator::muonToken_
private

Definition at line 37 of file WMuNuValidator.cc.

Referenced by filter().

const std::string WMuNuValidator::muonTrig_
private

Definition at line 44 of file WMuNuValidator.cc.

Referenced by filter(), and init_histograms().

unsigned int WMuNuValidator::nall
private

Definition at line 67 of file WMuNuValidator.cc.

Referenced by beginJob(), endJob(), and filter().

unsigned int WMuNuValidator::nhlt
private

Definition at line 70 of file WMuNuValidator.cc.

Referenced by beginJob(), endJob(), and filter().

unsigned int WMuNuValidator::niso
private

Definition at line 69 of file WMuNuValidator.cc.

Referenced by beginJob(), endJob(), and filter().

int WMuNuValidator::nJetMax_
private

Definition at line 65 of file WMuNuValidator.cc.

Referenced by filter().

unsigned int WMuNuValidator::nmet
private

Definition at line 71 of file WMuNuValidator.cc.

Referenced by beginJob(), endJob(), and filter().

double WMuNuValidator::normalizedChi2Cut_
private

Definition at line 57 of file WMuNuValidator.cc.

unsigned int WMuNuValidator::nrec
private

Definition at line 68 of file WMuNuValidator.cc.

Referenced by beginJob(), endJob(), and filter().

unsigned int WMuNuValidator::nsel
private

Definition at line 72 of file WMuNuValidator.cc.

Referenced by beginJob(), endJob(), and filter().

double WMuNuValidator::ptCut_
private
double WMuNuValidator::ptThrForZ1_
private

Definition at line 61 of file WMuNuValidator.cc.

Referenced by filter(), and init_histograms().

double WMuNuValidator::ptThrForZ2_
private

Definition at line 62 of file WMuNuValidator.cc.

Referenced by filter(), and init_histograms().

int WMuNuValidator::trackerHitsCut_
private

Definition at line 58 of file WMuNuValidator.cc.

Referenced by filter().

edm::EDGetTokenT<edm::TriggerResults> WMuNuValidator::trigToken_
private

Definition at line 36 of file WMuNuValidator.cc.

Referenced by filter().