00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ThePEG_HepMCTraits_H
00010 #define ThePEG_HepMCTraits_H
00011
00012 #include "HepMC/GenEvent.h"
00013
00014 namespace HepMC {
00015
00016 class GenEvent;
00017 class GenParticle;
00018 class GenVertex;
00019 class Polarization;
00020 class PdfInfo;
00021
00022 }
00023
00024 namespace ThePEG {
00025
00042 template <typename HepMCEventT, typename HepMCParticleT,
00043 typename HepMCVertexT, typename HepMCPolarizationT,
00044 typename HepMCPdfInfoT>
00045
00046 struct HepMCTraitsBase {
00047
00049 typedef HepMCParticleT ParticleT;
00050
00052 typedef HepMCEventT EventT;
00053
00055 typedef HepMCVertexT VertexT;
00056
00058 typedef HepMCPolarizationT PolarizationT;
00059
00061 typedef HepMCPdfInfoT PdfInfoT;
00062
00064 static EventT * newEvent(long evno, double weight) {
00065 EventT * e = new EventT();
00066 e->set_event_number(evno);
00067 e->weights().push_back(weight);
00068 return e;
00069 }
00070
00074 static bool hasUnits() {
00075 #ifdef HEPMC_HAS_UNITS
00076 return true;
00077 #else
00078 return false;
00079 #endif
00080 }
00081
00085 static Energy defaultEnergyUnit() {
00086 #ifndef HEPMC_HAS_UNITS
00087 return GeV;
00088 #else
00089 return HepMC::Units::default_momentum_unit() == HepMC::Units::GEV? GeV: MeV;
00090 #endif
00091 }
00092
00096 static Length defaultLengthUnit() {
00097 #ifndef HEPMC_HAS_UNITS
00098 return millimeter;
00099 #else
00100 return HepMC::Units::default_length_unit() == HepMC::Units::MM?
00101 millimeter: 10.0*millimeter;
00102 #endif
00103 }
00104
00109 static Energy momentumUnit(const EventT & e) {
00110 #ifdef HEPMC_HAS_UNITS
00111 return e.momentum_unit() == HepMC::Units::MEV? MeV: GeV;
00112 #else
00113 return GeV;
00114 #endif
00115 }
00116
00121 static Length lengthUnit(const EventT & e) {
00122 #ifdef HEPMC_HAS_UNITS
00123 return e.length_unit() == HepMC::Units::CM? centimeter: millimeter;
00124 #else
00125 return millimeter;
00126 #endif
00127 }
00128
00133 #ifdef HEPMC_HAS_UNITS
00134 static void setUnits(EventT & e, Energy momu, Length lenu) {
00135 e.use_units(momu == MeV? HepMC::Units::MEV: HepMC::Units::GEV,
00136 lenu == centimeter? HepMC::Units::CM: HepMC::Units::MM);
00137 }
00138 #else
00139 static void setUnits(EventT &, Energy, Length) {}
00140 #endif
00141
00142
00146 static void setScaleAndAlphas(EventT & e, Energy2 scale,
00147 double aS, double aEM, Energy unit) {
00148 e.set_event_scale(sqrt(scale)/unit);
00149 e.set_alphaQCD(aS);
00150 e.set_alphaQED(aEM);
00151 }
00152
00154 static void setSignalProcessVertex(EventT & e, VertexT * v) {
00155 e.set_signal_process_vertex(v);
00156 }
00157
00159 static void addVertex(EventT & e, VertexT * v) {
00160 e.add_vertex(v);
00161 }
00162
00167 static ParticleT * newParticle(const Lorentz5Momentum & p,
00168 long id, int status, Energy unit) {
00169
00170
00171 LorentzVector<double> p_scalar = p/unit;
00172 ParticleT * genp = new ParticleT(p_scalar, id, status);
00173 genp->setGeneratedMass(p.mass()/unit);
00174 return genp;
00175 }
00176
00179 static void setPolarization(ParticleT & genp, double the, double phi) {
00180 genp.set_polarization(PolarizationT(the, phi));
00181 }
00182
00185 static void setColourLine(ParticleT & p, int indx, int coline) {
00186 p.set_flow(indx, coline);
00187 }
00188
00190 static VertexT * newVertex() {
00191 return new VertexT();
00192 }
00193
00195 static void addIncoming(VertexT & v, ParticleT * p) {
00196 v.add_particle_in(p);
00197 }
00198
00200 static void addOutgoing(VertexT & v, ParticleT * p) {
00201 v.add_particle_out(p);
00202 }
00203
00206 static void setPosition(VertexT & v, const LorentzPoint & p, Length unit) {
00207 LorentzVector<double> p_scaled = p/unit;
00208 v.set_position(p_scaled);
00209 }
00210
00212 static void setBeamParticles(EventT & e, ParticleT * p1, ParticleT * p2) {
00213 e.set_beam_particles(p1,p2);
00214 p1->set_status(4);
00215 p2->set_status(4);
00216 }
00217
00219 #ifdef HEPMC_HAS_PDF_INFO
00220 static void setPdfInfo(EventT & e, int id1, int id2, double x1, double x2,
00221 double scale, double xf1, double xf2) {
00222 e.set_pdf_info(PdfInfoT(id1, id2, x1, x2, scale, xf1, xf2));
00223 }
00224 #else
00225 static void setPdfInfo(EventT &, int, int, double, double,
00226 double, double, double) {}
00227 #endif
00228
00230 #ifdef HEPMC_HAS_CROSS_SECTION
00231 static void setCrossSection(EventT & ev, double xs, double xserr) {
00232 HepMC::GenCrossSection x;
00233 x.set_cross_section(xs, xserr);
00234 ev.set_cross_section(x);
00235 }
00236 #else
00237 static void setCrossSection(EventT &, double, double) {}
00238 #endif
00239
00240 };
00241
00255 template <typename HepMCEventT>
00256 struct HepMCTraits {};
00257 }
00258
00259 #endif
00260