HepMC::GenEvent
.
More...
#include <GeneratorInterface/ThePEGInterface/interface/HepMCConverter.h>
Public Types | |
typedef map< tcColinePtr, long > | FlowMap |
Map ThePEG colour lines to HepMC colour indices. | |
typedef Traits::EventT | GenEvent |
Forward typedefs from Traits class. | |
typedef Traits::ParticleT | GenParticle |
Forward typedefs from Traits class. | |
typedef Traits::VertexT | GenVertex |
Forward typedefs from Traits class. | |
typedef map< const Vertex *, GenVertex * > | GenVertexMap |
Map vertices to GenVertex. | |
typedef map< tcPPtr, GenParticle * > | ParticleMap |
Map ThePEG particles to HepMC particles. | |
typedef map< tcPPtr, Vertex * > | VertexMap |
Map ThePEG particles to vertices. | |
Static Public Member Functions | |
static void | convert (const Event &ev, GenEvent &gev, bool nocopies=false, Energy eunit=GeV, Length lunit=millimeter) |
Convert a ThePEG::Event to a HepMC::GenEvent. | |
static GenEvent * | convert (const Event &ev, bool nocopies=false, Energy eunit=GeV, Length lunit=millimeter) |
Convert a ThePEG::Event to a HepMC::GenEvent. | |
Private Member Functions | |
GenParticle * | createParticle (tcPPtr p) const |
Create a GenParticle from a ThePEG Particle. | |
GenVertex * | createVertex (Vertex *v) |
Create a GenVertex from a temporary Vertex. | |
HepMCConverter (const HepMCConverter &) | |
Copy constructor is unimplemented and private and should never be used. | |
HepMCConverter () | |
Default constructor is unimplemented and private and should never be used. | |
HepMCConverter (const Event &ev, GenEvent &gev, bool nocopies, Energy eunit, Length lunit) | |
The proper constructors are private. | |
HepMCConverter (const Event &ev, bool nocopies, Energy eunit, Length lunit) | |
The proper constructors are private. | |
void | init (const Event &ev, bool nocopies) |
Common init function used by the constructors. | |
void | join (tcPPtr parent, tcPPtr child) |
Join the decay vertex of the parent with the decay vertex of the child. | |
HepMCConverter & | operator= (const HepMCConverter &) |
Assignment is unimplemented and private and should never be used. | |
Private Attributes | |
VertexMap | decv |
The mapping of particles to their decy vertices. | |
tcEHPtr | eh |
The primary event handler. | |
Energy | energyUnit |
The energy unit to be used in the GenEvent. | |
FlowMap | flowmap |
The translation table between ThePEG ColourLine objects and HepMC Flow indices. | |
GenEvent * | geneve |
The constructed GenEvent. | |
Length | lengthUnit |
The length unit to be used in the GenEvent. | |
ParticleMap | pmap |
The translation table between the ThePEG particles and the GenParticles. | |
VertexMap | prov |
The mapping of particles to their production vertices. | |
vector< Vertex > | vertices |
All temporary vertices created. | |
GenVertexMap | vmap |
The mapping between temporary vertices and the created GenVertex Objects. | |
Classes | |
struct | Vertex |
Help class to represent a temporary vertex which can be converted to a GenVertex. More... |
HepMC::GenEvent
.
All mother-daughter relationships and colour information is preserved.
Particle
Definition at line 31 of file HepMCConverter.h.
typedef map<tcColinePtr,long> ThePEG::HepMCConverter< HepMCEventT, Traits >::FlowMap |
typedef Traits::EventT ThePEG::HepMCConverter< HepMCEventT, Traits >::GenEvent |
typedef Traits::ParticleT ThePEG::HepMCConverter< HepMCEventT, Traits >::GenParticle |
typedef Traits::VertexT ThePEG::HepMCConverter< HepMCEventT, Traits >::GenVertex |
typedef map<const Vertex *, GenVertex*> ThePEG::HepMCConverter< HepMCEventT, Traits >::GenVertexMap |
typedef map<tcPPtr,GenParticle*> ThePEG::HepMCConverter< HepMCEventT, Traits >::ParticleMap |
typedef map<tcPPtr,Vertex*> ThePEG::HepMCConverter< HepMCEventT, Traits >::VertexMap |
ThePEG::HepMCConverter< HepMCEventT, Traits >::HepMCConverter | ( | const Event & | ev, | |
bool | nocopies, | |||
Energy | eunit, | |||
Length | lunit | |||
) | [inline, private] |
The proper constructors are private.
The class is only instantiated within the convert method.
Definition at line 56 of file HepMCConverter.cc.
References ThePEG::HepMCConverter< HepMCEventT, Traits >::geneve, and ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
00057 : energyUnit(eunit), lengthUnit(lunit) 00058 { 00059 geneve = Traits::newEvent(ev.number(), ev.weight()); 00060 00061 init(ev, nocopies); 00062 }
ThePEG::HepMCConverter< HepMCEventT, Traits >::HepMCConverter | ( | const Event & | ev, | |
GenEvent & | gev, | |||
bool | nocopies, | |||
Energy | eunit, | |||
Length | lunit | |||
) | [inline, private] |
The proper constructors are private.
The class is only instantiated within the convert method.
Definition at line 66 of file HepMCConverter.cc.
References ThePEG::HepMCConverter< HepMCEventT, Traits >::geneve, and ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
00067 : 00068 energyUnit(eunit), lengthUnit(lunit) 00069 { 00070 geneve = &gev; 00071 00072 init(ev, nocopies); 00073 }
ThePEG::HepMCConverter< HepMCEventT, Traits >::HepMCConverter | ( | ) | [private] |
Default constructor is unimplemented and private and should never be used.
ThePEG::HepMCConverter< HepMCEventT, Traits >::HepMCConverter | ( | const HepMCConverter< HepMCEventT, Traits > & | ) | [private] |
Copy constructor is unimplemented and private and should never be used.
void ThePEG::HepMCConverter< HepMCEventT, Traits >::convert | ( | const Event & | ev, | |
GenEvent & | gev, | |||
bool | nocopies = false , |
|||
Energy | eunit = GeV , |
|||
Length | lunit = millimeter | |||
) | [inline, static] |
Convert a ThePEG::Event to a HepMC::GenEvent.
The caller supplies a GenEvent object, gev, which will be filled. If nocopies is true, only final copies of particles connected with Particle::previous() and Particle::next() will be entered in the HepMC::GenEvent. In the GenEvent object, the energy/momentum variables will be in units of eunit and lengths variables in units of lunit.
Definition at line 48 of file HepMCConverter.cc.
00050 { 00051 HepMCConverter<HepMCEventT,Traits> converter(ev, gev, nocopies, eunit, lunit); 00052 }
HepMCConverter< HepMCEventT, Traits >::GenEvent * ThePEG::HepMCConverter< HepMCEventT, Traits >::convert | ( | const Event & | ev, | |
bool | nocopies = false , |
|||
Energy | eunit = GeV , |
|||
Length | lunit = millimeter | |||
) | [inline, static] |
Convert a ThePEG::Event to a HepMC::GenEvent.
The caller is responsible for deleting the constructed GenEvent object. If nocopies is true, only final copies of particles connected with Particle::previous() and Particle::next() will be entered in the HepMC::GenEvent. In the GenEvent object, the energy/momentum variables will be in units of eunit and lengths variables in units of lunit.
Definition at line 40 of file HepMCConverter.cc.
References ThePEG::HepMCConverter< HepMCEventT, Traits >::geneve.
Referenced by ThePEGInterface::convert().
00041 { 00042 HepMCConverter<HepMCEventT,Traits> converter(ev, nocopies, eunit, lunit); 00043 return converter.geneve; 00044 }
HepMCConverter< HepMCEventT, Traits >::GenParticle * ThePEG::HepMCConverter< HepMCEventT, Traits >::createParticle | ( | tcPPtr | p | ) | const [inline, private] |
Create a GenParticle from a ThePEG Particle.
Definition at line 207 of file HepMCConverter.cc.
References ThePEG::HepMCConverter< HepMCEventT, Traits >::eh, ThePEG::HepMCConverter< HepMCEventT, Traits >::energyUnit, StDecayID::status, and cmsRelvalreportInput::step.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
00208 { 00209 int status = 1; 00210 if ( !p->children().empty() || p->next() ) { 00211 tStepPtr step = p->birthStep(); 00212 if ((!step || step && 00213 (!step->handler() || step->handler() == eh)) && 00214 p->id() != 82) 00215 status = 3; 00216 else 00217 status = 2; 00218 } 00219 GenParticle *gp = 00220 Traits::newParticle(p->momentum(), p->id(), status, energyUnit); 00221 00222 if ( p->spinInfo() && p->spinInfo()->hasPolarization() ) { 00223 DPair pol = p->spinInfo()->polarization(); 00224 Traits::setPolarization(*gp, pol.first, pol.second); 00225 } 00226 00227 return gp; 00228 }
HepMCConverter< HepMCEventT, Traits >::GenVertex * ThePEG::HepMCConverter< HepMCEventT, Traits >::createVertex | ( | Vertex * | v | ) | [inline, private] |
Create a GenVertex from a temporary Vertex.
Definition at line 253 of file HepMCConverter.cc.
References ThePEG::HepMCConverter< HepMCEventT, Traits >::Vertex::in, it, ThePEG::HepMCConverter< HepMCEventT, Traits >::lengthUnit, ThePEG::HepMCConverter< HepMCEventT, Traits >::Vertex::out, p, and ThePEG::HepMCConverter< HepMCEventT, Traits >::pmap.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
00254 { 00255 if ( !v ) throw HepMCConverterException() 00256 << "Found internal null Vertex." << Exception::abortnow; 00257 00258 GenVertex *gv = new GenVertex(); 00259 00260 // We assume that the vertex position is the average of the decay 00261 // vertices of all incoming and the creation vertices of all 00262 // outgoing particles in the lab. Note that this will probably not 00263 // be useful information for very small distances. 00264 LorentzPoint p; 00265 for ( tcParticleSet::iterator it = v->in.begin(); 00266 it != v->in.end(); ++it ) { 00267 p += (**it).labDecayVertex(); 00268 Traits::addIncoming(*gv, pmap[*it]); 00269 } 00270 for (tcParticleSet::iterator it = v->out.begin(); 00271 it != v->out.end(); ++it ) { 00272 p += (**it).labVertex(); 00273 Traits::addOutgoing(*gv, pmap[*it]); 00274 } 00275 00276 p /= double(v->in.size() + v->out.size()); 00277 Traits::setPosition(*gv, p, lengthUnit); 00278 00279 return gv; 00280 }
void ThePEG::HepMCConverter< HepMCEventT, Traits >::init | ( | const Event & | ev, | |
bool | nocopies | |||
) | [inline, private] |
Common init function used by the constructors.
Definition at line 76 of file HepMCConverter.cc.
References python::cmstools::all(), ThePEG::HepMCConverter< HepMCEventT, Traits >::createParticle(), ThePEG::HepMCConverter< HepMCEventT, Traits >::createVertex(), ThePEG::HepMCConverter< HepMCEventT, Traits >::decv, ThePEG::HepMCConverter< HepMCEventT, Traits >::eh, ThePEG::HepMCConverter< HepMCEventT, Traits >::flowmap, ThePEG::HepMCConverter< HepMCEventT, Traits >::geneve, i, it, iter, ThePEG::HepMCConverter< HepMCEventT, Traits >::join(), edm::es::l(), N, p, ThePEG::HepMCConverter< HepMCEventT, Traits >::pmap, ThePEG::HepMCConverter< HepMCEventT, Traits >::prov, std::swap(), ThePEG::HepMCConverter< HepMCEventT, Traits >::vertices, and ThePEG::HepMCConverter< HepMCEventT, Traits >::vmap.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::HepMCConverter().
00077 { 00078 if ( ev.primaryCollision() ) 00079 eh = dynamic_ptr_cast<tcEHPtr>(ev.primaryCollision()->handler()); 00080 00081 // Extract all particles. 00082 tcPVector all; 00083 ev.select(back_inserter(all), SelectAll()); 00084 vertices.reserve(all.size()*2); 00085 00086 // order the particles topologically 00087 std::set<tcPPtr> visited; 00088 for(unsigned int head = 0; head < all.size(); head++) { 00089 bool vetoed = true; 00090 for(unsigned int cur = head; cur < all.size(); cur++) { 00091 vetoed = false; 00092 for(tParticleVector::const_iterator iter = 00093 all[cur]->parents().begin(); 00094 iter != all[cur]->parents().end(); ++iter) { 00095 if (visited.find(*iter) == visited.end()) { 00096 vetoed = true; 00097 break; 00098 } 00099 } 00100 if (!vetoed) { 00101 if (cur != head) 00102 std::swap(all[head], all[cur]); 00103 break; 00104 } 00105 } 00106 00107 visited.insert(all[head]); 00108 } 00109 visited.clear(); 00110 00111 GenParticle *beam1 = 0, *beam2 = 0; 00112 00113 // Create GenParticle's and map them to the ThePEG particles. 00114 for ( int i = 0, N = all.size(); i < N; ++i ) { 00115 tcPPtr p = all[i]; 00116 if ( nocopies && p->next() ) continue; 00117 if ( pmap.find(p) != pmap.end() ) continue; 00118 GenParticle *gp = pmap[p] = createParticle(p); 00119 if ( gp->status() == 3 && !beam1 ) 00120 beam1 = gp; 00121 else if ( gp->status() == 3 && !beam2) 00122 beam2 = gp; 00123 if ( p->hasColourInfo() ) { 00124 // Check if the particle is connected to colour lines, in which 00125 // case the lines are mapped to an integer and set in the 00126 // GenParticle's Flow info. 00127 tcColinePtr l; 00128 if ( l = p->colourLine() ) { 00129 if ( !member(flowmap, l) ) 00130 flowmap[l] = flowmap.size() + 500; 00131 Traits::setColourLine(*gp, 1, flowmap[l]); 00132 } 00133 if ( l = p->antiColourLine() ) { 00134 if ( !member(flowmap, l) ) 00135 flowmap[l] = flowmap.size() + 500; 00136 Traits::setColourLine(*gp, 2, flowmap[l]); 00137 } 00138 } 00139 00140 if ( !p->children().empty() || p->next() ) { 00141 // If the particle has children it should have a decay vertex: 00142 vertices.push_back(Vertex()); 00143 decv[p] = &vertices.back(); 00144 vertices.back().in.insert(p); 00145 } 00146 00147 if ( !p->parents().empty() || p->previous() || 00148 (p->children().empty() && !p->next()) ) { 00149 // If the particle has parents it should have a production 00150 // vertex. If neither parents or children it should still have a 00151 // dummy production vertex. 00152 vertices.push_back(Vertex()); 00153 prov[p] = &vertices.back(); 00154 vertices.back().out.insert(p); 00155 } 00156 } 00157 00158 // Now go through the the particles again, and join the vertices. 00159 for ( int i = 0, N = all.size(); i < N; ++i ) { 00160 tcPPtr p = all[i]; 00161 if ( nocopies ) { 00162 if ( p->next() ) continue; 00163 for ( int i = 0, N = p->children().size(); i < N; ++i ) 00164 join(p, p->children()[i]->final()); 00165 tcPPtr pp = p; 00166 while ( pp->parents().empty() && pp->previous() ) pp = pp->previous(); 00167 for ( int i = 0, N = pp->parents().size(); i < N; ++i ) 00168 join(pp->parents()[i]->final(), p); 00169 } else { 00170 for ( int i = 0, N = p->children().size(); i < N; ++i ) 00171 join(p, p->children()[i]); 00172 if ( p->next() ) join(p, p->next()); 00173 for ( int i = 0, N = p->parents().size(); i < N; ++i ) 00174 join(p->parents()[i], p); 00175 if ( p->previous() ) join(p->previous(), p); 00176 } 00177 } 00178 00179 // Time to create the GenVertex's 00180 for ( typename VertexMap::iterator it = prov.begin(); it != prov.end(); ++it ) 00181 if ( !member(vmap, it->second) ) 00182 vmap[it->second] = createVertex(it->second); 00183 for ( typename VertexMap::iterator it = decv.begin(); it != decv.end(); ++it ) 00184 if ( !member(vmap, it->second) ) 00185 vmap[it->second] = createVertex(it->second); 00186 00187 // Add the vertices. 00188 for ( typename GenVertexMap::iterator it = vmap.begin(); 00189 it != vmap.end(); ++it ) 00190 Traits::addVertex(*geneve, it->second); 00191 00192 // Now find the primary signal process vertex defined to be the 00193 // decay vertex of the first parton coming into the primary hard 00194 // sub-collision. 00195 tSubProPtr sub = ev.primarySubProcess(); 00196 if ( sub && sub->incoming().first ) { 00197 const Vertex *prim = decv[sub->incoming().first]; 00198 Traits::setSignalProcessVertex(*geneve, vmap[prim]); 00199 } 00200 00201 if (beam1 && beam2) 00202 geneve->set_beam_particles(beam1, beam2); 00203 }
void ThePEG::HepMCConverter< HepMCEventT, Traits >::join | ( | tcPPtr | parent, | |
tcPPtr | child | |||
) | [inline, private] |
Join the decay vertex of the parent with the decay vertex of the child.
Definition at line 231 of file HepMCConverter.cc.
References ThePEG::HepMCConverter< HepMCEventT, Traits >::decv, ThePEG::HepMCConverter< HepMCEventT, Traits >::Vertex::in, ThePEG::HepMCConverter< HepMCEventT, Traits >::Vertex::out, and ThePEG::HepMCConverter< HepMCEventT, Traits >::prov.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
00232 { 00233 Vertex *dec = decv[parent]; 00234 Vertex *pro = prov[child]; 00235 if ( !pro || !dec ) throw HepMCConverterException() 00236 << "Found a reference to a ThePEG::Particle which was not in the Event." 00237 << Exception::eventerror; 00238 if ( pro == dec ) return; 00239 while ( !pro->in.empty() ) { 00240 dec->in.insert(*(pro->in.begin())); 00241 decv[*(pro->in.begin())] = dec; 00242 pro->in.erase(pro->in.begin()); 00243 } 00244 while ( !pro->out.empty() ) { 00245 dec->out.insert(*(pro->out.begin())); 00246 prov[*(pro->out.begin())] = dec; 00247 pro->out.erase(pro->out.begin()); 00248 } 00249 }
HepMCConverter& ThePEG::HepMCConverter< HepMCEventT, Traits >::operator= | ( | const HepMCConverter< HepMCEventT, Traits > & | ) | [private] |
Assignment is unimplemented and private and should never be used.
VertexMap ThePEG::HepMCConverter< HepMCEventT, Traits >::decv [private] |
The mapping of particles to their decy vertices.
Definition at line 178 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::init(), and ThePEG::HepMCConverter< HepMCEventT, Traits >::join().
tcEHPtr ThePEG::HepMCConverter< HepMCEventT, Traits >::eh [private] |
The primary event handler.
Definition at line 198 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::createParticle(), and ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
Energy ThePEG::HepMCConverter< HepMCEventT, Traits >::energyUnit [private] |
The energy unit to be used in the GenEvent.
Definition at line 188 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::createParticle().
FlowMap ThePEG::HepMCConverter< HepMCEventT, Traits >::flowmap [private] |
The translation table between ThePEG ColourLine objects and HepMC Flow indices.
Definition at line 163 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
GenEvent* ThePEG::HepMCConverter< HepMCEventT, Traits >::geneve [private] |
The constructed GenEvent.
Definition at line 151 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::convert(), ThePEG::HepMCConverter< HepMCEventT, Traits >::HepMCConverter(), and ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
Length ThePEG::HepMCConverter< HepMCEventT, Traits >::lengthUnit [private] |
The length unit to be used in the GenEvent.
Definition at line 193 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::createVertex().
ParticleMap ThePEG::HepMCConverter< HepMCEventT, Traits >::pmap [private] |
The translation table between the ThePEG particles and the GenParticles.
Definition at line 157 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::createVertex(), and ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
VertexMap ThePEG::HepMCConverter< HepMCEventT, Traits >::prov [private] |
The mapping of particles to their production vertices.
Definition at line 173 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::init(), and ThePEG::HepMCConverter< HepMCEventT, Traits >::join().
vector<Vertex> ThePEG::HepMCConverter< HepMCEventT, Traits >::vertices [private] |
All temporary vertices created.
Definition at line 168 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::init().
GenVertexMap ThePEG::HepMCConverter< HepMCEventT, Traits >::vmap [private] |
The mapping between temporary vertices and the created GenVertex Objects.
Definition at line 183 of file HepMCConverter.h.
Referenced by ThePEG::HepMCConverter< HepMCEventT, Traits >::init().