CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CaloMCTruthTreeProducer Class Reference

#include <CaloMCTruthTreeProducer.h>

Inheritance diagram for CaloMCTruthTreeProducer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (edm::Event const &e, edm::EventSetup const &iSetup)
 
virtual void beginJob ()
 
 CaloMCTruthTreeProducer (edm::ParameterSet const &cfg)
 
virtual void endJob ()
 
 ~CaloMCTruthTreeProducer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

float dR_
 
float emfJet_
 
float etaGen_
 
float etaJet_
 
TFile * file_
 
edm::EDGetTokenT< GenEventInfoProductgen_
 
edm::EDGetTokenT< reco::GenJetCollectiongenjets_
 
std::string histogramFile_
 
edm::EDGetTokenT< reco::CaloJetCollectionjets_
 
TTree * mcTruthTree_
 
float phiGen_
 
float phiJet_
 
float ptGen_
 
float ptHat_
 
float ptJet_
 
int rank_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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 13 of file CaloMCTruthTreeProducer.h.

Constructor & Destructor Documentation

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

Definition at line 26 of file CaloMCTruthTreeProducer.cc.

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

27 {
28  jets_ = consumes<CaloJetCollection>(edm::InputTag(cfg.getParameter<std::string> ("jets")));
29  genjets_ = consumes<GenJetCollection>(edm::InputTag(cfg.getParameter<std::string> ("genjets")));
30  gen_ = consumes<GenEventInfoProduct>(edm::InputTag("generator"));
31  histogramFile_ = cfg.getParameter<std::string> ("histogramFile");
32 }
edm::EDGetTokenT< GenEventInfoProduct > gen_
edm::EDGetTokenT< reco::GenJetCollection > genjets_
edm::EDGetTokenT< reco::CaloJetCollection > jets_
CaloMCTruthTreeProducer::~CaloMCTruthTreeProducer ( )

Definition at line 103 of file CaloMCTruthTreeProducer.cc.

104 {
105  delete file_;
106  delete mcTruthTree_;
107 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 61 of file CaloMCTruthTreeProducer.cc.

References GenEventInfoProduct::binningValues(), fwrapper::jets, njet, TCMET_cfi::radius, and findQualityFiles::rr.

62 {
66  CaloJetCollection::const_iterator i_jet,i_matched;
67  GenJetCollection::const_iterator i_genjet;
68  event.getByToken (genjets_,genjets);
69  event.getByToken (jets_,jets);
70  event.getByToken(gen_,hEventInfo);
71  ptHat_ = hEventInfo->binningValues()[0];
72  float rr;
73  int njet(0);
74  if (jets->size()>0 && genjets->size()>0)
75  {
76  for (i_genjet = genjets->begin(); i_genjet != genjets->end(); i_genjet++)
77  {
78  float rmin(99);
79  for(i_jet = jets->begin();i_jet != jets->end(); i_jet++)
80  {
81  rr=radius(i_genjet,i_jet);
82  if (rr<rmin)
83  {
84  rmin = rr;
85  i_matched = i_jet;
86  }
87  }
88  ptGen_ = i_genjet->pt();
89  etaGen_ = i_genjet->eta();
90  phiGen_ = i_genjet->phi();
91  ptJet_ = i_matched->pt();
92  etaJet_ = i_matched->eta();
93  phiJet_ = i_matched->phi();
94  emfJet_ = i_matched->emEnergyFraction();
95  dR_ = rmin;
96  rank_ = njet;
97  mcTruthTree_->Fill();
98  njet++;
99  }
100  }
101 }
const std::vector< double > & binningValues() const
edm::EDGetTokenT< GenEventInfoProduct > gen_
edm::EDGetTokenT< reco::GenJetCollection > genjets_
int njet
Definition: HydjetWrapper.h:95
vector< PseudoJet > jets
edm::EDGetTokenT< reco::CaloJetCollection > jets_
void CaloMCTruthTreeProducer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 34 of file CaloMCTruthTreeProducer.cc.

35 {
36  file_ = new TFile(histogramFile_.c_str(),"RECREATE");
37  mcTruthTree_ = new TTree("mcTruthTree","mcTruthTree");
38 
39  mcTruthTree_->Branch("ptJet", &ptJet_, "ptJet_/F");
40  mcTruthTree_->Branch("ptGen", &ptGen_, "ptGen_/F");
41  mcTruthTree_->Branch("ptHat", &ptHat_, "ptHat_/F");
42  mcTruthTree_->Branch("emfJet", &emfJet_, "emfJet_/F");
43  mcTruthTree_->Branch("etaJet", &etaJet_, "etaJet_/F");
44  mcTruthTree_->Branch("etaGen", &etaGen_, "etaGen_/F");
45  mcTruthTree_->Branch("phiJet", &phiJet_, "phiJet_/F");
46  mcTruthTree_->Branch("phiGen", &phiGen_, "phiGen_/F");
47  mcTruthTree_->Branch("dR", &dR_, "dR_/F");
48  mcTruthTree_->Branch("rank", &rank_, "rank_/I");
49 }
void CaloMCTruthTreeProducer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file CaloMCTruthTreeProducer.cc.

52 {
53  if (file_ !=0)
54  {
55  file_->cd();
56  mcTruthTree_->Write();
57  }
58  file_ = 0;
59 }

Member Data Documentation

float CaloMCTruthTreeProducer::dR_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.

float CaloMCTruthTreeProducer::emfJet_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.

float CaloMCTruthTreeProducer::etaGen_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.

float CaloMCTruthTreeProducer::etaJet_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.

TFile* CaloMCTruthTreeProducer::file_
private

Definition at line 27 of file CaloMCTruthTreeProducer.h.

edm::EDGetTokenT<GenEventInfoProduct> CaloMCTruthTreeProducer::gen_
private

Definition at line 26 of file CaloMCTruthTreeProducer.h.

edm::EDGetTokenT<reco::GenJetCollection> CaloMCTruthTreeProducer::genjets_
private

Definition at line 25 of file CaloMCTruthTreeProducer.h.

std::string CaloMCTruthTreeProducer::histogramFile_
private

Definition at line 23 of file CaloMCTruthTreeProducer.h.

edm::EDGetTokenT<reco::CaloJetCollection> CaloMCTruthTreeProducer::jets_
private

Definition at line 24 of file CaloMCTruthTreeProducer.h.

TTree* CaloMCTruthTreeProducer::mcTruthTree_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

float CaloMCTruthTreeProducer::phiGen_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.

float CaloMCTruthTreeProducer::phiJet_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.

float CaloMCTruthTreeProducer::ptGen_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.

float CaloMCTruthTreeProducer::ptHat_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.

float CaloMCTruthTreeProducer::ptJet_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.

int CaloMCTruthTreeProducer::rank_
private

Definition at line 30 of file CaloMCTruthTreeProducer.h.