agile is hosted by Hepforge, IPPP Durham

HepMCTools.hh

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef AGILE_HEPMCTOOLS_HH
00003 #define AGILE_HEPMCTOOLS_HH
00004 
00005 #include "HepMC/GenEvent.h"
00006 
00007 namespace AGILe {
00008 
00009 
00010   inline void fixHepMCUnitsFromGeVmm(HepMC::GenEvent& evt) {
00011     #ifdef HEPMC_HAS_UNITS
00012     if (evt.momentum_unit() == HepMC::Units::MEV) {
00013       for (HepMC::GenEvent::particle_iterator p = evt.particles_begin(); p != evt.particles_end(); ++p) {
00014         const HepMC::FourVector fv((*p)->momentum().px() * 1000,
00015                                    (*p)->momentum().py() * 1000,
00016                                    (*p)->momentum().pz() * 1000,
00017                                    (*p)->momentum().e()  * 1000);
00018         (*p)->set_momentum( fv);
00019       }
00020     }
00021     if (evt.length_unit() == HepMC::Units::CM) {
00022       for (HepMC::GenEvent::vertex_iterator vtx = evt.vertices_begin(); vtx != evt.vertices_end(); ++vtx) {
00023         const HepMC::FourVector fv((*vtx)->position().x() / 10.,
00024                                    (*vtx)->position().y() / 10.,
00025                                    (*vtx)->position().z() / 10.,
00026                                    (*vtx)->position().t() / 10.);
00027         (*vtx)->set_position(fv);
00028       }
00029     }
00030     #endif
00031   }
00032 
00033 
00034 }
00035 
00036 #endif
Generated on Tue Mar 6 10:39:38 2012 for AGILe - A Generator Interface Library (+ executable) by  doxygen 1.6.3