CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
pat::JetCorrFactorsProducer Class Reference

Produces a ValueMap between JetCorrFactors and the to the originating reco jets. More...

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

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

Public Types

typedef std::map
< JetCorrFactors::Flavor,
std::vector< std::string > > 
FlavorCorrLevelMap
 map of correction levels to different flavors More...
 
typedef edm::ValueMap
< pat::JetCorrFactors
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

 JetCorrFactorsProducer (const edm::ParameterSet &cfg)
 default constructor More...
 
virtual void produce (edm::Event &event, const edm::EventSetup &setup) override
 everything that needs to be done per event More...
 
 ~JetCorrFactorsProducer ()
 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 ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 description of configuration file parameters More...
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

float evaluate (edm::View< reco::Jet >::const_iterator &jet, const JetCorrFactors::Flavor &flavor, int level)
 evaluate jet correction factor up to a given level More...
 
std::vector< std::string > expand (const std::vector< std::string > &levels, const JetCorrFactors::Flavor &flavor)
 
bool flavorDependent () const
 return true if the jec levels contain at least one flavor dependent correction level More...
 
int numberOf (const edm::Handle< std::vector< reco::Vertex > > &primaryVertices)
 determines the number of valid primary vertices for the standard L1Offset correction of JetMET More...
 
std::vector
< JetCorrectorParameters
params (const JetCorrectorParametersCollection &parameters, const std::vector< std::string > &levels) const
 return the jec parameters as input to the FactorizedJetCorrector for different flavors More...
 
std::string payload ()
 map jet algorithm to payload in DB More...
 

Private Attributes

unsigned long long cacheId_
 cache identifier for JetCorrectionsRecord More...
 
std::map
< JetCorrFactors::Flavor,
std::unique_ptr
< FactorizedJetCorrector > > 
correctors_
 cache container for jet corrections More...
 
bool emf_
 use electromagnetic fraction for jet energy corrections or not (will only have an effect for jets CaloJets) More...
 
std::vector< std::string > extraJPTOffset_
 
std::unique_ptr
< FactorizedJetCorrector
extraJPTOffsetCorrector_
 cache container for JPTOffset jet corrections More...
 
std::string label_
 label of jec factors More...
 
FlavorCorrLevelMap levels_
 
std::string payload_
 label of payload More...
 
edm::InputTag primaryVertices_
 label for L1Offset primaryVertex collection More...
 
edm::EDGetTokenT< std::vector
< reco::Vertex > > 
primaryVerticesToken_
 
edm::InputTag rho_
 label for L1FastJet energy density parameter rho More...
 
edm::EDGetTokenT< double > rhoToken_
 
edm::EDGetTokenT< edm::View
< reco::Jet > > 
srcToken_
 input jet collection More...
 
std::string type_
 type of flavor dependent JEC factors (only 'J' and 'T' are allowed) More...
 
bool useNPV_
 use the NPV and rho with the JEC? (used for L1Offset/L1FastJet and L1FastJet, resp.) More...
 
bool useRho_
 

Additional Inherited Members

- 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 JetCorrFactors and the to the originating reco jets.

The JetCorrFactorsProducer produces a set of correction factors, defined in the class pat::JetCorrFactors. This vector is linked to the originating reco jets through an edm::ValueMap. The initializing parameters of the module can be found in the recoLayer1/jetCorrFactors_cfi.py of the PatAlgos package. In the standard PAT workflow the module has to be run before the creation of the pat::Jet. The edm::ValueMap will then be embedded into the pat::Jet.

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

ATTENTION: available options for flavor corrections are L5Flavor_gJ L7Parton_gJ gluon from dijets L5Flavor_qJ/_qT L7Parton_qJ/_qT quark from dijets/top L5Flavor_cJ/_cT L7Parton_cJ/_cT charm from dijets/top L5Flavor_bJ/_bT L7Parton_bJ/_bT beauty from dijets/top L7Parton_jJ/_tT mixture from dijets/top

where mixture refers to the flavor mixture as determined from the MC sample the flavor dependent corrections have been derived from. 'J' and 'T' stand for a typical dijet (ttbar) sample.

L1Offset corrections require the collection of offlinePrimaryVertices, which are supposed to be added as an additional optional parameter primaryVertices in the jetCorrFactors_cfi.py file.

L1FastJet corrections, which are an alternative to the standard L1Offset correction as recommended by the JetMET PAG the energy density parameter rho is supposed to be added as an additional optional parameter rho in the jetCorrFactors_cfi.py file.

NOTE: the mixed mode (mc input mixture from dijets/ttbar) only exists for parton level corrections. jJ and tT are not covered in this implementation of the JetCorrFactorsProducer there are no gluon corrections available from the top sample on the L7Parton level.

Definition at line 59 of file JetCorrFactorsProducer.h.

Member Typedef Documentation

typedef std::map<JetCorrFactors::Flavor, std::vector<std::string> > pat::JetCorrFactorsProducer::FlavorCorrLevelMap

map of correction levels to different flavors

Definition at line 64 of file JetCorrFactorsProducer.h.

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

Definition at line 62 of file JetCorrFactorsProducer.h.

Constructor & Destructor Documentation

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

default constructor

Definition at line 22 of file JetCorrFactorsProducer.cc.

References pat::JetCorrFactors::BOTTOM, pat::JetCorrFactors::CHARM, Exception, edm::ParameterSet::existsAs(), expand(), extraJPTOffset_, spr::find(), edm::ParameterSet::getParameter(), pat::JetCorrFactors::GLUON, levels_, python.rootplot.argparse::message, pat::JetCorrFactors::NONE, primaryVertices_, primaryVerticesToken_, rho_, rhoToken_, AlCaHLTBitMon_QueryRunRegistry::string, pat::JetCorrFactors::UDS, useNPV_, and useRho_.

22  :
23  emf_(cfg.getParameter<bool>( "emf" )),
25  type_ (cfg.getParameter<std::string>("flavorType")),
26  label_(cfg.getParameter<std::string>( "@module_label" )),
27  payload_( cfg.getParameter<std::string>("payload") ),
28  useNPV_(cfg.getParameter<bool>("useNPV")),
29  useRho_(cfg.getParameter<bool>("useRho")),
30  cacheId_(0)
31 {
32  std::vector<std::string> levels = cfg.getParameter<std::vector<std::string> >("levels");
33  // fill the std::map for levels_, which might be flavor dependent or not;
34  // flavor dependency is determined from the fact whether the std::string
35  // L5Flavor or L7Parton can be found in levels; if flavor dependent four
36  // vectors of strings will be filled into the map corresponding to GLUON,
37  // UDS, CHARM and BOTTOM (according to JetCorrFactors::Flavor), 'L5Flavor'
38  // and 'L7Parton' will be expanded accordingly; if not levels_ is filled
39  // with only one vector of strings according to NONE. This vector will be
40  // equivalent to the original vector of strings.
41  if(std::find(levels.begin(), levels.end(), "L5Flavor")!=levels.end() || std::find(levels.begin(), levels.end(), "L7Parton")!=levels.end()){
46  }
47  else{
48  levels_[JetCorrFactors::NONE ] = levels;
49  }
50  // if the std::string L1JPTOffset can be found in levels an additional
51  // parameter extraJPTOffset is needed, which should pass on the the usual
52  // L1Offset correction, which is an additional input to the L1JPTOffset
53  // corrector
54  if(std::find(levels.begin(), levels.end(), "L1JPTOffset")!=levels.end()){
55  if(cfg.existsAs<std::string>("extraJPTOffset")){
56  extraJPTOffset_.push_back(cfg.getParameter<std::string>("extraJPTOffset"));
57  }
58  else{
59  throw cms::Exception("No parameter extraJPTOffset specified")
60  << "The configured correction levels contain a L1JPTOffset correction, which re- \n"
61  << "quires the additional parameter extraJPTOffset or type std::string. This \n"
62  << "string should correspond to the L1Offset corrections that should be applied \n"
63  << "together with the JPTL1Offset corrections. These corrections can be of type \n"
64  << "L1Offset or L1FastJet. \n";
65  }
66  }
67  // if the std::string L1Offset can be found in levels an additional para-
68  // meter primaryVertices is needed, which should pass on the offline pri-
69  // mary vertex collection. The size of this collection is needed for the
70  // L1Offset correction.
71  if(useNPV_){
72  if(cfg.existsAs<edm::InputTag>("primaryVertices")){
73  primaryVertices_=cfg.getParameter<edm::InputTag>("primaryVertices");
74  primaryVerticesToken_=mayConsume<std::vector<reco::Vertex> >(primaryVertices_);
75  }
76  else{
77  throw cms::Exception("No primaryVertices specified")
78  << "The configured correction levels contain an L1Offset or L1FastJet correction, \n"
79  << "which requires the number of offlinePrimaryVertices. Please specify this col- \n"
80  << "lection as additional optional parameter primaryVertices of type edm::InputTag\n"
81  << "in the jetCorrFactors module. \n";
82  }
83  }
84  // if the std::string L1FastJet can be found in levels an additional
85  // parameter rho is needed, which should pass on the energy density
86  // parameter for the corresponding jet collection.
87  if(useRho_){
88  if((!extraJPTOffset_.empty() && extraJPTOffset_.front()==std::string("L1FastJet")) || std::find(levels.begin(), levels.end(), "L1FastJet")!=levels.end()){
89  if(cfg.existsAs<edm::InputTag>("rho")){
90  rho_=cfg.getParameter<edm::InputTag>("rho");
91  rhoToken_=mayConsume<double>(rho_);
92  }
93  else{
94  throw cms::Exception("No parameter rho specified")
95  << "The configured correction levels contain a L1FastJet correction, which re- \n"
96  << "quires the energy density parameter rho. Please specify this collection as \n"
97  << "additional optional parameter rho of type edm::InputTag in the jetCorrFac- \n"
98  << "tors module. \n";
99  }
100  }
101  else{
102  edm::LogInfo message( "Parameter rho not used" );
103  message << "Module is configured to use the parameter rho, but rho is only used \n"
104  << "for L1FastJet corrections. The configuration of levels does not contain \n"
105  << "L1FastJet corrections though, so rho will not be used by this module. \n";
106  }
107  }
108  produces<JetCorrFactorsMap>();
109 }
T getParameter(std::string const &) const
edm::EDGetTokenT< double > rhoToken_
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
std::string label_
label of jec factors
edm::EDGetTokenT< std::vector< reco::Vertex > > primaryVerticesToken_
std::vector< std::string > extraJPTOffset_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
bool emf_
use electromagnetic fraction for jet energy corrections or not (will only have an effect for jets Cal...
std::string payload_
label of payload
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< std::string > expand(const std::vector< std::string > &levels, const JetCorrFactors::Flavor &flavor)
edm::EDGetTokenT< edm::View< reco::Jet > > srcToken_
input jet collection
edm::InputTag primaryVertices_
label for L1Offset primaryVertex collection
edm::InputTag rho_
label for L1FastJet energy density parameter rho
bool useNPV_
use the NPV and rho with the JEC? (used for L1Offset/L1FastJet and L1FastJet, resp.)
std::string type_
type of flavor dependent JEC factors (only &#39;J&#39; and &#39;T&#39; are allowed)
unsigned long long cacheId_
cache identifier for JetCorrectionsRecord
pat::JetCorrFactorsProducer::~JetCorrFactorsProducer ( )
inline

default destructor

Definition at line 70 of file JetCorrFactorsProducer.h.

70 {};

Member Function Documentation

float JetCorrFactorsProducer::evaluate ( edm::View< reco::Jet >::const_iterator &  jet,
const JetCorrFactors::Flavor flavor,
int  level 
)
private

evaluate jet correction factor up to a given level

Definition at line 149 of file JetCorrFactorsProducer.cc.

References pat::Jet::correctedP4(), mvaPFMET_cff::corrector, correctors_, emf_, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), extraJPTOffsetCorrector_, reco::JPTJet::getCaloJetRef(), metsig::jet, testEve_cfg::level, p4, reco::LeafCandidate::phi(), and reco::LeafCandidate::pt().

Referenced by produce().

150 {
151  std::unique_ptr<FactorizedJetCorrector>& corrector = correctors_.find(flavor)->second;
152  // add parameters for JPT corrections
153  const reco::JPTJet* jpt = dynamic_cast<reco::JPTJet const *>( &*jet );
154  if( jpt ){
155  TLorentzVector p4; p4.SetPtEtaPhiE(jpt->getCaloJetRef()->pt(), jpt->getCaloJetRef()->eta(), jpt->getCaloJetRef()->phi(), jpt->getCaloJetRef()->energy());
157  extraJPTOffsetCorrector_->setJPTrawP4(p4);
158  corrector->setJPTrawOff(extraJPTOffsetCorrector_->getSubCorrections()[0]);
159  }
160  corrector->setJPTrawP4(p4);
161  }
162  //For PAT jets undo previous jet energy corrections
163  const Jet* patjet = dynamic_cast<Jet const *>( &*jet );
164  if( patjet ){
165  corrector->setJetEta(patjet->correctedP4(0).eta()); corrector->setJetPt(patjet->correctedP4(0).pt()); corrector->setJetE(patjet->correctedP4(0).energy());
166  } else {
167  corrector->setJetEta(jet->eta()); corrector->setJetPt(jet->pt()); corrector->setJetE(jet->energy());
168  }
169  if( emf_ && dynamic_cast<const reco::CaloJet*>(&*jet)){
170  corrector->setJetEMF(dynamic_cast<const reco::CaloJet*>(&*jet)->emEnergyFraction());
171  }
172  return corrector->getSubCorrections()[level];
173 }
const LorentzVector correctedP4(const std::string &level, const std::string &flavor="none", const std::string &set="") const
Definition: Jet.h:155
const edm::RefToBase< reco::Jet > & getCaloJetRef() const
Definition: JPTJet.h:130
bool emf_
use electromagnetic fraction for jet energy corrections or not (will only have an effect for jets Cal...
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
virtual double energy() const
energy
tuple corrector
Definition: mvaPFMET_cff.py:86
double p4[4]
Definition: TauolaWrapper.h:92
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:29
Analysis-level calorimeter jet class.
Definition: Jet.h:77
std::unique_ptr< FactorizedJetCorrector > extraJPTOffsetCorrector_
cache container for JPTOffset jet corrections
std::map< JetCorrFactors::Flavor, std::unique_ptr< FactorizedJetCorrector > > correctors_
cache container for jet corrections
tuple level
Definition: testEve_cfg.py:34
virtual double phi() const
momentum azimuthal angle
std::vector< std::string > JetCorrFactorsProducer::expand ( const std::vector< std::string > &  levels,
const JetCorrFactors::Flavor flavor 
)
private

return an expanded version of correction levels for different flavors; the result should be of type ['L2Relative', 'L3Absolute', 'L5FLavor_gJ', 'L7Parton_gJ']; L7Parton_gT will result in an empty string as this correction level is not available

Definition at line 112 of file JetCorrFactorsProducer.cc.

References pat::JetCorrFactors::BOTTOM, pat::JetCorrFactors::CHARM, pat::JetCorrFactors::GLUON, testEve_cfg::level, python.rootplot.argparse::message, AlCaHLTBitMon_QueryRunRegistry::string, type_, and pat::JetCorrFactors::UDS.

Referenced by JetCorrFactorsProducer().

113 {
114  std::vector<std::string> expand;
115  for(std::vector<std::string>::const_iterator level=levels.begin(); level!=levels.end(); ++level){
116  if((*level)=="L5Flavor" || (*level)=="L7Parton"){
117  if(flavor==JetCorrFactors::GLUON ){
118  if(*level=="L7Parton" && type_=="T"){
119  edm::LogWarning message( "L7Parton::GLUON not available" );
120  message << "Jet energy corrections requested for level: L7Parton and type: 'T'. \n"
121  << "For this combination there is no GLUON correction available. The \n"
122  << "correction for this flavor type will be taken from 'J'.";
123  }
124  expand.push_back(std::string(*level).append("_").append("g").append("J"));
125  }
126  if(flavor==JetCorrFactors::UDS ) expand.push_back(std::string(*level).append("_").append("q").append(type_));
127  if(flavor==JetCorrFactors::CHARM ) expand.push_back(std::string(*level).append("_").append("c").append(type_));
128  if(flavor==JetCorrFactors::BOTTOM) expand.push_back(std::string(*level).append("_").append("b").append(type_));
129  }
130  else{
131  expand.push_back(*level);
132  }
133  }
134  return expand;
135 }
std::vector< std::string > expand(const std::vector< std::string > &levels, const JetCorrFactors::Flavor &flavor)
tuple level
Definition: testEve_cfg.py:34
std::string type_
type of flavor dependent JEC factors (only &#39;J&#39; and &#39;T&#39; are allowed)
void JetCorrFactorsProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

description of configuration file parameters

Definition at line 297 of file JetCorrFactorsProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_25ns14e33_v1_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

298 {
300  iDesc.add<bool>("emf", false);
301  iDesc.add<std::string>("flavorType", "J");
302  iDesc.add<edm::InputTag>("src", edm::InputTag("ak5CaloJets"));
303  iDesc.add<std::string>("payload", "AK5Calo");
304  iDesc.add<bool>("useNPV", true);
305  iDesc.add<edm::InputTag>("primaryVertices", edm::InputTag("offlinePrimaryVertices"));
306  iDesc.add<bool>("useRho", true);
307  iDesc.add<edm::InputTag>("rho", edm::InputTag("fixedGridRhoFastjetAllCalo"));
308  iDesc.add<std::string>("extraJPTOffset", "L1Offset");
309 
310  std::vector<std::string> levels;
311  levels.push_back(std::string("L1Offset" ));
312  levels.push_back(std::string("L2Relative"));
313  levels.push_back(std::string("L3Absolute"));
314  levels.push_back(std::string("L2L3Residual"));
315  levels.push_back(std::string("L5Flavor" ));
316  levels.push_back(std::string("L7Parton" ));
317  iDesc.add<std::vector<std::string> >("levels", levels);
318  descriptions.add("JetCorrFactorsProducer", iDesc);
319 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool pat::JetCorrFactorsProducer::flavorDependent ( ) const
inlineprivate

return true if the jec levels contain at least one flavor dependent correction level

Definition at line 78 of file JetCorrFactorsProducer.h.

References levels_.

Referenced by produce().

78 { return (levels_.size()>1); };
int pat::JetCorrFactorsProducer::numberOf ( const edm::Handle< std::vector< reco::Vertex > > &  primaryVertices)
inlineprivate

determines the number of valid primary vertices for the standard L1Offset correction of JetMET

Definition at line 135 of file JetCorrFactorsProducer.h.

References HLT_25ns14e33_v1_cff::primaryVertices, and MetAnalyzer::pv().

Referenced by produce().

136  {
137  int npv=0;
138  for(std::vector<reco::Vertex>::const_iterator pv=primaryVertices->begin(); pv!=primaryVertices->end(); ++pv){
139  if(pv->ndof()>=4) ++npv;
140  }
141  return npv;
142  }
std::vector< JetCorrectorParameters > JetCorrFactorsProducer::params ( const JetCorrectorParametersCollection parameters,
const std::vector< std::string > &  levels 
) const
private

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

Definition at line 138 of file JetCorrFactorsProducer.cc.

References testEve_cfg::level, and JetCorrectorParametersCollection::push_back().

Referenced by produce().

139 {
140  std::vector<JetCorrectorParameters> params;
141  for(std::vector<std::string>::const_iterator level=levels.begin(); level!=levels.end(); ++level){
142  const JetCorrectorParameters& ip = parameters[*level]; //ip.printScreen();
143  params.push_back(ip);
144  }
145  return params;
146 }
void push_back(key_type i, value_type const &j, label_type const &flav="")
std::vector< JetCorrectorParameters > params(const JetCorrectorParametersCollection &parameters, const std::vector< std::string > &levels) const
return the jec parameters as input to the FactorizedJetCorrector for different flavors ...
tuple level
Definition: testEve_cfg.py:34
std::string JetCorrFactorsProducer::payload ( )
private

map jet algorithm to payload in DB

Definition at line 176 of file JetCorrFactorsProducer.cc.

References payload_.

Referenced by produce().

177 {
178  return payload_;
179 }
std::string payload_
label of payload
void JetCorrFactorsProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
overridevirtual

everything that needs to be done per event

Implements edm::stream::EDProducerBase.

Definition at line 182 of file JetCorrFactorsProducer.cc.

References cacheId_, correctors_, evaluate(), Exception, extraJPTOffset_, extraJPTOffsetCorrector_, edm::helper::Filler< Map >::fill(), flavorDependent(), edm::EventSetup::get(), edm::Event::getByToken(), customizeTrackingMonitorSeedNumber::idx, edm::helper::Filler< Map >::insert(), patTestJEC_cfi::jec, metsig::jet, fwrapper::jets, edm::InputTag::label(), label_, levels_, numberOf(), Parameters::parameters, params(), payload(), HLT_25ns14e33_v1_cff::primaryVertices, primaryVertices_, primaryVerticesToken_, rho, rho_, rhoToken_, srcToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

183 {
184  // get jet collection from the event
186  event.getByToken(srcToken_, jets);
187 
188  // get primary vertices for L1Offset correction level if needed
190  if(!primaryVertices_.label().empty()) event.getByToken(primaryVerticesToken_, primaryVertices);
191 
192  // get parameter rho for L1FastJet correction level if needed
194  if(!rho_.label().empty()) event.getByToken(rhoToken_, rho);
195 
196  auto const& rec = setup.get<JetCorrectionsRecord>();
197  if (cacheId_ != rec.cacheIdentifier()) {
198  // retreive parameters from the DB
200  setup.get<JetCorrectionsRecord>().get(payload(), parameters);
201  // initialize jet correctors
202  for(FlavorCorrLevelMap::const_iterator flavor=levels_.begin(); flavor!=levels_.end(); ++flavor){
203  correctors_[flavor->first].reset( new FactorizedJetCorrector(params(*parameters, flavor->second)) );
204  }
205  // initialize extra jet corrector for jpt if needed
206  if(!extraJPTOffset_.empty()){
208  }
209  cacheId_ = rec.cacheIdentifier();
210  }
211 
212  // fill the jetCorrFactors
213  std::vector<JetCorrFactors> jcfs;
214  for(edm::View<reco::Jet>::const_iterator jet = jets->begin(); jet!=jets->end(); ++jet){
215  // the JetCorrFactors::CorrectionFactor is a std::pair<std::string, std::vector<float> >
216  // the string corresponds to the label of the correction level, the vector contains four
217  // floats if flavor dependent and one float else. Per construction jet energy corrections
218  // will be flavor independent up to the first flavor dependent correction and flavor de-
219  // pendent afterwards. The first correction level is predefined with label 'Uncorrected'.
220  // Per definition it is flavor independent. The correction factor is 1.
221  std::vector<JetCorrFactors::CorrectionFactor> jec;
222  jec.push_back(std::make_pair<std::string, std::vector<float> >(std::string("Uncorrected"), std::vector<float>(1, 1)));
223 
224  // pick the first element in the map (which could be the only one) and loop all jec
225  // levels listed for that element. If this is not the only element all jec levels, which
226  // are flavor independent will give the same correction factors until the first flavor
227  // dependent correction level is reached. So the first element is still a good choice.
228  FlavorCorrLevelMap::const_iterator corrLevel=levels_.begin();
229  if(corrLevel==levels_.end()){
230  throw cms::Exception("No JECFactors") << "You request to create a jetCorrFactors object with no JEC Levels indicated. \n"
231  << "This makes no sense, either you should correct this or drop the module from \n"
232  << "the sequence.";
233  }
234  for(unsigned int idx=0; idx<corrLevel->second.size(); ++idx){
235  bool flavorDependent=false;
236  std::vector<float> factors;
237  if(flavorDependent ||
238  corrLevel->second[idx].find("L5Flavor")!=std::string::npos ||
239  corrLevel->second[idx].find("L7Parton")!=std::string::npos){
240  flavorDependent=true;
241  // after the first encounter all subsequent correction levels are flavor dependent
242  for(FlavorCorrLevelMap::const_iterator flavor=corrLevel; flavor!=levels_.end(); ++flavor){
243  if(!primaryVertices_.label().empty()){
244  // if primaryVerticesToken_ has a value the number of primary vertices needs to be
245  // specified
246  correctors_.find(flavor->first)->second->setNPV(numberOf(primaryVertices));
247  }
248  if(!rho_.label().empty()){
249  // if rhoToken_ has a value the energy density parameter rho and the jet area need
250  // to be specified
251  correctors_.find(flavor->first)->second->setRho(*rho);
252  correctors_.find(flavor->first)->second->setJetA(jet->jetArea());
253  }
254  factors.push_back(evaluate(jet, flavor->first, idx));
255  }
256  }
257  else{
258  if(!primaryVertices_.label().empty()){
259  // if primaryVerticesToken_ has a value the number of primary vertices needs to be
260  // specified
261  correctors_.find(corrLevel->first)->second->setNPV(numberOf(primaryVertices));
262  }
263  if(!rho_.label().empty()){
264  // if rhoToken_ has a value the energy density parameter rho and the jet area need
265  // to be specified
266  correctors_.find(corrLevel->first)->second->setRho(*rho);
267  correctors_.find(corrLevel->first)->second->setJetA(jet->jetArea());
268  }
269  factors.push_back(evaluate(jet, corrLevel->first, idx));
270  }
271  // push back the set of JetCorrFactors: the first entry corresponds to the label
272  // of the correction level, which is taken from the first element in levels_. For
273  // L5Flavor and L7Parton the part including the first '_' indicating the flavor
274  // of the first element in levels_ is chopped of from the label to avoid confusion
275  // of the correction levels. The second parameter corresponds to the set of jec
276  // factors, which might be flavor dependent or not. In the default configuration
277  // the CorrectionFactor will look like this: 'Uncorrected': 1 ; 'L2Relative': x ;
278  // 'L3Absolute': x ; 'L5Flavor': v, x, y, z ; 'L7Parton': v, x, y, z
279  jec.push_back(std::make_pair((corrLevel->second[idx]).substr(0, (corrLevel->second[idx]).find("_")), factors));
280  }
281  // create the actual object with the scale factors we want the valuemap to refer to
282  // label_ corresponds to the label of the module instance
283  JetCorrFactors corrFactors(label_, jec);
284  jcfs.push_back(corrFactors);
285  }
286  // build the value map
287  std::auto_ptr<JetCorrFactorsMap> jetCorrsMap(new JetCorrFactorsMap());
288  JetCorrFactorsMap::Filler filler(*jetCorrsMap);
289  // jets and jetCorrs have their indices aligned by construction
290  filler.insert(jets, jcfs.begin(), jcfs.end());
291  filler.fill(); // do the actual filling
292  // put our produced stuff in the event
293  event.put(jetCorrsMap);
294 }
edm::EDGetTokenT< double > rhoToken_
dictionary parameters
Definition: Parameters.py:2
std::string payload()
map jet algorithm to payload in DB
std::string label_
label of jec factors
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< std::vector< reco::Vertex > > primaryVerticesToken_
std::vector< std::string > extraJPTOffset_
bool flavorDependent() const
return true if the jec levels contain at least one flavor dependent correction level ...
int numberOf(const edm::Handle< std::vector< reco::Vertex > > &primaryVertices)
determines the number of valid primary vertices for the standard L1Offset correction of JetMET ...
Class for the storage of jet correction factors.
vector< PseudoJet > jets
helper::Filler< ValueMap< pat::JetCorrFactors > > Filler
Definition: ValueMap.h:170
edm::ValueMap< pat::JetCorrFactors > JetCorrFactorsMap
value map for JetCorrFactors (to be written into the event)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
edm::EDGetTokenT< edm::View< reco::Jet > > srcToken_
input jet collection
const T & get() const
Definition: EventSetup.h:56
std::vector< JetCorrectorParameters > params(const JetCorrectorParametersCollection &parameters, const std::vector< std::string > &levels) const
return the jec parameters as input to the FactorizedJetCorrector for different flavors ...
std::string const & label() const
Definition: InputTag.h:43
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85
std::unique_ptr< FactorizedJetCorrector > extraJPTOffsetCorrector_
cache container for JPTOffset jet corrections
std::map< JetCorrFactors::Flavor, std::unique_ptr< FactorizedJetCorrector > > correctors_
cache container for jet corrections
edm::InputTag primaryVertices_
label for L1Offset primaryVertex collection
edm::InputTag rho_
label for L1FastJet energy density parameter rho
float evaluate(edm::View< reco::Jet >::const_iterator &jet, const JetCorrFactors::Flavor &flavor, int level)
evaluate jet correction factor up to a given level
unsigned long long cacheId_
cache identifier for JetCorrectionsRecord

Member Data Documentation

unsigned long long pat::JetCorrFactorsProducer::cacheId_
private

cache identifier for JetCorrectionsRecord

Definition at line 127 of file JetCorrFactorsProducer.h.

Referenced by produce().

std::map<JetCorrFactors::Flavor, std::unique_ptr<FactorizedJetCorrector> > pat::JetCorrFactorsProducer::correctors_
private

cache container for jet corrections

Definition at line 129 of file JetCorrFactorsProducer.h.

Referenced by evaluate(), and produce().

bool pat::JetCorrFactorsProducer::emf_
private

use electromagnetic fraction for jet energy corrections or not (will only have an effect for jets CaloJets)

Definition at line 94 of file JetCorrFactorsProducer.h.

Referenced by evaluate().

std::vector<std::string> pat::JetCorrFactorsProducer::extraJPTOffset_
private

label of additional L1Offset corrector for JPT jets; for format reasons this string is kept in a vector of strings

Definition at line 105 of file JetCorrFactorsProducer.h.

Referenced by JetCorrFactorsProducer(), and produce().

std::unique_ptr<FactorizedJetCorrector> pat::JetCorrFactorsProducer::extraJPTOffsetCorrector_
private

cache container for JPTOffset jet corrections

Definition at line 131 of file JetCorrFactorsProducer.h.

Referenced by evaluate(), and produce().

std::string pat::JetCorrFactorsProducer::label_
private

label of jec factors

Definition at line 100 of file JetCorrFactorsProducer.h.

Referenced by Mixins._Labelable::_findDependencies(), produce(), and Mixins._Labelable::setLabel().

FlavorCorrLevelMap pat::JetCorrFactorsProducer::levels_
private

jec levels for different flavors. In the default configuration this map would look like this: GLUON : 'L2Relative', 'L3Absolute', 'L5FLavor_jg', L7Parton_jg' UDS : 'L2Relative', 'L3Absolute', 'L5FLavor_jq', L7Parton_jq' CHARM : 'L2Relative', 'L3Absolute', 'L5FLavor_jc', L7Parton_jc' BOTTOM : 'L2Relative', 'L3Absolute', 'L5FLavor_jb', L7Parton_jb' or just like this: NONE : 'L2Relative', 'L3Absolute', 'L2L3Residual' per definition the vectors for all elements in this map should have the same size

Definition at line 125 of file JetCorrFactorsProducer.h.

Referenced by flavorDependent(), JetCorrFactorsProducer(), and produce().

std::string pat::JetCorrFactorsProducer::payload_
private

label of payload

Definition at line 102 of file JetCorrFactorsProducer.h.

Referenced by payload().

edm::InputTag pat::JetCorrFactorsProducer::primaryVertices_
private

label for L1Offset primaryVertex collection

Definition at line 107 of file JetCorrFactorsProducer.h.

Referenced by JetCorrFactorsProducer(), and produce().

edm::EDGetTokenT<std::vector<reco::Vertex> > pat::JetCorrFactorsProducer::primaryVerticesToken_
private

Definition at line 108 of file JetCorrFactorsProducer.h.

Referenced by JetCorrFactorsProducer(), and produce().

edm::InputTag pat::JetCorrFactorsProducer::rho_
private

label for L1FastJet energy density parameter rho

Definition at line 110 of file JetCorrFactorsProducer.h.

Referenced by JetCorrFactorsProducer(), and produce().

edm::EDGetTokenT<double> pat::JetCorrFactorsProducer::rhoToken_
private

Definition at line 111 of file JetCorrFactorsProducer.h.

Referenced by JetCorrFactorsProducer(), and produce().

edm::EDGetTokenT<edm::View<reco::Jet> > pat::JetCorrFactorsProducer::srcToken_
private

input jet collection

Definition at line 96 of file JetCorrFactorsProducer.h.

Referenced by produce().

std::string pat::JetCorrFactorsProducer::type_
private
bool pat::JetCorrFactorsProducer::useNPV_
private

use the NPV and rho with the JEC? (used for L1Offset/L1FastJet and L1FastJet, resp.)

Definition at line 113 of file JetCorrFactorsProducer.h.

Referenced by JetCorrFactorsProducer().

bool pat::JetCorrFactorsProducer::useRho_
private

Definition at line 114 of file JetCorrFactorsProducer.h.

Referenced by JetCorrFactorsProducer().