CMS 3D CMS Logo

FlavorJetCorrectionExample.cc
Go to the documentation of this file.
1 /* Example analizer to use L5 flavor JetCorrector services
2  Applies different flavor corrections randomly
3  F.Ratnikov (UMd) Nov 16, 2007
4 */
5 
6 #include <string>
7 
10 
12  public:
13  explicit FlavorJetCorrectionExample (const edm::ParameterSet& fParameters);
15  void analyze(const edm::Event&, const edm::EventSetup&) override;
16  private:
21 };
22 
23 
24 
25 
32 
33 using namespace std;
34 using namespace reco;
35 
37  : mInput (fConfig.getParameter <edm::InputTag> ("src")),
38  mUDSCorrectorName (fConfig.getParameter <std::string> ("UDSQuarksCorrector")),
39  mCCorrectorName (fConfig.getParameter <std::string> ("CQuarkCorrector")),
40  mBCorrectorName (fConfig.getParameter <std::string> ("BQuarkCorrector"))
41 {}
42 
44  // get all correctors
45  const JetCorrector* udsJetCorrector = JetCorrector::getJetCorrector (mUDSCorrectorName, fSetup);
46  const JetCorrector* cQuarkJetCorrector = JetCorrector::getJetCorrector (mCCorrectorName, fSetup);
47  const JetCorrector* bQuarkJetCorrector = JetCorrector::getJetCorrector (mBCorrectorName, fSetup);
48  const JetCorrector* corrector = nullptr;
49 
50  // get input jets (supposed to be MC corrected already)
52  fEvent.getByLabel (mInput, jets);
53  // loop over jets
54  for (unsigned ijet = 0; ijet < jets->size(); ++ijet) {
55  const CaloJet& jet = (*jets)[ijet];
56  std::cout << "FlavorJetCorrectionExample::analize-> jet #" << ijet;
57  if (ijet%3 == 0) { // assume it is light quark
58  std::cout << ": use USD quark corrections" << std::endl;
59  corrector = udsJetCorrector;
60  }
61  else if (ijet%3 == 1) { // assume it is c quark
62  std::cout << ": use c quark corrections" << std::endl;
63  corrector = cQuarkJetCorrector;
64  }
65  else { // assume it is b quark
66  std::cout << ": use b quark corrections" << std::endl;
67  corrector = bQuarkJetCorrector;
68  }
69  // get selected correction for the jet
70  double correction = corrector->correction (jet);
71  // dump it
72  std::cout << " jet pt/eta/phi: " << jet.pt() << '/' << jet.eta() << '/' << jet.phi()
73  << " -> correction factor: " << correction
74  << ", corrected pt: " << jet.pt()*correction
75  << std::endl;
76  }
77 }
78 
81 
82 
double eta() const final
momentum pseudorapidity
Jets made from CaloTowers.
Definition: CaloJet.h:29
double pt() const final
transverse momentum
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:49
FlavorJetCorrectionExample(const edm::ParameterSet &fParameters)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
vector< PseudoJet > jets
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:50
fixed size matrix
HLT enums.
void analyze(const edm::Event &, const edm::EventSetup &) override
double phi() const final
momentum azimuthal angle