CMS 3D CMS Logo

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

#include <HectorProducer.h>

Inheritance diagram for HectorProducer:
edm::one::EDProducer< edm::one::SharedResources > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HectorProducer (edm::ParameterSet const &p)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~HectorProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::SharedResources >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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)
 

Private Attributes

int m_evtAnalysed
 just to count events that have been analysed More...
 
bool m_FP420Transport
 
std::unique_ptr< Hectorm_Hector
 
edm::EDGetTokenT< edm::HepMCProductm_HepMC
 
bool m_verbosity
 
bool m_ZDCTransport
 
edm::ESGetToken< HepPDT::ParticleDataTable, PDTRecordtok_pdt_
 

Additional Inherited Members

- Public Types inherited from edm::one::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
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 29 of file HectorProducer.h.

Constructor & Destructor Documentation

◆ HectorProducer()

HectorProducer::HectorProducer ( edm::ParameterSet const &  p)
explicit

Definition at line 34 of file HectorProducer.cc.

References Exception, m_evtAnalysed, m_FP420Transport, m_Hector, m_verbosity, m_ZDCTransport, AlCaHLTBitMon_ParallelJobs::p, and tok_pdt_.

35  : m_HepMC(consumes<edm::HepMCProduct>(p.getParameter<edm::InputTag>("HepMCProductLabel"))) {
36  tok_pdt_ = esConsumes<HepPDT::ParticleDataTable, PDTRecord>();
37  m_verbosity = p.getParameter<bool>("Verbosity");
38  m_FP420Transport = p.getParameter<bool>("FP420Transport");
39  m_ZDCTransport = p.getParameter<bool>("ZDCTransport");
40  m_evtAnalysed = 0;
41 
42  produces<edm::HepMCProduct>();
43  produces<edm::LHCTransportLinkContainer>();
44 
45  usesResource("Hector");
46  m_Hector = std::make_unique<Hector>(p, tok_pdt_, m_verbosity, m_FP420Transport, m_ZDCTransport);
47 
49  if (!rng.isAvailable()) {
50  throw cms::Exception("Configuration") << "LHCTransport (HectorProducer) requires the "
51  "RandomNumberGeneratorService\n"
52  "which is not present in the configuration file. You must add the "
53  "service\n"
54  "in the configuration file or remove the modules that require it.";
55  }
56  edm::LogVerbatim("SimTransportHectorProducer") << "Hector is created";
57 }
Log< level::Info, true > LogVerbatim
int m_evtAnalysed
just to count events that have been analysed
edm::EDGetTokenT< edm::HepMCProduct > m_HepMC
edm::ESGetToken< HepPDT::ParticleDataTable, PDTRecord > tok_pdt_
std::unique_ptr< Hector > m_Hector

◆ ~HectorProducer()

HectorProducer::~HectorProducer ( )
override

Definition at line 59 of file HectorProducer.cc.

59 {}

Member Function Documentation

◆ produce()

void HectorProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::one::EDProducerBase.

Definition at line 61 of file HectorProducer.cc.

References Exception, edm::RandomNumberGenerator::getEngine(), edm::HepMCProduct::GetEvent(), mps_fire::i, iEvent, edm::HandleBase::isValid(), m_evtAnalysed, m_FP420Transport, m_Hector, m_HepMC, m_verbosity, m_ZDCTransport, edm::Provenance::moduleLabel(), eostools::move(), and edm::HandleBase::provenance().

61  {
63  CLHEP::HepRandomEngine *engine = &rng->getEngine(iEvent.streamID());
64  if (engine->name() != "TRandom3") {
65  throw cms::Exception("Configuration") << "The TRandom3 engine type must be used with HectorProducer, "
66  << "Random Number Generator Service not correctly configured!";
67  }
68  TRandom3 *rootEngine = ((edm::TRandomAdaptor *)engine)->getRootEngine();
69 
70  ++m_evtAnalysed;
71 
72  edm::LogVerbatim("SimTransportHectorProducer") << "produce evt " << m_evtAnalysed;
73 
75  iEvent.getByToken(m_HepMC, HepMCEvt);
76 
77  if (!HepMCEvt.isValid()) {
78  throw cms::Exception("InvalidReference") << "Invalid reference to HepMCProduct\n";
79  }
80 
81  if (HepMCEvt.provenance()->moduleLabel() == "LHCTransport") {
82  throw cms::Exception("LogicError") << "HectorTrasported HepMCProduce already exists\n";
83  }
84 
85  auto evt = new HepMC::GenEvent(*HepMCEvt->GetEvent());
86  m_Hector->clearApertureFlags();
87  if (m_FP420Transport) {
88  m_Hector->clear();
89  m_Hector->add(evt, es);
90  m_Hector->filterFP420(rootEngine);
91  }
92  if (m_ZDCTransport) {
93  m_Hector->clear();
94  m_Hector->add(evt, es);
95  m_Hector->filterZDC(rootEngine);
96 
97  m_Hector->clear();
98  m_Hector->add(evt, es);
99  m_Hector->filterD1(rootEngine);
100  }
101  evt = m_Hector->addPartToHepMC(evt);
102  if (m_verbosity)
103  evt->print();
104 
105  edm::LogVerbatim("SimTransportHectorProducer") << "new HepMC product ";
106 
107  unique_ptr<edm::HepMCProduct> NewProduct(new edm::HepMCProduct());
108  NewProduct->addHepMCData(evt);
109 
110  iEvent.put(std::move(NewProduct));
111 
112  edm::LogVerbatim("SimTransportHectorProducer") << "new LHCTransportLinkContainer ";
113  unique_ptr<edm::LHCTransportLinkContainer> NewCorrespondenceMap(new edm::LHCTransportLinkContainer());
114  edm::LHCTransportLinkContainer thisLink(m_Hector->getCorrespondenceMap());
115  (*NewCorrespondenceMap).swap(thisLink);
116 
117  if (m_verbosity) {
118  for (unsigned int i = 0; i < (*NewCorrespondenceMap).size(); ++i)
119  edm::LogVerbatim("HectorEventProcessing") << "Hector correspondence table: " << (*NewCorrespondenceMap)[i];
120  }
121 
122  iEvent.put(std::move(NewCorrespondenceMap));
123  edm::LogVerbatim("SimTransportHectorProducer") << "produce end ";
124 }
Log< level::Info, true > LogVerbatim
int m_evtAnalysed
just to count events that have been analysed
edm::EDGetTokenT< edm::HepMCProduct > m_HepMC
Provenance const * provenance() const
Definition: HandleBase.h:74
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
int iEvent
Definition: GenABIO.cc:224
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
bool isValid() const
Definition: HandleBase.h:70
std::vector< LHCTransportLink > LHCTransportLinkContainer
std::unique_ptr< Hector > m_Hector
std::string const & moduleLabel() const
Definition: Provenance.h:55
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ m_evtAnalysed

int HectorProducer::m_evtAnalysed
private

just to count events that have been analysed

Definition at line 43 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().

◆ m_FP420Transport

bool HectorProducer::m_FP420Transport
private

Definition at line 41 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().

◆ m_Hector

std::unique_ptr<Hector> HectorProducer::m_Hector
private

Definition at line 36 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().

◆ m_HepMC

edm::EDGetTokenT<edm::HepMCProduct> HectorProducer::m_HepMC
private

Definition at line 39 of file HectorProducer.h.

Referenced by produce().

◆ m_verbosity

bool HectorProducer::m_verbosity
private

Definition at line 40 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().

◆ m_ZDCTransport

bool HectorProducer::m_ZDCTransport
private

Definition at line 42 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().

◆ tok_pdt_

edm::ESGetToken<HepPDT::ParticleDataTable, PDTRecord> HectorProducer::tok_pdt_
private

Definition at line 38 of file HectorProducer.h.

Referenced by HectorProducer().