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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 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 }
MuonSelectionType muonSelType_
bool isMediumMuon(const reco::Muon &)
bool isLooseMuon(const reco::Muon &)
bool isSoftMuon(const reco::Muon &, const reco::Vertex &)
bool isHighPtMuon(const reco::Muon &, const reco::Vertex &)
bool isTightMuon(const reco::Muon &, const reco::Vertex &)
void HLTDQMMuonSelector::produce ( edm::Event ,
edm::EventSetup const &   
)
overridevirtual

Implements edm::stream::EDProducerBase.

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().