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

void analyze (edm::Event const &e, edm::EventSetup const &iSetup) override
 
void beginJob () override
 
 CaloMCTruthTreeProducer (edm::ParameterSet const &cfg)
 
void endJob () override
 
 ~CaloMCTruthTreeProducer () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 13 of file CaloMCTruthTreeProducer.h.

Constructor & Destructor Documentation

◆ CaloMCTruthTreeProducer()

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

Definition at line 26 of file CaloMCTruthTreeProducer.cc.

References looper::cfg, HLT_2022v14_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

26  {
27  jets_ = consumes<CaloJetCollection>(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< GenEventInfoProduct > gen_
edm::EDGetTokenT< reco::GenJetCollection > genjets_
edm::EDGetTokenT< reco::CaloJetCollection > jets_

◆ ~CaloMCTruthTreeProducer()

CaloMCTruthTreeProducer::~CaloMCTruthTreeProducer ( )
override

Definition at line 94 of file CaloMCTruthTreeProducer.cc.

94  {
95  delete file_;
96  delete mcTruthTree_;
97 }

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 57 of file CaloMCTruthTreeProducer.cc.

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

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

◆ beginJob()

void CaloMCTruthTreeProducer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 33 of file CaloMCTruthTreeProducer.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("emfJet", &emfJet_, "emfJet_/F");
41  mcTruthTree_->Branch("etaJet", &etaJet_, "etaJet_/F");
42  mcTruthTree_->Branch("etaGen", &etaGen_, "etaGen_/F");
43  mcTruthTree_->Branch("phiJet", &phiJet_, "phiJet_/F");
44  mcTruthTree_->Branch("phiGen", &phiGen_, "phiGen_/F");
45  mcTruthTree_->Branch("dR", &dR_, "dR_/F");
46  mcTruthTree_->Branch("rank", &rank_, "rank_/I");
47 }

◆ endJob()

void CaloMCTruthTreeProducer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 49 of file CaloMCTruthTreeProducer.cc.

49  {
50  if (file_ != nullptr) {
51  file_->cd();
52  mcTruthTree_->Write();
53  }
54  file_ = nullptr;
55 }

Member Data Documentation

◆ dR_

float CaloMCTruthTreeProducer::dR_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

◆ emfJet_

float CaloMCTruthTreeProducer::emfJet_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

◆ etaGen_

float CaloMCTruthTreeProducer::etaGen_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

◆ etaJet_

float CaloMCTruthTreeProducer::etaJet_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

◆ file_

TFile* CaloMCTruthTreeProducer::file_
private

Definition at line 26 of file CaloMCTruthTreeProducer.h.

◆ gen_

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

Definition at line 25 of file CaloMCTruthTreeProducer.h.

◆ genjets_

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

Definition at line 24 of file CaloMCTruthTreeProducer.h.

◆ histogramFile_

std::string CaloMCTruthTreeProducer::histogramFile_
private

Definition at line 22 of file CaloMCTruthTreeProducer.h.

◆ jets_

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

Definition at line 23 of file CaloMCTruthTreeProducer.h.

◆ mcTruthTree_

TTree* CaloMCTruthTreeProducer::mcTruthTree_
private

Definition at line 27 of file CaloMCTruthTreeProducer.h.

◆ phiGen_

float CaloMCTruthTreeProducer::phiGen_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

◆ phiJet_

float CaloMCTruthTreeProducer::phiJet_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

◆ ptGen_

float CaloMCTruthTreeProducer::ptGen_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

◆ ptHat_

float CaloMCTruthTreeProducer::ptHat_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

◆ ptJet_

float CaloMCTruthTreeProducer::ptJet_
private

Definition at line 28 of file CaloMCTruthTreeProducer.h.

◆ rank_

int CaloMCTruthTreeProducer::rank_
private

Definition at line 29 of file CaloMCTruthTreeProducer.h.