CMS 3D CMS Logo

HLTDQMMuonSelector.cc
Go to the documentation of this file.
16 
18 public:
20  void produce(edm::Event&, edm::EventSetup const&) override;
21  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
22 
23 private:
25 
27  bool passMuonSel(const reco::Muon& muon, const reco::Vertex& vertex) const;
28 
32 
34 };
35 
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 }
43 
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 }
52 
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 }
77 
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 }
95 
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 }
116 
ConfigurationDescriptions.h
HLTDQMMuonSelector::vtxToken_
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
Definition: HLTDQMMuonSelector.cc:30
Muon.h
MessageLogger.h
HLTDQMMuonSelector::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTDQMMuonSelector.cc:44
muon::isSoftMuon
bool isSoftMuon(const reco::Muon &, const reco::Vertex &, bool run2016_hip_mitigation=false)
Definition: MuonSelectors.cc:916
muon
Definition: MuonCocktails.h:17
edm::EDGetTokenT< reco::MuonCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTDQMMuonSelector
Definition: HLTDQMMuonSelector.cc:17
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HLTDQMMuonSelector::MuonSelectionType::Medium
HLTDQMMuonSelector::HLTDQMMuonSelector
HLTDQMMuonSelector(const edm::ParameterSet &config)
Definition: HLTDQMMuonSelector.cc:36
EDProducer.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::MuonCollection >
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
reco::Muon
Definition: Muon.h:27
config
Definition: config.py:1
MakerMacros.h
HLTDQMMuonSelector::MuonSelectionType::Soft
muon::isLooseMuon
bool isLooseMuon(const reco::Muon &)
Definition: MuonSelectors.cc:895
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HLTDQMMuonSelector::passMuonSel
bool passMuonSel(const reco::Muon &muon, const reco::Vertex &vertex) const
Definition: HLTDQMMuonSelector.cc:96
MuonSelectors.h
HLTDQMMuonSelector::MuonSelectionType::HighPt
MuonFwd.h
reco::MuonCollection
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
ParameterSetDescription.h
EDGetToken.h
HLTDQMMuonSelector::MuonSelectionType::Tight
HLTDQMMuonSelector::muonToken_
edm::EDGetTokenT< reco::MuonCollection > muonToken_
Definition: HLTDQMMuonSelector.cc:29
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
muon::isHighPtMuon
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
Definition: MuonSelectors.cc:933
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
muon::isTightMuon
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
Definition: MuonSelectors.cc:880
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
HLTDQMMuonSelector::muonSelType_
MuonSelectionType muonSelType_
Definition: HLTDQMMuonSelector.cc:33
HLTDQMMuonSelector::MuonSelectionType::Loose
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
muon::isMediumMuon
bool isMediumMuon(const reco::Muon &, bool run2016_hip_mitigation=false)
Definition: MuonSelectors.cc:899
HLTDQMMuonSelector::MuonSelectionType::None
ValueMap.h
VertexFwd.h
HLTDQMMuonSelector::convertToEnum
static MuonSelectionType convertToEnum(const std::string &val)
Definition: HLTDQMMuonSelector.cc:78
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
heppy_batch.val
val
Definition: heppy_batch.py:351
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
StringCutObjectSelector.h
StringCutObjectSelector< reco::Muon, true >
Exception
Definition: hltDiff.cc:246
EventSetup.h
HLTDQMMuonSelector::selection_
StringCutObjectSelector< reco::Muon, true > selection_
Definition: HLTDQMMuonSelector.cc:31
HLTDQMMuonSelector::produce
void produce(edm::Event &, edm::EventSetup const &) override
Definition: HLTDQMMuonSelector.cc:53
HLTDQMMuonSelector::MuonSelectionType
MuonSelectionType
Definition: HLTDQMMuonSelector.cc:24
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35