#include <HepMCtoG4.h>
Inheritance diagram for HepMCtoG4:
Public Types | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
enum | Status |
Public Member Functions | |
HepMCtoG4 (const std::string &type, const std::string &name, const IInterface *parent) | |
Note that how this works makes assumptions as to how the HepMC::Gen* classes are filled. | |
virtual | ~HepMCtoG4 () |
virtual StatusCode | initialize () |
virtual StatusCode | finalize () |
virtual StatusCode | convert (const HepMC::GenEvent &input, std::vector< G4PrimaryVertex * > &output) |
Do the conversion. | |
INTupleSvc * | ntupleSvc () const |
INTupleSvc * | evtColSvc () const |
IDataProviderSvc * | detSvc () const |
IDataProviderSvc * | evtSvc () const |
IIncidentSvc * | incSvc () const |
IChronoStatSvc * | chronoSvc () const |
IHistogramSvc * | histoSvc () const |
IAlgContextSvc * | contextSvc () const |
DataObject * | put (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const |
DataObject * | put (DataObject *object, const std::string &address, const bool useRootInTES=true) const |
Gaudi::Utils::GetData< TYPE >::return_type | get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const |
Gaudi::Utils::GetData< TYPE >::return_type | get (const std::string &location, const bool useRootInTES=true) const |
TYPE * | getDet (IDataProviderSvc *svc, const std::string &location) const |
TYPE * | getDet (const std::string &location) const |
bool | exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const |
bool | exist (const std::string &location, const bool useRootInTES=true) const |
bool | existDet (IDataProviderSvc *svc, const std::string &location) const |
bool | existDet (const std::string &location) const |
TYPE * | getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const |
TYPE * | getOrCreate (const std::string &location, const bool useRootInTES=true) const |
TOOL * | tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const |
TOOL * | tool (const std::string &type, const IInterface *parent=0, bool create=true) const |
SERVICE * | svc (const std::string &name, const bool create=true) const |
IUpdateManagerSvc * | updMgrSvc () const |
IDataProviderSvc * | fastContainersSvc () const |
StatusCode | Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const |
StatusCode | Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const |
StatusCode | Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const |
StatusCode | Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
MsgStream & | msgStream (const MSG::Level level) const |
MsgStream & | always () const |
MsgStream & | fatal () const |
MsgStream & | err () const |
MsgStream & | error () const |
MsgStream & | warning () const |
MsgStream & | info () const |
MsgStream & | debug () const |
MsgStream & | verbose () const |
MsgStream & | msg () const |
const Statistics & | counters () const |
StatEntity & | counter (const std::string &tag) const |
MSG::Level | msgLevel () const |
bool | msgLevel (const MSG::Level level) const |
void | resetMsgStream () const |
bool | typePrint () const |
bool | propsPrint () const |
bool | statPrint () const |
bool | errorsPrint () const |
long | printStat (const MSG::Level level=MSG::ALWAYS) const |
long | printErrors (const MSG::Level level=MSG::ALWAYS) const |
long | printProps (const MSG::Level level=MSG::ALWAYS) const |
void | registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=NULL) |
void | registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL) |
void | registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL) |
void | registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL) |
StatusCode | runUpdate () |
TransientFastContainer< T > * | getFastContainer (const std::string &location, typename TransientFastContainer< T >::size_type initial=0) |
StatusCode | release (const IInterface *interface) const |
virtual unsigned long | release () |
const std::string & | context () const |
const std::string & | rootInTES () const |
double | globalTimeOffset () const |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown) |
virtual unsigned long | addRef () |
virtual const std::string & | name () const |
virtual const std::string & | type () const |
virtual const IInterface * | parent () const |
virtual StatusCode | configure () |
virtual StatusCode | start () |
virtual StatusCode | stop () |
virtual StatusCode | terminate () |
virtual StatusCode | reinitialize () |
virtual StatusCode | restart () |
virtual Gaudi::StateMachine::State | FSMState () const |
virtual Gaudi::StateMachine::State | targetFSMState () const |
virtual StatusCode | sysInitialize () |
virtual StatusCode | sysStart () |
virtual StatusCode | sysStop () |
virtual StatusCode | sysFinalize () |
virtual StatusCode | sysReinitialize () |
virtual StatusCode | sysRestart () |
virtual StatusCode | setProperty (const Property &p) |
virtual StatusCode | setProperty (const std::string &s) |
virtual StatusCode | setProperty (const std::string &n, const std::string &v) |
StatusCode | setProperty (const std::string &name, const TYPE &value) |
virtual StatusCode | getProperty (Property *p) const |
virtual const Property & | getProperty (const std::string &name) const |
virtual StatusCode | getProperty (const std::string &n, std::string &v) const |
virtual const std::vector< Property * > & | getProperties () const |
PropertyMgr * | getPropertyMgr () |
ISvcLocator * | serviceLocator () const |
ISvcLocator * | svcLoc () const |
IMessageSvc * | msgSvc () const |
IToolSvc * | toolSvc () const |
StatusCode | setProperties () |
StatusCode | service (const std::string &name, T *&svc, bool createIf=true) const |
StatusCode | service (const std::string &type, const std::string &name, T *&svc) const |
void | declInterface (const InterfaceID &, void *) |
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const |
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const |
IAuditorSvc * | auditorSvc () const |
IMonitorSvc * | monitorSvc () const |
void | declareInfo (const std::string &name, const T &var, const std::string &desc) const |
void | declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const |
virtual const std::string & | type () const =0 |
virtual const IInterface * | parent () const =0 |
virtual StatusCode | configure ()=0 |
virtual StatusCode | start ()=0 |
virtual StatusCode | stop ()=0 |
virtual StatusCode | terminate ()=0 |
virtual StatusCode | reinitialize ()=0 |
virtual StatusCode | restart ()=0 |
virtual Gaudi::StateMachine::State | FSMState () const =0 |
virtual StatusCode | sysInitialize ()=0 |
virtual StatusCode | sysStart ()=0 |
virtual StatusCode | sysStop ()=0 |
virtual StatusCode | sysFinalize ()=0 |
virtual StatusCode | sysReinitialize ()=0 |
virtual StatusCode | sysRestart ()=0 |
virtual unsigned long | refCount () const =0 |
virtual const std::string & | name () const =0 |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface)=0 |
virtual unsigned long | addRef ()=0 |
virtual unsigned long | release ()=0 |
Static Public Member Functions | |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
Public Attributes | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
Protected Types | |
typedef std::map< std::string, StatEntity > | Statistics |
typedef std::map< std::string, unsigned int > | Counter |
typedef std::vector< IAlgTool * > | AlgTools |
typedef std::pair< IInterface *, std::string > | ServiceEntry |
typedef std::vector< ServiceEntry > | Services |
Protected Member Functions | |
StatusCode | releaseTool (const IAlgTool *tool) const |
StatusCode | releaseSvc (const IInterface *svc) const |
int | outputLevel () const |
virtual unsigned long | refCount () const |
IntegerProperty & | outputLevelProperty () |
void | initOutputLevel (Property &prop) |
Static Protected Attributes | |
static const bool | IgnoreRootInTES |
static const bool | UseRootInTES |
Private Member Functions | |
G4PrimaryParticle * | makeG4particle (const HepMC::GenParticle &part, const HepMC::GenEvent *event, const HepMC::GenVertex *vertex) |
Private Attributes | |
bool | m_zeroTime |
Property: ZeroTime. | |
IParticlePropertySvc * | m_pps |
bv@bnl.gov 2008/1/1.
Definition at line 18 of file HepMCtoG4.h.
HepMCtoG4::HepMCtoG4 | ( | const std::string & | type, | |
const std::string & | name, | |||
const IInterface * | parent | |||
) |
Note that how this works makes assumptions as to how the HepMC::Gen* classes are filled.
Definition at line 31 of file HepMCtoG4.cc.
00034 : GaudiTool(type,name,parent) 00035 , m_pps(0) // djaffe 00036 { 00037 declareInterface<IHepMCtoG4>(this); 00038 00039 declareProperty("ZeroTime",m_zeroTime = true, 00040 "Set true and all times will be reset so the signal vertex is at t=0."); 00041 }
HepMCtoG4::~HepMCtoG4 | ( | ) | [virtual] |
StatusCode HepMCtoG4::initialize | ( | ) | [virtual] |
Reimplemented from GaudiTool.
Definition at line 48 of file HepMCtoG4.cc.
00049 { 00050 m_pps = svc<IParticlePropertySvc>( "ParticlePropertySvc", true ) ; //djaffe 00051 return StatusCode::SUCCESS; 00052 }
StatusCode HepMCtoG4::finalize | ( | ) | [virtual] |
Reimplemented from GaudiTool.
Definition at line 54 of file HepMCtoG4.cc.
00055 { 00056 return StatusCode::SUCCESS; 00057 }
StatusCode HepMCtoG4::convert | ( | const HepMC::GenEvent & | input, | |
std::vector< G4PrimaryVertex * > & | output | |||
) | [virtual] |
Do the conversion.
Implements IHepMCtoG4.
Definition at line 122 of file HepMCtoG4.cc.
00124 { 00125 00126 // Catch HepMC::GenEvent weighting 00127 bool hasEventWeight = false; 00128 double eventWeight = 1.0; 00129 // If HepMC event weights container has only one value, apply to 00130 // all vertices as described in HepMC v2 documentation. 00131 if( input.weights().size() == 1 ){ 00132 hasEventWeight = true; 00133 eventWeight *= input.weights().front(); 00134 } 00135 00136 // Loop over vertices in the event 00137 HepMC::GenEvent::vertex_const_iterator 00138 iVtx = input.vertices_begin(), 00139 doneVtx = input.vertices_end(); 00140 for (/*nop*/; doneVtx != iVtx; ++iVtx) { 00141 00142 G4PrimaryVertex* g4vtx = new G4PrimaryVertex; 00143 bool first_time = true; 00144 00145 // Catch HepMC::GenVertex weighting 00146 bool hasVertexWeight = false; 00147 double vertexWeight = 1.0; 00148 // If HepMC::GenVertex weights container has only one value, 00149 // apply to current vertex as described in HepMC v2 00150 // documentation. 00151 if( (*iVtx)->weights().size() == 1 ){ 00152 hasVertexWeight = true; 00153 vertexWeight *= (*iVtx)->weights().front(); 00154 } 00155 if( hasEventWeight || hasVertexWeight ){ 00156 g4vtx->SetWeight( eventWeight*vertexWeight ); 00157 } 00158 00159 // Loop over particles in the vertex 00160 HepMC::GenVertex::particles_out_const_iterator 00161 iPart = (*iVtx)->particles_out_const_begin(), 00162 donePart = (*iVtx)->particles_out_const_end(); 00163 for (/*nop*/; donePart != iPart; ++iPart) { 00164 00165 // Only keep particles that are important for tracking 00166 if ((*iPart)->status() != 1) continue; 00167 00168 if (first_time) { 00169 first_time = false; 00170 HepMC::FourVector v = (*iPart)->production_vertex()->position(); 00171 g4vtx->SetPosition(v.x(),v.y(),v.z()); 00172 if (m_zeroTime) 00173 g4vtx->SetT0(0.0); 00174 else 00175 g4vtx->SetT0(v.t()); 00176 g4vtx->SetUserInformation(new G4DhPrimaryVertexInformation(&input,*iVtx)); 00177 } 00178 g4vtx->SetPrimary(makeG4particle(*(*iPart),&input,*iVtx)); 00179 } 00180 00181 if (!g4vtx->GetNumberOfParticle()) { 00182 delete g4vtx; 00183 continue; 00184 } 00185 00186 output.push_back(g4vtx); 00187 } 00188 return StatusCode::SUCCESS; 00189 }
G4PrimaryParticle * HepMCtoG4::makeG4particle | ( | const HepMC::GenParticle & | part, | |
const HepMC::GenEvent * | event, | |||
const HepMC::GenVertex * | vertex | |||
) | [private] |
Definition at line 65 of file HepMCtoG4.cc.
00066 { 00067 HepMC::FourVector p = part.momentum(); 00068 00069 G4PrimaryParticle* g4part = 0; 00070 00071 double m, cm ; 00072 if (part.pdg_id() == 20022 /*opticalphoton*/) { 00073 g4part = new G4PrimaryParticle(G4OpticalPhoton::Definition(), 00074 p.px(),p.py(),p.pz()); 00075 m = 0. ; 00076 } 00077 else { 00078 g4part = new G4PrimaryParticle(part.pdg_id(),p.px(),p.py(),p.pz()); 00079 m = cm = sqrt(fabs( p.t()*p.t() - (p.x()*p.x() + p.y()*p.y() + p.z()*p.z()) )); 00080 00081 ParticleProperty* ppp = m_pps->findByStdHepID( part.pdg_id() ); 00082 if ( ppp ) 00083 { 00084 m = ppp->mass(); 00085 double r = 0.; 00086 if ( m > 0 ) { r = std::abs(cm-m)/m; } 00087 if ( r > 0.001 || std::abs(cm-m) > 0.01*MeV ) 00088 { 00089 warning() << "calculated mass = " << cm 00090 << " differs from IParticlePropertySvc mass " << m 00091 << " for pdg_id " << part.pdg_id() 00092 << ". Using IParticlePropertySvc mass. " << endreq; 00093 } 00094 } 00095 else 00096 { 00097 if ( p.t() < 0.01*MeV && std::abs(part.pdg_id()) > 1000000000 ) 00098 { 00099 debug() << "As expected, there is no IParticlePropertySvc mass for pdg_id " 00100 << part.pdg_id() << " which is a zero-energy, recoil nucleus created by GenDecay. Use calculated mass " << m 00101 << " from particle energy " << p.t() << " momentum " << sqrt(p.x()*p.x() + p.y()*p.y() + p.z()*p.z()) 00102 << endreq; 00103 } 00104 else 00105 { 00106 warning() << "cannot find IParticlePropertySvc mass for pdg_id " 00107 << part.pdg_id() << " and status " << part.status() << " . Using calculated mass " << m 00108 << " from particle energy " << p.t() << " momentum " << sqrt(p.x()*p.x() + p.y()*p.y() + p.z()*p.z()) 00109 << endreq; 00110 } 00111 } 00112 00113 } 00114 g4part->SetMass(m); 00115 HepMC::ThreeVector pol = part.polarization().normal3d(); 00116 g4part->SetPolarization(pol.x(),pol.y(),pol.z()); 00117 00118 g4part->SetUserInformation(new G4DhPrimaryParticleInformation(event,vertex,&part)); 00119 return g4part; 00120 }
const InterfaceID & IHepMCtoG4::interfaceID | ( | ) | [static, inherited] |
Reimplemented from IAlgTool.
Definition at line 8 of file IHepMCtoG4.cc.
00009 { 00010 return IID_IHepMCtoG4; 00011 }
bool HepMCtoG4::m_zeroTime [private] |
Property: ZeroTime.
Set true and all times will be reset so the signal vertex is at t=0. NOTE: default is true.
Definition at line 37 of file HepMCtoG4.h.
IParticlePropertySvc* HepMCtoG4::m_pps [private] |
Definition at line 39 of file HepMCtoG4.h.