Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77545
b: "refs/heads/CMSSW_7_1_X"
c: 8ccfdd0
h: "refs/heads/CMSSW_7_1_X"
i:
  77543: 1d7da34
v: v3
  • Loading branch information
Philipp Schieferdecker committed Nov 10, 2009
1 parent 57a2979 commit 6444332
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 70 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
refs/heads/gh-pages: 09c786f70121f131b3715aaf3464996502bbeb7e
"refs/heads/CMSSW_7_1_X": 419389406198346a9cb95363674dade67d4e5863
"refs/heads/CMSSW_7_1_X": 8ccfdd091a5be573bcf69baf4b1257f7c4736328
14 changes: 14 additions & 0 deletions trunk/JetMETCorrections/Modules/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
2009-11-10 Philipp SCHIEFERDECKER <[email protected]>

* adjust JetCorrectionProducer to interface change in
JetMETCorrections/Objects:
JetCorrector::correction(jet,event,setup) has become
JetCorrector::correction(jet,jetRef,event,setup)
* define new L1FastjetCorrectionService and L6SLBCorrectionService
in plugins/SealModule.cc
* define new GenJetCorrectionProducer in
plugins/SealModule.cc. This is useful to cross-check corrections
which are derived by studying the difference between two different
GenJet definitions, e.g. one clustered with and one without
neutrinos

148 changes: 79 additions & 69 deletions trunk/JetMETCorrections/Modules/interface/JetCorrectionProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class JetCorrector;
namespace cms
{
template<class T>
class JetCorrectionProducer : public edm::EDProducer {
class JetCorrectionProducer : public edm::EDProducer
{
public:
typedef std::vector<T> JetCollection;
explicit JetCorrectionProducer (const edm::ParameterSet& fParameters);
Expand All @@ -45,77 +46,86 @@ namespace cms
// ---------- implementation ----------

namespace cms {

template<class T>
JetCorrectionProducer<T>::JetCorrectionProducer (const edm::ParameterSet& fConfig)
:
mInput (fConfig.getParameter <edm::InputTag> ("src")),
mCorrectorNames (fConfig.getParameter <std::vector <std::string> > ("correctors")),
mCorrectors (mCorrectorNames.size(), 0),
mCacheId (0),
mVerbose (fConfig.getUntrackedParameter <bool> ("verbose", false))
{

std::string alias = fConfig.getUntrackedParameter <std::string> ("alias", "");
if (alias.empty ())
produces <JetCollection>();
else
produces <JetCollection>().setBranchAlias (alias);
}

JetCorrectionProducer<T>::JetCorrectionProducer(const edm::ParameterSet& fConfig)
: mInput(fConfig.getParameter <edm::InputTag> ("src"))
, mCorrectorNames(fConfig.getParameter<std::vector<std::string> >("correctors"))
, mCorrectors(mCorrectorNames.size(), 0)
, mCacheId (0)
, mVerbose (fConfig.getUntrackedParameter <bool> ("verbose", false))
{
std::string alias = fConfig.getUntrackedParameter <std::string> ("alias", "");
if (alias.empty ())
produces <JetCollection>();
else
produces <JetCollection>().setBranchAlias(alias);
}

template<class T>
void JetCorrectionProducer<T>::produce(edm::Event& fEvent, const edm::EventSetup& fSetup)
{
// look for correctors
const JetCorrectionsRecord& record = fSetup.get <JetCorrectionsRecord> ();
if (record.cacheIdentifier() != mCacheId)
{ // need to renew cache
for (unsigned i = 0; i < mCorrectorNames.size(); i++)
{
edm::ESHandle <JetCorrector> handle;
record.get (mCorrectorNames [i], handle);
mCorrectors [i] = &*handle;
void JetCorrectionProducer<T>::produce(edm::Event& fEvent,
const edm::EventSetup& fSetup)
{
// look for correctors
const JetCorrectionsRecord& record = fSetup.get <JetCorrectionsRecord> ();
if (record.cacheIdentifier() != mCacheId)
{ // need to renew cache
for (unsigned i = 0; i < mCorrectorNames.size(); i++)
{
edm::ESHandle <JetCorrector> handle;
record.get (mCorrectorNames [i], handle);
mCorrectors [i] = &*handle;
}
mCacheId = record.cacheIdentifier();
}
edm::Handle<JetCollection> jets; //Define Inputs
fEvent.getByLabel (mInput, jets); //Get Inputs
std::auto_ptr<JetCollection> result (new JetCollection); //Corrected jets
typename JetCollection::const_iterator jet;
for (jet = jets->begin(); jet != jets->end(); jet++)
{
const T* referenceJet = &*jet;
int index = jet-jets->begin();
edm::RefToBase<reco::Jet> jetRef(edm::Ref<JetCollection>(jets,index));
T correctedJet = *jet; //copy original jet
if (mVerbose)
std::cout<<"JetCorrectionProducer::produce-> original jet: "
<<jet->print()<<std::endl;
for (unsigned i = 0; i < mCorrectors.size(); ++i)
{
if ( !(mCorrectors[i]->vectorialCorrection()) ) {
// Scalar correction
double scale = mCorrectors[i]->correction (*referenceJet,jetRef,
fEvent,fSetup);
if (mVerbose)
std::cout<<"JetCorrectionProducer::produce-> Corrector # "
<<i<<", correction factor: "<<scale<<std::endl;
correctedJet.scaleEnergy (scale); // apply scalar correction
referenceJet = &correctedJet;
} else {
// Vectorial correction
JetCorrector::LorentzVector corrected;
double scale = mCorrectors[i]->correction (*referenceJet, fEvent,
fSetup, corrected);
if (mVerbose)
std::cout<<"JetCorrectionProducer::produce-> Corrector # "
<<i<<", correction factor: "<<scale<<std::endl;
correctedJet.setP4( corrected ); // apply vectorial correction
referenceJet = &correctedJet;
}
mCacheId = record.cacheIdentifier();
}
edm::Handle<JetCollection> jets; //Define Inputs
fEvent.getByLabel (mInput, jets); //Get Inputs
std::auto_ptr<JetCollection> result (new JetCollection); //Corrected jets
typename JetCollection::const_iterator jet;
for (jet = jets->begin(); jet != jets->end(); jet++)
{
const T* referenceJet = &*jet;
T correctedJet = *jet; //copy original jet
if (mVerbose)
std::cout << "JetCorrectionProducer::produce-> original jet: " << jet->print () << std::endl;
for (unsigned i = 0; i < mCorrectors.size(); ++i)
{
if ( !(mCorrectors[i]->vectorialCorrection()) ) {
// Scalar correction
double scale = mCorrectors[i]->correction (*referenceJet, fEvent, fSetup);
if (mVerbose)
std::cout << "JetCorrectionProducer::produce-> Corrector # " << i << ", correction factor: " << scale << std::endl;
correctedJet.scaleEnergy (scale); // apply scalar correction
referenceJet = &correctedJet;
} else {
// Vectorial correction
JetCorrector::LorentzVector corrected;
double scale = mCorrectors[i]->correction (*referenceJet, fEvent, fSetup, corrected);
if (mVerbose)
std::cout << "JetCorrectionProducer::produce-> Corrector # " << i << ", correction factor: " << scale << std::endl;
correctedJet.setP4( corrected ); // apply vectorial correction
referenceJet = &correctedJet;
}
}
if (mVerbose)
std::cout << "JetCorrectionProducer::produce-> corrected jet: " << correctedJet.print () << std::endl;
result->push_back (correctedJet);
}
NumericSafeGreaterByPt<T> compJets;
std::sort (result->begin (), result->end (), compJets); // reorder corrected jets
fEvent.put(result); //Puts Corrected Jet Collection into event
}

}
if (mVerbose)
std::cout<<"JetCorrectionProducer::produce-> corrected jet: "
<<correctedJet.print ()<<std::endl;
result->push_back (correctedJet);
}
NumericSafeGreaterByPt<T> compJets;
// reorder corrected jets
std::sort (result->begin (), result->end (), compJets);
// put corrected jet collection into event
fEvent.put(result);
}

}

#endif
13 changes: 13 additions & 0 deletions trunk/JetMETCorrections/Modules/plugins/SealModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ DEFINE_SEAL_MODULE();
#include "JetMETCorrections/Modules/interface/PlotJetCorrections.h"
#include "JetMETCorrections/Algorithms/interface/ZSPJetCorrector.h"
#include "JetMETCorrections/Algorithms/interface/LXXXCorrector.h"
#include "JetMETCorrections/Algorithms/interface/L1FastjetCorrector.h"
#include "JetMETCorrections/Algorithms/interface/L6SLBCorrector.h"
#include "JetMETCorrections/Algorithms/interface/JetPlusTrackCorrector.h"
#include "DataFormats/JetReco/interface/CaloJet.h"
#include "DataFormats/JetReco/interface/PFJet.h"
#include "DataFormats/JetReco/interface/GenJet.h"

REGISTER_PLUGIN (JetCorrectionsRecord, JetCorrector);

using namespace cms;
Expand All @@ -26,13 +30,22 @@ DEFINE_ANOTHER_FWK_MODULE(CaloJetCorrectionProducer);
typedef JetCorrectionProducer<PFJet> PFJetCorrectionProducer;
DEFINE_ANOTHER_FWK_MODULE(PFJetCorrectionProducer);

typedef JetCorrectionProducer<GenJet> GenJetCorrectionProducer;
DEFINE_ANOTHER_FWK_MODULE(GenJetCorrectionProducer);

DEFINE_ANOTHER_FWK_MODULE(PlotJetCorrections);

DEFINE_ANOTHER_FWK_EVENTSETUP_SOURCE(JetCorrectionServiceChain);

//--------------- Generic LX correction service --------------------
DEFINE_JET_CORRECTION_SERVICE (LXXXCorrector, LXXXCorrectionService);

//--------------- L1 fastjet UE&PU subtraction correction service --
DEFINE_JET_CORRECTION_SERVICE (L1FastjetCorrector, L1FastjetCorrectionService);

//--------------- L6 SLB correction service -----------------------
DEFINE_JET_CORRECTION_SERVICE (L6SLBCorrector, L6SLBCorrectionService);

//--------------- Zero suppression correction service --------------
DEFINE_JET_CORRECTION_SERVICE (ZSPJetCorrector, ZSPJetCorrectionService);

Expand Down

0 comments on commit 6444332

Please sign in to comment.