test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Attributes
PFTauDecayModeCutMultiplexer Class Reference
Inheritance diagram for PFTauDecayModeCutMultiplexer:
TauDiscriminationProducerBase< TauType, TauDiscriminator > edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  ComputerAndCut
 

Public Types

typedef std::vector
< ComputerAndCut
CutList
 
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
< TauCollection
TauRefProd
 
- 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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
 

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 ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau) const =0
 
virtual void endEvent (edm::Event &evt)
 
void produce (edm::Event &, const edm::EventSetup &)
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
virtual ~TauDiscriminationProducerBase ()
 
- 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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

DecayModeToCutMap computerMap_
 
CutList computers_
 
edm::EDGetTokenT
< PFTauDiscriminator
discriminant_token
 
edm::InputTag discriminantToMultiplex_
 
edm::EDGetTokenT
< PFTauDiscriminator
pfTauDecayModeIndex_token
 
edm::InputTag pfTauDecayModeIndexSrc_
 
edm::Handle< PFTauDiscriminatorpfTauDecayModeIndices
 
edm::Handle< PFTauDiscriminatortargetDiscriminant
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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)
 
- 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 30 of file PFTauDecayModeCutMultiplexer.cc.

Member Typedef Documentation

Definition at line 40 of file PFTauDecayModeCutMultiplexer.cc.

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

Definition at line 41 of file PFTauDecayModeCutMultiplexer.cc.

Constructor & Destructor Documentation

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

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

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

Definition at line 33 of file PFTauDecayModeCutMultiplexer.cc.

33 {}

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 103 of file PFTauDecayModeCutMultiplexer.cc.

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

104 {
105 
108 }
int iEvent
Definition: GenABIO.cc:230
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 110 of file PFTauDecayModeCutMultiplexer.cc.

References computerMap_, and pfTauDecayModeIndices.

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

Member Data Documentation

DecayModeToCutMap PFTauDecayModeCutMultiplexer::computerMap_
private

Definition at line 55 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by discriminate(), and PFTauDecayModeCutMultiplexer().

CutList PFTauDecayModeCutMultiplexer::computers_
private

Definition at line 56 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

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

Definition at line 53 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and PFTauDecayModeCutMultiplexer().

edm::InputTag PFTauDecayModeCutMultiplexer::discriminantToMultiplex_
private

Definition at line 52 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

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

Definition at line 49 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and PFTauDecayModeCutMultiplexer().

edm::InputTag PFTauDecayModeCutMultiplexer::pfTauDecayModeIndexSrc_
private

Definition at line 48 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by PFTauDecayModeCutMultiplexer().

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

Definition at line 58 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent(), and discriminate().

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

Definition at line 59 of file PFTauDecayModeCutMultiplexer.cc.

Referenced by beginEvent().