/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes | Private Member Functions
Sim15::Eff::Sim15Eff Class Reference
Inheritance diagram for Sim15::Eff::Sim15Eff:
Inheritance graph
[legend]
Collaboration diagram for Sim15::Eff::Sim15Eff:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def execute
def finalize

Public Attributes

 genCounts
 trigCounts
 gh_list

Private Member Functions

def _get_gen_headers
def _add_generated
def _add_triggered

Detailed Description

Give an example of calculating some efficiencies

Definition at line 38 of file Eff.py.


Constructor & Destructor Documentation

def Sim15::Eff::Sim15Eff::__init__ (   self,
  name = 'Sim15Eff' 
)

Definition at line 43 of file Eff.py.

00044                                       :
00045         GaudiAlgo.__init__(self,name)
00046         self.genCounts = {}     # count GenHeaders generated
00047         self.trigCounts = {}    # count GenHeaders found via Readouts
00048         return


Member Function Documentation

def Sim15::Eff::Sim15Eff::execute (   self)

Definition at line 49 of file Eff.py.

00050                      :
00051         tes = self.evtSvc()
00052 
00053         rs = tes['/Event/RegistrationSequence']
00054 
00055         regs = rs.registrations()
00056         nregs = regs.size()
00057         #print 'Found %d HeaderObjects'%regs.size()
00058         for ireg in range(0,nregs):
00059             reg = regs[ireg]
00060             loc = reg.path()
00061             obj = reg.object()  # this auto casts to right HeaderObject type
00062 
00063             #print loc, obj.name()
00064             if loc == '/Event/Gen/GenHeader':
00065                 self._add_generated(obj)
00066                 pass
00067             
00068             if loc == '/Event/Readout/ReadoutHeader':
00069                 ghs = self._get_gen_headers(obj)
00070                 #print 'Found %d GenHeaders in this readout'%len(ghs)
00071                 for gh in ghs:
00072                     self._add_triggered(gh)
00073                 pass
00074 
00075             continue
00076         return SUCCESS

def Sim15::Eff::Sim15Eff::finalize (   self)
Print efficiencies. 

Definition at line 77 of file Eff.py.

00078                       :
00079         '''
00080         Print efficiencies. 
00081         '''
00082 
00083         for nam in self.genCounts.keys():
00084             if nam not in self.trigCounts.keys():
00085                 self.trigCounts[nam] = 0
00086             print 'Kin type: %s has %d/%d = %f'\
00087                 %(nam,self.trigCounts[nam],self.genCounts[nam],
00088                   (self.trigCounts[nam]*1.0)/(self.genCounts[nam]*1.0))
00089             continue
00090         return SUCCESS

def Sim15::Eff::Sim15Eff::_get_gen_headers (   self,
  obj 
) [private]
Descend through obj's inputHeaders and build up a list of GenHeaders

Definition at line 91 of file Eff.py.

00092                                   :
00093         '''
00094         Descend through obj's inputHeaders and build up a list of GenHeaders
00095         '''
00096         class CollectGH:
00097             def __init__(self):
00098                 self.gh_list = []
00099                 return
00100             def __call__(self,obj):
00101                 if obj.name() == '/GenHeader':
00102                     self.gh_list.append(obj)
00103                 return
00104             pass
00105 
00106         cgh = CollectGH()
00107         visitInputHeaders(obj,cgh)
00108         return cgh.gh_list

def Sim15::Eff::Sim15Eff::_add_generated (   self,
  obj 
) [private]
Count a generated event

Definition at line 109 of file Eff.py.

00110                                 :
00111         '''
00112         Count a generated event
00113         '''
00114         nam = obj.generatorName()
00115         try:
00116             self.genCounts[nam] += 1
00117         except KeyError:
00118             self.genCounts[nam] = 1
00119             pass
00120         return

def Sim15::Eff::Sim15Eff::_add_triggered (   self,
  obj 
) [private]
Count a triggered event

Definition at line 121 of file Eff.py.

00122                                 :
00123         '''
00124         Count a triggered event
00125         '''
00126         nam = obj.generatorName()
00127         try:
00128             self.trigCounts[nam] += 1
00129         except KeyError:
00130             self.trigCounts[nam] = 1
00131             pass
00132         return
00133     


Member Data Documentation

Definition at line 43 of file Eff.py.

Definition at line 43 of file Eff.py.

Definition at line 93 of file Eff.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 Fri May 16 2014 10:07:48 for Sim15 by doxygen 1.7.4