CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
PFTauDecayModeCutMultiplexer Class Reference
Inheritance diagram for PFTauDecayModeCutMultiplexer:
TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType > edm::stream::EDProducer<>

Classes

struct  ComputerAndCut
 

Public Types

typedef std::vector< ComputerAndCutCutList
 
typedef std::map< int, CutList::iterator > DecayModeToCutMap
 
- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd< TauCollectionTauRefProd
 
- 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 Member Functions

void beginEvent (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
double discriminate (const PFTauRef &thePFTau) const override
 
 PFTauDecayModeCutMultiplexer (const edm::ParameterSet &)
 
 ~PFTauDecayModeCutMultiplexer () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
virtual TauDiscriminatorDataType discriminate (const TauRef &tau) const =0
 
virtual void endEvent (edm::Event &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 TauDiscriminationProducerBase ()
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 ~TauDiscriminationProducerBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
static void fillProducerDescriptions (edm::ParameterSetDescription &desc)
 
static std::string getTauTypeString ()
 helper method to retrieve tau type name, e.g. to build correct cfi getter More...
 

Private Attributes

DecayModeToCutMap computerMap_
 
CutList computers_
 
edm::EDGetTokenT< PFTauDiscriminatordiscriminant_token
 
edm::InputTag discriminantToMultiplex_
 
edm::EDGetTokenT< PFTauDiscriminatorpfTauDecayModeIndex_token
 
edm::InputTag pfTauDecayModeIndexSrc_
 
edm::Handle< PFTauDiscriminatorpfTauDecayModeIndices
 
edm::Handle< PFTauDiscriminatortargetDiscriminant
 

Additional Inherited Members

- Protected Attributes inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >
std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::EDGetTokenT< TauCollectionTau_token
 
size_t tauIndex_
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 33 of file PFTauDecayModeCutMultiplexer.cc.

Member Typedef Documentation

◆ CutList

Definition at line 43 of file PFTauDecayModeCutMultiplexer.cc.

◆ DecayModeToCutMap

typedef std::map<int, CutList::iterator> PFTauDecayModeCutMultiplexer::DecayModeToCutMap

Definition at line 44 of file PFTauDecayModeCutMultiplexer.cc.

Constructor & Destructor Documentation

◆ PFTauDecayModeCutMultiplexer()

PFTauDecayModeCutMultiplexer::PFTauDecayModeCutMultiplexer ( const edm::ParameterSet iConfig)
explicit

Definition at line 69 of file PFTauDecayModeCutMultiplexer.cc.

71  pfTauDecayModeIndexSrc_ = iConfig.getParameter<edm::InputTag>("PFTauDecayModeSrc");
72  discriminantToMultiplex_ = iConfig.getParameter<edm::InputTag>("PFTauDiscriminantToMultiplex");
73  pfTauDecayModeIndex_token = consumes<PFTauDiscriminator>(pfTauDecayModeIndexSrc_);
74  discriminant_token = consumes<PFTauDiscriminator>(discriminantToMultiplex_);
75  //get the computer/decay mode map
76  std::vector<edm::ParameterSet> decayModeMap = iConfig.getParameter<std::vector<edm::ParameterSet> >("computers");
77  computers_.reserve(decayModeMap.size());
78 
79  // for each decay mode MVA implementation (which may correspond to multiple decay modes, map the decay modes to the correct MVA computer
80  for (std::vector<edm::ParameterSet>::const_iterator iComputer = decayModeMap.begin(); iComputer != decayModeMap.end();
81  ++iComputer) {
82  ComputerAndCut toInsert;
83  toInsert.computerName = iComputer->getParameter<std::string>("computerName");
84  toInsert.userCut = iComputer->getParameter<double>("cut");
85  CutList::iterator computerJustAdded =
86  computers_.insert(computers_.end(), toInsert); //add this computer to the end of the list
87 
88  //populate the map
89  std::vector<int> associatedDecayModes = iComputer->getParameter<std::vector<int> >("decayModeIndices");
90  for (std::vector<int>::const_iterator iDecayMode = associatedDecayModes.begin();
91  iDecayMode != associatedDecayModes.end();
92  ++iDecayMode) {
93  //map this integer specifying the decay mode to the MVA comptuer we just added to the list
94  std::pair<DecayModeToCutMap::iterator, bool> insertResult =
95  computerMap_.insert(std::make_pair(*iDecayMode, computerJustAdded));
96 
97  //make sure we aren't double mapping a decay mode
98  if (insertResult.second == false) { //indicates that the current key (decaymode) has already been entered!
99  throw cms::Exception("PFTauDecayModeCutMultiplexer::ctor")
100  << "A tau decay mode: " << *iDecayMode << " has been mapped to two different MVA implementations, "
101  << insertResult.first->second->computerName << " and " << toInsert.computerName
102  << ". Please check the appropriate cfi file." << std::endl;
103  }
104  }
105  }
106 }

References computerMap_, PFTauDecayModeCutMultiplexer::ComputerAndCut::computerName, computers_, discriminant_token, discriminantToMultiplex_, Exception, edm::ParameterSet::getParameter(), pfTauDecayModeIndex_token, pfTauDecayModeIndexSrc_, AlCaHLTBitMon_QueryRunRegistry::string, and PFTauDecayModeCutMultiplexer::ComputerAndCut::userCut.

◆ ~PFTauDecayModeCutMultiplexer()

PFTauDecayModeCutMultiplexer::~PFTauDecayModeCutMultiplexer ( )
inlineoverride

Definition at line 36 of file PFTauDecayModeCutMultiplexer.cc.

36 {}

Member Function Documentation

◆ beginEvent()

void PFTauDecayModeCutMultiplexer::beginEvent ( const edm::Event event,
const edm::EventSetup eventSetup 
)
overridevirtual

◆ discriminate()

double PFTauDecayModeCutMultiplexer::discriminate ( const PFTauRef thePFTau) const
override

Definition at line 114 of file PFTauDecayModeCutMultiplexer.cc.

114  {
115  // get decay mode for current tau
116  int decayMode = lrint((*pfTauDecayModeIndices)[pfTau]); //convert to int
117 
118  // get value we are trying to multiplex
119  float valueToMultiplex = (*targetDiscriminant)[pfTau];
120 
121  // Get correct cut
122  auto iterToComputer = computerMap_.find(decayMode);
123  if (iterToComputer != computerMap_.end()) //if we don't have a MVA mapped to this decay mode, skip it, it fails.
124  {
125  // use the supplied cut to make a decision
126  if (valueToMultiplex > iterToComputer->second->userCut)
127  return 1.0;
128  else
129  return 0.0;
130  }
131 
132  // no computer associated to this decay mode; it fails
133  return 0.;
134 }

References computerMap_, taus_cff::decayMode, and pfTauDecayModeIndices.

◆ fillDescriptions()

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

Definition at line 136 of file PFTauDecayModeCutMultiplexer.cc.

136  {
137  // pfTauDecayModeCutMultiplexer
139 
140  desc.add<edm::InputTag>("PFTauDecayModeSrc");
141  desc.add<edm::InputTag>("PFTauDiscriminantToMultiplex");
142 
143  edm::ParameterSetDescription vpsd_computers;
144  vpsd_computers.add<std::string>("computerName");
145  vpsd_computers.add<double>("cut");
146  vpsd_computers.add<std::vector<int> >("decayModeIndices");
147 
148  // name description defaults items
149  //desc.addVPSet("computers", vpsd_builders, builders_vector);
150  desc.addVPSet("computers", vpsd_computers);
151 
152  fillProducerDescriptions(desc); // inherited from the base
153 
154  descriptions.add("pfTauDecayModeCutMultiplexer", desc);
155 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, TauDiscriminationProducerBase< TauType, TauDiscriminator, TauDiscriminatorDataType, ConsumeType >::fillProducerDescriptions(), and AlCaHLTBitMon_QueryRunRegistry::string.

Member Data Documentation

◆ computerMap_

DecayModeToCutMap PFTauDecayModeCutMultiplexer::computerMap_
private

Definition at line 60 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by discriminate(), and PFTauDecayModeCutMultiplexer().

◆ computers_

CutList PFTauDecayModeCutMultiplexer::computers_
private

Definition at line 61 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

◆ discriminant_token

edm::EDGetTokenT<PFTauDiscriminator> PFTauDecayModeCutMultiplexer::discriminant_token
private

Definition at line 58 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and PFTauDecayModeCutMultiplexer().

◆ discriminantToMultiplex_

edm::InputTag PFTauDecayModeCutMultiplexer::discriminantToMultiplex_
private

Definition at line 57 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

◆ pfTauDecayModeIndex_token

edm::EDGetTokenT<PFTauDiscriminator> PFTauDecayModeCutMultiplexer::pfTauDecayModeIndex_token
private

Definition at line 54 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and PFTauDecayModeCutMultiplexer().

◆ pfTauDecayModeIndexSrc_

edm::InputTag PFTauDecayModeCutMultiplexer::pfTauDecayModeIndexSrc_
private

Definition at line 53 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

◆ pfTauDecayModeIndices

edm::Handle<PFTauDiscriminator> PFTauDecayModeCutMultiplexer::pfTauDecayModeIndices
private

Definition at line 64 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and discriminate().

◆ targetDiscriminant

edm::Handle<PFTauDiscriminator> PFTauDecayModeCutMultiplexer::targetDiscriminant
private

Definition at line 66 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent().

edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PFTauDiscriminationProducerBase
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
Definition: TauDiscriminationProducerBase.h:124
PFTauDecayModeCutMultiplexer::computers_
CutList computers_
Definition: PFTauDecayModeCutMultiplexer.cc:61
PFTauDecayModeCutMultiplexer::targetDiscriminant
edm::Handle< PFTauDiscriminator > targetDiscriminant
Definition: PFTauDecayModeCutMultiplexer.cc:66
PFTauDecayModeCutMultiplexer::pfTauDecayModeIndexSrc_
edm::InputTag pfTauDecayModeIndexSrc_
Definition: PFTauDecayModeCutMultiplexer.cc:53
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
taus_cff.decayMode
decayMode
Definition: taus_cff.py:58
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PFTauDecayModeCutMultiplexer::pfTauDecayModeIndex_token
edm::EDGetTokenT< PFTauDiscriminator > pfTauDecayModeIndex_token
Definition: PFTauDecayModeCutMultiplexer.cc:54
TauDiscriminationProducerBase::fillProducerDescriptions
static void fillProducerDescriptions(edm::ParameterSetDescription &desc)
Definition: TauDiscriminationProducerBase.cc:173
iEvent
int iEvent
Definition: GenABIO.cc:224
PFTauDecayModeCutMultiplexer::pfTauDecayModeIndices
edm::Handle< PFTauDiscriminator > pfTauDecayModeIndices
Definition: PFTauDecayModeCutMultiplexer.cc:64
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Exception
Definition: hltDiff.cc:245
PFTauDecayModeCutMultiplexer::discriminantToMultiplex_
edm::InputTag discriminantToMultiplex_
Definition: PFTauDecayModeCutMultiplexer.cc:57
PFTauDecayModeCutMultiplexer::discriminant_token
edm::EDGetTokenT< PFTauDiscriminator > discriminant_token
Definition: PFTauDecayModeCutMultiplexer.cc:58
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PFTauDecayModeCutMultiplexer::computerMap_
DecayModeToCutMap computerMap_
Definition: PFTauDecayModeCutMultiplexer.cc:60
edm::InputTag
Definition: InputTag.h:15