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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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 (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
 ~TauDiscriminationProducerBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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.

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

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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< PFTauDiscriminator > discriminant_token
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
edm::EDGetTokenT< PFTauDiscriminator > pfTauDecayModeIndex_token

◆ ~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.

References computerMap_, boostedTaus_cff::decayMode, and pfTauDecayModeIndices.

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 }
edm::Handle< PFTauDiscriminator > pfTauDecayModeIndices

◆ fillDescriptions()

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

Definition at line 136 of file PFTauDecayModeCutMultiplexer.cc.

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

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 }
static void fillProducerDescriptions(edm::ParameterSetDescription &desc)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

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