/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
UserTagging::UserData::GenData::GenData Class Reference
Inheritance diagram for UserTagging::UserData::GenData::GenData:
Inheritance graph
[legend]
Collaboration diagram for UserTagging::UserData::GenData::GenData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def initTagList
def check
def SaveGenData
def initialize
def addTag
def getTag
def tagIt
def reset
def config
def save
def post_save
def execute
def finalPrint
def finalize

Public Attributes

 target_de_name
 genTypes
 jobId
 tagSet
 execNumber

Detailed Description

Add Generator Info to UserData

Definition at line 17 of file GenData.py.


Member Function Documentation

def UserTagging::UserData::GenData::GenData::initTagList (   self)
Child Class should overwrite this function.
Child Class should initialize UserTag and UserData here

example adding Tag:
self.addTag('AD' , '/Event/UserTag/Detector/AD')

or alternative (pythonic) syntax:
self.tagSet.AD  = Tag('/Event/UserTag/Detector/AD')

example adding a Dummy Tag and UserData:
self.addTag('Dummy', ''
    ).addData('ADReadoutData', '/Event/UserData/AD/ADReadoutData'
    ).addInt('nChannels', 'nHits'
    ).addFloat('chargeSum')

or alternative (pythonic) syntax:
self.tagSet.Dummy = Tag()
self.tagSet.Dummy.dataSet.ADReadoutData = Data('/Event/UserData/AD/ADReadoutData')
paraSet = self.tagSet.Dummy.dataSet.ADReadoutData.paraSet
paraSet.nChannels = Int()
paraSet.nHits = Int()
paraSet.chargeSum = Float()

Reimplemented from UserTagging::UserTaggingAlg::UserTaggingAlg.

Definition at line 21 of file GenData.py.

00022                          :
00023         # for details see doc-6020
00024         #
00025         # generator info, size of nGen
00026         # positon from first vtx
00027         # nVtx is the number of 'real primary' particles of each generator
00028         # IBD event has nVtx = 1 : nu_e_bar
00029         # Radioactive event nVtx > 1 for correlated decay events
00030         # Muon event nVtx = 1 : one out-going muon
00031         #
00032         # the first incoming particles of each vtx info, size of nVtxTotal, or 0 (muon)
00033         # for IBD, pid = [-12] for nu_e
00034         #          KE = KE for nu_e
00035         # for radioactive event, pid = [parent nuclei]
00036         # for radioactive event, t[j] - t[i] tells the correlation time
00037         # nOut[i] is the number of out-going particles at each primary vertex
00038         # nOut[i] == 2 for IBD 
00039         # nIn[i] should be 1, but 0 for muons
00040         #
00041         # outgoing particles info, size of nOutTotal
00042         # for IBD, out_pid = [-11, 2112]
00043         # for radioactive event, out_pid = [daughter nucliei+decay particles]
00044         self.addTag('Dummy', ''
00045             ).addData('GenData', '/Event/UserData/General/GenData'
00046             ).addInt('nGen', 'nVtxTotal', 'nOutTotal'
00047             ).addIntArray('genType', 'nVtx'
00048             ).addFloatArray('genX', 'genY', 'genZ'
00049             ).addIntArray('nIn', 'nOut', 'in_pid', 'out_pid'
00050             ).addFloatArray('in_x', 'in_y', 'in_z', 'in_t', 'in_KE', 'in_px', 'in_py', 'in_pz'
00051             ).addFloatArray('out_x', 'out_y', 'out_z', 'out_t', 'out_KE', 'out_px', 'out_py', 'out_pz')
00052                
00053         self.target_de_name = '/dd/Structure/AD/db-ade1/db-sst1/db-oil1'
00054         
00055         self.genTypes = {
00056             "IBD_gds":11, "IBD_lso":12, "IBD_oil":13, "IBD_acrylic":14,           
00057             "U238_gds":21, "U238_lso":22, "U238_PMT":23, "U238_sst":24,
00058             "Th232_gds":31, "Th232_lso":32, "Th232_PMT":33, "Th232_sst":34,
00059             "K40_gds":41, "K40_lso":42, "K40_PMT":43, "K40_sst":44,
00060             "Co60_sst":54,
00061         }
        
def UserTagging::UserData::GenData::GenData::check (   self,
  evt 
)
Child Class should overwrie this function

Reimplemented from UserTagging::UserTaggingAlg::UserTaggingAlg.

Definition at line 63 of file GenData.py.

00064                         :
00065 
00066         readoutHdr = evt['/Event/Readout/ReadoutHeader']
00067         if not readoutHdr:
00068             self.warning('cannot find readoutHdr')
00069             return
00070         
00071         genHdrs = readoutHdr.findHeaders(gbl.DayaBay.GenHeader.classID())
00072         self.SaveGenData(genHdrs)
00073         
00074         self.tagIt('Dummy')
        
def UserTagging::UserData::GenData::GenData::SaveGenData (   self,
  genHdrs 
)

Definition at line 76 of file GenData.py.

00077                                   :
00078 
00079         myData = self.getTag('Dummy').getData('GenData')
00080 
00081         de = self.getDet(self.target_de_name)
00082         if not de:
00083             self.info('Failed to get DE' + self.target_de_name)
00084             return FAILURE
00085         Gaudi = PyCintex.makeNamespace('Gaudi')
00086                                 
00087         # number of generators associated with this readout
00088         # nGen should be one except for pile-up events    
00089         nGen = len(genHdrs) 
00090         # total number of 'real primary' particles (vtx)
00091         nVtxTotal = 0
00092         # total number of outgoing particles
00093         nOutTotal = 0
00094  
00095         for genHdr in genHdrs:
00096             genName = genHdr.generatorName()
00097             self.debug("genName:" + genName)
00098             myData.append('genType', self.genTypes.get(genName, 0))
00099             
00100             nVtx = 0
00101             genEvt = genHdr.event()
00102             for vtx in irange(genEvt.vertices_begin(), genEvt.vertices_end()):
00103                 # do stuff with the vertex
00104                 nVtx += 1
00105                 nVtxTotal += 1
00106                 position = vtx.position()
00107                 genGlbPoint = Gaudi.XYZPoint(
00108                     position.x(), 
00109                     position.y(),
00110                     position.z()
00111                 )
00112                 genLclPoint = de.geometry().toLocal(genGlbPoint)
00113                 myData.append('in_x', genLclPoint.x()/units.mm)
00114                 myData.append('in_y', genLclPoint.y()/units.mm)
00115                 myData.append('in_z', genLclPoint.z()/units.mm)
00116                 myData.append('in_t', vtx.position().t()/units.microsecond)
00117                 
00118                 if nVtx == 1:
00119                     myData.append('genX', genLclPoint.x()/units.mm)
00120                     myData.append('genY', genLclPoint.y()/units.mm)
00121                     myData.append('genZ', genLclPoint.z()/units.mm)
00122                                 
00123                 nIn = 0    
00124                 for particle in irange(vtx.particles_in_const_begin(),
00125                                       vtx.particles_in_const_end()):
00126                     # do stuff with the incoming particles
00127                     nIn += 1
00128                     if nIn == 1:                  
00129                         myData.append('in_pid', particle.pdg_id())
00130                         momentum = particle.momentum()
00131                         myData.append('in_KE', (momentum.e() - momentum.m())/units.MeV)
00132                         myData.append('in_px', momentum.px()/units.MeV)
00133                         myData.append('in_py', momentum.py()/units.MeV)
00134                         myData.append('in_pz', momentum.pz()/units.MeV)
00135                 myData.append('nIn', nIn)
00136                 
00137                 nOut = 0
00138                 for particle in irange(vtx.particles_out_const_begin(),
00139                                        vtx.particles_out_const_end()):
00140                     # do stuff with the outgoing particles
00141                     nOut += 1
00142                     nOutTotal += 1
00143                     myData.append('out_pid', particle.pdg_id())
00144                     momentum = particle.momentum()
00145                     myData.append('out_KE', (momentum.e() - momentum.m())/units.MeV)
00146                     myData.append('out_px', momentum.px()/units.MeV)
00147                     myData.append('out_py', momentum.py()/units.MeV)
00148                     myData.append('out_pz', momentum.pz()/units.MeV)
00149                                  
00150                 myData.append('nOut', nOut)
00151                     
00152             myData.append('nVtx', nVtx)
00153 
00154         # set more user data
00155         myData.set("nGen", nGen
00156             ).set("nVtxTotal", nVtxTotal
00157             ).set("nOutTotal", nOutTotal)
00158         
00159         # print 'genX: ', myData.get('genX')
            
def UserTagging::UserTaggingAlg::UserTaggingAlg::initialize (   self) [inherited]
User need not implement, but if so, you must call this method on the
super-class

Definition at line 65 of file UserTaggingAlg.py.

00066                         :
00067 
00068         '''
00069         User need not implement, but if so, you must call this method on the
00070         super-class'''
00071 
00072         status = DybPythonAlg.initialize(self)
00073         if status.isFailure(): return status
00074         
00075         # Catch current Job ID
00076         jobInfoSvc = self.svc("IJobInfoSvc","JobInfoSvc")
00077         if not jobInfoSvc:
00078             self.error("Failed to initialize JobInfoSvc")
00079             return FAILURE
00080         self.jobId = jobInfoSvc.currentJobInfo().jobId()
00081         
00082         # self.tagSet = {}
00083         self.tagSet = TagSet()
00084         
00085         status = self.initTagList()
00086         if status == FAILURE: 
00087             self.error('error in initTagList() function')
00088             return FAILURE
00089 
00090         self.execNumber = 1
00091         
00092         return SUCCESS  
    
def UserTagging::UserTaggingAlg::UserTaggingAlg::addTag (   self,
  name,
  path = '' 
) [inherited]
Add one UserTag by name, provide a path to cause the tag
object to be sent through I/O.

Can also do:

  self.tagSet.<name> = Models.Tag([path])

Definition at line 121 of file UserTaggingAlg.py.

00122                                    :
00123         """
00124         Add one UserTag by name, provide a path to cause the tag
00125         object to be sent through I/O.
00126 
00127         Can also do:
00128 
00129           self.tagSet.<name> = Models.Tag([path])
00130         """
00131         return self.tagSet.addTag(name, path)

def UserTagging::UserTaggingAlg::UserTaggingAlg::getTag (   self,
  name 
) [inherited]
Look the UserTagHeader a tag by name.

Can also do:

  mytag = self.tagSet.<name>

Definition at line 133 of file UserTaggingAlg.py.

00134                           :
00135         """
00136         Look the UserTagHeader a tag by name.
00137 
00138         Can also do:
00139 
00140           mytag = self.tagSet.<name>
00141         """
00142         return self.tagSet.get(name)
    
def UserTagging::UserTaggingAlg::UserTaggingAlg::tagIt (   self,
  name 
) [inherited]
Tag the named UserTag.

Can also do:

  self.tagSet.<name>.tagIt()

Definition at line 144 of file UserTaggingAlg.py.

00145                          :
00146         """
00147         Tag the named UserTag.
00148 
00149         Can also do:
00150         
00151           self.tagSet.<name>.tagIt()
00152         """
00153         return self.tagSet.get(name).tagIt()
            
def UserTagging::UserTaggingAlg::UserTaggingAlg::reset (   self) [inherited]
Reset the Tag States

Definition at line 155 of file UserTaggingAlg.py.

00156                    :
00157         '''Reset the Tag States'''
00158         
00159         for tag in self.tagSet.all():
00160             if tag.isTagged:
00161                 if tag.path:
00162                     tag.header = gbl.DayaBay.HeaderObject()
00163                     self.initializeHeader(tag.header)
00164                 for data in tag.dataSet.all():
00165                     data.header = gbl.DayaBay.UserDataHeader()
00166                     self.initializeHeader(data.header)
00167                 tag.isTagged = False
                    
def UserTagging::UserTaggingAlg::UserTaggingAlg::config (   self,
  evt 
) [inherited]
Configure the UserTagHeader and UserDataHeader object
Child class can overwrite depends on the situation.

The "evt" is the transient event store object.

Definition at line 185 of file UserTaggingAlg.py.

00186                          :
00187         '''
00188         Configure the UserTagHeader and UserDataHeader object
00189         Child class can overwrite depends on the situation.
00190 
00191         The "evt" is the transient event store object.
00192         '''
00193         
00194         for tag in self.tagSet.all():
00195             if tag.isTagged:
00196                 if tag.path:
00197                     self.finalizeHeader(tag.header, evt[tag.baseHeader])
00198                 for data in tag.dataSet.all():
00199                     if tag.path:
00200                         self.finalizeHeader(data.header, tag.header)
00201                     else:
00202                         self.finalizeHeader(data.header, evt[tag.baseHeader])
00203 
                    
def UserTagging::UserTaggingAlg::UserTaggingAlg::save (   self,
  evt 
) [inherited]
Save the UserTag and UserData objects

Most subclass should not override.

Definition at line 205 of file UserTaggingAlg.py.

00206                        :
00207         '''
00208         Save the UserTag and UserData objects
00209 
00210         Most subclass should not override.
00211         '''
00212         
00213         for tag in self.tagSet.all():
00214             if tag.isTagged:
00215                 tag.nTagged += 1
00216                 if tag.path:
00217                     evt[tag.path] = tag.header
00218                     del tag.header
00219                 for data in tag.dataSet.all():
00220                     data.save()
00221                     evt[data.path] = data.header
00222                     del data.header

def UserTagging::UserTaggingAlg::UserTaggingAlg::post_save (   self,
  evt 
) [inherited]
Hook to allow subclass to perform actions
after UserTag and UserData being saved to the event store. 

Definition at line 224 of file UserTaggingAlg.py.

00225                             :
00226         '''
00227         Hook to allow subclass to perform actions
00228         after UserTag and UserData being saved to the event store. 
00229         '''
00230         pass
00231                                 
        # --------------------------------------
def UserTagging::UserTaggingAlg::UserTaggingAlg::execute (   self) [inherited]

Definition at line 232 of file UserTaggingAlg.py.

00233                      :
00234         'Subclass should not override'
00235                     
00236         evt = self.evtSvc()
00237         
00238         status = self.reset()  
00239         if status == FAILURE: 
00240             self.error('error in reset() method')
00241             return FAILURE
00242         
00243         status = self.check(evt)
00244         if status == FAILURE: 
00245             self.error('error in check() method')
00246             return FAILURE
00247         
00248         status = self.config(evt)
00249         if status == FAILURE: 
00250             self.error('error in config() method')
00251             return FAILURE
00252         
00253         status = self.save(evt)
00254         if status == FAILURE: 
00255             self.error('error in save() method')
00256             return FAILURE
00257         
00258         status = self.post_save(evt)
00259         if status == FAILURE: 
00260             self.error('error in post_save() method')
00261             return FAILURE
00262                 
00263         self.execNumber += 1
00264         return SUCCESS

def UserTagging::UserTaggingAlg::UserTaggingAlg::finalPrint (   self) [inherited]
Print how many tagged events

Definition at line 266 of file UserTaggingAlg.py.

00267                         :
00268         '''Print how many tagged events'''
00269         
00270         for name, tag in self.tagSet.all_dict().items():
00271             self.info( 'Summary: UserTag %s : %d events tagged at %s' % (name, tag.nTagged, tag.path) )
00272             for dataName, data in tag.dataSet.all_dict().items():
00273                 self.info( "\tUserData %s saved at %s" % (dataName, data.path) )
                
def UserTagging::UserTaggingAlg::UserTaggingAlg::finalize (   self) [inherited]

Definition at line 275 of file UserTaggingAlg.py.

00275                       :     
00276         'Subclass may override, but it must called this method on the super-class'
00277         self.finalPrint()   
00278         status = DybPythonAlg.finalize(self)
00279         return status
00280 
00281 

Member Data Documentation

Definition at line 21 of file GenData.py.

Definition at line 21 of file GenData.py.

Definition at line 67 of file UserTaggingAlg.py.

Definition at line 67 of file UserTaggingAlg.py.

Definition at line 67 of file UserTaggingAlg.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:02:01 for UserTagging by doxygen 1.7.4