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 Types | Private Member Functions | Private Attributes
pat::TauJetCorrFactorsProducer Class Reference

Produces a ValueMap between TauJetCorrFactors and the originating reco taus. More...

#include "PhysicsTools/PatAlgos/interface/TauJetCorrFactorsProducer.h"

Inheritance diagram for pat::TauJetCorrFactorsProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  payloadMappingType
 

Public Types

typedef edm::ValueMap
< pat::TauJetCorrFactors
JetCorrFactorsMap
 value map for JetCorrFactors (to be written into the event) More...
 
- 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

virtual void produce (edm::Event &, const edm::EventSetup &) override
 everything that needs to be done per event More...
 
 TauJetCorrFactorsProducer (const edm::ParameterSet &)
 default constructor More...
 
 ~TauJetCorrFactorsProducer ()
 default destructor More...
 
- 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 (const std::string &iProcessName, std::vector< const char * > &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 Types

typedef std::vector< int > vint
 mapping of reconstructed tau decay modes to payloads More...
 
typedef std::vector< std::string > vstring
 jec levels More...
 

Private Member Functions

float evaluate (edm::View< reco::BaseTau >::const_iterator &, boost::shared_ptr< FactorizedJetCorrector > &, int)
 evaluate jet correction factor up to a given level More...
 
std::vector
< JetCorrectorParameters
params (const JetCorrectorParametersCollection &, const std::vector< std::string > &) const
 return the jec parameters as input to the FactorizedJetCorrector for different flavors More...
 

Private Attributes

std::string defaultPayload_
 
vstring levels_
 
std::string moduleLabel_
 python label of this TauJetCorrFactorsProducer module More...
 
std::vector< payloadMappingTypepayloadMappings_
 
edm::EDGetTokenT< edm::View
< reco::BaseTau > > 
srcToken_
 input tau-jet collection More...
 

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)
 

Detailed Description

Produces a ValueMap between TauJetCorrFactors and the originating reco taus.

The TauJetCorrFactorsProducer produces a set of tau-jet energy correction factors, defined in the class pat::TauJetCorrFactors. This vector is linked to the originating reco taus through an edm::ValueMap. The initializing parameters of the module can be found in the recoLayer1/tauJetCorrFactors_cfi.py of the PatAlgos package. In the standard PAT workflow the module has to be run before the creation of the pat::Tau. The edm::ValueMap will then be embedded into the pat::Tau.

Jets corrected up to a given correction level can then be accessed via the pat::Tau member function correctedJet. For more details have a look into the class description of the pat::Tau.

Definition at line 38 of file TauJetCorrFactorsProducer.h.

Member Typedef Documentation

value map for JetCorrFactors (to be written into the event)

Definition at line 42 of file TauJetCorrFactorsProducer.h.

typedef std::vector<int> pat::TauJetCorrFactorsProducer::vint
private

mapping of reconstructed tau decay modes to payloads

Definition at line 68 of file TauJetCorrFactorsProducer.h.

typedef std::vector<std::string> pat::TauJetCorrFactorsProducer::vstring
private

jec levels

Definition at line 88 of file TauJetCorrFactorsProducer.h.

Constructor & Destructor Documentation

TauJetCorrFactorsProducer::TauJetCorrFactorsProducer ( const edm::ParameterSet cfg)
explicit

default constructor

Definition at line 15 of file TauJetCorrFactorsProducer.cc.

References pat::TauJetCorrFactorsProducer::payloadMappingType::decayModes_, defaultPayload_, edm::ParameterSet::getParameter(), Parameters::parameters, pat::TauJetCorrFactorsProducer::payloadMappingType::payload_, payloadMappings_, and AlCaHLTBitMon_QueryRunRegistry::string.

16  : moduleLabel_(cfg.getParameter<std::string>("@module_label")),
18  levels_(cfg.getParameter<std::vector<std::string> >("levels"))
19 {
20  typedef std::vector<edm::ParameterSet> vParameterSet;
21  vParameterSet parameters = cfg.getParameter<vParameterSet>("parameters");
22  for ( vParameterSet::const_iterator param = parameters.begin();
23  param != parameters.end(); ++param ) {
24  payloadMappingType payloadMapping;
25 
26  payloadMapping.payload_ = param->getParameter<std::string>("payload");
27 
28  vstring decayModes_string = param->getParameter<vstring>("decayModes");
29  for ( vstring::const_iterator decayMode = decayModes_string.begin();
30  decayMode != decayModes_string.end(); ++decayMode ) {
31  if ( (*decayMode) == "*" ) {
32  defaultPayload_ = payloadMapping.payload_;
33  } else {
34  payloadMapping.decayModes_.push_back(atoi(decayMode->data()));
35  }
36  }
37 
38  if ( payloadMapping.decayModes_.size() > 0 ) payloadMappings_.push_back(payloadMapping);
39  }
40 
41  produces<TauJetCorrFactorsMap>();
42 }
T getParameter(std::string const &) const
dictionary parameters
Definition: Parameters.py:2
vector< string > vstring
Definition: ExoticaDQM.cc:86
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< reco::BaseTau > > srcToken_
input tau-jet collection
std::string moduleLabel_
python label of this TauJetCorrFactorsProducer module
std::vector< payloadMappingType > payloadMappings_
pat::TauJetCorrFactorsProducer::~TauJetCorrFactorsProducer ( )
inline

default destructor

Definition at line 48 of file TauJetCorrFactorsProducer.h.

48 {};

Member Function Documentation

float TauJetCorrFactorsProducer::evaluate ( edm::View< reco::BaseTau >::const_iterator &  tauJet,
boost::shared_ptr< FactorizedJetCorrector > &  corrector,
int  corrLevel 
)
private

evaluate jet correction factor up to a given level

Definition at line 57 of file TauJetCorrFactorsProducer.cc.

Referenced by produce().

59 {
60  corrector->setJetEta(tauJet->eta());
61  corrector->setJetPt(tauJet->pt());
62  corrector->setJetE(tauJet->energy());
63  return corrector->getSubCorrections()[corrLevel];
64 }
tuple corrector
Definition: mvaPFMET_cff.py:86
std::vector< JetCorrectorParameters > TauJetCorrFactorsProducer::params ( const JetCorrectorParametersCollection jecParameters,
const std::vector< std::string > &  levels 
) const
private

return the jec parameters as input to the FactorizedJetCorrector for different flavors

Definition at line 45 of file TauJetCorrFactorsProducer.cc.

References JetCorrectorParametersCollection::push_back().

Referenced by produce().

46 {
47  std::vector<JetCorrectorParameters> retVal;
48  for ( std::vector<std::string>::const_iterator corrLevel = levels.begin();
49  corrLevel != levels.end(); ++corrLevel ) {
50  const JetCorrectorParameters& jecParameter_level = jecParameters[*corrLevel];
51  retVal.push_back(jecParameter_level);
52  }
53  return retVal;
54 }
void push_back(key_type i, value_type const &j, label_type const &flav="")
void TauJetCorrFactorsProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
overridevirtual

everything that needs to be done per event

Implements edm::stream::EDProducerBase.

Definition at line 67 of file TauJetCorrFactorsProducer.cc.

References mvaPFMET_cff::corrector, reco::PFTau::decayMode(), defaultPayload_, evaluate(), edm::helper::Filler< Map >::fill(), edm::EventSetup::get(), edm::Event::getByToken(), customizeTrackingMonitorSeedNumber::idx, edm::helper::Filler< Map >::insert(), patTestJEC_cfi::jec, levels_, moduleLabel_, params(), payloadMappings_, edm::Event::put(), srcToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

68 {
69  // get tau-jet collection from the event
71  evt.getByToken(srcToken_, tauJets);
72 
73  typedef boost::shared_ptr<FactorizedJetCorrector> FactorizedJetCorrectorPtr;
74  std::map<std::string, FactorizedJetCorrectorPtr> correctorMapping;
75 
76  // fill the tauJetCorrFactors
77  std::vector<TauJetCorrFactors> tauJetCorrections;
78  for ( edm::View<reco::BaseTau>::const_iterator tauJet = tauJets->begin();
79  tauJet != tauJets->end(); ++tauJet ) {
80 
81  // the TauJetCorrFactors::CorrectionFactor is a std::pair<std::string, float>
82  // the string corresponds to the label of the correction level, the float to the tau-jet energy correction factor.
83  // The first correction level is predefined with label 'Uncorrected'. The correction factor is 1.
84  std::vector<TauJetCorrFactors::CorrectionFactor> jec;
85  jec.push_back(std::make_pair(std::string("Uncorrected"), 1.0));
86 
87  if ( levels_.size() == 0 )
88  throw cms::Exception("No JECFactors")
89  << "You request to create a jetCorrFactors object with no JEC Levels indicated. \n"
90  << "This makes no sense, either you should correct this or drop the module from \n"
91  << "the sequence.";
92 
93  std::string payload = defaultPayload_;
94  if ( dynamic_cast<const reco::PFTau*>(&(*tauJet)) ) {
95  const reco::PFTau* pfTauJet = dynamic_cast<const reco::PFTau*>(&(*tauJet));
96  for ( std::vector<payloadMappingType>::const_iterator payloadMapping = payloadMappings_.begin();
97  payloadMapping != payloadMappings_.end(); ++payloadMapping ) {
98  for( vint::const_iterator decayMode = payloadMapping->decayModes_.begin();
99  decayMode != payloadMapping->decayModes_.end(); ++decayMode ) {
100  if ( pfTauJet->decayMode() == (*decayMode) ) payload = payloadMapping->payload_;
101  }
102  }
103  }
104 
105  // retrieve JEC parameters from the DB and build a new corrector,
106  // in case it does not exist already for current payload
107  if ( correctorMapping.find(payload) == correctorMapping.end() ) {
109  es.get<JetCorrectionsRecord>().get(payload, jecParameters);
110 
111  correctorMapping[payload] = FactorizedJetCorrectorPtr(new FactorizedJetCorrector(params(*jecParameters, levels_)));
112  }
113  FactorizedJetCorrectorPtr& corrector = correctorMapping[payload];
114 
115  // evaluate tau-jet energy corrections
116  size_t numLevels = levels_.size();
117  for ( size_t idx = 0; idx < numLevels; ++idx ) {
118  const std::string& corrLevel = levels_[idx];
119 
120  float jecFactor = evaluate(tauJet, corrector, idx);
121 
122  // push back the set of JetCorrFactors: the first entry corresponds to the label
123  // of the correction level. The second parameter corresponds to the jec factor.
124  // In the default configuration the CorrectionFactor will look like this:
125  // 'Uncorrected' : 1 ;
126  // 'L2Relative' : x ;
127  // 'L3Absolute' : x ;
128  jec.push_back(std::make_pair(corrLevel.substr(0, corrLevel.find("_")), jecFactor));
129  }
130 
131  // create the actual object with the scale factors we want the valuemap to refer to
132  // moduleLabel_ corresponds to the python label of the TauJetCorrFactorsProducer module instance
133  TauJetCorrFactors tauJetCorrection(moduleLabel_, jec);
134  tauJetCorrections.push_back(tauJetCorrection);
135  }
136 
137  // build the valuemap
138  std::auto_ptr<TauJetCorrFactorsMap> jecMapping(new TauJetCorrFactorsMap());
139  TauJetCorrFactorsMap::Filler filler(*jecMapping);
140  // tauJets and tauJetCorrections vectors have their indices aligned by construction
141  filler.insert(tauJets, tauJetCorrections.begin(), tauJetCorrections.end());
142  filler.fill(); // do the actual filling
143 
144  // add valuemap to the event
145  evt.put(jecMapping);
146 }
float evaluate(edm::View< reco::BaseTau >::const_iterator &, boost::shared_ptr< FactorizedJetCorrector > &, int)
evaluate jet correction factor up to a given level
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< JetCorrectorParameters > params(const JetCorrectorParametersCollection &, const std::vector< std::string > &) const
return the jec parameters as input to the FactorizedJetCorrector for different flavors ...
hadronicDecayMode decayMode() const
Definition: PFTau.cc:212
tuple corrector
Definition: mvaPFMET_cff.py:86
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
edm::EDGetTokenT< edm::View< reco::BaseTau > > srcToken_
input tau-jet collection
std::string moduleLabel_
python label of this TauJetCorrFactorsProducer module
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const T & get() const
Definition: EventSetup.h:56
edm::ValueMap< pat::TauJetCorrFactors > TauJetCorrFactorsMap
value map for JetCorrFactors (to be written into the event)
std::vector< payloadMappingType > payloadMappings_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85

Member Data Documentation

std::string pat::TauJetCorrFactorsProducer::defaultPayload_
private

payload to be used for decay modes not explicitely specified

NOTE: no decay mode reconstruction implemented for CaloTaus so far –> this payload is used for all CaloTaus

Definition at line 85 of file TauJetCorrFactorsProducer.h.

Referenced by produce(), and TauJetCorrFactorsProducer().

vstring pat::TauJetCorrFactorsProducer::levels_
private

Definition at line 89 of file TauJetCorrFactorsProducer.h.

Referenced by produce().

std::string pat::TauJetCorrFactorsProducer::moduleLabel_
private
std::vector<payloadMappingType> pat::TauJetCorrFactorsProducer::payloadMappings_
private

Definition at line 78 of file TauJetCorrFactorsProducer.h.

Referenced by produce(), and TauJetCorrFactorsProducer().

edm::EDGetTokenT<edm::View<reco::BaseTau> > pat::TauJetCorrFactorsProducer::srcToken_
private

input tau-jet collection

Definition at line 65 of file TauJetCorrFactorsProducer.h.

Referenced by produce().