Skip to content

Commit

Permalink
Changing SimPPS/PPSSimTrasnProducer in view of the change implemented…
Browse files Browse the repository at this point in the history
… in SimTransport
  • Loading branch information
mundim committed May 16, 2020
1 parent 9a66943 commit ce13f8c
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions SimPPS/PPSSimTrackProducer/plugins/PPSSimTrackProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
#include "SimDataFormats/Forward/interface/LHCTransportLink.h"
#include "SimDataFormats/Forward/interface/LHCTransportLinkContainer.h"

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "SimTransport/PPSProtonTransport/interface/TotemTransport.h"
#include "SimTransport/PPSProtonTransport/interface/HectorTransport.h"
#include "SimTransport/PPSProtonTransport/interface/ProtonTransport.h"
#include "TRandom3.h"
#include "IOMC/RandomEngine/src/TRandomAdaptor.h"

//
// class declaration
//
Expand All @@ -47,7 +49,7 @@ class PPSSimTrackProducer : public edm::stream::EDProducer<> {
explicit PPSSimTrackProducer(const edm::ParameterSet&);
~PPSSimTrackProducer() override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
//static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
void beginStream(edm::StreamID) override;
Expand All @@ -56,7 +58,7 @@ class PPSSimTrackProducer : public edm::stream::EDProducer<> {

// ----------member data ---------------------------
bool m_verbosity;
ProtonTransport* theTransporter = nullptr;
ProtonTransport* theTransporter;
edm::InputTag m_InTag;
edm::EDGetTokenT<edm::HepMCProduct> m_InTagToken;

Expand All @@ -78,28 +80,17 @@ class PPSSimTrackProducer : public edm::stream::EDProducer<> {
PPSSimTrackProducer::PPSSimTrackProducer(const edm::ParameterSet& iConfig) {
//now do what ever other initialization is needed
// TransportHector
theTransporter = new ProtonTransport(iConfig);

m_InTag = iConfig.getParameter<edm::InputTag>("HepMCProductLabel");
m_InTagToken = consumes<edm::HepMCProduct>(m_InTag);

m_verbosity = iConfig.getParameter<bool>("Verbosity");
m_transportMethod = iConfig.getParameter<std::string>("TransportMethod");
//m_transportMethod = iConfig.getParameter<std::string>("TransportMethod");

produces<edm::HepMCProduct>();
produces<edm::LHCTransportLinkContainer>();

theTransporter = nullptr;

if (m_transportMethod == "Totem") {
theTransporter = new TotemTransport(iConfig, m_verbosity);
} else if (m_transportMethod == "Hector") {
theTransporter = new HectorTransport(iConfig, m_verbosity);
} else {
throw cms::Exception("Configuration")
<< "LHCTransport (ProtonTransport) requires a Method (Hector or Totem) \n"
"which is not present in the configuration file. You should add one of the method\n"
"above in the configuration file or remove the module that requires it.";
}

edm::Service<edm::RandomNumberGenerator> rng;
if (!rng.isAvailable()) {
throw cms::Exception("Configuration")
Expand Down Expand Up @@ -143,12 +134,12 @@ void PPSSimTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
}

if (HepMCEvt.provenance()->moduleLabel() == "LHCTransport") {
throw cms::Exception("LogicError") << "HectorTrasported HepMCProduce already exists\n";
throw cms::Exception("LogicError") << "LHCTrasport HepMCProduce already exists\n";
}

evt = new HepMC::GenEvent(*HepMCEvt->GetEvent());

theTransporter->clear();
//theTransporter->clear();
theTransporter->process(evt, iSetup, engine);

if (m_verbosity)
Expand All @@ -165,7 +156,8 @@ void PPSSimTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe

if (m_verbosity) {
for (unsigned int i = 0; i < (*NewCorrespondenceMap).size(); i++)
LogDebug("HectorEventProcessing") << "Hector correspondence table: " << (*NewCorrespondenceMap)[i];
LogDebug("ProtonTransportEventProcessing")
<< "ProtonTransport correspondence table: " << (*NewCorrespondenceMap)[i];
}

iEvent.put(std::move(NewCorrespondenceMap));
Expand All @@ -181,13 +173,14 @@ void PPSSimTrackProducer::beginStream(edm::StreamID) {}
void PPSSimTrackProducer::endStream() {}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
/*
void PPSSimTrackProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
}

*/
//define this as a plug-in
DEFINE_FWK_MODULE(PPSSimTrackProducer);

0 comments on commit ce13f8c

Please sign in to comment.