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 hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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 47 of file PPSSimTrackProducer.cc.

Constructor & Destructor Documentation

◆ PPSSimTrackProducer()

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

Definition at line 80 of file PPSSimTrackProducer.cc.

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

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

◆ ~PPSSimTrackProducer()

PPSSimTrackProducer::~PPSSimTrackProducer ( )
override

Definition at line 103 of file PPSSimTrackProducer.cc.

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

References theTransporter.

Member Function Documentation

◆ beginStream()

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

Definition at line 170 of file PPSSimTrackProducer.cc.

170 {}

◆ endStream()

void PPSSimTrackProducer::endStream ( )
overrideprivate

Definition at line 173 of file PPSSimTrackProducer.cc.

173 {}

◆ produce()

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

Definition at line 117 of file PPSSimTrackProducer.cc.

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

References 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 66 of file PPSSimTrackProducer.cc.

Referenced by produce().

◆ m_InTag

edm::InputTag PPSSimTrackProducer::m_InTag
private

Definition at line 62 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer().

◆ m_InTagToken

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

Definition at line 63 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

◆ m_transportMethod

std::string PPSSimTrackProducer::m_transportMethod
private

Definition at line 65 of file PPSSimTrackProducer.cc.

◆ m_verbosity

bool PPSSimTrackProducer::m_verbosity
private

Definition at line 60 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

◆ theTransporter

ProtonTransport* PPSSimTrackProducer::theTransporter
private

Definition at line 61 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:355
edm::LHCTransportLinkContainer
std::vector< LHCTransportLink > LHCTransportLinkContainer
Definition: LHCTransportLinkContainer.h:8
PPSSimTrackProducer::m_verbosity
bool m_verbosity
Definition: PPSSimTrackProducer.cc:60
edm
HLT enums.
Definition: AlignableModifier.h:19
PPSSimTrackProducer::m_InTagToken
edm::EDGetTokenT< edm::HepMCProduct > m_InTagToken
Definition: PPSSimTrackProducer.cc:63
PPSSimTrackProducer::m_InTag
edm::InputTag m_InTag
Definition: PPSSimTrackProducer.cc:62
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:670
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:61
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:66
ProtonTransport::process
void process(const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine)
Definition: ProtonTransport.h:21
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:246
edm::HepMCProduct
Definition: HepMCProduct.h:18
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15