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

List of all members.

Public Member Functions

def initTagList
def check
def SaveReadoutData
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

 cableSvc
 jobId
 tagSet
 execNumber

Detailed Description

Add AD Channel Stats to UserData

Definition at line 11 of file ADChannelData.py.


Member Function Documentation

def UserTagging::UserData::ADChannelData::ADChannelData::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 15 of file ADChannelData.py.

00016                          :
00017         
00018         # Chao recommends method chaning since it's less typing and he is lazy.
00019         # A tag with no path (default to '') means no tag HeaderObject will be created
00020         # but this dummy tag is still need in order to manage the UserData 
00021         #
00022         self.addTag('Dummy', ''
00023             ).addData('ADChannelData', '/Event/UserData/AD/ADChannelData'
00024             ).addIntArray('board', 'connector', 'ring', 'column', 'hitCount'
00025             ).addFloatArray('adc0', 'preAdc0', 'charge0', 'tdc0', 'adcMax', 'charge')
00026 
00027         # or use Brett's preferred pythonic syntax:
00028         #
00029         # dummyTag = self.tagSet.Dummy = Tag()
00030         # myData = dummyTag.dataSet.ADChannelData = Data('/Event/UserData/AD/ADChannelData')
00031         #        
00032         # myData.paraSet.board     = IntArray()
00033         # myData.paraSet.connector = IntArray()
00034         # myData.paraSet.ring      = IntArray()
00035         # myData.paraSet.column    = IntArray()
00036         # myData.paraSet.hitCount  = IntArray()
00037         # 
00038         # myData.paraSet.adc0    = FloatArray()
00039         # myData.paraSet.preAdc0 = FloatArray()
00040         # myData.paraSet.charge0 = FloatArray()
00041         # myData.paraSet.tdc0    = FloatArray()
00042         # myData.paraSet.adcMax  = FloatArray()
00043         # myData.paraSet.charge  = FloatArray()
00044                 
00045         self.cableSvc = self.svc('ICableSvc','CableSvc')
00046         if self.cableSvc == None:
00047             self.error("Failed to get CableSvc")
00048             return FAILURE    
00049 

def UserTagging::UserData::ADChannelData::ADChannelData::check (   self,
  evt 
)
Child Class should overwrie this function

Reimplemented from UserTagging::UserTaggingAlg::UserTaggingAlg.

Definition at line 51 of file ADChannelData.py.

00052                         :
00053         ADTag = evt['/Event/UserTag/Detector/AD']
00054         if not ADTag:
00055             return
00056         
00057         readoutHdr = evt['/Event/Readout/ReadoutHeader']
00058         if not readoutHdr:
00059             self.warning('cannot find readoutHdr')
00060             return
00061         self.SaveReadoutData(readoutHdr)        
00062         
00063         self.tagIt('Dummy')
                    
def UserTagging::UserData::ADChannelData::ADChannelData::SaveReadoutData (   self,
  readoutHdr 
)

Definition at line 65 of file ADChannelData.py.

00066                                          :
00067         
00068         myData = self.getTag('Dummy').getData('ADChannelData')
00069                 
00070         svcMode = gbl.ServiceMode(readoutHdr.context(), 0)     
00071         daqCrate = readoutHdr.daqCrate()
00072         pmtCrate = daqCrate.asPmtCrate();
00073                 
00074         nChannels = 0
00075         for channel in pmtCrate.channelReadouts():
00076             nChannels += 1
00077             channelId = channel.channelId()
00078             board     = channelId.board()
00079             connector = channelId.connector()
00080             pmtId     = self.cableSvc.adPmtSensor(channelId, svcMode)
00081             ring      = pmtId.ring()
00082             column    = pmtId.column()
00083             
00084             myData.append('board', board
00085                 ).append('connector', connector
00086                 ).append('ring', ring
00087                 ).append('column', column
00088                 ).append('hitCount', channel.hitCount())
00089                 
00090             # or use Brett's preferred pythonic syntax:
00091             # myData.paraSet.board.append(board)
00092             # myData.paraSet.connector.append(connector)
00093             # myData.paraSet.ring.append(ring)
00094             # myData.paraSet.column.append(column)
00095             # myData.paraSet.hitCount.append(channel.hitCount())
00096                 
00097             adc0 = channel.adc(0)
00098             preAdc0 = channel.preAdcAvg(0)
00099             if channel.isHighGainAdc(0):
00100                 charge0 = adc0 - preAdc0
00101             else:
00102                 charge0 = (adc0 - preAdc0) * 20
00103             tdc0 = channel.tdc(0)
00104             
00105             myData.append('adc0', adc0
00106                 ).append('preAdc0', preAdc0
00107                 ).append('charge0', charge0
00108                 ).append('tdc0', tdc0)
00109                      
00110             adcMax = adc0
00111             charge = charge0
00112             for i in range(1, channel.hitCount()):
00113                 adc = channel.adc(i)
00114                 preAdc = channel.preAdcAvg(i)
00115 
00116                 if channel.isHighGainAdc(i):
00117                     if (adc > adcMax): adcMax = adc 
00118                     charge += (adc - preAdc)
00119                 else:
00120                     if (adc*20 > adcMax): adcMax = adc*20
00121                     charge += (adc - preAdc) * 20
00122                     
00123             myData.append('adcMax', adcMax
00124                 ).append('charge', charge)
00125         
00126         # you can print all branches of UserData    
00127         # myData.dump()
00128         # or an individual branch
00129         # print 'charge: ', myData.get('charge')
00130             
                
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 15 of file ADChannelData.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