CMS 3D CMS Logo

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

JetPlotsExample< Jet > Class Template Reference

#include <JetPlotsExample.h>

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

List of all members.

Public Member Functions

 JetPlotsExample (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
TFile * m_file
std::map< TString, TH1 * > m_HistNames1D
int NJets

Detailed Description

template<class Jet>
class JetPlotsExample< Jet >

Definition at line 15 of file JetPlotsExample.h.


Member Typedef Documentation

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

Definition at line 20 of file JetPlotsExample.h.


Constructor & Destructor Documentation

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

Definition at line 25 of file JetPlotsExample.cc.

References edm::ParameterSet::getParameter().

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 49 of file JetPlotsExample.cc.

References edm::Event::getByLabel(), getHLTprescales::index, and fwrapper::jets.

{
  Handle<JetCollection> jets;
  evt.getByLabel(JetAlgorithm,jets);
  typename JetCollection::const_iterator i_jet;
  int index = 0;
  TString hname; 
  hname = "NumberOfJets";
  FillHist1D(hname,jets->size()); 
  for(i_jet = jets->begin(); i_jet != jets->end() && index < NJets; ++i_jet) 
    {
      hname = "JetPt";
      FillHist1D(hname,i_jet->pt());   
      hname = "JetEta";
      FillHist1D(hname,i_jet->eta());
      hname = "JetPhi";
      FillHist1D(hname,i_jet->phi());
      index++;
    }
}
template<class Jet >
void JetPlotsExample< Jet >::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 33 of file JetPlotsExample.cc.

References M_PI.

{
  TString hname;
  m_file = new TFile(HistoFileName.c_str(),"RECREATE"); 
  hname = "JetPt";
  m_HistNames1D[hname] = new TH1F(hname,hname,100,0,1000);
  hname = "JetEta";
  m_HistNames1D[hname] = new TH1F(hname,hname,120,-6,6);
  hname = "JetPhi";
  m_HistNames1D[hname] = new TH1F(hname,hname,100,-M_PI,M_PI);
  hname = "NumberOfJets";
  m_HistNames1D[hname] = new TH1F(hname,hname,100,0,100);
}
template<class Jet >
void JetPlotsExample< Jet >::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 74 of file JetPlotsExample.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 JetPlotsExample< Jet >::FillHist1D ( const TString &  histName,
const Double_t &  x 
) [private]

Definition at line 88 of file JetPlotsExample.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 JetPlotsExample< Jet >::HistoFileName [private]

Definition at line 31 of file JetPlotsExample.h.

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

Definition at line 29 of file JetPlotsExample.h.

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

Definition at line 26 of file JetPlotsExample.h.

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

Definition at line 25 of file JetPlotsExample.h.

template<class Jet >
int JetPlotsExample< Jet >::NJets [private]

Definition at line 33 of file JetPlotsExample.h.