CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PPSSimTrackProducer Class Reference

#include <SimPPS/PPSSimTrackProducer/plugins/PPSSimTrackProducer.cc>

Inheritance diagram for PPSSimTrackProducer:
edm::stream::EDProducer<>

Public Member Functions

 PPSSimTrackProducer (const edm::ParameterSet &)
 
 ~PPSSimTrackProducer () override=default
 
- Public Member Functions inherited from edm::stream::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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

int m_eventsAnalysed
 just to count events that have been analysed More...
 
edm::InputTag m_InTag
 
edm::EDGetTokenT< edm::HepMCProductm_InTagToken
 
std::string m_transportMethod
 
bool m_verbosity
 
ProtonTransport theTransporter
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 48 of file PPSSimTrackProducer.cc.

Constructor & Destructor Documentation

◆ PPSSimTrackProducer()

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

Definition at line 79 of file PPSSimTrackProducer.cc.

References Exception, edm::ParameterSet::getParameter(), m_eventsAnalysed, m_InTag, m_InTagToken, and m_verbosity.

80  : theTransporter(iConfig, consumesCollector()) {
81  m_InTag = iConfig.getParameter<edm::InputTag>("HepMCProductLabel");
82  m_InTagToken = consumes<edm::HepMCProduct>(m_InTag);
83 
84  m_verbosity = iConfig.getParameter<bool>("Verbosity");
85  m_eventsAnalysed = 0;
86  //m_transportMethod = iConfig.getParameter<std::string>("TransportMethod");
87 
88  produces<edm::HepMCProduct>();
89  produces<edm::LHCTransportLinkContainer>();
90 
92  if (!rng.isAvailable()) {
93  throw cms::Exception("Configuration")
94  << "LHCTransport (ProtonTransport) requires the RandomNumberGeneratorService\n"
95  "which is not present in the configuration file. You must add the service\n"
96  "in the configuration file or remove the modules that require it.";
97  }
98 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ProtonTransport theTransporter
int m_eventsAnalysed
just to count events that have been analysed
edm::EDGetTokenT< edm::HepMCProduct > m_InTagToken

◆ ~PPSSimTrackProducer()

PPSSimTrackProducer::~PPSSimTrackProducer ( )
overridedefault

Member Function Documentation

◆ produce()

void PPSSimTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 105 of file PPSSimTrackProducer.cc.

References ProtonTransport::addPartToHepMC(), Exception, ProtonTransport::getCorrespondenceMap(), edm::RandomNumberGenerator::getEngine(), edm::HepMCProduct::GetEvent(), mps_fire::i, iEvent, edm::HandleBase::isValid(), LogDebug, m_eventsAnalysed, m_InTagToken, m_verbosity, edm::Provenance::moduleLabel(), eostools::move(), ProtonTransport::process(), edm::HandleBase::provenance(), and theTransporter.

105  {
106  using namespace edm;
107  using namespace std;
108  HepMC::GenEvent* evt;
110  CLHEP::HepRandomEngine* engine = &rng->getEngine(iEvent.streamID());
111  if (engine->name() != "TRandom3") {
112  throw cms::Exception("Configuration") << "The TRandom3 engine type must be used with ProtonTransport, Random "
113  "Number Generator Service not correctly configured!";
114  }
115 
117  Handle<HepMCProduct> HepMCEvt;
118  iEvent.getByToken(m_InTagToken, HepMCEvt);
119 
120  if (!HepMCEvt.isValid()) {
121  throw cms::Exception("InvalidReference") << "Invalid reference to HepMCProduct\n";
122  }
123 
124  if (HepMCEvt.provenance()->moduleLabel() == "LHCTransport") {
125  throw cms::Exception("LogicError") << "LHCTrasport HepMCProduce already exists\n";
126  }
127  edm::LogVerbatim("ProtonTransportEventProcessing") << "produce begin for event " << m_eventsAnalysed;
128 
129  evt = new HepMC::GenEvent(HepMCEvt->GetEvent()->signal_process_id(), HepMCEvt->GetEvent()->event_number());
130 
131  theTransporter.process(HepMCEvt->GetEvent(), iSetup, engine);
132  theTransporter.addPartToHepMC(HepMCEvt->GetEvent(), evt);
133 
134  if (m_verbosity)
135  evt->print();
136 
137  unique_ptr<HepMCProduct> newProduct(new edm::HepMCProduct());
138  newProduct->addHepMCData(evt);
139 
140  iEvent.put(std::move(newProduct));
141 
142  unique_ptr<LHCTransportLinkContainer> NewCorrespondenceMap(new edm::LHCTransportLinkContainer());
144  (*NewCorrespondenceMap).swap(thisLink);
145 
146  if (m_verbosity) {
147  for (unsigned int i = 0; i < (*NewCorrespondenceMap).size(); ++i)
148  LogDebug("ProtonTransportEventProcessing")
149  << "ProtonTransport correspondence table: " << (*NewCorrespondenceMap)[i];
150  }
151 
152  iEvent.put(std::move(NewCorrespondenceMap));
153  // There is no need to delete the pointer to the event, since it is deleted in HepMCProduct,
154  // in fact, it MUST NOT be delete here, as a protection is missing in above package
155  edm::LogVerbatim("ProtonTransportEventProcessing") << "produce end ";
156 }
Log< level::Info, true > LogVerbatim
void addPartToHepMC(const HepMC::GenEvent *iev, HepMC::GenEvent *ev)
ProtonTransport theTransporter
Provenance const * provenance() const
Definition: HandleBase.h:74
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
int m_eventsAnalysed
just to count events that have been analysed
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::HepMCProduct > m_InTagToken
std::vector< LHCTransportLink > & getCorrespondenceMap()
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
std::vector< LHCTransportLink > LHCTransportLinkContainer
std::string const & moduleLabel() const
Definition: Provenance.h:55
void process(const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine)
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ m_eventsAnalysed

int PPSSimTrackProducer::m_eventsAnalysed
private

just to count events that have been analysed

Definition at line 65 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

◆ m_InTag

edm::InputTag PPSSimTrackProducer::m_InTag
private

Definition at line 61 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer().

◆ m_InTagToken

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

Definition at line 62 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

◆ m_transportMethod

std::string PPSSimTrackProducer::m_transportMethod
private

Definition at line 64 of file PPSSimTrackProducer.cc.

◆ m_verbosity

bool PPSSimTrackProducer::m_verbosity
private

Definition at line 59 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

◆ theTransporter

ProtonTransport PPSSimTrackProducer::theTransporter
private

Definition at line 60 of file PPSSimTrackProducer.cc.

Referenced by produce().