CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SimTauProducer Class Reference
Inheritance diagram for SimTauProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 SimTauProducer (const edm::ParameterSet &)
 
 ~SimTauProducer () override=default
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void buildSimTau (SimTauCPLink &, uint8_t, int, const reco::GenParticle &, int, edm::Handle< std::vector< CaloParticle >>, const std::vector< int > &) const
 
void produce (edm::StreamID, edm::Event &, edm::EventSetup const &) const override
 

Private Attributes

const edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_token_
 
const edm::EDGetTokenT< std::vector< int > > genBarcodes_token_
 
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticles_token_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- 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 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 30 of file SimTauCPLinkProducer.cc.

Constructor & Destructor Documentation

◆ SimTauProducer()

SimTauProducer::SimTauProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 53 of file SimTauCPLinkProducer.cc.

54  : caloParticles_token_(consumes<std::vector<CaloParticle>>(iConfig.getParameter<edm::InputTag>("caloParticles"))),
55  genParticles_token_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("genParticles"))),
56  genBarcodes_token_(consumes<std::vector<int>>(iConfig.getParameter<edm::InputTag>("genBarcodes"))) {
57  produces<std::vector<SimTauCPLink>>();
58 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< std::vector< int > > genBarcodes_token_
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticles_token_
const edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_token_

◆ ~SimTauProducer()

SimTauProducer::~SimTauProducer ( )
overridedefault

Member Function Documentation

◆ buildSimTau()

void SimTauProducer::buildSimTau ( SimTauCPLink t,
uint8_t  generation,
int  resonance_idx,
const reco::GenParticle gen_particle,
int  gen_particle_key,
edm::Handle< std::vector< CaloParticle >>  calo_particle_h,
const std::vector< int > &  gen_particle_barcodes 
) const
private

Definition at line 60 of file SimTauCPLinkProducer.cc.

References reco::CompositeRefCandidateT< D >::daughterRefVector(), BPhysicsValidation_cfi::daughters, createfilelist::int, LogDebug, AlCaHLTBitMon_ParallelJobs::p, EgammaValidation_cff::pdgId, reco::LeafCandidate::pdgId(), and submitPVValidationJobs::t.

Referenced by produce().

66  {
67  const auto& caloPartVec = *calo_particle_h;
68  auto& daughters = gen_particle.daughterRefVector();
69  bool is_leaf = (daughters.empty());
70 
71  if (is_leaf) {
72  LogDebug("SimTauProducer").format(" TO BE SAVED {} ", resonance_idx);
73  auto const& gen_particle_barcode = gen_particle_barcodes[gen_particle_key];
74  auto const& found_in_caloparticles = std::find_if(caloPartVec.begin(), caloPartVec.end(), [&](const auto& p) {
75  return p.g4Tracks()[0].genpartIndex() == gen_particle_barcode;
76  });
77  if (found_in_caloparticles != caloPartVec.end()) {
78  auto calo_particle_idx = (found_in_caloparticles - caloPartVec.begin());
79  t.calo_particle_leaves.push_back(CaloParticleRef(calo_particle_h, calo_particle_idx));
80  t.leaves.push_back(
81  {gen_particle.pdgId(), resonance_idx, (int)t.calo_particle_leaves.size() - 1, gen_particle_key});
82  LogDebug("SimTauProducer").format(" CP {} {}", calo_particle_idx, caloPartVec[calo_particle_idx].pdgId());
83  } else {
84  t.leaves.push_back({gen_particle.pdgId(), resonance_idx, -1, gen_particle_key});
85  }
86  return;
87  } else if (generation != 0) {
88  t.resonances.push_back({gen_particle.pdgId(), resonance_idx});
89  resonance_idx = t.resonances.size() - 1;
90  LogDebug("SimTauProducer").format(" RESONANCE/INTERMEDIATE {} ", resonance_idx);
91  }
92 
93  ++generation;
94  for (auto daughter = daughters.begin(); daughter != daughters.end(); ++daughter) {
95  int gen_particle_key = (*daughter).key();
96  LogDebug("SimTauProducer").format(" gen {} {} {} ", generation, gen_particle_key, (*daughter)->pdgId());
97  buildSimTau(t, generation, resonance_idx, *(*daughter), gen_particle_key, calo_particle_h, gen_particle_barcodes);
98  }
99 }
void buildSimTau(SimTauCPLink &, uint8_t, int, const reco::GenParticle &, int, edm::Handle< std::vector< CaloParticle >>, const std::vector< int > &) const
const daughters & daughterRefVector() const
references to daughtes
int pdgId() const final
PDG identifier.
edm::Ref< CaloParticleCollection > CaloParticleRef
#define LogDebug(id)

◆ fillDescriptions()

void SimTauProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 125 of file SimTauCPLinkProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

125  {
127  desc.add<edm::InputTag>("caloParticles", edm::InputTag("mix", "MergedCaloTruth"));
128  desc.add<edm::InputTag>("genParticles", edm::InputTag("genParticles"));
129  desc.add<edm::InputTag>("genBarcodes", edm::InputTag("genParticles"));
130  descriptions.add("SimTauProducer", desc);
131 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void SimTauProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
edm::EventSetup const &  iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 101 of file SimTauCPLinkProducer.cc.

References funct::abs(), buildSimTau(), caloParticles_token_, HLT_2024v14_cff::flags, g, genBarcodes_token_, AJJGenJetFilter_cfi::genParticles, genParticles_token_, iEvent, eostools::move(), and submitPVValidationJobs::t.

101  {
102  using namespace edm;
103 
104  auto caloParticles_h = iEvent.getHandle(caloParticles_token_);
105  const auto& genParticles = iEvent.get(genParticles_token_);
106  const auto& genBarcodes = iEvent.get(genBarcodes_token_);
107 
108  auto tauDecayVec = std::make_unique<std::vector<SimTauCPLink>>();
109  for (auto const& g : genParticles) {
110  auto const& flags = g.statusFlags();
111  if (std::abs(g.pdgId()) == 15 and flags.isPrompt() and flags.isDecayedLeptonHadron()) {
112  SimTauCPLink t;
113  buildSimTau(t, 0, -1, g, -1, caloParticles_h, genBarcodes);
114  t.decayMode = t.buildDecayModes();
115 #ifdef EDM_ML_DEBUG
116  t.dumpFullDecay();
117  t.dump();
118 #endif
119  (*tauDecayVec).push_back(t);
120  }
121  }
122  iEvent.put(std::move(tauDecayVec));
123 }
void buildSimTau(SimTauCPLink &, uint8_t, int, const reco::GenParticle &, int, edm::Handle< std::vector< CaloParticle >>, const std::vector< int > &) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< std::vector< int > > genBarcodes_token_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genParticles_token_
HLT enums.
const edm::EDGetTokenT< std::vector< CaloParticle > > caloParticles_token_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ caloParticles_token_

const edm::EDGetTokenT<std::vector<CaloParticle> > SimTauProducer::caloParticles_token_
private

Definition at line 48 of file SimTauCPLinkProducer.cc.

Referenced by produce().

◆ genBarcodes_token_

const edm::EDGetTokenT<std::vector<int> > SimTauProducer::genBarcodes_token_
private

Definition at line 50 of file SimTauCPLinkProducer.cc.

Referenced by produce().

◆ genParticles_token_

const edm::EDGetTokenT<std::vector<reco::GenParticle> > SimTauProducer::genParticles_token_
private

Definition at line 49 of file SimTauCPLinkProducer.cc.

Referenced by produce().