CMS 3D CMS Logo

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

#include <CTPPSHectorProducer.h>

Inheritance diagram for CTPPSHectorProducer:
edm::one::EDProducer< edm::one::SharedResources, edm::one::WatchRuns > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
 CTPPSHectorProducer (edm::ParameterSet const &p)
 default constructor More...
 
virtual void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
virtual void produce (edm::Event &e, const edm::EventSetup &c) override
 
virtual ~CTPPSHectorProducer ()
 default destructor More...
 
- 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
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > 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

int eventsAnalysed
 just to count events that have been analysed More...
 
CTPPSHectorhector_ctpps
 
bool m_CTPPSTransport
 
std::string m_InTag
 
edm::EDGetTokenT< edm::HepMCProductm_InTagToken
 
bool m_verbosity
 

Additional Inherited Members

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

Constructor & Destructor Documentation

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

default constructor

Definition at line 32 of file CTPPSHectorProducer.cc.

References HectorTransportCTPPS_cfi::CTPPSHector, Exception, edm::ParameterSet::getParameter(), hector_ctpps, edm::Service< T >::isAvailable(), m_CTPPSTransport, m_InTag, m_InTagToken, m_verbosity, and AlCaHLTBitMon_QueryRunRegistry::string.

32  :eventsAnalysed(0){
33 
34  // TransportHector
35  m_InTag = parameters.getParameter<std::string>("HepMCProductLabel") ;
36  m_InTagToken = consumes<edm::HepMCProduct>(m_InTag);
37  m_verbosity = parameters.getParameter<bool>("Verbosity");
38  m_CTPPSTransport = parameters.getParameter<bool>("CTPPSTransport");
39 
40  produces<edm::HepMCProduct>();
41  produces<edm::LHCTransportLinkContainer>();
42 
43  hector_ctpps = new CTPPSHector(parameters, m_verbosity,m_CTPPSTransport);
44 
46  if ( ! rng.isAvailable() ) {
47  throw cms::Exception("Configuration")
48  << "LHCTransport (CTPPSHectorProducer) 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::EDGetTokenT< edm::HepMCProduct > m_InTagToken
CTPPSHector * hector_ctpps
bool isAvailable() const
Definition: Service.h:46
int eventsAnalysed
just to count events that have been analysed
CTPPSHectorProducer::~CTPPSHectorProducer ( )
virtual

default destructor

Definition at line 54 of file CTPPSHectorProducer.cc.

54 {}

Member Function Documentation

void CTPPSHectorProducer::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
overridevirtual

Definition at line 57 of file CTPPSHectorProducer.cc.

57 {}
void CTPPSHectorProducer::endRun ( const edm::Run r,
const edm::EventSetup c 
)
overridevirtual

Definition at line 60 of file CTPPSHectorProducer.cc.

60 {}
void CTPPSHectorProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Definition at line 62 of file CTPPSHectorProducer.cc.

References CTPPSHector::add(), CTPPSHector::addPartToHepMC(), CTPPSHector::clear(), CTPPSHector::clearApertureFlags(), DEFINE_FWK_MODULE, eventsAnalysed, Exception, CTPPSHector::filterCTPPS(), edm::Event::getByToken(), CTPPSHector::getCorrespondenceMap(), edm::RandomNumberGenerator::getEngine(), edm::HepMCProduct::GetEvent(), hector_ctpps, mps_fire::i, edm::HandleBase::isValid(), LogDebug, m_CTPPSTransport, m_InTagToken, m_verbosity, edm::Provenance::moduleLabel(), eostools::move(), edm::HandleBase::provenance(), edm::Event::put(), and edm::Event::streamID().

62  {
63 
64  using namespace edm;
65  using namespace std;
66  HepMC::GenEvent * evt_;
68  CLHEP::HepRandomEngine* engine = &rng->getEngine(iEvent.streamID());
69  if ( engine->name() != "TRandom3" ) {
70  throw cms::Exception("Configuration")
71  << "The TRandom3 engine type must be used with CTPPSHectorProducer, Random Number Generator Service not correctly configured!";
72  }
73  TRandom3* rootEngine = ( (edm::TRandomAdaptor*) engine )->getRootEngine();
74 
76  Handle<HepMCProduct> HepMCEvt;
77  iEvent.getByToken( m_InTagToken, HepMCEvt ) ;
78 
79  if ( !HepMCEvt.isValid() ){
80  throw cms::Exception("InvalidReference")
81  << "Invalid reference to HepMCProduct\n";
82  }
83 
84  if ( HepMCEvt.provenance()->moduleLabel() == "LHCTransport" ){
85  throw cms::Exception("LogicError")
86  << "HectorTrasported HepMCProduce already exists\n";
87  }
88 
89  evt_ = new HepMC::GenEvent( *HepMCEvt->GetEvent() );
91  if(m_CTPPSTransport) {
93  hector_ctpps->add( evt_ ,es ,engine);
94  hector_ctpps->filterCTPPS(rootEngine);
95  }
96 
97  evt_ = hector_ctpps->addPartToHepMC( evt_ );
98  if (m_verbosity) {
99  evt_->print();
100  }
101 
102  unique_ptr<HepMCProduct> NewProduct(new edm::HepMCProduct()) ;
103  NewProduct->addHepMCData( evt_ ) ;
104 
105  iEvent.put(std::move(NewProduct)) ;
106 
107  unique_ptr<LHCTransportLinkContainer> NewCorrespondenceMap(new edm::LHCTransportLinkContainer() );
109  (*NewCorrespondenceMap).swap(thisLink);
110 
111  if ( m_verbosity ) {
112  for ( unsigned int i = 0; i < (*NewCorrespondenceMap).size(); i++)
113  LogDebug("HectorEventProcessing") << "Hector correspondence table: " << (*NewCorrespondenceMap)[i];
114  }
115 
116  iEvent.put(std::move(NewCorrespondenceMap));
117  hector_ctpps->clear();
118 
119 }
#define LogDebug(id)
HepMC::GenEvent * addPartToHepMC(HepMC::GenEvent *event)
Definition: CTPPSHector.cc:345
edm::EDGetTokenT< edm::HepMCProduct > m_InTagToken
void clearApertureFlags()
Definition: CTPPSHector.cc:107
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
int iEvent
Definition: GenABIO.cc:230
CTPPSHector * hector_ctpps
void add(const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine)
Definition: CTPPSHector.cc:123
bool isValid() const
Definition: HandleBase.h:74
void clear()
Definition: CTPPSHector.cc:111
int eventsAnalysed
just to count events that have been analysed
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
std::string const & moduleLabel() const
Definition: Provenance.h:50
HLT enums.
std::vector< LHCTransportLink > LHCTransportLinkContainer
void filterCTPPS(TRandom3 *)
Definition: CTPPSHector.cc:197
std::vector< LHCTransportLink > & getCorrespondenceMap()
Definition: CTPPSHector.h:76
def move(src, dest)
Definition: eostools.py:510
Provenance const * provenance() const
Definition: HandleBase.h:83

Member Data Documentation

int CTPPSHectorProducer::eventsAnalysed
private

just to count events that have been analysed

Definition at line 46 of file CTPPSHectorProducer.h.

Referenced by produce().

CTPPSHector* CTPPSHectorProducer::hector_ctpps
private

Definition at line 39 of file CTPPSHectorProducer.h.

Referenced by CTPPSHectorProducer(), and produce().

bool CTPPSHectorProducer::m_CTPPSTransport
private

Definition at line 45 of file CTPPSHectorProducer.h.

Referenced by CTPPSHectorProducer(), and produce().

std::string CTPPSHectorProducer::m_InTag
private

Definition at line 41 of file CTPPSHectorProducer.h.

Referenced by CTPPSHectorProducer().

edm::EDGetTokenT<edm::HepMCProduct> CTPPSHectorProducer::m_InTagToken
private

Definition at line 42 of file CTPPSHectorProducer.h.

Referenced by CTPPSHectorProducer(), and produce().

bool CTPPSHectorProducer::m_verbosity
private

Definition at line 44 of file CTPPSHectorProducer.h.

Referenced by CTPPSHectorProducer(), and produce().