/usr/include/ThePEG/Vectors/HepMCTraits.h is in libthepeg-dev 1.8.0-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | // -*- C++ -*-
//
// HepMCTraits.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef ThePEG_HepMCTraits_H
#define ThePEG_HepMCTraits_H
#include "HepMC/GenEvent.h"
namespace HepMC {
class GenEvent;
class GenParticle;
class GenVertex;
class Polarization;
class PdfInfo;
}
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
* implementation of HepMC. To use the HepMCConverter class for any
* flavour of HepMC you have to specialize the HepMCTraits class
* accordingly, possibly inheriting the functionality from the
* HepMCTraitsBase class and only overriding the functions and
* typedefs which are different. For the CLHEP flavour of HepMC you
* only need to do <code>template<> struct
* HepMCTraits<HepMC::GenEvent>: public
* HepMCTraitsBase<HepMC::GenEvent,HepMC::GenParticle,HepMC::GenVertex,
* HepMC::Polarization> {};</code> somewhere inside the ThePEG
* namespace. The boolean template argument determines whether the
* HepMC implementation is specifying units or not.
*/
template <typename HepMCEventT, typename HepMCParticleT,
typename HepMCVertexT, typename HepMCPolarizationT,
typename HepMCPdfInfoT>
struct HepMCTraitsBase {
/** Typedef of the particle class. */
typedef HepMCParticleT ParticleT;
/** Typedef of the event class. */
typedef HepMCEventT EventT;
/** Typedef of the vertex class. */
typedef HepMCVertexT VertexT;
/** Typedef of the polarization class. */
typedef HepMCPolarizationT PolarizationT;
/** Typedef of the PdfInfo class. */
typedef HepMCPdfInfoT PdfInfoT;
/** Create an event object with number \a evno and \a weight. */
static EventT * newEvent(long evno, double weight,
const map<string,double>& optionalWeights) {
EventT * e = new EventT();
e->set_event_number(evno);
e->weights().push_back(weight);
for ( map<string,double>::const_iterator w = optionalWeights.begin();
w != optionalWeights.end(); ++w ) {
#ifdef HEPMC_HAS_NAMED_WEIGHTS
e->weights()[w->first] = w->second;
#else
e->weights().push_back(w->second);
#endif
}
return e;
}
/** Reset event weight and number of a re-used GenEvent. */
static void resetEvent(EventT * e, long evno, double weight,
const map<string,double>& optionalWeights) {
e->set_event_number(evno);
e->weights().clear();
e->weights().push_back(weight);
for ( map<string,double>::const_iterator w = optionalWeights.begin();
w != optionalWeights.end(); ++w ) {
#ifdef HEPMC_HAS_NAMED_WEIGHTS
e->weights()[w->first] = w->second;
#else
e->weights().push_back(w->second);
#endif
}
}
/**
* Return true if this version of HepMC accept user-defined units.
*/
static bool hasUnits() {
#ifdef HEPMC_HAS_UNITS
return true;
#else
return false;
#endif
}
/**
* Return the energy unit used in the installed version of HepMC.
*/
static Energy defaultEnergyUnit() {
#ifndef HEPMC_HAS_UNITS
return GeV;
#else
return HepMC::Units::default_momentum_unit() == HepMC::Units::GEV? GeV: MeV;
#endif
}
/**
* Return the length unit used in the installed version of HepMC.
*/
static Length defaultLengthUnit() {
#ifndef HEPMC_HAS_UNITS
return millimeter;
#else
return HepMC::Units::default_length_unit() == HepMC::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) {
#ifdef HEPMC_HAS_UNITS
return e.momentum_unit() == HepMC::Units::MEV? MeV: GeV;
#else
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) {
#ifdef HEPMC_HAS_UNITS
return e.length_unit() == HepMC::Units::CM? centimeter: millimeter;
#else
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? HepMC::Units::MEV: HepMC::Units::GEV,
lenu == centimeter? HepMC::Units::CM: HepMC::Units::MM);
}
#else
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);
e.set_alphaQCD(aS);
e.set_alphaQED(aEM);
}
/** Set the primary vertex, \a v, for the event \a e. */
static void setSignalProcessVertex(EventT & e, VertexT * v) {
e.set_signal_process_vertex(v);
}
/** Set a vertex, \a v, for the event \a e. */
static void addVertex(EventT & e, VertexT * 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 ParticleT * 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<double> p_scalar = p/unit;
ParticleT * 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));
}
/** 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 VertexT * newVertex() {
return new VertexT();
}
/** Add an incoming particle, \a p, to the vertex, \a v. */
static void addIncoming(VertexT & v, ParticleT * p) {
v.add_particle_in(p);
}
/** Add an outgoing particle, \a p, to the vertex, \a v. */
static void addOutgoing(VertexT & v, ParticleT * 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<double> p_scaled = p/unit;
v.set_position(p_scaled);
}
/** Set the beam particles for the event.*/
static void setBeamParticles(EventT & e, ParticleT * p1, ParticleT * 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) {
e.set_pdf_info(PdfInfoT(id1, id2, x1, x2, scale, xf1, xf2));
}
#else
static void setPdfInfo(EventT &, int, int, double, double,
double, double, double) {}
#endif
/** Set the cross section info for the event. */
#ifdef HEPMC_HAS_CROSS_SECTION
static void setCrossSection(EventT & ev, double xs, double xserr) {
HepMC::GenCrossSection x;
x.set_cross_section(xs, xserr);
ev.set_cross_section(x);
}
#else
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
* HepMCTraits class accordingly, possibly inheriting the
* functionality from the HepMCTraitsBase class and only overriding
* the functions and typedefs which are different. For the CLHEP
* flavour of HepMC you only need to do <code>template<> struct
* HepMCTraits<HepMC::GenEvent>: public
* HepMCTraitsBase<HepMC::GenEvent,HepMC::GenParticle,HepMC::GenVertex,
* HepMC::Polarization,HepMC::PdfInfo> {};</code> somewhere inside the ThePEG
* namespace.
*/
template <typename HepMCEventT>
struct HepMCTraits {};
}
#endif
|