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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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)
 
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 >
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 66 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.

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

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

108 {
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.

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

Definition at line 138 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.

138  {
139  // pfTauDecayModeCutMultiplexer
141 
142  desc.add<edm::InputTag>("PFTauDecayModeSrc");
143  desc.add<edm::InputTag>("PFTauDiscriminantToMultiplex");
144 
145  edm::ParameterSetDescription vpsd_computers;
146  vpsd_computers.add<std::string>("computerName");
147  vpsd_computers.add<double>("cut");
148  vpsd_computers.add<std::vector<int> >("decayModeIndices");
149 
150  // name description defaults items
151  //desc.addVPSet("computers", vpsd_builders, builders_vector);
152  desc.addVPSet("computers", vpsd_computers);
153 
154  fillProducerDescriptions(desc); // inherited from the base
155 
156  descriptions.add("pfTauDecayModeCutMultiplexer", desc);
157 }
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 59 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by discriminate(), and PFTauDecayModeCutMultiplexer().

CutList PFTauDecayModeCutMultiplexer::computers_
private

Definition at line 60 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

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

Definition at line 57 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and PFTauDecayModeCutMultiplexer().

edm::InputTag PFTauDecayModeCutMultiplexer::discriminantToMultiplex_
private

Definition at line 56 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

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

Definition at line 53 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and PFTauDecayModeCutMultiplexer().

edm::InputTag PFTauDecayModeCutMultiplexer::pfTauDecayModeIndexSrc_
private

Definition at line 52 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

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

Definition at line 62 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and discriminate().

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

Definition at line 63 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent().