diff --git a/GeneratorInterface/Herwig7Interface/interface/HepMC3Traits.h b/GeneratorInterface/Herwig7Interface/interface/HepMC3Traits.h index 92bb08fb126..70d08abaf2d 100644 --- a/GeneratorInterface/Herwig7Interface/interface/HepMC3Traits.h +++ b/GeneratorInterface/Herwig7Interface/interface/HepMC3Traits.h @@ -14,7 +14,7 @@ namespace HepMC3 { class GenParticle; class GenVertex; class GenPdfInfo; -} +} // namespace HepMC3 namespace ThePEG { @@ -35,12 +35,14 @@ namespace ThePEG { * HepMC implementation is specifying units or not. */ template + typename HepMCParticleT, + typename HepMCParticlePtrT, + typename HepMCVertexT, + typename HepMCVertexPtrT, + typename HepMCPolarizationT, + typename HepMCPdfInfoT> struct HepMCTraitsBase { - /** Typedef of the particle class. */ typedef HepMCParticleT ParticleT; @@ -63,32 +65,33 @@ namespace ThePEG { typedef HepMCVertexPtrT VertexPtrT; /** Create an event object with number \a evno and \a weight. */ - static EventT * newEvent(long evno, double weight, const map& optionalWeights) { - EventT * e = new EventT(); + static EventT* newEvent(long evno, double weight, const map& optionalWeights) { + EventT* e = new EventT(); e->set_event_number(evno); std::vector wnames; std::vector wvalues; wnames.push_back("Default"); wvalues.push_back(weight); - for ( map::const_iterator w = optionalWeights.begin(); w != optionalWeights.end(); ++w ) { + for (map::const_iterator w = optionalWeights.begin(); w != optionalWeights.end(); ++w) { wnames.push_back(w->first); wvalues.push_back(w->second); } e->run_info()->set_weight_names(wnames); - e->weights()=wvalues; + e->weights() = wvalues; #ifdef HEPMC_HAS_NAMED_WEIGHTS - for (size_t i=0;iweights()[wnames[i]] = wvalues[i]; + for (size_t i = 0; i < wnames.size(); i++) + e->weights()[wnames[i]] = wvalues[i]; #else - e->weights()=wvalues; + e->weights() = wvalues; #endif return e; } /** Reset event weight and number of a re-used GenEvent. */ - static void resetEvent(EventT *e, long evno, double weight, const map& optionalWeights) { + static void resetEvent(EventT* e, long evno, double weight, const map& optionalWeights) { e->set_event_number(evno); e->weights().clear(); std::vector wnames; @@ -96,15 +99,16 @@ namespace ThePEG { wnames.push_back("Default"); wvalues.push_back(weight); - for ( map::const_iterator w = optionalWeights.begin(); w != optionalWeights.end(); ++w ) { + for (map::const_iterator w = optionalWeights.begin(); w != optionalWeights.end(); ++w) { wnames.push_back(w->first); wvalues.push_back(w->second); } e->run_info()->set_weight_names(wnames); - e->weights()=wvalues; + e->weights() = wvalues; #ifdef HEPMC_HAS_NAMED_WEIGHTS - for (size_t i=0; iweights()[wnames[i]] = wvalues[i]; + for (size_t i = 0; i < wnames.size(); i++) + e->weights()[wnames[i]] = wvalues[i]; #else e->weights() = wvalues; #endif @@ -128,7 +132,7 @@ namespace ThePEG { #ifndef HEPMC_HAS_UNITS return GeV; #else - return HepMC3::Units::default_momentum_unit() == HepMC3::Units::GEV? GeV: MeV; + return HepMC3::Units::default_momentum_unit() == HepMC3::Units::GEV ? GeV : MeV; #endif } @@ -139,7 +143,7 @@ namespace ThePEG { #ifndef HEPMC_HAS_UNITS return millimeter; #else - return HepMC3::Units::default_length_unit() == HepMC3::Units::MM? millimeter: 10.0*millimeter; + return HepMC3::Units::default_length_unit() == HepMC3::Units::MM ? millimeter : 10.0 * millimeter; #endif } @@ -147,9 +151,9 @@ namespace ThePEG { * Return the momentum unit used by a given GenEvent object. If * HepMC does not support units this must return GeV. */ - static Energy momentumUnit(const EventT & e) { + static Energy momentumUnit(const EventT& e) { #ifdef HEPMC_HAS_UNITS - return e.momentum_unit() == HepMC3::Units::MEV? MeV: GeV; + return e.momentum_unit() == HepMC3::Units::MEV ? MeV : GeV; #else return GeV; #endif @@ -159,9 +163,9 @@ namespace ThePEG { * Return the length unit used by a given GenEvent object. If * HepMC does not support units this must return millimeter. */ - static Length lengthUnit(const EventT & e) { + static Length lengthUnit(const EventT& e) { #ifdef HEPMC_HAS_UNITS - return e.length_unit() == HepMC3::Units::CM? centimeter: millimeter; + return e.length_unit() == HepMC3::Units::CM ? centimeter : millimeter; #else return millimeter; #endif @@ -172,109 +176,96 @@ namespace ThePEG { * HepMC does not support units this should be a no-op. */ #ifdef HEPMC_HAS_UNITS - static void setUnits(EventT & e, Energy momu, Length lenu) { - e.use_units(momu == MeV? HepMC3::Units::MEV: HepMC3::Units::GEV, - lenu == centimeter? HepMC3::Units::CM: HepMC3::Units::MM); + static void setUnits(EventT& e, Energy momu, Length lenu) { + e.use_units(momu == MeV ? HepMC3::Units::MEV : HepMC3::Units::GEV, + lenu == centimeter ? HepMC3::Units::CM : HepMC3::Units::MM); } #else - static void setUnits(EventT &, Energy, Length) {} + static void setUnits(EventT&, Energy, Length) {} #endif /** Set the \a scale, \f$\alpha_S\f$ (\a aS) and \f$\alpha_{EM}\f$ (\a aEM) for the event \a e. The scale will be scaled with \a unit before given to the GenEvent. */ - static void setScaleAndAlphas(EventT &e, Energy2 scale, double aS, double aEM, Energy unit) { - e.set_event_scale(sqrt(scale)/unit); + static void setScaleAndAlphas(EventT& e, Energy2 scale, double aS, double aEM, Energy unit) { + e.set_event_scale(sqrt(scale) / unit); e.set_alphaQCD(aS); e.set_alphaQED(aEM); } /** Set the primary vertex, \a v, for the event \a e. */ - static void setSignalProcessVertex(EventT & e, VertexPtrT v) { - e.set_signal_process_vertex(v); - } + static void setSignalProcessVertex(EventT& e, VertexPtrT v) { e.set_signal_process_vertex(v); } /** Set a vertex, \a v, for the event \a e. */ - static void addVertex(EventT & e, VertexPtrT v) { - e.add_vertex(v); - } + static void addVertex(EventT& e, VertexPtrT v) { e.add_vertex(v); } /** Create a new particle object with momentum \a p, PDG number \a id and status code \a status. The momentum will be scaled with \a unit which according to the HepMC documentation should be GeV. */ - static ParticlePtrT newParticle(const Lorentz5Momentum & p, long id, int status, Energy unit) { + static ParticlePtrT newParticle(const Lorentz5Momentum& p, long id, int status, Energy unit) { // Note that according to the documentation the momentum is stored in a // HepLorentzVector in GeV (event though the CLHEP standard is MeV). - LorentzVector p_scalar = p/unit; + LorentzVector p_scalar = p / unit; ParticlePtrT genp = new ParticleT(p_scalar, id, status); - genp->setGeneratedMass(p.mass()/unit); + genp->setGeneratedMass(p.mass() / unit); return genp; } /** Set the polarization directions, \a the and \a phi, for particle \a p. */ - static void setPolarization(ParticleT & genp, double the, double phi) { + static void setPolarization(ParticleT& genp, double the, double phi) { genp.set_polarization(PolarizationT(the, phi)); } /** Set the colour line (with index \a indx) to \a coline for particle \a p. */ - static void setColourLine(ParticleT & p, int indx, int coline) { - p.set_flow(indx, coline); - } + static void setColourLine(ParticleT& p, int indx, int coline) { p.set_flow(indx, coline); } /** Create a new vertex. */ - static VertexPtrT newVertex() { - return new VertexT(); - } + static VertexPtrT newVertex() { return new VertexT(); } /** Add an incoming particle, \a p, to the vertex, \a v. */ - static void addIncoming(VertexT & v, ParticlePtrT p) { - v.add_particle_in(p); - } + static void addIncoming(VertexT& v, ParticlePtrT p) { v.add_particle_in(p); } /** Add an outgoing particle, \a p, to the vertex, \a v. */ - static void addOutgoing(VertexT & v, ParticlePtrT p) { - v.add_particle_out(p); - } + static void addOutgoing(VertexT& v, ParticlePtrT p) { v.add_particle_out(p); } /** Set the position \a p for the vertex, \a v. The length will be scaled with \a unit which normally should be millimeters. */ - static void setPosition(VertexT & v, const LorentzPoint & p, Length unit) { - LorentzVector p_scaled = p/unit; + static void setPosition(VertexT& v, const LorentzPoint& p, Length unit) { + LorentzVector p_scaled = p / unit; v.set_position(p_scaled); } /** Set the beam particles for the event.*/ - static void setBeamParticles(EventT & e, ParticlePtrT p1, ParticlePtrT p2) { - e.set_beam_particles(p1,p2); + static void setBeamParticles(EventT& e, ParticlePtrT p1, ParticlePtrT p2) { + e.set_beam_particles(p1, p2); p1->set_status(4); p2->set_status(4); } /** Set the PDF info for the event. */ #ifdef HEPMC_HAS_PDF_INFO - static void setPdfInfo(EventT & e, int id1, int id2, double x1, double x2, double scale, double xf1, double xf2) { + static void setPdfInfo(EventT& e, int id1, int id2, double x1, double x2, double scale, double xf1, double xf2) { HepMC::GenPdfInfoPtr pdfinfo = std::make_shared(); pdfinfo->set(id1, id2, x1, x2, scale, xf1, xf2); e.set_pdf_info(pdfinfo); } #else - static void setPdfInfo(EventT &, int, int, double, double, double, double, double) {} + static void setPdfInfo(EventT&, int, int, double, double, double, double, double) {} #endif - /** Set the cross section info for the event. */ + /** Set the cross section info for the event. */ #ifdef HEPMC_HAS_CROSS_SECTION - static void setCrossSection(EventT & ev, double xs, double xserr) { - std::shared_ptr x =std::make_shared(); - x->set_cross_section(xs,xserr); + static void setCrossSection(EventT& ev, double xs, double xserr) { + std::shared_ptr x = std::make_shared(); + x->set_cross_section(xs, xserr); ev.set_cross_section(x); } #else - static void setCrossSection(EventT &, double, double) {} + static void setCrossSection(EventT&, double, double) {} #endif - }; /** @@ -290,8 +281,9 @@ namespace ThePEG { * HepMC::Polarization,HepMC::PdfInfo> {}; somewhere inside the ThePEG * namespace. */ - template struct HepMCTraits {}; + template + struct HepMCTraits {}; -} +} // namespace ThePEG #endif diff --git a/GeneratorInterface/Herwig7Interface/plugins/Herwig7HepMC3Hadronizer.cc b/GeneratorInterface/Herwig7Interface/plugins/Herwig7HepMC3Hadronizer.cc index 471c2adf62b..3858a175dcb 100644 --- a/GeneratorInterface/Herwig7Interface/plugins/Herwig7HepMC3Hadronizer.cc +++ b/GeneratorInterface/Herwig7Interface/plugins/Herwig7HepMC3Hadronizer.cc @@ -35,7 +35,6 @@ namespace CLHEP { class HepRandomEngine; } - class Herwig7HepMC3Hadronizer : public Herwig7HepMC3Interface, public gen::BaseHadronizer { public: Herwig7HepMC3Hadronizer(const edm::ParameterSet& params); @@ -189,12 +188,12 @@ bool Herwig7HepMC3Hadronizer::hadronize() { } return true; } - edm::LogWarning("Generator|Herwig7HepMC3Hadronizer") << "Event " << evtnum << " not generated (likely skipped in merging)"; + edm::LogWarning("Generator|Herwig7HepMC3Hadronizer") + << "Event " << evtnum << " not generated (likely skipped in merging)"; return false; } void Herwig7HepMC3Hadronizer::finalizeEvent() { - eventInfo3() = std::make_unique(event3().get()); eventInfo3()->setBinningValues(std::vector(1, pthat(thepegEvent))); @@ -204,8 +203,8 @@ void Herwig7HepMC3Hadronizer::finalizeEvent() { HepMC3::Print::listing(*(event3().get())); } -// if (iobc_.get()) -// iobc_->write_event(event().get()); + // if (iobc_.get()) + // iobc_->write_event(event().get()); edm::LogInfo("Generator|Herwig7HepMC3Hadronizer") << "Event produced"; } diff --git a/GeneratorInterface/Herwig7Interface/src/Herwig7HepMC3Interface.cc b/GeneratorInterface/Herwig7Interface/src/Herwig7HepMC3Interface.cc index 5456dba7116..6e8d0fcefa6 100644 --- a/GeneratorInterface/Herwig7Interface/src/Herwig7HepMC3Interface.cc +++ b/GeneratorInterface/Herwig7Interface/src/Herwig7HepMC3Interface.cc @@ -45,7 +45,6 @@ using namespace std; using namespace gen; - Herwig7HepMC3Interface::Herwig7HepMC3Interface(const edm::ParameterSet &pset) : randomEngineGlueProxy_(ThePEG::RandomEngineGlue::Proxy::create()), dataLocation_(ParameterCollector::resolve(pset.getParameter("dataLocation"))), @@ -102,36 +101,38 @@ void Herwig7HepMC3Interface::initRepository(const edm::ParameterSet &pset) { runModeTemp.erase(0, pos + 1); HwUI_ = std::make_shared(pset, dumpConfig_, Herwig::RunMode::READ); - edm::LogInfo("Herwig7HepMC3Interface") << "HerwigUIProvider object with run mode " << HwUI_->runMode() << " created.\n"; + edm::LogInfo("Herwig7HepMC3Interface") + << "HerwigUIProvider object with run mode " << HwUI_->runMode() << " created.\n"; // Chose run mode if (choice == "read") { createInputFile(pset); HwUI_->setRunMode(Herwig::RunMode::READ, pset, dumpConfig_); - edm::LogInfo("Herwig7HepMC3Interface") << "Input file " << dumpConfig_ - << " will be passed to Herwig for the read step.\n"; + edm::LogInfo("Herwig7HepMC3Interface") + << "Input file " << dumpConfig_ << " will be passed to Herwig for the read step.\n"; callHerwigGenerator(); } else if (choice == "build") { createInputFile(pset); HwUI_->setRunMode(Herwig::RunMode::BUILD, pset, dumpConfig_); - edm::LogInfo("Herwig7HepMC3Interface") << "Input file " << dumpConfig_ - << " will be passed to Herwig for the build step.\n"; + edm::LogInfo("Herwig7HepMC3Interface") + << "Input file " << dumpConfig_ << " will be passed to Herwig for the build step.\n"; callHerwigGenerator(); } else if (choice == "integrate") { std::string runFileName = run_ + ".run"; - edm::LogInfo("Herwig7HepMC3Interface") << "Run file " << runFileName - << " will be passed to Herwig for the integrate step.\n"; + edm::LogInfo("Herwig7HepMC3Interface") + << "Run file " << runFileName << " will be passed to Herwig for the integrate step.\n"; HwUI_->setRunMode(Herwig::RunMode::INTEGRATE, pset, runFileName); callHerwigGenerator(); } else if (choice == "run") { std::string runFileName = run_ + ".run"; - edm::LogInfo("Herwig7HepMC3Interface") << "Run file " << runFileName << " will be passed to Herwig for the run step.\n"; + edm::LogInfo("Herwig7HepMC3Interface") + << "Run file " << runFileName << " will be passed to Herwig for the run step.\n"; HwUI_->setRunMode(Herwig::RunMode::RUN, pset, runFileName); } else { edm::LogInfo("Herwig7HepMC3Interface") << "Cannot recognize \"" << choice << "\".\n" - << "Trying to skip step.\n"; + << "Trying to skip step.\n"; continue; } } @@ -139,8 +140,8 @@ void Herwig7HepMC3Interface::initRepository(const edm::ParameterSet &pset) { void Herwig7HepMC3Interface::callHerwigGenerator() { try { - edm::LogInfo("Herwig7HepMC3Interface") << "callHerwigGenerator function invoked with run mode " << HwUI_->runMode() - << ".\n"; + edm::LogInfo("Herwig7HepMC3Interface") + << "callHerwigGenerator function invoked with run mode " << HwUI_->runMode() << ".\n"; // Call program switches according to runMode switch (HwUI_->runMode()) { @@ -276,8 +277,8 @@ void Herwig7HepMC3Interface::createInputFile(const edm::ParameterSet &pset) { // Comment out occurence of saverun in config file since it is set later considering run and generator option string searchKeyword("saverun"); if (configFileContent.find(searchKeyword) != std::string::npos) { - edm::LogInfo("Herwig7HepMC3Interface") << "Commented out saverun command in external input config file(" << iter - << ")" << endl; + edm::LogInfo("Herwig7HepMC3Interface") + << "Commented out saverun command in external input config file(" << iter << ")" << endl; configFileContent.insert(configFileContent.find(searchKeyword), "#"); } herwiginputconfig << "# Begin Config file input" << endl