Public Member Functions | |
def | __init__ |
def | initialize |
def | execute |
def | __init__ |
def | initialize |
def | execute |
def | finalize |
def | verbose |
def | debug |
def | info |
def | warning |
def | error |
def | fatal |
def | getAES |
Public Attributes | |
ppsvc | |
msgSvc | |
archiveSvc | |
stats |
Definition at line 19 of file TestMasses.py.
def GenMuon::TestMasses::MassiveFailure::__init__ | ( | self, | ||
name = 'MassiveFailure' | ||||
) |
Definition at line 21 of file TestMasses.py.
00021 : 00022 DybPythonAlg.__init__(self, name) 00023 self.ppsvc = None 00024 return 00025 def initialize(self):
def GenMuon::TestMasses::MassiveFailure::initialize | ( | self | ) |
Definition at line 26 of file TestMasses.py.
00026 : 00027 sc = DybPythonAlg.initialize(self) 00028 if sc.isFailure(): return sc 00029 00030 self.ppsvc = self.svc('IParticlePropertySvc','ParticlePropertySvc') 00031 if not self.ppsvc: 00032 self.error('Failed to get the ParticlePropertySvc') 00033 return FAILURE 00034 00035 return SUCCESS 00036 def execute(self):
def GenMuon::TestMasses::MassiveFailure::execute | ( | self | ) |
Definition at line 37 of file TestMasses.py.
00037 : 00038 tes = self.evtSvc() 00039 gh = tes['/Event/Gen/GenHeader'] 00040 if not gh: 00041 self.error('Failed to get a GenHeader') 00042 return FAILURE 00043 00044 ge = gh.event() 00045 if not ge: 00046 self.error('Failed to get a GenEvent') 00047 return FAILURE 00048 00049 for part in irange(ge.particles_begin(),ge.particles_end()): 00050 mom = part.momentum() # HepMC::FourVector 00051 pid = part.pdg_id() # int 00052 00053 prop = self.ppsvc.findByStdHepID(pid) 00054 if not prop: 00055 self.warning('No particle property for PID %d'%pid) 00056 continue 00057 00058 def check_mass(label,mtest,mcalc): 00059 dM = fabs(mtest-mcalc) 00060 dM_rat = dM / mtest 00061 dM_eps = 0.01*units.MeV 00062 if dM_rat > 0.001 or dM > dM_eps: 00063 self.warning('PID %d has %s mass %.2f MeV but calculated as %.2f MeV' % \ 00064 (pid, label, mtest / units.MeV, mcalc / units.MeV)) 00065 return False 00066 return True 00067 00068 mcalc = sqrt(fabs( mom.t()**2 - (mom.x()**2 + mom.y()**2 + mom.z()**2) )) 00069 ok1 = check_mass('generated',part.generated_mass(),mcalc) 00070 ok2 = check_mass('property',prop.mass(),mcalc) 00071 if not ok1 and not ok2: 00072 error("Failed to get reasonable mass") 00073 return FAILURE 00074 else: 00075 self.info('PID %d has mass %.2f MeV, energy %.2f GeV/c' % \ 00076 (pid, mcalc / units.MeV, mom.e() / units.GeV )) 00077 continue 00078 return SUCCESS 00079 00080 def run(app):
Definition at line 23 of file TestMasses.py.