CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
HLTDQMMuonSelector Class Reference
Inheritance diagram for HLTDQMMuonSelector:
edm::stream::EDProducer<>

Public Member Functions

 HLTDQMMuonSelector (const edm::ParameterSet &config)
 
void produce (edm::Event &, edm::EventSetup const &) override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

enum  MuonSelectionType {
  MuonSelectionType::Tight, MuonSelectionType::Medium, MuonSelectionType::Loose, MuonSelectionType::Soft,
  MuonSelectionType::HighPt, MuonSelectionType::None
}
 

Private Member Functions

bool passMuonSel (const reco::Muon &muon, const reco::Vertex &vertex) const
 

Static Private Member Functions

static MuonSelectionType convertToEnum (const std::string &val)
 

Private Attributes

MuonSelectionType muonSelType_
 
edm::EDGetTokenT< reco::MuonCollectionmuonToken_
 
StringCutObjectSelector< reco::Muon, true > selection_
 
edm::EDGetTokenT< reco::VertexCollectionvtxToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 17 of file HLTDQMMuonSelector.cc.

Member Enumeration Documentation

◆ MuonSelectionType

Enumerator
Tight 
Medium 
Loose 
Soft 
HighPt 
None 

Definition at line 24 of file HLTDQMMuonSelector.cc.

24 { Tight, Medium, Loose, Soft, HighPt, None };

Constructor & Destructor Documentation

◆ HLTDQMMuonSelector()

HLTDQMMuonSelector::HLTDQMMuonSelector ( const edm::ParameterSet config)
explicit

Definition at line 36 of file HLTDQMMuonSelector.cc.

37  : muonToken_(consumes<reco::MuonCollection>(config.getParameter<edm::InputTag>("objs"))),
38  vtxToken_(consumes<reco::VertexCollection>(config.getParameter<edm::InputTag>("vertices"))),
39  selection_(config.getParameter<std::string>("selection")),
40  muonSelType_(convertToEnum(config.getParameter<std::string>("muonSelectionType"))) {
41  produces<edm::ValueMap<bool> >();
42 }
static MuonSelectionType convertToEnum(const std::string &val)
MuonSelectionType muonSelType_
Definition: config.py:1
StringCutObjectSelector< reco::Muon, true > selection_
edm::EDGetTokenT< reco::MuonCollection > muonToken_
edm::EDGetTokenT< reco::VertexCollection > vtxToken_

Member Function Documentation

◆ convertToEnum()

HLTDQMMuonSelector::MuonSelectionType HLTDQMMuonSelector::convertToEnum ( const std::string &  val)
staticprivate

Definition at line 78 of file HLTDQMMuonSelector.cc.

References Exception, HighPt, Loose, Medium, None, Soft, Tight, and heppy_batch::val.

78  {
79  const std::vector<std::pair<std::string, MuonSelectionType> > strsToEnums = {{"tight", MuonSelectionType::Tight},
80  {"medium", MuonSelectionType::Medium},
81  {"loose", MuonSelectionType::Loose},
82  {"soft", MuonSelectionType::Soft},
83  {"highpt", MuonSelectionType::HighPt},
84  {"none", MuonSelectionType::None}};
85  for (const auto& strEnumPair : strsToEnums) {
86  if (val == strEnumPair.first)
87  return strEnumPair.second;
88  }
89  std::ostringstream validEnums;
90  for (const auto& strEnumPair : strsToEnums)
91  validEnums << strEnumPair.first << " ";
92  throw cms::Exception("InvalidConfig") << "invalid muonSelectionType " << val << ", allowed values are "
93  << validEnums.str();
94 }

◆ fillDescriptions()

void HLTDQMMuonSelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 44 of file HLTDQMMuonSelector.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, HLT_2022v15_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

44  {
46  desc.add<edm::InputTag>("objs", edm::InputTag("muons"));
47  desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
48  desc.add<std::string>("selection", "et > 5");
49  desc.add<std::string>("muonSelectionType", "tight");
50  descriptions.add("hltDQMMuonSelector", desc);
51 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ passMuonSel()

bool HLTDQMMuonSelector::passMuonSel ( const reco::Muon muon,
const reco::Vertex vertex 
) const
private

Definition at line 96 of file HLTDQMMuonSelector.cc.

References HighPt, muon::isHighPtMuon(), muon::isLooseMuon(), muon::isMediumMuon(), muon::isSoftMuon(), muon::isTightMuon(), Loose, Medium, muonSelType_, None, Soft, Tight, and bphysicsOniaDQM_cfi::vertex.

Referenced by produce().

96  {
97  switch (muonSelType_) {
99  return muon::isTightMuon(muon, vertex);
101  return muon::isMediumMuon(muon);
103  return muon::isLooseMuon(muon);
105  return muon::isSoftMuon(muon, vertex);
107  return muon::isHighPtMuon(muon, vertex);
109  return true;
110  default:
111  edm::LogError("HLTDQMMuonSelector") << " inconsistent code, an option has been added to MuonSelectionType "
112  "without updating HLTDQMMuonSelector::passMuonSel";
113  return false;
114  }
115 }
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
MuonSelectionType muonSelType_
Log< level::Error, false > LogError
bool isLooseMuon(const reco::Muon &)
bool isSoftMuon(const reco::Muon &, const reco::Vertex &, bool run2016_hip_mitigation=false)
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)

◆ produce()

void HLTDQMMuonSelector::produce ( edm::Event event,
edm::EventSetup const &  setup 
)
override

Definition at line 53 of file HLTDQMMuonSelector.cc.

References trigObjTnPSource_cfi::filler, edm::HandleBase::isValid(), eostools::move(), muonToken_, passMuonSel(), selection_, and vtxToken_.

53  {
55  event.getByToken(muonToken_, muonHandle);
56 
58  event.getByToken(vtxToken_, vtxHandle);
59 
60  if (!muonHandle.isValid())
61  return;
62 
63  std::vector<bool> selResults;
64  for (auto& muon : *muonHandle) {
65  if (vtxHandle.isValid() && !vtxHandle->empty()) {
66  selResults.push_back(passMuonSel(muon, vtxHandle->front()) && selection_(muon));
67  } else {
68  selResults.push_back(false);
69  }
70  }
71  auto valMap = std::make_unique<edm::ValueMap<bool> >();
73  filler.insert(muonHandle, selResults.begin(), selResults.end());
74  filler.fill();
75  event.put(std::move(valMap));
76 }
StringCutObjectSelector< reco::Muon, true > selection_
edm::EDGetTokenT< reco::MuonCollection > muonToken_
bool isValid() const
Definition: HandleBase.h:70
bool passMuonSel(const reco::Muon &muon, const reco::Vertex &vertex) const
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ muonSelType_

MuonSelectionType HLTDQMMuonSelector::muonSelType_
private

Definition at line 33 of file HLTDQMMuonSelector.cc.

Referenced by passMuonSel().

◆ muonToken_

edm::EDGetTokenT<reco::MuonCollection> HLTDQMMuonSelector::muonToken_
private

Definition at line 29 of file HLTDQMMuonSelector.cc.

Referenced by produce().

◆ selection_

StringCutObjectSelector<reco::Muon, true> HLTDQMMuonSelector::selection_
private

Definition at line 31 of file HLTDQMMuonSelector.cc.

Referenced by produce().

◆ vtxToken_

edm::EDGetTokenT<reco::VertexCollection> HLTDQMMuonSelector::vtxToken_
private

Definition at line 30 of file HLTDQMMuonSelector.cc.

Referenced by produce().