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::WatchRuns > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
 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, edm::one::WatchRuns >
 EDProducer ()=default
 
- Public Member Functions inherited from edm::one::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
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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

HepMC::GenEventevt_
 
int m_evtAnalysed
 just to count events that have been analysed More...
 
bool m_FP420Transport
 
Hectorm_Hector
 
edm::EDGetTokenT< edm::HepMCProductm_HepMC
 
bool m_verbosity
 
bool m_ZDCTransport
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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::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 27 of file HectorProducer.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file HectorProducer.cc.

References Exception, edm::ParameterSet::getParameter(), HectorTransport_cfi::Hector, edm::Service< T >::isAvailable(), m_evtAnalysed, m_FP420Transport, m_Hector, m_verbosity, and m_ZDCTransport.

32  :
33  m_HepMC(consumes<edm::HepMCProduct>(p.getParameter<std::string>("HepMCProductLabel")))
34 {
35  m_verbosity = p.getParameter<bool>("Verbosity");
36  m_FP420Transport = p.getParameter<bool>("FP420Transport");
37  m_ZDCTransport = p.getParameter<bool>("ZDCTransport");
38  m_evtAnalysed = 0;
39 
40  produces<edm::HepMCProduct>();
41  produces<edm::LHCTransportLinkContainer>();
42 
43  m_Hector = new Hector(p, m_verbosity, m_FP420Transport, m_ZDCTransport);
44 
46  if ( ! rng.isAvailable() ) {
47  throw cms::Exception("Configuration")
48  << "LHCTransport (HectorProducer) requires the RandomNumberGeneratorService\n"
49  "which is not present in the configuration file. You must add the service\n"
50  "in the configuration file or remove the modules that require it.";
51  }
52  edm::LogInfo("SimTransportHectorProducer") << "Hector is created";
53 }
int m_evtAnalysed
just to count events that have been analysed
edm::EDGetTokenT< edm::HepMCProduct > m_HepMC
bool isAvailable() const
Definition: Service.h:46
Hector * m_Hector
HectorProducer::~HectorProducer ( )
override

Definition at line 55 of file HectorProducer.cc.

55 {}

Member Function Documentation

void HectorProducer::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 57 of file HectorProducer.cc.

57 {}
void HectorProducer::endRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 59 of file HectorProducer.cc.

59 {}
void HectorProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 61 of file HectorProducer.cc.

References Hector::add(), Hector::addPartToHepMC(), Hector::clear(), Hector::clearApertureFlags(), DEFINE_FWK_MODULE, evt_, Exception, Hector::filterD1(), Hector::filterFP420(), Hector::filterZDC(), edm::Event::getByToken(), Hector::getCorrespondenceMap(), edm::RandomNumberGenerator::getEngine(), edm::HepMCProduct::GetEvent(), mps_fire::i, edm::HandleBase::isValid(), LogDebug, m_evtAnalysed, m_FP420Transport, m_Hector, m_HepMC, m_verbosity, m_ZDCTransport, edm::Provenance::moduleLabel(), eostools::move(), edm::HandleBase::provenance(), edm::Event::put(), and edm::Event::streamID().

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

Member Data Documentation

HepMC::GenEvent* HectorProducer::evt_
private

Definition at line 38 of file HectorProducer.h.

Referenced by produce().

int HectorProducer::m_evtAnalysed
private

just to count events that have been analysed

Definition at line 45 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().

bool HectorProducer::m_FP420Transport
private

Definition at line 43 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().

Hector* HectorProducer::m_Hector
private

Definition at line 39 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().

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

Definition at line 41 of file HectorProducer.h.

Referenced by produce().

bool HectorProducer::m_verbosity
private

Definition at line 42 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().

bool HectorProducer::m_ZDCTransport
private

Definition at line 44 of file HectorProducer.h.

Referenced by HectorProducer(), and produce().