| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

GenDecay::Histogram::DecayEnergy Class Reference

Inheritance diagram for GenDecay::Histogram::DecayEnergy:
[legend]
Collaboration diagram for GenDecay::Histogram::DecayEnergy:
[legend]
List of all members.

Public Member Functions

def __init__
def __init__
def initialize
def initialize
def finalize
def finalize
def __setitem__
def __getitem__
def execute
def verbose
def debug
def info
def warning
def error
def fatal
def getAES

Public Attributes

 dk_type
 parentHist
 lastRefTime
 default_path
 data
 statsSvc
 msgSvc
 archiveSvc
 stats

Classes

class  ParentHist

Detailed Description

Histogram radioactive decays by parent

Definition at line 100 of file Histogram.py.


Member Function Documentation

def GenDecay::Histogram::DecayEnergy::__init__ (   self,
  name,
  dk_type 
)

Reimplemented from GenDecay::Histogram::MyPythonAlg.

Definition at line 143 of file Histogram.py.

00145                                    :
00146         MyPythonAlg.__init__(self,name,'/file1/%s/%s'%(name,dk_type))
00147         self.dk_type = dk_type
00148         self.parentHist = {}    # map pdgid to ParentHist
00149         self.lastRefTime = 0.0
00150         return
00151 
00152     def initialize(self):
00153         status = MyPythonAlg.initialize(self)
00154         if status.isFailure(): return status
00155         self.info("initializing")
00156         self['ngamma'] = TH1F("ngamma","Number of Gammas",100,0,100)
00157         self['necap'] = TH1F("necap","Number of Electron Captures",100,0,100)
00158         self['alphabeta'] = TH1F("alphabeta","Alpha(<0) or Beta(>0)",2,-1,1)
00159         self['Ealpha'] = TH1F("Ealpha","Alpha kinetic energy (MeV)",2000,0,10)
00160         self['Ebeta'] = TH1F("Ebeta","Beta kinetic energy (MeV)",2000,0,10)
00161         self['Egamma'] = TH1F("Egamma","Gamma kinetic energy (MeV)",2000,0,10)
00162         self['Ecap'] = TH1F("Ecap","Energy from electron capture (MeV)",2000,0,10)
00163         self['deltaT'] = TH1F("deltaT","Time between parents (sec)",1000,0,100)
00164         '''
00165         histograms to add:  
00166 
00167         * parent nuclide specie
00168         * per parent alpha, beta & gamma spectra
00169         * time between parents
00170         * per parent time from parent to alpha, beta, gamma
00171 
00172         code to add:
00173 
00174         * GenEvent should hold daughter nuclides, take care with
00175           corelated decays, save only last daughter.
00176 
00177         '''
00178         return status
00179 
00180     def execute(self):
00181         evt = self.evtSvc()
00182         path = "/Event/Gen/GenHeader"
00183         hdr = evt[path]
00184 
00185         refTimestamp = hdr.timeStamp()
00186         refSeconds = refTimestamp.GetSeconds()
00187         #print 'refSeconds=',refSeconds,'self.lastRefTme',self.lastRefTime
00188         deltaRefSeconds = refSeconds - self.lastRefTime
00189         self.lastRefTime = refSeconds
00190 
00191         event = hdr.event()
00192         if event is None:
00193             error('Failed to get %s'%path)
00194             return FAILURE
00195 
00196 
00197         sigvtx = event.signal_process_vertex()
00198         if sigvtx is None: 
00199             error('No signal vertex')
00200             return FAILURE
00201 
00202         if sigvtx.particles_in_size() == 0:
00203             error('No input particles in signal process vertex')
00204             return FAILURE
00205 
00206         parent = sigvtx.particles_in_const_begin().__deref__()
00207         if parent is None:
00208             fatal('Unable to deref iterator')
00209             return FAILURE
00210 
00211         parent_pos = sigvtx.position()
00212         thisRelSeconds = parent_pos.t()/units.second
00213 
00214         # to fix: get times consistent between More and Gaudi side of things.
00215 
00216         dT = deltaRefSeconds + thisRelSeconds
00217         #print 'dT=',dT,'(sec) deltaRefSeconds=',deltaRefSeconds,'thisRelSeconds=',thisRelSeconds,'refSeconds=',refSeconds,'self.lastRefTime=',self.lastRefTime
00218         if dT <= 0.0: logT = 0.0
00219         else: logT = math.log10(dT)
00220         self['deltaT'].Fill(logT)
00221 
00222         try:
00223             parentHist = self.parentHist[parent.pdg_id()]
00224         except KeyError:
00225             parentHist = DecayEnergy.ParentHist(parent,self)
00226             self.parentHist[parent.pdg_id()] = parentHist
00227             pass            
00228 
00229         ndecay = 0
00230         ngamma = 0
00231         necap = 0
00232         #print "%d vertices:"%event.vertices_size()
00233         for vertex in irange(event.vertices_begin(),
00234                              event.vertices_end()):
00235             pos = vertex.position()
00236             #print "vertex position = (%f, %f, %f, %e s) %d particles:"%\
00237             #    (pos.x(), pos.y(), pos.z(), pos.t()/units.second, vertex.particles_out_size())
00238 
00239             deltaT = pos.t()/units.ns
00240 
00241             for particle in irange(vertex.particles_out_const_begin(),
00242                                    vertex.particles_out_const_end()):
00243                 id = particle.pdg_id()
00244                 mom = particle.momentum()
00245                 mass = particle.generated_mass()
00246                 #print "\t%s 4 momentum = (%f, %f, %f, %f)"%(pdgid2name(id), mom.px(), mom.py(), mom.pz(), mom.e())
00247                 
00248                 ndecay += 1
00249 
00250                 ke = (mom.e()-mass)/units.MeV
00251                 # Alphas
00252                 if id == 1000020040: 
00253                     self['Ealpha'].Fill(ke)
00254                     parentHist.Ealpha.Fill(ke)
00255                     parentHist.Talpha.Fill(deltaT)
00256                     self['alphabeta'].Fill(-0.5)
00257                     #if ke > 7.0:
00258                     #    print "BIG ALPHA"
00259                     pass
00260                 # Betas
00261                 if id == 11 or id == -11: 
00262                     self['Ebeta'].Fill(ke)
00263                     parentHist.Ebeta.Fill(ke)
00264                     parentHist.Tbeta.Fill(deltaT)
00265                     self['alphabeta'].Fill(+0.5)
00266                     pass
00267                 # Gammas
00268                 if id == 22: 
00269                     self['Egamma'].Fill(ke)
00270                     parentHist.Egamma.Fill(ke)
00271                     parentHist.Tgamma.Fill(deltaT)
00272                     ngamma += 1
00273                     pass
00274                 # EleCapture
00275                 if id == 0:
00276                     self['Ecap'].Fill(ke)
00277                     parentHist.Ecap.Fill(ke)
00278                     parentHist.Tecap.Fill(deltaT)
00279                     necap += 1
00280                     pass
00281                 continue
00282             continue
00283         #print ngamma,'gammas'
00284         self['ngamma'].Fill(ngamma)
00285         self['necap'].Fill(necap)
00286         parentHist.nDecay.Fill(ndecay)
00287 
00288         return SUCCESS
00289 
00290     def finalize(self):
00291         return MyPythonAlg.finalize(self)
00292 
    pass

def GenDecay::Histogram::MyPythonAlg::initialize (   self  )  [inherited]

Definition at line 25 of file Histogram.py.

00025                         :
00026         status = DybPythonAlg.initialize(self)
00027         if status.isFailure(): return status
00028         self.statsSvc = self.svc('IStatisticsSvc','StatisticsSvc')
00029         if self.statsSvc == None:
00030             self.error("Failed to initialize StatisticsSvc.")
00031             return FAILURE        
00032         return SUCCESS
00033 
    def finalize(self):

def GenDecay::Histogram::MyPythonAlg::finalize (   self  )  [inherited]

Definition at line 34 of file Histogram.py.

00034                       :
00035         return DybPythonAlg.finalize(self)
00036 
    def _key2path(self,key):

def GenDecay::Histogram::MyPythonAlg::__setitem__ (   self,
  key,
  value 
) [inherited]

Definition at line 42 of file Histogram.py.

00042                                    :
00043         #self.info('MyPthonAlg.__setitem__(%s,%s)'%(key,value))
00044         key = self._key2path(key)
00045         if self.data.has_key(key):
00046             raise KeyError, 'key "%s" already set'%key
00047         self.statsSvc.put(key,value)
00048         self.data[key] = value
00049         return
00050 
    def __getitem__(self,key):

def GenDecay::Histogram::MyPythonAlg::__getitem__ (   self,
  key 
) [inherited]

Definition at line 51 of file Histogram.py.

00051                              :
00052         return self.data[self._key2path(key)]
00053 
00054     pass


Member Data Documentation

GenDecay::Histogram::DecayEnergy::dk_type

Definition at line 145 of file Histogram.py.

GenDecay::Histogram::DecayEnergy::parentHist

Definition at line 146 of file Histogram.py.

GenDecay::Histogram::DecayEnergy::lastRefTime

Definition at line 147 of file Histogram.py.

GenDecay::Histogram::MyPythonAlg::default_path [inherited]

Definition at line 21 of file Histogram.py.

GenDecay::Histogram::MyPythonAlg::data [inherited]

Definition at line 22 of file Histogram.py.

GenDecay::Histogram::MyPythonAlg::statsSvc [inherited]

Definition at line 28 of file Histogram.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 21:01:10 2011 for GenDecay by doxygen 1.4.7