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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 18 of file HLTDQMMuonSelector.cc.

Member Enumeration Documentation

Enumerator
Tight 
Medium 
Loose 
Soft 
HighPt 
None 

Definition at line 25 of file HLTDQMMuonSelector.cc.

25  {
26  Tight,Medium,Loose,Soft,HighPt,None
27  };

Constructor & Destructor Documentation

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

Definition at line 43 of file HLTDQMMuonSelector.cc.

43  :
44  muonToken_(consumes<reco::MuonCollection>(config.getParameter<edm::InputTag>("objs"))),
45  vtxToken_(consumes<reco::VertexCollection>(config.getParameter<edm::InputTag>("vertices"))),
46  selection_(config.getParameter<std::string>("selection")),
47  muonSelType_(convertToEnum(config.getParameter<std::string>("muonSelectionType")))
48 {
49  produces<edm::ValueMap<bool> >();
50 }
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 88 of file HLTDQMMuonSelector.cc.

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

89 {
90  const std::vector<std::pair<std::string,MuonSelectionType> > strsToEnums = {
91  {"tight",MuonSelectionType::Tight},
92  {"medium",MuonSelectionType::Medium},
93  {"loose",MuonSelectionType::Loose},
94  {"soft",MuonSelectionType::Soft},
95  {"highpt",MuonSelectionType::HighPt},
97  };
98  for(const auto& strEnumPair : strsToEnums){
99  if(val==strEnumPair.first) return strEnumPair.second;
100  }
101  std::ostringstream validEnums;
102  for(const auto& strEnumPair : strsToEnums) validEnums <<strEnumPair.first<<" ";
103  throw cms::Exception("InvalidConfig") << "invalid muonSelectionType "<<val<<", allowed values are "<<validEnums.str();
104 }
void HLTDQMMuonSelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 52 of file HLTDQMMuonSelector.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

53 {
55  desc.add<edm::InputTag>("objs", edm::InputTag("muons"));
56  desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
57  desc.add<std::string>("selection","et > 5");
58  desc.add<std::string>("muonSelectionType","tight");
59  descriptions.add("hltDQMMuonSelector", desc);
60 }
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 106 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().

107 {
108  switch(muonSelType_){
110  return muon::isTightMuon(muon,vertex);
112  return muon::isMediumMuon(muon);
114  return muon::isLooseMuon(muon);
116  return muon::isSoftMuon(muon,vertex);
118  return muon::isHighPtMuon(muon,vertex);
120  return true;
121  default:
122  edm::LogError("HLTDQMMuonSelector")<<" inconsistent code, an option has been added to MuonSelectionType without updating HLTDQMMuonSelector::passMuonSel";
123  return false;
124  }
125 
126 }
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 63 of file HLTDQMMuonSelector.cc.

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

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

64 {
66  event.getByToken(muonToken_,muonHandle);
67 
69  event.getByToken(vtxToken_,vtxHandle);
70 
71  if(!muonHandle.isValid()) return;
72 
73  std::vector<bool> selResults;
74  for(auto& muon : *muonHandle){
75  if(vtxHandle.isValid() && !vtxHandle->empty()){
76  selResults.push_back(passMuonSel(muon,vtxHandle->front()) && selection_(muon));
77  }else{
78  selResults.push_back(false);
79  }
80  }
81  auto valMap = std::make_unique<edm::ValueMap<bool> >();
83  filler.insert(muonHandle, selResults.begin(), selResults.end());
84  filler.fill();
85  event.put(std::move(valMap));
86 }
StringCutObjectSelector< reco::Muon, true > selection_
bool isValid() const
Definition: HandleBase.h:74
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:510

Member Data Documentation

MuonSelectionType HLTDQMMuonSelector::muonSelType_
private

Definition at line 37 of file HLTDQMMuonSelector.cc.

Referenced by passMuonSel().

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

Definition at line 33 of file HLTDQMMuonSelector.cc.

Referenced by produce().

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

Definition at line 35 of file HLTDQMMuonSelector.cc.

Referenced by produce().

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

Definition at line 34 of file HLTDQMMuonSelector.cc.

Referenced by produce().