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 Attributes
PFMCTruthTreeProducer Class Reference

#include <PFMCTruthTreeProducer.h>

Inheritance diagram for PFMCTruthTreeProducer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (edm::Event const &e, edm::EventSetup const &iSetup)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 PFMCTruthTreeProducer (edm::ParameterSet const &cfg)
 
 ~PFMCTruthTreeProducer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

float cemfJet_
 
float chfJet_
 
int cmultiJet_
 
float dR_
 
float etaGen_
 
float etaJet_
 
TFile * file_
 
std::string genjets_
 
std::string histogramFile_
 
std::string jets_
 
TTree * mcTruthTree_
 
float nemfJet_
 
float nhfJet_
 
int nmultiJet_
 
float phiGen_
 
float phiJet_
 
float ptGen_
 
float ptHat_
 
float ptJet_
 
int rank_
 

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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 10 of file PFMCTruthTreeProducer.h.

Constructor & Destructor Documentation

PFMCTruthTreeProducer::PFMCTruthTreeProducer ( edm::ParameterSet const &  cfg)
explicit

Definition at line 29 of file PFMCTruthTreeProducer.cc.

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

30 {
31  jets_ = cfg.getParameter<std::string> ("jets");
32  genjets_ = cfg.getParameter<std::string> ("genjets");
33  histogramFile_ = cfg.getParameter<std::string> ("histogramFile");
34 }
PFMCTruthTreeProducer::~PFMCTruthTreeProducer ( )

Definition at line 115 of file PFMCTruthTreeProducer.cc.

116 {
117  delete file_;
118  delete mcTruthTree_;
119 }

Member Function Documentation

void PFMCTruthTreeProducer::analyze ( edm::Event const &  e,
edm::EventSetup const &  iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 68 of file PFMCTruthTreeProducer.cc.

References fwrapper::jets, njet, CosmicsPD_Skims::radius, and findQualityFiles::rr.

69 {
73  PFJetCollection::const_iterator i_jet,i_matched;
74  GenJetCollection::const_iterator i_genjet;
75  event.getByLabel (genjets_,genjets);
76  event.getByLabel (jets_,jets);
77  event.getByLabel("generator",hEventInfo);
78  ptHat_ = hEventInfo->binningValues()[0];
79  float rr;
80  int njet(0);
81  if (jets->size()>0 && genjets->size()>0)
82  {
83  for (i_genjet = genjets->begin(); i_genjet != genjets->end(); i_genjet++)
84  {
85  float rmin(99);
86  for(i_jet = jets->begin();i_jet != jets->end(); i_jet++)
87  {
88  rr=radius(i_genjet,i_jet);
89  if (rr<rmin)
90  {
91  rmin = rr;
92  i_matched = i_jet;
93  }
94  }
95  ptGen_ = i_genjet->pt();
96  etaGen_ = i_genjet->eta();
97  phiGen_ = i_genjet->phi();
98  ptJet_ = i_matched->pt();
99  etaJet_ = i_matched->eta();
100  phiJet_ = i_matched->phi();
101  chfJet_ = i_matched->chargedHadronEnergyFraction();
102  nhfJet_ = i_matched->neutralHadronEnergyFraction();
103  cemfJet_ = i_matched->chargedEmEnergyFraction();
104  nemfJet_ = i_matched->neutralEmEnergyFraction();
105  cmultiJet_ = i_matched->chargedMultiplicity();
106  nmultiJet_ = i_matched->neutralMultiplicity();
107  dR_ = rmin;
108  rank_ = njet;
109  mcTruthTree_->Fill();
110  njet++;
111  }
112  }
113 }
int njet
Definition: HydjetWrapper.h:91
vector< PseudoJet > jets
void PFMCTruthTreeProducer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 36 of file PFMCTruthTreeProducer.cc.

37 {
38  file_ = new TFile(histogramFile_.c_str(),"RECREATE");
39  mcTruthTree_ = new TTree("mcTruthTree","mcTruthTree");
40 
41  mcTruthTree_->Branch("ptJet", &ptJet_, "ptJet_/F");
42  mcTruthTree_->Branch("ptGen", &ptGen_, "ptGen_/F");
43  mcTruthTree_->Branch("ptHat", &ptHat_, "ptHat_/F");
44  mcTruthTree_->Branch("chfJet", &chfJet_, "chfJet_/F");
45  mcTruthTree_->Branch("nhfJet", &nhfJet_, "nhfJet_/F");
46  mcTruthTree_->Branch("cemfJet", &cemfJet_, "cemfJet_/F");
47  mcTruthTree_->Branch("nemfJet", &nemfJet_, "nemfJet_/F");
48  mcTruthTree_->Branch("cmultiJet", &cmultiJet_, "cmultiJet_/I");
49  mcTruthTree_->Branch("nmultiJet", &nmultiJet_, "nmultiJet_/I");
50  mcTruthTree_->Branch("etaJet", &etaJet_, "etaJet_/F");
51  mcTruthTree_->Branch("etaGen", &etaGen_, "etaGen_/F");
52  mcTruthTree_->Branch("phiJet", &phiJet_, "phiJet_/F");
53  mcTruthTree_->Branch("phiGen", &phiGen_, "phiGen_/F");
54  mcTruthTree_->Branch("dR", &dR_, "dR_/F");
55  mcTruthTree_->Branch("rank", &rank_, "rank_/I");
56 }
void PFMCTruthTreeProducer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 58 of file PFMCTruthTreeProducer.cc.

59 {
60  if (file_ !=0)
61  {
62  file_->cd();
63  mcTruthTree_->Write();
64  }
65  file_ = 0;
66 }

Member Data Documentation

float PFMCTruthTreeProducer::cemfJet_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::chfJet_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

int PFMCTruthTreeProducer::cmultiJet_
private

Definition at line 26 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::dR_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::etaGen_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::etaJet_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

TFile* PFMCTruthTreeProducer::file_
private

Definition at line 23 of file PFMCTruthTreeProducer.h.

std::string PFMCTruthTreeProducer::genjets_
private

Definition at line 22 of file PFMCTruthTreeProducer.h.

std::string PFMCTruthTreeProducer::histogramFile_
private

Definition at line 20 of file PFMCTruthTreeProducer.h.

std::string PFMCTruthTreeProducer::jets_
private

Definition at line 21 of file PFMCTruthTreeProducer.h.

TTree* PFMCTruthTreeProducer::mcTruthTree_
private

Definition at line 24 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::nemfJet_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::nhfJet_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

int PFMCTruthTreeProducer::nmultiJet_
private

Definition at line 26 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::phiGen_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::phiJet_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::ptGen_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::ptHat_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::ptJet_
private

Definition at line 25 of file PFMCTruthTreeProducer.h.

int PFMCTruthTreeProducer::rank_
private

Definition at line 26 of file PFMCTruthTreeProducer.h.