CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

JetCorExample< Jet > Class Template Reference

#include <JetCorExample.h>

Inheritance diagram for JetCorExample< Jet >:
edm::EDAnalyzer

List of all members.

Public Member Functions

 JetCorExample (edm::ParameterSet const &cfg)

Private Types

typedef std::vector< Jet > JetCollection

Private Member Functions

void analyze (edm::Event const &e, edm::EventSetup const &iSetup)
void beginJob ()
void endJob ()
void FillHist1D (const TString &histName, const Double_t &x)

Private Attributes

std::string HistoFileName
std::string JetAlgorithm
std::string JetCorrectionService
TFile * m_file
std::map< TString, TH1 * > m_HistNames1D

Detailed Description

template<class Jet>
class JetCorExample< Jet >

Definition at line 15 of file JetCorExample.h.


Member Typedef Documentation

template<class Jet >
typedef std::vector<Jet> JetCorExample< Jet >::JetCollection [private]

Definition at line 20 of file JetCorExample.h.


Constructor & Destructor Documentation

template<class Jet >
JetCorExample< Jet >::JetCorExample ( edm::ParameterSet const &  cfg)

Definition at line 22 of file JetCorExample.cc.

References edm::ParameterSet::getParameter().

{
  JetAlgorithm         = cfg.getParameter<std::string> ("JetAlgorithm"); 
  HistoFileName        = cfg.getParameter<std::string> ("HistoFileName");
  JetCorrectionService = cfg.getParameter<std::string> ("JetCorrectionService");
}

Member Function Documentation

template<class Jet >
void JetCorExample< Jet >::analyze ( edm::Event const &  e,
edm::EventSetup const &  iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 42 of file JetCorExample.cc.

References JetCorrector::correction(), edm::Event::getByLabel(), JetCorrector::getJetCorrector(), and analyzePatCleaning_cfg::jets.

{
  Handle<JetCollection> jets;
  evt.getByLabel(JetAlgorithm,jets);
  typename JetCollection::const_iterator i_jet;
  TString hname; 
  const JetCorrector* corrector = JetCorrector::getJetCorrector (JetCorrectionService,iSetup);
  double scale;
  for(i_jet = jets->begin(); i_jet != jets->end(); i_jet++) 
    {
      scale = corrector->correction(i_jet->p4()); 
      hname = "JetPt";
      FillHist1D(hname,i_jet->pt());   
      hname = "CorJetPt";
      FillHist1D(hname,scale*i_jet->pt()); 
    }
}
template<class Jet >
void JetCorExample< Jet >::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 30 of file JetCorExample.cc.

{
  TString hname;
  m_file = new TFile(HistoFileName.c_str(),"RECREATE"); 
  hname = "JetPt";
  m_HistNames1D[hname] = new TH1F(hname,hname,100,0,1000);
  hname = "CorJetPt";
  m_HistNames1D[hname] = new TH1F(hname,hname,100,0,1000);
}
template<class Jet >
void JetCorExample< Jet >::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 63 of file JetCorExample.cc.

{
  if (m_file !=0) 
    {
      m_file->cd();
      for (std::map<TString, TH1*>::iterator hid = m_HistNames1D.begin(); hid != m_HistNames1D.end(); hid++)
        hid->second->Write();
      delete m_file;
      m_file = 0;      
    }
}
template<class Jet >
void JetCorExample< Jet >::FillHist1D ( const TString &  histName,
const Double_t &  x 
) [private]

Definition at line 77 of file JetCorExample.cc.

References gather_cfg::cout.

{
  std::map<TString, TH1*>::iterator hid=m_HistNames1D.find(histName);
  if (hid==m_HistNames1D.end())
    std::cout << "%fillHist -- Could not find histogram with name: " << histName << std::endl;
  else
    hid->second->Fill(value);
}

Member Data Documentation

template<class Jet >
std::string JetCorExample< Jet >::HistoFileName [private]

Definition at line 31 of file JetCorExample.h.

template<class Jet >
std::string JetCorExample< Jet >::JetAlgorithm [private]

Definition at line 29 of file JetCorExample.h.

template<class Jet >
std::string JetCorExample< Jet >::JetCorrectionService [private]

Definition at line 33 of file JetCorExample.h.

template<class Jet >
TFile* JetCorExample< Jet >::m_file [private]

Definition at line 26 of file JetCorExample.h.

template<class Jet >
std::map<TString, TH1*> JetCorExample< Jet >::m_HistNames1D [private]

Definition at line 25 of file JetCorExample.h.