CMS 3D CMS Logo

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
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void endStream () override
 
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
 
ProtonTransporttheTransporter
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 49 of file PPSSimTrackProducer.cc.

Constructor & Destructor Documentation

◆ PPSSimTrackProducer()

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

Definition at line 82 of file PPSSimTrackProducer.cc.

82  {
83  //now do what ever other initialization is needed
84  // TransportHector
85  theTransporter = new ProtonTransport(iConfig);
86 
87  m_InTag = iConfig.getParameter<edm::InputTag>("HepMCProductLabel");
88  m_InTagToken = consumes<edm::HepMCProduct>(m_InTag);
89 
90  m_verbosity = iConfig.getParameter<bool>("Verbosity");
91  m_eventsAnalysed = 0;
92  //m_transportMethod = iConfig.getParameter<std::string>("TransportMethod");
93 
94  produces<edm::HepMCProduct>();
95  produces<edm::LHCTransportLinkContainer>();
96 
98  if (!rng.isAvailable()) {
99  throw cms::Exception("Configuration")
100  << "LHCTransport (ProtonTransport) requires the RandomNumberGeneratorService\n"
101  "which is not present in the configuration file. You must add the service\n"
102  "in the configuration file or remove the modules that require it.";
103  }
104 }

References Exception, edm::ParameterSet::getParameter(), edm::Service< T >::isAvailable(), m_eventsAnalysed, m_InTag, m_InTagToken, m_verbosity, and theTransporter.

◆ ~PPSSimTrackProducer()

PPSSimTrackProducer::~PPSSimTrackProducer ( )
override

Definition at line 106 of file PPSSimTrackProducer.cc.

106  {
107  // do anything here that needs to be done at destruction time
108  // (e.g. close files, deallocate resources etc.)
109  if (theTransporter) {
110  delete theTransporter;
111  theTransporter = nullptr;
112  }
113 }

References theTransporter.

Member Function Documentation

◆ beginStream()

void PPSSimTrackProducer::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 175 of file PPSSimTrackProducer.cc.

175 {}

◆ endStream()

void PPSSimTrackProducer::endStream ( )
overrideprivate

Definition at line 178 of file PPSSimTrackProducer.cc.

178 {}

◆ produce()

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

Definition at line 120 of file PPSSimTrackProducer.cc.

120  {
121  using namespace edm;
122  using namespace std;
123  HepMC::GenEvent* evt;
125  CLHEP::HepRandomEngine* engine = &rng->getEngine(iEvent.streamID());
126  if (engine->name() != "TRandom3") {
127  throw cms::Exception("Configuration") << "The TRandom3 engine type must be used with ProtonTransport, Random "
128  "Number Generator Service not correctly configured!";
129  }
130 
132  Handle<HepMCProduct> HepMCEvt;
133  iEvent.getByToken(m_InTagToken, HepMCEvt);
134 
135  if (!HepMCEvt.isValid()) {
136  throw cms::Exception("InvalidReference") << "Invalid reference to HepMCProduct\n";
137  }
138 
139  if (HepMCEvt.provenance()->moduleLabel() == "LHCTransport") {
140  throw cms::Exception("LogicError") << "LHCTrasport HepMCProduce already exists\n";
141  }
142  edm::LogVerbatim("ProtonTransportEventProcessing") << "produce begin for event " << m_eventsAnalysed;
143 
144  evt = new HepMC::GenEvent(HepMCEvt->GetEvent()->signal_process_id(), HepMCEvt->GetEvent()->event_number());
145 
146  theTransporter->process(HepMCEvt->GetEvent(), iSetup, engine);
147  theTransporter->addPartToHepMC(HepMCEvt->GetEvent(), evt);
148 
149  if (m_verbosity)
150  evt->print();
151 
152  unique_ptr<HepMCProduct> newProduct(new edm::HepMCProduct());
153  newProduct->addHepMCData(evt);
154 
155  iEvent.put(std::move(newProduct));
156 
157  unique_ptr<LHCTransportLinkContainer> NewCorrespondenceMap(new edm::LHCTransportLinkContainer());
159  (*NewCorrespondenceMap).swap(thisLink);
160 
161  if (m_verbosity) {
162  for (unsigned int i = 0; i < (*NewCorrespondenceMap).size(); ++i)
163  LogDebug("ProtonTransportEventProcessing")
164  << "ProtonTransport correspondence table: " << (*NewCorrespondenceMap)[i];
165  }
166 
167  iEvent.put(std::move(NewCorrespondenceMap));
168  // There is no need to delete the pointer to the event, since it is deleted in HepMCProduct,
169  // in fact, it MUST NOT be delete here, as a protection is missing in above package
170  edm::LogVerbatim("ProtonTransportEventProcessing") << "produce end ";
171 }

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.

Member Data Documentation

◆ m_eventsAnalysed

int PPSSimTrackProducer::m_eventsAnalysed
private

just to count events that have been analysed

Definition at line 68 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

◆ m_InTag

edm::InputTag PPSSimTrackProducer::m_InTag
private

Definition at line 64 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer().

◆ m_InTagToken

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

Definition at line 65 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

◆ m_transportMethod

std::string PPSSimTrackProducer::m_transportMethod
private

Definition at line 67 of file PPSSimTrackProducer.cc.

◆ m_verbosity

bool PPSSimTrackProducer::m_verbosity
private

Definition at line 62 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

◆ theTransporter

ProtonTransport* PPSSimTrackProducer::theTransporter
private

Definition at line 63 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), produce(), and ~PPSSimTrackProducer().

edm::Provenance::moduleLabel
std::string const & moduleLabel() const
Definition: Provenance.h:55
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
mps_fire.i
i
Definition: mps_fire.py:428
edm::LHCTransportLinkContainer
std::vector< LHCTransportLink > LHCTransportLinkContainer
Definition: LHCTransportLinkContainer.h:8
PPSSimTrackProducer::m_verbosity
bool m_verbosity
Definition: PPSSimTrackProducer.cc:62
edm
HLT enums.
Definition: AlignableModifier.h:19
PPSSimTrackProducer::m_InTagToken
edm::EDGetTokenT< edm::HepMCProduct > m_InTagToken
Definition: PPSSimTrackProducer.cc:65
PPSSimTrackProducer::m_InTag
edm::InputTag m_InTag
Definition: PPSSimTrackProducer.cc:64
edm::Handle
Definition: AssociativeIterator.h:50
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
edm::HandleBase::provenance
Provenance const * provenance() const
Definition: HandleBase.h:74
ProtonTransport
Definition: ProtonTransport.h:12
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
ProtonTransport::getCorrespondenceMap
std::vector< LHCTransportLink > & getCorrespondenceMap()
Definition: ProtonTransport.h:20
edm::Service< edm::RandomNumberGenerator >
iEvent
int iEvent
Definition: GenABIO.cc:224
PPSSimTrackProducer::theTransporter
ProtonTransport * theTransporter
Definition: PPSSimTrackProducer.cc:63
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
PPSSimTrackProducer::m_eventsAnalysed
int m_eventsAnalysed
just to count events that have been analysed
Definition: PPSSimTrackProducer.cc:68
ProtonTransport::process
void process(const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine)
Definition: ProtonTransport.h:21
ProtonTransport::addPartToHepMC
void addPartToHepMC(const HepMC::GenEvent *iev, HepMC::GenEvent *ev)
Definition: ProtonTransport.h:24
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:246
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::HepMCProduct
Definition: HepMCProduct.h:18
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15