ATLAS Offline Software
Herwig7HepMC.cxx
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*
3  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 
13 #include "ThePEG/EventRecord/Event.h"
14 #include "ThePEG/EventRecord/SubProcess.h"
15 #include "ThePEG/Handlers/XComb.h"
16 #include "ThePEG/Handlers/EventHandler.h"
17 #include "ThePEG/PDF/PDF.h"
18 
19 #include "Herwig/API/HerwigAPI.h"
20 
24 #define HEPMC_HAS_CROSS_SECTION
25 #define HEPMC_HAS_PDF_INFO
26 
27 #include "ThePEG/Vectors/HepMCConverter.h"
28 #ifdef HWVER_IS_72
29 #ifdef HEPMC3
30 #include "HepMC3/GenEvent.h"
31 #include "HepMC3/GenParticle.h"
32 #include "HepMC3/GenVertex.h"
33 namespace ThePEG {
34  template<>
35  struct HepMCTraits<HepMC3::GenEvent>
36  : public HepMCTraitsBase<HepMC3::GenEvent,
37  HepMC3::GenParticle,
38  HepMC3::GenParticlePtr,
39  HepMC3::GenVertex,
40  HepMC3::GenVertexPtr,
41  std::pair<double,double>,
42  HepMC3::GenPdfInfo>
43  {
44  static bool hasUnits() {
45  return true;
46  }
47 
48 
52  static void setScaleAndAlphas(HepMC3::GenEvent & e, Energy2 scale,
53  double aS, double aEM, Energy unit) {
54  e.add_attribute("event_scale",std::make_shared<HepMC3::DoubleAttribute>(sqrt(scale)/unit));
55  e.add_attribute("alphaQCD",std::make_shared<HepMC3::DoubleAttribute>(aS));
56  e.add_attribute("alphaQED",std::make_shared<HepMC3::DoubleAttribute>(aEM));
57  }
58 
60  static void setSignalProcessVertex(HepMC3::GenEvent & e, HepMC3::GenVertexPtr v) {
61  e.add_attribute("signal_process_vertex",std::make_shared<HepMC3::IntAttribute>(v->id()));
62  }
63 
66  static void setPolarization(HepMC3::GenParticle & genp, double the, double phi) {
67  genp.add_attribute("theta",std::make_shared<HepMC3::DoubleAttribute>(the));
68  genp.add_attribute("phi",std::make_shared<HepMC3::DoubleAttribute>(phi));
69  }
70 
73  static void setColourLine(HepMC3::GenParticle & p, int indx, int coline) {
74  p.add_attribute("flow"+std::to_string(indx),std::make_shared<HepMC3::IntAttribute>(coline));
75  }
77  static void setBeamParticles(HepMC3::GenEvent & e, HepMC3::GenParticlePtr p1, HepMC3::GenParticlePtr p2) {
78  p1->set_status(4);
79  p2->set_status(4);
80  e.set_beam_particles(p1,p2);
81  }
82 
83  static HepMC3::GenParticlePtr newParticle(const Lorentz5Momentum & p,
84  long id, int status, Energy unit) {
85  // Note that according to the documentation the momentum is stored in a
86  // HepLorentzVector in GeV (event though the CLHEP standard is MeV).
87  LorentzVector<double> p_scalar = p/unit;
88  HepMC3::GenParticlePtr genp = std::make_shared<HepMC3::GenParticle>(HepMC::FourVector(p_scalar.x(),p_scalar.y(),p_scalar.z(),p_scalar.e()), id, status);
89  genp->set_generated_mass(p.mass()/unit);
90  return genp;
91  }
94  static void setPosition( HepMC3::GenVertex & v, const LorentzPoint & p, Length unit) {
95  LorentzVector<double> p_scaled = p/unit;
96  v.set_position(HepMC::FourVector(p_scaled.x(),p_scaled.y(),p_scaled.z(),p_scaled.t()));
97  }
98 
100  static HepMC3::GenVertexPtr newVertex() {
101  return std::make_shared<HepMC3::GenVertex>();
102  }
103  };
104 }
105 #else
106 namespace ThePEG {
107  template<>
108  struct HepMCTraits<HepMC::GenEvent>
109  : public HepMCTraitsBase<HepMC::GenEvent,
110  HepMC::GenParticle,
111  HepMC::GenParticle *,
112  HepMC::GenVertex,
113  HepMC::GenVertex *,
114  HepMC::Polarization,
115  HepMC::PdfInfo>
116  {
117  static bool hasUnits() {
118  return true;
119  }
120  };
121 }
122 #endif
123 #else
124 namespace ThePEG {
125  template<>
126  struct HepMCTraits<HepMC::GenEvent>
127  : public HepMCTraitsBase<HepMC::GenEvent,
128  HepMC::GenParticle,
129  HepMC::GenVertex,
130  HepMC::Polarization,
131  HepMC::PdfInfo>
132  {
133  static bool hasUnits() {
134  return true;
135  }
136  };
137 }
138 #endif
139 
140 void convert_to_HepMC(const ThePEG::Event & event, HepMC::GenEvent & evt, bool nocopies,ThePEG::Energy eunit, ThePEG::Length lunit){
142 }
HepMC::GenVertexPtr
HepMC::GenVertex * GenVertexPtr
Definition: GenVertex.h:59
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
Energy
std::vector< double > Energy
Definition: CalibHitToCaloCell.h:23
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
JiveXML::Event
struct Event_t Event
Definition: ONCRPCServer.h:65
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
ThePEG::HepMCTraits< HepMC::GenEvent >::hasUnits
static bool hasUnits()
Definition: Herwig7HepMC.cxx:133
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
ThePEG
Definition: PowhegLesHouchesFileReader.h:24
convert_to_HepMC
void convert_to_HepMC(const ThePEG::Event &event, HepMC::GenEvent &evt, bool nocopies, ThePEG::Energy eunit, ThePEG::Length lunit)
Definition: Herwig7HepMC.cxx:140
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TMVAToMVAUtils::convert
std::unique_ptr< MVAUtils::BDT > convert(TMVA::MethodBDT *bdt, bool isRegression=true, bool useYesNoLeaf=false)
Definition: TMVAToMVAUtils.h:114
python.PyAthena.v
v
Definition: PyAthena.py:157
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
HepMC
Definition: Barcode.h:14
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:20
merge.status
status
Definition: merge.py:17
GenParticle
@ GenParticle
Definition: TruthClasses.h:30