CMS 3D CMS Logo

List of all members | Public Member Functions | Static 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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

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 = 0
 

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

Constructor & Destructor Documentation

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

Definition at line 78 of file PPSSimTrackProducer.cc.

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

78  {
79  //now do what ever other initialization is needed
80  // TransportHector
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_transportMethod = iConfig.getParameter<std::string>("TransportMethod");
86 
87  produces<edm::HepMCProduct>();
88  produces<edm::LHCTransportLinkContainer>();
89 
90  theTransporter = nullptr;
91 
92  if (m_transportMethod == "Totem") {
93  theTransporter = new TotemTransport(iConfig, m_verbosity);
94  } else if (m_transportMethod == "Hector") {
95  theTransporter = new HectorTransport(iConfig, m_verbosity);
96  } else {
97  throw cms::Exception("Configuration")
98  << "LHCTransport (ProtonTransport) requires a Method (Hector or Totem) \n"
99  "which is not present in the configuration file. You should add one of the method\n"
100  "above in the configuration file or remove the module that requires it.";
101  }
102 
104  if (!rng.isAvailable()) {
105  throw cms::Exception("Configuration")
106  << "LHCTransport (ProtonTransport) requires the RandomNumberGeneratorService\n"
107  "which is not present in the configuration file. You must add the service\n"
108  "in the configuration file or remove the modules that require it.";
109  }
110 }
T getParameter(std::string const &) const
ProtonTransport * theTransporter
edm::EDGetTokenT< edm::HepMCProduct > m_InTagToken
bool isAvailable() const
Definition: Service.h:40
PPSSimTrackProducer::~PPSSimTrackProducer ( )
override

Definition at line 112 of file PPSSimTrackProducer.cc.

References theTransporter.

112  {
113  // do anything here that needs to be done at destruction time
114  // (e.g. close files, deallocate resources etc.)
115  if (theTransporter) {
116  delete theTransporter;
117  theTransporter = nullptr;
118  }
119 }
ProtonTransport * theTransporter

Member Function Documentation

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

Definition at line 178 of file PPSSimTrackProducer.cc.

178 {}
void PPSSimTrackProducer::endStream ( )
overrideprivate

Definition at line 181 of file PPSSimTrackProducer.cc.

181 {}
void PPSSimTrackProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 184 of file PPSSimTrackProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

184  {
185  //The following says we do not know what parameters are allowed so do no validation
186  // Please change this to state exactly what you do use, even if it is no parameters
188  desc.setUnknown();
189  descriptions.addDefault(desc);
190 }
void addDefault(ParameterSetDescription const &psetDescription)
void PPSSimTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 126 of file PPSSimTrackProducer.cc.

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

126  {
127  using namespace edm;
128  using namespace std;
129  HepMC::GenEvent* evt;
131  CLHEP::HepRandomEngine* engine = &rng->getEngine(iEvent.streamID());
132  if (engine->name() != "TRandom3") {
133  throw cms::Exception("Configuration") << "The TRandom3 engine type must be used with ProtonTransport, Random "
134  "Number Generator Service not correctly configured!";
135  }
136 
138  Handle<HepMCProduct> HepMCEvt;
139  iEvent.getByToken(m_InTagToken, HepMCEvt);
140 
141  if (!HepMCEvt.isValid()) {
142  throw cms::Exception("InvalidReference") << "Invalid reference to HepMCProduct\n";
143  }
144 
145  if (HepMCEvt.provenance()->moduleLabel() == "LHCTransport") {
146  throw cms::Exception("LogicError") << "HectorTrasported HepMCProduce already exists\n";
147  }
148 
149  evt = new HepMC::GenEvent(*HepMCEvt->GetEvent());
150 
152  theTransporter->process(evt, iSetup, engine);
153 
154  if (m_verbosity)
155  evt->print();
156 
157  unique_ptr<HepMCProduct> newProduct(new edm::HepMCProduct());
158  newProduct->addHepMCData(evt);
159 
160  iEvent.put(std::move(newProduct));
161 
162  unique_ptr<LHCTransportLinkContainer> NewCorrespondenceMap(new edm::LHCTransportLinkContainer());
164  (*NewCorrespondenceMap).swap(thisLink);
165 
166  if (m_verbosity) {
167  for (unsigned int i = 0; i < (*NewCorrespondenceMap).size(); i++)
168  LogDebug("HectorEventProcessing") << "Hector correspondence table: " << (*NewCorrespondenceMap)[i];
169  }
170 
171  iEvent.put(std::move(NewCorrespondenceMap));
172  // There is no need to delete the pointer to the event, since it is deleted in HepMCProduct,
173  // in fact, it MUST NOT be delete here, as a protection is missing in above package
174 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
ProtonTransport * theTransporter
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
int m_eventsAnalysed
just to count events that have been analysed
edm::EDGetTokenT< edm::HepMCProduct > m_InTagToken
std::vector< LHCTransportLink > & getCorrespondenceMap()
bool isValid() const
Definition: HandleBase.h:74
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
std::string const & moduleLabel() const
Definition: Provenance.h:53
HLT enums.
StreamID streamID() const
Definition: Event.h:95
std::vector< LHCTransportLink > LHCTransportLinkContainer
virtual void process(const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine)=0
def move(src, dest)
Definition: eostools.py:511
Provenance const * provenance() const
Definition: HandleBase.h:83

Member Data Documentation

int PPSSimTrackProducer::m_eventsAnalysed
private

just to count events that have been analysed

Definition at line 64 of file PPSSimTrackProducer.cc.

Referenced by produce().

edm::InputTag PPSSimTrackProducer::m_InTag
private

Definition at line 60 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer().

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

Definition at line 61 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

std::string PPSSimTrackProducer::m_transportMethod
private

Definition at line 63 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer().

bool PPSSimTrackProducer::m_verbosity
private

Definition at line 58 of file PPSSimTrackProducer.cc.

Referenced by PPSSimTrackProducer(), and produce().

ProtonTransport* PPSSimTrackProducer::theTransporter = 0
private

Definition at line 59 of file PPSSimTrackProducer.cc.

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