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 > 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 >
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 >
virtual double 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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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 >
static void fillProducerDescriptions (edm::ParameterSetDescription &desc)
 

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 >
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

Definition at line 43 of file PFTauDecayModeCutMultiplexer.cc.

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

Definition at line 44 of file PFTauDecayModeCutMultiplexer.cc.

Constructor & Destructor Documentation

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
edm::EDGetTokenT< PFTauDiscriminator > discriminant_token
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
edm::EDGetTokenT< PFTauDiscriminator > pfTauDecayModeIndex_token
PFTauDecayModeCutMultiplexer::~PFTauDecayModeCutMultiplexer ( )
inlineoverride

Definition at line 36 of file PFTauDecayModeCutMultiplexer.cc.

36 {}

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 109 of file PFTauDecayModeCutMultiplexer.cc.

References discriminant_token, edm::Event::getByToken(), pfTauDecayModeIndex_token, pfTauDecayModeIndices, and targetDiscriminant.

109  {
112 }
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< PFTauDiscriminator > discriminant_token
edm::EDGetTokenT< PFTauDiscriminator > pfTauDecayModeIndex_token
edm::Handle< PFTauDiscriminator > pfTauDecayModeIndices
edm::Handle< PFTauDiscriminator > targetDiscriminant
double PFTauDecayModeCutMultiplexer::discriminate ( const PFTauRef thePFTau) const
override

Definition at line 114 of file PFTauDecayModeCutMultiplexer.cc.

References computerMap_, taus_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
void PFTauDecayModeCutMultiplexer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 136 of file PFTauDecayModeCutMultiplexer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addVPSet(), DEFINE_FWK_MODULE, TauDiscriminationProducerBase< TauType, TauDiscriminator >::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 }
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
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

DecayModeToCutMap PFTauDecayModeCutMultiplexer::computerMap_
private

Definition at line 60 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by discriminate(), and PFTauDecayModeCutMultiplexer().

CutList PFTauDecayModeCutMultiplexer::computers_
private

Definition at line 61 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

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

Definition at line 58 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and PFTauDecayModeCutMultiplexer().

edm::InputTag PFTauDecayModeCutMultiplexer::discriminantToMultiplex_
private

Definition at line 57 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

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

Definition at line 54 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and PFTauDecayModeCutMultiplexer().

edm::InputTag PFTauDecayModeCutMultiplexer::pfTauDecayModeIndexSrc_
private

Definition at line 53 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

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

Definition at line 64 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and discriminate().

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

Definition at line 66 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent().