CMS 3D CMS Logo

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

void analyze (edm::Event const &e, edm::EventSetup const &iSetup) override
 
void beginJob () override
 
void endJob () override
 
 PFMCTruthTreeProducer (edm::ParameterSet const &cfg)
 
 ~PFMCTruthTreeProducer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

float cemfJet_
 
float chfJet_
 
int cmultiJet_
 
float dR_
 
float etaGen_
 
float etaJet_
 
TFile * file_
 
edm::EDGetTokenT< GenEventInfoProductgen_
 
edm::EDGetTokenT< reco::GenJetCollectiongenjets_
 
std::string histogramFile_
 
edm::EDGetTokenT< reco::PFJetCollectionjets_
 
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
 
- 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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 PFMCTruthTreeProducer.h.

Constructor & Destructor Documentation

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

Definition at line 26 of file PFMCTruthTreeProducer.cc.

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

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

Definition at line 104 of file PFMCTruthTreeProducer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 62 of file PFMCTruthTreeProducer.cc.

References GenEventInfoProduct::binningValues(), singleTopDQM_cfi::jets, njet, CosmicsPD_Skims::radius, and findQualityFiles::rr.

62  {
66  PFJetCollection::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->empty() && !genjets->empty()) {
75  for (i_genjet = genjets->begin(); i_genjet != genjets->end(); i_genjet++) {
76  float rmin(99);
77  for (i_jet = jets->begin(); i_jet != jets->end(); i_jet++) {
78  rr = radius(i_genjet, i_jet);
79  if (rr < rmin) {
80  rmin = rr;
81  i_matched = i_jet;
82  }
83  }
84  ptGen_ = i_genjet->pt();
85  etaGen_ = i_genjet->eta();
86  phiGen_ = i_genjet->phi();
87  ptJet_ = i_matched->pt();
88  etaJet_ = i_matched->eta();
89  phiJet_ = i_matched->phi();
90  chfJet_ = i_matched->chargedHadronEnergyFraction();
91  nhfJet_ = i_matched->neutralHadronEnergyFraction();
92  cemfJet_ = i_matched->chargedEmEnergyFraction();
93  nemfJet_ = i_matched->neutralEmEnergyFraction();
94  cmultiJet_ = i_matched->chargedMultiplicity();
95  nmultiJet_ = i_matched->neutralMultiplicity();
96  dR_ = rmin;
97  rank_ = njet;
98  mcTruthTree_->Fill();
99  njet++;
100  }
101  }
102 }
const std::vector< double > & binningValues() const
edm::EDGetTokenT< reco::GenJetCollection > genjets_
int njet
Definition: HydjetWrapper.h:89
edm::EDGetTokenT< GenEventInfoProduct > gen_
edm::EDGetTokenT< reco::PFJetCollection > jets_
void PFMCTruthTreeProducer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 33 of file PFMCTruthTreeProducer.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 54 of file PFMCTruthTreeProducer.cc.

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

Member Data Documentation

float PFMCTruthTreeProducer::cemfJet_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::chfJet_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

int PFMCTruthTreeProducer::cmultiJet_
private

Definition at line 29 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::dR_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::etaGen_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::etaJet_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

TFile* PFMCTruthTreeProducer::file_
private

Definition at line 26 of file PFMCTruthTreeProducer.h.

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

Definition at line 25 of file PFMCTruthTreeProducer.h.

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

Definition at line 24 of file PFMCTruthTreeProducer.h.

std::string PFMCTruthTreeProducer::histogramFile_
private

Definition at line 22 of file PFMCTruthTreeProducer.h.

edm::EDGetTokenT<reco::PFJetCollection> PFMCTruthTreeProducer::jets_
private

Definition at line 23 of file PFMCTruthTreeProducer.h.

TTree* PFMCTruthTreeProducer::mcTruthTree_
private

Definition at line 27 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::nemfJet_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::nhfJet_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

int PFMCTruthTreeProducer::nmultiJet_
private

Definition at line 29 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::phiGen_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::phiJet_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::ptGen_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::ptHat_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

float PFMCTruthTreeProducer::ptJet_
private

Definition at line 28 of file PFMCTruthTreeProducer.h.

int PFMCTruthTreeProducer::rank_
private

Definition at line 29 of file PFMCTruthTreeProducer.h.