CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | 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

Public Member Functions

 JetPlotsExample (edm::ParameterSet const &cfg)
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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 21 of file JetPlotsExample.cc.

References edm::ParameterSet::getParameter().

22 {
23  JetAlgorithm = cfg.getParameter<std::string> ("JetAlgorithm");
24  HistoFileName = cfg.getParameter<std::string> ("HistoFileName");
25  NJets = cfg.getParameter<int> ("NJets");
26 }
std::string HistoFileName
std::string JetAlgorithm

Member Function Documentation

template<class Jet >
void JetPlotsExample< Jet >::analyze ( edm::Event const &  e,
edm::EventSetup const &  iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 45 of file JetPlotsExample.cc.

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

46 {
49  evt.getByLabel(JetAlgorithm,jets);
50  typename JetCollection::const_iterator i_jet;
51  int index = 0;
52  TString hname;
54  hname = "NumberOfJets";
55  FillHist1D(hname,jets->size());
57  for(i_jet = jets->begin(); i_jet != jets->end() && index < NJets; ++i_jet)
58  {
59  hname = "JetPt";
60  FillHist1D(hname,i_jet->pt());
61  hname = "JetEta";
62  FillHist1D(hname,i_jet->eta());
63  hname = "JetPhi";
64  FillHist1D(hname,i_jet->phi());
65  index++;
66  }
67 }
void FillHist1D(const TString &histName, const Double_t &x)
std::string JetAlgorithm
template<class Jet >
void JetPlotsExample< Jet >::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 29 of file JetPlotsExample.cc.

References M_PI.

30 {
31  TString hname;
32  m_file = new TFile(HistoFileName.c_str(),"RECREATE");
34  hname = "JetPt";
35  m_HistNames1D[hname] = new TH1F(hname,hname,100,0,1000);
36  hname = "JetEta";
37  m_HistNames1D[hname] = new TH1F(hname,hname,120,-6,6);
38  hname = "JetPhi";
39  m_HistNames1D[hname] = new TH1F(hname,hname,100,-M_PI,M_PI);
40  hname = "NumberOfJets";
41  m_HistNames1D[hname] = new TH1F(hname,hname,100,0,100);
42 }
std::string HistoFileName
std::map< TString, TH1 * > m_HistNames1D
#define M_PI
Definition: BFit3D.cc:3
template<class Jet >
void JetPlotsExample< Jet >::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 70 of file JetPlotsExample.cc.

71 {
73  if (m_file !=0)
74  {
75  m_file->cd();
76  for (std::map<TString, TH1*>::iterator hid = m_HistNames1D.begin(); hid != m_HistNames1D.end(); hid++)
77  hid->second->Write();
78  delete m_file;
79  m_file = 0;
80  }
81 }
std::map< TString, TH1 * > m_HistNames1D
template<class Jet >
void JetPlotsExample< Jet >::FillHist1D ( const TString &  histName,
const Double_t &  x 
)
private

Definition at line 84 of file JetPlotsExample.cc.

References gather_cfg::cout.

85 {
86  std::map<TString, TH1*>::iterator hid=m_HistNames1D.find(histName);
87  if (hid==m_HistNames1D.end())
88  std::cout << "%fillHist -- Could not find histogram with name: " << histName << std::endl;
89  else
90  hid->second->Fill(value);
91 }
std::map< TString, TH1 * > m_HistNames1D
tuple cout
Definition: gather_cfg.py:41

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.