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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 17 of file HLTDQMMuonSelector.cc.

Member Enumeration Documentation

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 ( 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)
T getParameter(std::string const &) const
MuonSelectionType muonSelType_
StringCutObjectSelector< reco::Muon, true > selection_
edm::EDGetTokenT< reco::MuonCollection > muonToken_
edm::EDGetTokenT< reco::VertexCollection > vtxToken_

Member Function Documentation

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

Definition at line 78 of file HLTDQMMuonSelector.cc.

References Exception, HighPt, Loose, Medium, None, Soft, and Tight.

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 }
void HLTDQMMuonSelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 44 of file HLTDQMMuonSelector.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_2018_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 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool HLTDQMMuonSelector::passMuonSel ( const reco::Muon muon,
const reco::Vertex vertex 
) const
private

Definition at line 96 of file HLTDQMMuonSelector.cc.

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

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_
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 &)
void HLTDQMMuonSelector::produce ( edm::Event ,
edm::EventSetup const &   
)
override

Definition at line 53 of file HLTDQMMuonSelector.cc.

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

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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 }
bool isValid() const
Definition: HandleBase.h:70
StringCutObjectSelector< reco::Muon, true > selection_
edm::EDGetTokenT< reco::MuonCollection > muonToken_
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

MuonSelectionType HLTDQMMuonSelector::muonSelType_
private

Definition at line 33 of file HLTDQMMuonSelector.cc.

Referenced by passMuonSel().

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

Definition at line 29 of file HLTDQMMuonSelector.cc.

Referenced by produce().

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

Definition at line 31 of file HLTDQMMuonSelector.cc.

Referenced by produce().

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

Definition at line 30 of file HLTDQMMuonSelector.cc.

Referenced by produce().