CMS 3D CMS Logo

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

Classes

struct  DiscriminantCutEntry
 

Public Member Functions

void beginEvent (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
double discriminate (const reco::PFTauRef &) override
 
 RecoTauDiscriminantCutMultiplexer (const edm::ParameterSet &pset)
 
 ~RecoTauDiscriminantCutMultiplexer ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau)=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::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::map< int,
DiscriminantCutEntry * > 
DiscriminantCutMap
 

Private Attributes

DiscriminantCutMap cuts_
 
std::vector< TFile * > inputFilesToDelete_
 
edm::InputTag key_
 
edm::EDGetTokenT
< reco::PFTauDiscriminator
key_token
 
edm::Handle
< reco::PFTauDiscriminator
keyHandle_
 
std::string moduleLabel_
 
const TFormula * mvaOutput_normalization_
 
edm::InputTag toMultiplex_
 
edm::EDGetTokenT
< reco::PFTauDiscriminator
toMultiplex_token
 
edm::Handle
< reco::PFTauDiscriminator
toMultiplexHandle_
 
int verbosity_
 

Additional Inherited Members

- 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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 29 of file RecoTauDiscriminantCutMultiplexer.cc.

Member Typedef Documentation

Definition at line 59 of file RecoTauDiscriminantCutMultiplexer.cc.

Constructor & Destructor Documentation

RecoTauDiscriminantCutMultiplexer::RecoTauDiscriminantCutMultiplexer ( const edm::ParameterSet pset)
explicit

Definition at line 94 of file RecoTauDiscriminantCutMultiplexer.cc.

References python.rootplot.argparse::category, GOODCOLL_filter_cfg::cut, cuts_, edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), PFRecoTauDiscriminationAgainstMuonMVA_cfi::inputFileName, inputFilesToDelete_, key_, key_token, RecoTauDiscriminantCutMultiplexer::DiscriminantCutEntry::kFixedCut, RecoTauDiscriminantCutMultiplexer::DiscriminantCutEntry::kVariableCut, mvaOutput_normalization_, AlCaHLTBitMon_QueryRunRegistry::string, toMultiplex_, toMultiplex_token, and verbosity_.

96  moduleLabel_(cfg.getParameter<std::string>("@module_label")),
98 {
99  toMultiplex_ = cfg.getParameter<edm::InputTag>("toMultiplex");
100  toMultiplex_token = consumes<reco::PFTauDiscriminator>(toMultiplex_);
101  key_ = cfg.getParameter<edm::InputTag>("key");
102  key_token = consumes<reco::PFTauDiscriminator>(key_);
103 
104  if ( cfg.exists("mvaOutput_normalization" ) ) {
105  edm::FileInPath inputFileName = cfg.getParameter<edm::FileInPath>("inputFileName");
106  std::string mvaOutput_normalization_string = cfg.getParameter<std::string>("mvaOutput_normalization");
107  mvaOutput_normalization_ = loadObjectFromFile<TFormula>(inputFileName, mvaOutput_normalization_string, inputFilesToDelete_);
108  }
109 
110  // Setup our cut map
111  typedef std::vector<edm::ParameterSet> VPSet;
112  VPSet mapping = cfg.getParameter<VPSet>("mapping");
113  for ( VPSet::const_iterator mappingEntry = mapping.begin();
114  mappingEntry != mapping.end(); ++mappingEntry ) {
115  unsigned category = mappingEntry->getParameter<uint32_t>("category");
116  DiscriminantCutEntry* cut = new DiscriminantCutEntry();
117  if ( mappingEntry->existsAs<double>("cut") ) {
118  cut->cutValue_ = mappingEntry->getParameter<double>("cut");
119  cut->mode_ = DiscriminantCutEntry::kFixedCut;
120  } else if ( mappingEntry->existsAs<std::string>("cut") ) {
121  std::string cut_string = mappingEntry->getParameter<std::string>("cut");
122  edm::FileInPath inputFileName = cfg.getParameter<edm::FileInPath>("inputFileName");
123  cut->cutFunction_ = loadObjectFromFile<TGraph>(inputFileName, cut_string, inputFilesToDelete_);
124  std::string cutVariable_string = mappingEntry->getParameter<std::string>("variable");
125  cut->cutVariable_ = new StringObjectFunction<reco::PFTau>(cutVariable_string.data());
127  } else {
128  throw cms::Exception("RecoTauDiscriminantCutMultiplexer")
129  << " Undefined Configuration Parameter 'cut' !!\n";
130  }
131  cuts_[category] = cut;
132  }
133 
134  verbosity_ = ( cfg.exists("verbosity") ) ?
135  cfg.getParameter<int>("verbosity") : 0;
136 }
edm::EDGetTokenT< reco::PFTauDiscriminator > toMultiplex_token
edm::EDGetTokenT< reco::PFTauDiscriminator > key_token
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
RecoTauDiscriminantCutMultiplexer::~RecoTauDiscriminantCutMultiplexer ( )

Definition at line 138 of file RecoTauDiscriminantCutMultiplexer.cc.

References cuts_, and inputFilesToDelete_.

139 {
140  for ( std::map<int, DiscriminantCutEntry*>::iterator it = cuts_.begin();
141  it != cuts_.end(); ++it ) {
142  delete it->second;
143  }
144  // CV: all entries in inputFilesToDelete list actually refer to the same file
145  // --> delete the first entry only
146  if ( inputFilesToDelete_.size() >= 1 ) {
147  delete inputFilesToDelete_.front();
148  }
149 }

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 151 of file RecoTauDiscriminantCutMultiplexer.cc.

References edm::Event::getByToken(), key_token, keyHandle_, toMultiplex_token, and toMultiplexHandle_.

152 {
153  evt.getByToken(toMultiplex_token, toMultiplexHandle_);
154  evt.getByToken(key_token, keyHandle_);
155 }
edm::Handle< reco::PFTauDiscriminator > keyHandle_
edm::Handle< reco::PFTauDiscriminator > toMultiplexHandle_
edm::EDGetTokenT< reco::PFTauDiscriminator > toMultiplex_token
edm::EDGetTokenT< reco::PFTauDiscriminator > key_token
double RecoTauDiscriminantCutMultiplexer::discriminate ( const reco::PFTauRef tau)
override

Definition at line 158 of file RecoTauDiscriminantCutMultiplexer.cc.

References gather_cfg::cout, cuts_, epsilon, RecoTauDiscriminantCutMultiplexer::DiscriminantCutEntry::kFixedCut, RecoTauDiscriminantCutMultiplexer::DiscriminantCutEntry::kVariableCut, moduleLabel_, mvaOutput_normalization_, TauDiscriminationProducerBase< TauType, TauDiscriminator >::prediscriminantFailValue_, metsig::tau, and verbosity_.

159 {
160  if ( verbosity_ ) {
161  std::cout << "<RecoTauDiscriminantCutMultiplexer::discriminate>:" << std::endl;
162  std::cout << " moduleLabel = " << moduleLabel_ << std::endl;
163  }
164 
165  double disc_result = (*toMultiplexHandle_)[tau];
166  if ( verbosity_ ) {
167  std::cout << "disc_result = " << disc_result << std::endl;
168  }
169  if ( mvaOutput_normalization_ ) {
170  disc_result = mvaOutput_normalization_->Eval(disc_result);
171  //if ( disc_result > 1. ) disc_result = 1.;
172  //if ( disc_result < 0. ) disc_result = 0.;
173  if ( verbosity_ ) {
174  std::cout << "disc_result (normalized) = " << disc_result << std::endl;
175  }
176  }
177  double key_result = (*keyHandle_)[tau];
178  DiscriminantCutMap::const_iterator cutIter = cuts_.find(TMath::Nint(key_result));
179 
180  // Return null if it doesn't exist
181  if ( cutIter == cuts_.end() ) {
183  }
184 
185  // See if the discriminator passes our cuts
186  bool passesCuts = false;
187  if ( cutIter->second->mode_ == DiscriminantCutEntry::kFixedCut ) {
188  passesCuts = (disc_result > cutIter->second->cutValue_);
189  if ( verbosity_ ) {
190  std::cout << "cutValue (fixed) = " << cutIter->second->cutValue_ << " --> passesCuts = " << passesCuts << std::endl;
191  }
192  } else if ( cutIter->second->mode_ == DiscriminantCutEntry::kVariableCut ) {
193  double cutVariable = (*cutIter->second->cutVariable_)(*tau);
194  double xMin, xMax, dummy;
195  cutIter->second->cutFunction_->GetPoint(0, xMin, dummy);
196  cutIter->second->cutFunction_->GetPoint(cutIter->second->cutFunction_->GetN() - 1, xMax, dummy);
197  const double epsilon = 1.e-3;
198  if ( cutVariable < (xMin + epsilon) ) cutVariable = xMin + epsilon;
199  else if ( cutVariable > (xMax - epsilon) ) cutVariable = xMax - epsilon;
200  double cutValue = cutIter->second->cutFunction_->Eval(cutVariable);
201  passesCuts = (disc_result > cutValue);
202  if ( verbosity_ ) {
203  std::cout << "cutValue (@" << cutVariable << ") = " << cutValue << " --> passesCuts = " << passesCuts << std::endl;
204  }
205  } else assert(0);
206 
207  return passesCuts;
208 }
tuple cout
Definition: gather_cfg.py:121
const double epsilon

Member Data Documentation

DiscriminantCutMap RecoTauDiscriminantCutMultiplexer::cuts_
private
std::vector<TFile*> RecoTauDiscriminantCutMultiplexer::inputFilesToDelete_
private
edm::InputTag RecoTauDiscriminantCutMultiplexer::key_
private
edm::EDGetTokenT<reco::PFTauDiscriminator> RecoTauDiscriminantCutMultiplexer::key_token
private
edm::Handle<reco::PFTauDiscriminator> RecoTauDiscriminantCutMultiplexer::keyHandle_
private

Definition at line 65 of file RecoTauDiscriminantCutMultiplexer.cc.

Referenced by beginEvent().

std::string RecoTauDiscriminantCutMultiplexer::moduleLabel_
private
const TFormula* RecoTauDiscriminantCutMultiplexer::mvaOutput_normalization_
private
edm::InputTag RecoTauDiscriminantCutMultiplexer::toMultiplex_
private
edm::EDGetTokenT<reco::PFTauDiscriminator> RecoTauDiscriminantCutMultiplexer::toMultiplex_token
private
edm::Handle<reco::PFTauDiscriminator> RecoTauDiscriminantCutMultiplexer::toMultiplexHandle_
private

Definition at line 64 of file RecoTauDiscriminantCutMultiplexer.cc.

Referenced by beginEvent().

int RecoTauDiscriminantCutMultiplexer::verbosity_
private