CMS 3D CMS Logo

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

Produces pat::Jet's. More...

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

Inheritance diagram for pat::PATJetUpdater:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATJetUpdater (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATJetUpdater ()
 
- 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
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)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

bool addJetCorrFactors_
 
std::vector< edm::EDGetTokenT
< edm::ValueMap
< JetCorrFactors > > > 
jetCorrFactorsTokens_
 
edm::EDGetTokenT< edm::View
< Jet > > 
jetsToken_
 
GreaterByPt< JetpTComparator_
 
pat::PATUserDataHelper< pat::JetuserDataHelper_
 
bool useUserData_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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)
 

Detailed Description

Produces pat::Jet's.

The PATJetUpdater produces analysis-level pat::Jet's starting from a collection of pat::Jet's and updates information.

Author
Andreas Hinzmann
Version
Id:
PATJetUpdater.h,v 1.00 2014/03/11 18:13:54 srappocc Exp

Definition at line 34 of file PATJetUpdater.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file PATJetUpdater.cc.

References addJetCorrFactors_, edm::ParameterSet::getParameter(), jetCorrFactorsTokens_, jetsToken_, edm::EDConsumerBase::mayConsume(), GlobalPosition_Frontier_DevDB_cff::tag, and edm::vector_transform().

28  :
29  useUserData_(iConfig.exists("userData"))
30 {
31  // initialize configurables
32  jetsToken_ = consumes<edm::View<Jet> >(iConfig.getParameter<edm::InputTag>( "jetSource" ));
33  addJetCorrFactors_ = iConfig.getParameter<bool>( "addJetCorrFactors" );
34  jetCorrFactorsTokens_ = edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >( "jetCorrFactorsSource" ), [this](edm::InputTag const & tag){return mayConsume<edm::ValueMap<JetCorrFactors> >(tag);});
35  // Check to see if the user wants to add user data
36  if ( useUserData_ ) {
38  }
39  // produces vector of jets
40  produces<std::vector<Jet> >();
41 }
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
bool exists(std::string const &parameterName) const
checks if a parameter exists
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
pat::PATUserDataHelper< pat::Jet > userDataHelper_
Definition: PATJetUpdater.h:55
edm::EDGetTokenT< edm::View< Jet > > jetsToken_
Definition: PATJetUpdater.h:48
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::vector< edm::EDGetTokenT< edm::ValueMap< JetCorrFactors > > > jetCorrFactorsTokens_
Definition: PATJetUpdater.h:50
PATJetUpdater::~PATJetUpdater ( )

Definition at line 44 of file PATJetUpdater.cc.

44  {
45 
46 }

Member Function Documentation

void PATJetUpdater::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 121 of file PATJetUpdater.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), pat::PATUserDataHelper< ObjectType >::fillDescription(), HLT_25ns14e33_v1_cff::InputTag, and edm::ParameterSetDescription::setComment().

122 {
124  iDesc.setComment("PAT jet producer module");
125 
126  // input source
127  iDesc.add<edm::InputTag>("jetSource", edm::InputTag("no default"))->setComment("input collection");
128 
129  // jet energy corrections
130  iDesc.add<bool>("addJetCorrFactors", true);
131  std::vector<edm::InputTag> emptyVInputTags;
132  iDesc.add<std::vector<edm::InputTag> >("jetCorrFactorsSource", emptyVInputTags);
133 
134  // Check to see if the user wants to add user data
135  edm::ParameterSetDescription userDataPSet;
137  iDesc.addOptional("userData", userDataPSet);
138 
139  descriptions.add("PATJetUpdater", iDesc);
140 }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PATJetUpdater::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 49 of file PATJetUpdater.cc.

References pat::Jet::addJECFactors(), addJetCorrFactors_, pat::Jet::availableJECSets(), pat::Jet::correctedP4(), spr::find(), plotBeamSpotDB::first, edm::Event::getByToken(), i, customizeTrackingMonitorSeedNumber::idx, pat::Jet::initializeJEC(), jetCorrFactorsTokens_, fwrapper::jets, jetsToken_, pat::JetCorrFactors::NONE, jetProducer_cfi::patJets, pTComparator_, edm::Event::put(), reco::LeafCandidate::setP4(), python.multivaluedict::sort(), userDataHelper_, and useUserData_.

50 {
51  // Get the vector of jets
53  iEvent.getByToken(jetsToken_, jets);
54 
55  // read in the jet correction factors ValueMap
56  std::vector<edm::ValueMap<JetCorrFactors> > jetCorrs;
57  if (addJetCorrFactors_) {
58  for ( size_t i = 0; i < jetCorrFactorsTokens_.size(); ++i ) {
60  iEvent.getByToken(jetCorrFactorsTokens_[i], jetCorr);
61  jetCorrs.push_back( *jetCorr );
62  }
63  }
64 
65  // loop over jets
66  std::auto_ptr< std::vector<Jet> > patJets ( new std::vector<Jet>() );
67 
68  bool first=true; // this is introduced to issue warnings only for the first jet
69  for (edm::View<Jet>::const_iterator itJet = jets->begin(); itJet != jets->end(); itJet++) {
70 
71  // construct the Jet from the ref -> save ref to original object
72  unsigned int idx = itJet - jets->begin();
73  edm::RefToBase<Jet> jetRef = jets->refAt(idx);
74  edm::Ptr<Jet> jetPtr = jets->ptrAt(idx);
75  Jet ajet(jetPtr);
76 
77  if (addJetCorrFactors_) {
78  unsigned int setindex = ajet.availableJECSets().size();
79  // Undo previous jet energy corrections
80  ajet.setP4(ajet.correctedP4(0));
81  // add additional JetCorrs to the jet
82  for ( unsigned int i=0; i<jetCorrFactorsTokens_.size(); ++i ) {
83  const JetCorrFactors& jcf = jetCorrs[i][jetRef];
84  // uncomment for debugging
85  // jcf.print();
86  ajet.addJECFactors(jcf);
87  }
88  std::vector<std::string> levels = jetCorrs[0][jetRef].correctionLabels();
89  if(std::find(levels.begin(), levels.end(), "L2L3Residual")!=levels.end()){
90  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L2L3Residual"), JetCorrFactors::NONE, setindex);
91  }
92  else if(std::find(levels.begin(), levels.end(), "L3Absolute")!=levels.end()){
93  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("L3Absolute"), JetCorrFactors::NONE, setindex);
94  }
95  else{
96  ajet.initializeJEC(jetCorrs[0][jetRef].jecLevel("Uncorrected"), JetCorrFactors::NONE, setindex);
97  if(first){
98  edm::LogWarning("L3Absolute not found") << "L2L3Residual and L3Absolute are not part of the correction applied jetCorrFactors \n"
99  << "of module " << jetCorrs[0][jetRef].jecSet() << " jets will remain"
100  << " uncorrected."; first=false;
101  }
102  }
103  }
104 
105  if ( useUserData_ ) {
106  userDataHelper_.add( ajet, iEvent, iSetup );
107  }
108 
109  patJets->push_back(ajet);
110  }
111 
112  // sort jets in pt
113  std::sort(patJets->begin(), patJets->end(), pTComparator_);
114 
115  // put genEvt in Event
116  iEvent.put(patJets);
117 
118 }
int i
Definition: DBlmapReader.cc:9
GreaterByPt< Jet > pTComparator_
Definition: PATJetUpdater.h:52
std::vector< std::string > correctionLabels() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
Class for the storage of jet correction factors.
vector< PseudoJet > jets
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
Analysis-level calorimeter jet class.
Definition: Jet.h:77
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
pat::PATUserDataHelper< pat::Jet > userDataHelper_
Definition: PATJetUpdater.h:55
edm::EDGetTokenT< edm::View< Jet > > jetsToken_
Definition: PATJetUpdater.h:48
std::vector< edm::EDGetTokenT< edm::ValueMap< JetCorrFactors > > > jetCorrFactorsTokens_
Definition: PATJetUpdater.h:50

Member Data Documentation

bool pat::PATJetUpdater::addJetCorrFactors_
private

Definition at line 49 of file PATJetUpdater.h.

Referenced by PATJetUpdater(), and produce().

std::vector<edm::EDGetTokenT<edm::ValueMap<JetCorrFactors> > > pat::PATJetUpdater::jetCorrFactorsTokens_
private

Definition at line 50 of file PATJetUpdater.h.

Referenced by PATJetUpdater(), and produce().

edm::EDGetTokenT<edm::View<Jet> > pat::PATJetUpdater::jetsToken_
private

Definition at line 48 of file PATJetUpdater.h.

Referenced by PATJetUpdater(), and produce().

GreaterByPt<Jet> pat::PATJetUpdater::pTComparator_
private

Definition at line 52 of file PATJetUpdater.h.

Referenced by produce().

pat::PATUserDataHelper<pat::Jet> pat::PATJetUpdater::userDataHelper_
private

Definition at line 55 of file PATJetUpdater.h.

Referenced by produce().

bool pat::PATJetUpdater::useUserData_
private

Definition at line 54 of file PATJetUpdater.h.

Referenced by produce().