CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
cms::JetCorrectionProducer< T > Class Template Reference

#include <JetCorrectionProducer.h>

Inheritance diagram for cms::JetCorrectionProducer< T >:
edm::stream::EDProducer<>

Public Types

typedef std::vector< TJetCollection
 
- 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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

 JetCorrectionProducer (const edm::ParameterSet &fParameters)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~JetCorrectionProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

unsigned long long mCacheId
 
std::vector< std::string > mCorrectorNames
 
std::vector< const JetCorrector * > mCorrectors
 
edm::EDGetTokenT< JetCollectionmInput
 
bool mVerbose
 

Detailed Description

template<class T>
class cms::JetCorrectionProducer< T >

Definition at line 31 of file JetCorrectionProducer.h.

Member Typedef Documentation

template<class T >
typedef std::vector<T> cms::JetCorrectionProducer< T >::JetCollection

Definition at line 34 of file JetCorrectionProducer.h.

Constructor & Destructor Documentation

template<class T >
cms::JetCorrectionProducer< T >::JetCorrectionProducer ( const edm::ParameterSet fParameters)
explicit

Definition at line 53 of file JetCorrectionProducer.h.

References egammaCTFFinalFitWithMaterial_cff::alias, edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

54  : mInput(consumes<JetCollection>(fConfig.getParameter <edm::InputTag> ("src")))
55  , mCorrectorNames(fConfig.getParameter<std::vector<std::string> >("correctors"))
56  , mCorrectors(mCorrectorNames.size(), nullptr)
57  , mCacheId (0)
58  , mVerbose (fConfig.getUntrackedParameter <bool> ("verbose", false))
59  {
60  std::string alias = fConfig.getUntrackedParameter <std::string> ("alias", "");
61  if (alias.empty ())
62  produces <JetCollection>();
63  else
64  produces <JetCollection>().setBranchAlias(alias);
65  }
std::vector< std::string > mCorrectorNames
edm::EDGetTokenT< JetCollection > mInput
std::vector< const JetCorrector * > mCorrectors
template<class T >
cms::JetCorrectionProducer< T >::~JetCorrectionProducer ( )
inlineoverride

Definition at line 36 of file JetCorrectionProducer.h.

36 {}

Member Function Documentation

template<class T >
void cms::JetCorrectionProducer< T >::produce ( edm::Event fEvent,
const edm::EventSetup fSetup 
)
override

Definition at line 68 of file JetCorrectionProducer.h.

References edm::eventsetup::EventSetupRecord::cacheIdentifier(), gather_cfg::cout, edm::EventSetup::get(), edm::eventsetup::EventSetupRecordImplementation< T >::get(), edm::Event::getByToken(), cmsBatch::handle, mps_fire::i, metsig::jet, fwrapper::jets, cms::JetCorrectionProducer< T >::mCacheId, cms::JetCorrectionProducer< T >::mCorrectorNames, cms::JetCorrectionProducer< T >::mCorrectors, cms::JetCorrectionProducer< T >::mInput, eostools::move(), cms::JetCorrectionProducer< T >::mVerbose, edm::Event::put(), record, mps_fire::result, Scenarios_cff::scale, and jetUpdater_cfi::sort.

70  {
71  // look for correctors
73  if (record.cacheIdentifier() != mCacheId)
74  { // need to renew cache
75  for (unsigned i = 0; i < mCorrectorNames.size(); i++)
76  {
78  record.get (mCorrectorNames [i], handle);
79  mCorrectors [i] = &*handle;
80  }
81  mCacheId = record.cacheIdentifier();
82  }
83  edm::Handle<JetCollection> jets; //Define Inputs
84  fEvent.getByToken (mInput, jets); //Get Inputs
85  std::unique_ptr<JetCollection> result (new JetCollection); //Corrected jets
86  typename JetCollection::const_iterator jet;
87  for (jet = jets->begin(); jet != jets->end(); jet++)
88  {
89  const T* referenceJet = &*jet;
90  int index = jet-jets->begin();
92  T correctedJet = *jet; //copy original jet
93  if (mVerbose)
94  std::cout<<"JetCorrectionProducer::produce-> original jet: "
95  <<jet->print()<<std::endl;
96  for (unsigned i = 0; i < mCorrectors.size(); ++i)
97  {
98  if ( !(mCorrectors[i]->vectorialCorrection()) ) {
99  // Scalar correction
100  double scale = 1.;
101  if (!(mCorrectors[i]->refRequired()))
102  scale = mCorrectors[i]->correction (*referenceJet,fEvent,fSetup);
103  else
104  scale = mCorrectors[i]->correction (*referenceJet,jetRef,fEvent,fSetup);
105  if (mVerbose)
106  std::cout<<"JetCorrectionProducer::produce-> Corrector # "
107  <<i<<", correction factor: "<<scale<<std::endl;
108  correctedJet.scaleEnergy (scale); // apply scalar correction
109  referenceJet = &correctedJet;
110  } else {
111  // Vectorial correction
112  JetCorrector::LorentzVector corrected;
113  double scale = mCorrectors[i]->correction (*referenceJet, jetRef,
114  fEvent, fSetup, corrected);
115  if (mVerbose)
116  std::cout<<"JetCorrectionProducer::produce-> Corrector # "
117  <<i<<", correction factor: "<<scale<<std::endl;
118  correctedJet.setP4( corrected ); // apply vectorial correction
119  referenceJet = &correctedJet;
120  }
121  }
122  if (mVerbose)
123  std::cout<<"JetCorrectionProducer::produce-> corrected jet: "
124  <<correctedJet.print ()<<std::endl;
125  result->push_back (correctedJet);
126  }
127  NumericSafeGreaterByPt<T> compJets;
128  // reorder corrected jets
129  std::sort (result->begin (), result->end (), compJets);
130  // put corrected jet collection into event
131  fEvent.put(std::move(result));
132  }
unsigned long long cacheIdentifier() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
JetCorrectorParameters::Record record
Definition: classes.h:7
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< std::string > mCorrectorNames
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
edm::EDGetTokenT< JetCollection > mInput
vector< PseudoJet > jets
T get() const
Definition: EventSetup.h:71
std::vector< const JetCorrector * > mCorrectors
long double T
def move(src, dest)
Definition: eostools.py:511
reco::Particle::LorentzVector LorentzVector
Definition: JetCorrector.h:23

Member Data Documentation

template<class T >
unsigned long long cms::JetCorrectionProducer< T >::mCacheId
private

Definition at line 43 of file JetCorrectionProducer.h.

Referenced by cms::JetCorrectionProducer< T >::produce().

template<class T >
std::vector<std::string> cms::JetCorrectionProducer< T >::mCorrectorNames
private

Definition at line 40 of file JetCorrectionProducer.h.

Referenced by cms::JetCorrectionProducer< T >::produce().

template<class T >
std::vector<const JetCorrector*> cms::JetCorrectionProducer< T >::mCorrectors
private

Definition at line 42 of file JetCorrectionProducer.h.

Referenced by cms::JetCorrectionProducer< T >::produce().

template<class T >
edm::EDGetTokenT<JetCollection> cms::JetCorrectionProducer< T >::mInput
private

Definition at line 39 of file JetCorrectionProducer.h.

Referenced by cms::JetCorrectionProducer< T >::produce().

template<class T >
bool cms::JetCorrectionProducer< T >::mVerbose
private

Definition at line 44 of file JetCorrectionProducer.h.

Referenced by cms::JetCorrectionProducer< T >::produce().