diff --git a/GeneratorInterface/Herwig7Interface/interface/HepMC3Converter.h b/GeneratorInterface/Herwig7Interface/interface/HepMC3Converter.h index 6ee53896977a..8664671af860 100644 --- a/GeneratorInterface/Herwig7Interface/interface/HepMC3Converter.h +++ b/GeneratorInterface/Herwig7Interface/interface/HepMC3Converter.h @@ -16,8 +16,7 @@ namespace ThePEG { - -/** + /** * The HepMCConverter defines only one public static function which * converts a ThePEG::Event object to a * HepMC::GenEvent. All mother-daughter relationships and @@ -28,51 +27,48 @@ namespace ThePEG { * * @author Leif Lönnblad */ -template > -class HepMCConverter { - -public: - - /** @cond EXCEPTIONCLASSES */ - /** Exception class for HepMCConverter. */ - struct HepMCConverterException: public Exception {}; - /** @endcond */ - - /** + template > + class HepMCConverter { + public: + /** @cond EXCEPTIONCLASSES */ + /** Exception class for HepMCConverter. */ + struct HepMCConverterException : public Exception {}; + /** @endcond */ + + /** * Help class to represent a temporary vertex which can be * converted to a GenVertex. */ - struct Vertex { - /** Particles going in to the vertex. */ - tcParticleSet in; - /** Particles going out of the vertex. */ - tcParticleSet out; - }; - - /** Forward typedefs from Traits class. */ - typedef typename Traits::ParticleT GenParticle; - /** Forward typedefs from Traits class. */ - typedef typename Traits::ParticlePtrT GenParticlePtrT; - /** Forward typedefs from Traits class. */ - typedef typename Traits::EventT GenEvent; - /** Forward typedefs from Traits class. */ - typedef typename Traits::VertexT GenVertex; - /** Forward typedefs from Traits class. */ - typedef typename Traits::VertexPtrT GenVertexPtrT; - /** Forward typedefs from Traits class. */ - typedef typename Traits::PdfInfoT PdfInfo; - /** Map ThePEG particles to HepMC particles. */ - typedef map ParticleMap; - /** Map ThePEG colour lines to HepMC colour indices. */ - typedef map FlowMap; - /** Map ThePEG particles to vertices. */ - typedef map VertexMap; - /** Map vertices to GenVertex */ - typedef map GenVertexMap; - -public: - - /** + struct Vertex { + /** Particles going in to the vertex. */ + tcParticleSet in; + /** Particles going out of the vertex. */ + tcParticleSet out; + }; + + /** Forward typedefs from Traits class. */ + typedef typename Traits::ParticleT GenParticle; + /** Forward typedefs from Traits class. */ + typedef typename Traits::ParticlePtrT GenParticlePtrT; + /** Forward typedefs from Traits class. */ + typedef typename Traits::EventT GenEvent; + /** Forward typedefs from Traits class. */ + typedef typename Traits::VertexT GenVertex; + /** Forward typedefs from Traits class. */ + typedef typename Traits::VertexPtrT GenVertexPtrT; + /** Forward typedefs from Traits class. */ + typedef typename Traits::PdfInfoT PdfInfo; + /** Map ThePEG particles to HepMC particles. */ + typedef map ParticleMap; + /** Map ThePEG colour lines to HepMC colour indices. */ + typedef map FlowMap; + /** Map ThePEG particles to vertices. */ + typedef map VertexMap; + /** Map vertices to GenVertex */ + typedef map GenVertexMap; + + public: + /** * Convert a ThePEG::Event to a HepMC::GenEvent. The caller is * responsible for deleting the constructed GenEvent object. If \a * nocopies is true, only final copies of particles connected with @@ -81,11 +77,12 @@ public: * variables will be in units of \a eunit and lengths variables in * units of \a lunit. */ - static GenEvent * convert(const Event & ev, bool nocopies = false, - Energy eunit = Traits::defaultEnergyUnit(), - Length lunit = Traits::defaultLengthUnit()); + static GenEvent *convert(const Event &ev, + bool nocopies = false, + Energy eunit = Traits::defaultEnergyUnit(), + Length lunit = Traits::defaultLengthUnit()); - /** + /** * Convert a ThePEG::Event to a HepMC::GenEvent. The caller supplies * a GenEvent object, \a gev, which will be filled. If \a nocopies * is true, only final copies of particles connected with @@ -94,11 +91,9 @@ public: * variables will be in units of \a eunit and lengths variables in * units of \a lunit. */ - static void - convert(const Event & ev, GenEvent & gev, bool nocopies, - Energy eunit, Length lunit); + static void convert(const Event &ev, GenEvent &gev, bool nocopies, Energy eunit, Length lunit); - /** + /** * Convert a ThePEG::Event to a HepMC::GenEvent. The caller supplies * a GenEvent object, \a gev, which will be filled. If \a nocopies * is true, only final copies of particles connected with @@ -107,119 +102,113 @@ public: * variables will be in units of \a eunit and lengths variables in * units of \a lunit. */ - static void - convert(const Event & ev, GenEvent & gev, bool nocopies = false); + static void convert(const Event &ev, GenEvent &gev, bool nocopies = false); -private: - - /** + private: + /** * The proper constructors are private. The class is only * instantiated within the convert method. */ - HepMCConverter(const Event & ev, bool nocopies, Energy eunit, Length lunit); + HepMCConverter(const Event &ev, bool nocopies, Energy eunit, Length lunit); - /** + /** * The proper constructors are private. The class is only * instantiated within the convert method. */ - HepMCConverter(const Event & ev, GenEvent & gev, bool nocopies, - Energy eunit, Length lunit); + HepMCConverter(const Event &ev, GenEvent &gev, bool nocopies, Energy eunit, Length lunit); - /** + /** * Common init function used by the constructors. */ - void init(const Event & ev, bool nocopies); + void init(const Event &ev, bool nocopies); - /** + /** * Default constructor is unimplemented and private and should never be used. */ - HepMCConverter() = delete; + HepMCConverter() = delete; - /** + /** * Copy constructor is unimplemented and private and should never be used. */ - HepMCConverter(const HepMCConverter &) = delete; + HepMCConverter(const HepMCConverter &) = delete; - /** + /** * Assignment is unimplemented and private and should never be used. */ - HepMCConverter & operator=(const HepMCConverter &) = delete; - -private: + HepMCConverter &operator=(const HepMCConverter &) = delete; - /** + private: + /** * Create a GenParticle from a ThePEG Particle. */ - GenParticlePtrT createParticle(tcPPtr p) const; + GenParticlePtrT createParticle(tcPPtr p) const; - /** + /** * Join the decay vertex of the parent with the decay vertex of the * child. */ - void join(tcPPtr parent, tcPPtr child); + void join(tcPPtr parent, tcPPtr child); - /** + /** * Create a GenVertex from a temporary Vertex. */ - GenVertexPtrT createVertex(Vertex * v); + GenVertexPtrT createVertex(Vertex *v); - /** + /** * Create and set a PdfInfo object for the event */ - void setPdfInfo(const Event & e); - -private: + void setPdfInfo(const Event &e); - /** + private: + /** * The constructed GenEvent. */ - GenEvent * geneve; + GenEvent *geneve; - /** + /** * The translation table between the ThePEG particles and the * GenParticles. */ - ParticleMap pmap; + ParticleMap pmap; - /** + /** * The translation table between ThePEG ColourLine objects and HepMC * Flow indices. */ - FlowMap flowmap; + FlowMap flowmap; - /** + /** * All temporary vertices created. */ - vector vertices; + vector vertices; - /** + /** * The mapping of particles to their production vertices. */ - VertexMap prov; + VertexMap prov; - /** + /** * The mapping of particles to their decy vertices. */ - VertexMap decv; + VertexMap decv; - /** + /** * The mapping between temporary vertices and the created GenVertex Objects. */ - GenVertexMap vmap; + GenVertexMap vmap; - /** + /** * The energy unit to be used in the GenEvent. */ - Energy energyUnit; + Energy energyUnit; - /** + /** * The length unit to be used in the GenEvent. */ - Length lengthUnit; - -}; + Length lengthUnit; + }; -} +} // namespace ThePEG #include "ThePEG/Vectors/HepMCConverter.tcc" diff --git a/GeneratorInterface/Herwig7Interface/interface/HepMC3Helper.h b/GeneratorInterface/Herwig7Interface/interface/HepMC3Helper.h index 07952eef17a3..7c0baae3d56b 100644 --- a/GeneratorInterface/Herwig7Interface/interface/HepMC3Helper.h +++ b/GeneratorInterface/Herwig7Interface/interface/HepMC3Helper.h @@ -24,125 +24,110 @@ #include "HepMC3/WriterRootTree.h" #endif namespace HepMC3 { -using Polarization=std::pair; + using Polarization = std::pair; } namespace ThePEG { -/** + /** * Struct for HepMC conversion */ // This is version 3! -template<> -struct HepMCTraits - : public HepMCTraitsBase -{ + template <> + struct HepMCTraits : public HepMCTraitsBase { + /** 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(HepMC3::Units::GEV, HepMC3::Units::MM); + e->set_event_number(evno); + e->set_event_number(evno); + //std::vector wnames; + std::vector wvalues; - /** 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(HepMC3::Units::GEV, HepMC3::Units::MM); - e->set_event_number(evno); - 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 ) { - //wnames.push_back(w->first); - wvalues.push_back(w->second); + //wnames.push_back("Default"); + wvalues.push_back(weight); + 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; + return e; } - //e->run_info()->set_weight_names(wnames); - e->weights()=wvalues; - return e; - } - /** Create a new vertex. */ - static VertexPtrT newVertex() { - return std::make_shared(VertexT()); - } + /** Create a new vertex. */ + static VertexPtrT newVertex() { return std::make_shared(VertexT()); } - /** Set the \a scale, \f$\alpha_S\f$ (\a aS) and \f$\alpha_{EM}\f$ + /** 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.add_attribute("event_scale",std::make_shared(sqrt(scale)/unit)); - e.add_attribute("mpi",std::make_shared(-1));//Please fix it later, once ThePEG authors respond - e.add_attribute("signal_process_id",std::make_shared(0));//Please fix it later, once ThePEG authors respond - e.add_attribute("alphaQCD",std::make_shared(aS)); - e.add_attribute("alphaQED",std::make_shared(aEM)); - } + static void setScaleAndAlphas(EventT& e, Energy2 scale, double aS, double aEM, Energy unit) { + e.add_attribute("event_scale", std::make_shared(sqrt(scale) / unit)); + e.add_attribute("mpi", + std::make_shared(-1)); //Please fix it later, once ThePEG authors respond + e.add_attribute("signal_process_id", + std::make_shared(0)); //Please fix it later, once ThePEG authors respond + e.add_attribute("alphaQCD", std::make_shared(aS)); + e.add_attribute("alphaQED", std::make_shared(aEM)); + } - /** Set the colour line (with index \a indx) to \a coline for + /** 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.add_attribute("flow"+std::to_string(indx),std::make_shared(coline)); - } + static void setColourLine(ParticleT& p, int indx, int coline) { + p.add_attribute("flow" + std::to_string(indx), std::make_shared(coline)); + } - /** Add an incoming particle, \a p, to the vertex, \a v. */ - static void addIncoming(VertexT & v, ParticlePtrT p) { - v.add_particle_in(p); - } + /** Add an incoming particle, \a p, to the vertex, \a v. */ + 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); - } + /** Add an outgoing particle, \a p, to the vertex, \a v. */ + static void addOutgoing(VertexT& v, ParticlePtrT p) { v.add_particle_out(p); } - /** Set the primary vertex, \a v, for the event \a e. */ - static void setSignalProcessVertex(EventT & e, VertexPtrT v) { - e.add_vertex(v); - e.add_attribute("signal_process_vertex", - std::make_shared(v->id())); - } + /** Set the primary vertex, \a v, for the event \a e. */ + static void setSignalProcessVertex(EventT& e, VertexPtrT v) { + e.add_vertex(v); + e.add_attribute("signal_process_vertex", std::make_shared(v->id())); + } - /** Set a vertex, \a v, for the event \a e. */ - static void addVertex(EventT & e, VertexPtrT v) { - e.add_vertex(v); - } + /** Set a vertex, \a v, for the event \a e. */ + static void addVertex(EventT& e, VertexPtrT v) { e.add_vertex(v); } - /** Set the beam particles for the event.*/ - static void setBeamParticles(EventT & e, ParticlePtrT p1, ParticlePtrT p2) { - // e.set_beam_particles(p1,p2); - p1->set_status(4); - p2->set_status(4); - e.set_beam_particles(p1, p2); - } + /** Set the beam particles for the event.*/ + static void setBeamParticles(EventT& e, ParticlePtrT p1, ParticlePtrT p2) { + // e.set_beam_particles(p1,p2); + p1->set_status(4); + p2->set_status(4); + e.set_beam_particles(p1, p2); + } - /** Create a new particle object with momentum \a p, PDG number \a + /** 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) { - // Note that according to the documentation the momentum is stored in a - // HepLorentzVector in GeV (event though the CLHEP standard is MeV). - HepMC3::FourVector p_scalar(p.x()/unit, p.y()/unit, p.z()/unit, p.e()/unit); - ParticlePtrT genp = std::make_shared(ParticleT(p_scalar, id, status)); - genp->set_generated_mass(p.mass()/unit); - return genp; - } + 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). + HepMC3::FourVector p_scalar(p.x() / unit, p.y() / unit, p.z() / unit, p.e() / unit); + ParticlePtrT genp = std::make_shared(ParticleT(p_scalar, id, status)); + genp->set_generated_mass(p.mass() / unit); + return genp; + } - /** Set the polarization directions, \a the and \a phi, for particle + /** Set the polarization directions, \a the and \a phi, for particle \a p. */ - static void setPolarization(ParticleT & genp, double the, double phi) { - genp.add_attribute("theta",std::make_shared(the)); - genp.add_attribute("phi",std::make_shared(phi)); - } + static void setPolarization(ParticleT& genp, double the, double phi) { + genp.add_attribute("theta", std::make_shared(the)); + genp.add_attribute("phi", std::make_shared(phi)); + } - /** Set the position \a p for the vertex, \a v. The length will be + /** 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) { - HepMC3::FourVector v_scaled(p.x()/unit, p.y()/unit, p.z()/unit, p.e()/unit); - v.set_position(v_scaled); - } - -}; -} + static void setPosition(VertexT& v, const LorentzPoint& p, Length unit) { + HepMC3::FourVector v_scaled(p.x() / unit, p.y() / unit, p.z() / unit, p.e() / unit); + v.set_position(v_scaled); + } + }; +} // namespace ThePEG diff --git a/GeneratorInterface/Herwig7Interface/interface/HepMC3Traits.h b/GeneratorInterface/Herwig7Interface/interface/HepMC3Traits.h index 2f76eeeb71d4..e81dcfa5052d 100644 --- a/GeneratorInterface/Herwig7Interface/interface/HepMC3Traits.h +++ b/GeneratorInterface/Herwig7Interface/interface/HepMC3Traits.h @@ -11,20 +11,19 @@ #include "HepMC3/GenEvent.h" namespace HepMC3 { -class GenEvent; -class GenParticle; -class GenVertex; -class GenPdfInfo; -} + class GenEvent; + class GenParticle; + class GenVertex; + class GenPdfInfo; +} // namespace HepMC3 namespace HepMC3 { -using PdfInfo=GenPdfInfo; -using Polarization=std::pair; -} - + using PdfInfo = GenPdfInfo; + using Polarization = std::pair; +} // namespace HepMC3 namespace ThePEG { -/** + /** * HepMCTraitsBase is a convenient base class for specializing the * HepMCTraits class to deal with different flavours of HepMC in the * HepMCConverter class. The default version will work for the CLHEP @@ -40,266 +39,243 @@ namespace ThePEG { * namespace. The boolean template argument determines whether the * HepMC implementation is specifying units or not. */ -template - -struct HepMCTraitsBase { + template - /** Typedef of the particle class. */ - typedef HepMCParticleT ParticleT; + struct HepMCTraitsBase { + /** Typedef of the particle class. */ + typedef HepMCParticleT ParticleT; - /** Typedef of the event class. */ - typedef HepMCEventT EventT; + /** Typedef of the event class. */ + typedef HepMCEventT EventT; - /** Typedef of the vertex class. */ - typedef HepMCVertexT VertexT; + /** Typedef of the vertex class. */ + typedef HepMCVertexT VertexT; - /** Typedef of the polarization class. */ - typedef HepMCPolarizationT PolarizationT; + /** Typedef of the polarization class. */ + typedef HepMCPolarizationT PolarizationT; - /** Typedef of the PdfInfo class. */ - typedef HepMCPdfInfoT PdfInfoT; + /** Typedef of the PdfInfo class. */ + typedef HepMCPdfInfoT PdfInfoT; - /** Typedef of a particle pointer */ - typedef HepMCParticlePtrT ParticlePtrT; + /** Typedef of a particle pointer */ + typedef HepMCParticlePtrT ParticlePtrT; - /** Typedef of a vertex pointer */ - typedef HepMCVertexPtrT VertexPtrT; + /** Typedef of a vertex pointer */ + 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(); - 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 ) { - wnames.push_back(w->first); - wvalues.push_back(w->second); - } + /** 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(); + 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) { + wnames.push_back(w->first); + wvalues.push_back(w->second); + } - e->run_info()->set_weight_names(wnames); - e->weights()=wvalues; + e->run_info()->set_weight_names(wnames); + 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) { - e->set_event_number(evno); - e->weights().clear(); - 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 ) { - wnames.push_back(w->first); - wvalues.push_back(w->second); + return e; } + /** Reset event weight and number of a re-used GenEvent. */ + static void resetEvent(EventT* e, long evno, double weight, const map& optionalWeights) { + e->set_event_number(evno); + e->weights().clear(); + 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) { + wnames.push_back(w->first); + wvalues.push_back(w->second); + } - e->run_info()->set_weight_names(wnames); - e->weights()=wvalues; + e->run_info()->set_weight_names(wnames); + 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 true if this version of HepMC accept user-defined units. */ - static bool hasUnits() { + static bool hasUnits() { #ifdef HEPMC_HAS_UNITS - return true; + return true; #else - return false; + return false; #endif - } + } - /** + /** * Return the energy unit used in the installed version of HepMC. */ - static Energy defaultEnergyUnit() { + static Energy defaultEnergyUnit() { #ifndef HEPMC_HAS_UNITS - return GeV; + 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 - } + } - /** + /** * Return the length unit used in the installed version of HepMC. */ - static Length defaultLengthUnit() { + static Length defaultLengthUnit() { #ifndef HEPMC_HAS_UNITS - return millimeter; + 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 - } + } - /** + /** * 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; + return GeV; #endif - } + } - /** + /** * 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; + return millimeter; #endif - } + } - /** + /** * Set the units to be used by the given GenEvent object. If * 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$ + /** 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); - 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); - } - - /** Set a vertex, \a v, for the event \a e. */ - static void addVertex(EventT & e, VertexPtrT v) { - e.add_vertex(v); - } - - /** Create a new particle object with momentum \a p, PDG number \a + 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); } + + /** Set a vertex, \a v, for the event \a e. */ + 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) { - // 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; - ParticlePtrT genp = - new ParticleT(p_scalar, id, status); - genp->setGeneratedMass(p.mass()/unit); - return genp; - } - - /** Set the polarization directions, \a the and \a phi, for particle + 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; + ParticlePtrT genp = new ParticleT(p_scalar, id, status); + 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) { - genp.set_polarization(PolarizationT(the, 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 + /** 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); - } - - /** Create a new vertex. */ - 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); - } - - /** Add an outgoing particle, \a p, to the vertex, \a v. */ - 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 + static void setColourLine(ParticleT& p, int indx, int coline) { p.set_flow(indx, coline); } + + /** Create a new vertex. */ + 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); } + + /** Add an outgoing particle, \a p, to the vertex, \a v. */ + 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; - 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); - 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 setPosition(VertexT& v, const LorentzPoint& p, Length unit) { + LorentzVector p_scaled = p / unit; + v.set_position(p_scaled); + } - HepMC::GenPdfInfoPtr pdfinfo = std::make_shared(); - pdfinfo->set(id1, id2, x1, x2, scale, xf1, xf2); - e.set_pdf_info(pdfinfo); - } + /** Set the beam particles for the event.*/ + 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) { + 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); - ev.set_cross_section(x); - } + 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 + }; -}; - -/** + /** * The HepMCTraits class is used to deal with different flavours of * HepMC in the HepMCConverter class. To use the HepMCConverter class * for any flavour of HepMC you have to specialize the @@ -312,9 +288,8 @@ struct HepMCTraitsBase { * 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 471c2adf62b1..3858a175dcbd 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 5456dba71162..6e8d0fcefa6f 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