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

In This Package:

UserTagging::UserData::ADReadoutData::ADReadoutData Class Reference

Inheritance diagram for UserTagging::UserData::ADReadoutData::ADReadoutData:
[legend]
Collaboration diagram for UserTagging::UserData::ADReadoutData::ADReadoutData:
[legend]
List of all members.

Public Member Functions

def initTagList
def check
def SaveReadoutData
def __init__
def initialize
def addTag
def getTag
def tagIt
def reset
def config
def save
def execute
def finalPrint
def finalize

Public Attributes

 cableSvc

Detailed Description

Add AD Readout (DaqFormat) Info to UserData

Definition at line 11 of file ADReadoutData.py.


Member Function Documentation

def UserTagging::UserData::ADReadoutData::ADReadoutData::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 ADReadoutData.py.

00015                          :
00016         
00017         # Chao recommends method chaning since it's less typing and he is lazy.
00018         # A tag with no path (default to '') means no tag HeaderObject will be created
00019         # but this dummy tag is still need in order to manage the UserData 
00020         #
00021         self.addTag('Dummy'
00022             ).addData('ADReadoutData', '/Event/UserData/AD/ADReadoutData'
00023             ).addInt('nChannels', 'nHits'
00024             ).addFloat('chargeSum')
00025         
00026         # or use Brett's preferred pythonic syntax:
00027         #
00028         # self.tagSet.Dummy = Tag()
00029         # self.tagSet.Dummy.dataSet.ADReadoutData = Data('/Event/UserData/AD/ADReadoutData')
00030         # paraSet = self.tagSet.Dummy.dataSet.ADReadoutData.paraSet
00031         # paraSet.nChannels = Int()
00032         # paraSet.nHits = Int()
00033         # paraSet.chargeSum = Float()
00034         
00035         # you can do other necessary initialization here
00036         self.cableSvc = self.svc('ICableSvc','StaticCableSvc')
00037         if self.cableSvc == None:
00038             self.error("Failed to get StaticCableSvc")
00039             return FAILURE
00040 
00041     # ----------------------------------------
    def check(self, evt):

def UserTagging::UserData::ADReadoutData::ADReadoutData::check (   self,
  evt 
)

Child Class should overwrie this function

Reimplemented from UserTagging::UserTaggingAlg::UserTaggingAlg.

Definition at line 42 of file ADReadoutData.py.

00042                         :
00043 
00044         # check if this is an 'AD' event
00045         ADTag = evt['/Event/UserTag/Detector/AD']
00046         if not ADTag:
00047             return False
00048         
00049         # save some useful user data
00050         readoutHdr = evt['/Event/Readout/ReadoutHeader']
00051         if not readoutHdr:
00052             self.warning('cannot find readoutHdr')
00053             return
00054         self.SaveReadoutData(readoutHdr)            
00055         
00056         # tag the event so the user data can be saved
00057         self.tagIt('Dummy')
00058         
00059         # or use Brett's favorate syntax
00060         # self.tagSet.Dummy.tagIt()
00061         
00062     # ----------------------------------------
    def SaveReadoutData(self, readoutHdr):

def UserTagging::UserData::ADReadoutData::ADReadoutData::SaveReadoutData (   self,
  readoutHdr 
)

Save Readout (DaqFormat) Info to UserData

Definition at line 63 of file ADReadoutData.py.

00063                                          :
00064         '''Save Readout (DaqFormat) Info to UserData'''
00065                 
00066         nChannels = 0
00067         nHits = 0
00068         chargeSum = 0.
00069         
00070         # calculate the variables ...    
00071         svcMode = gbl.ServiceMode(readoutHdr.context(), 0)     
00072         daqCrate = readoutHdr.daqCrate()
00073         pmtCrate = daqCrate.asPmtCrate()
00074        
00075         for channel in pmtCrate.channelReadouts():
00076             # channel = channelPair.second
00077             channelId = channel.channelId()
00078             board = channelId.board()
00079             connector = channelId.connector()
00080             pmtId = self.cableSvc.adPmtSensor(channelId, svcMode)
00081             ring = pmtId.ring()
00082             if ring == 0: continue   # exclude 2'' PMT
00083             
00084             nChannels += 1
00085             nHits += channel.hitCount()
00086             for i in range(channel.hitCount()):
00087                 adc = channel.adc(i)
00088                 preAdc = channel.preAdcAvg(i)
00089 
00090                 if channel.isHighGainAdc(i): 
00091                     adc = adc - preAdc
00092                 else:
00093                     adc = (adc - preAdc) * 20
00094                 
00095                 chargeSum += adc
00096 
00097         # ...
00098         
00099         # save the variables to the User Data
00100         myData = self.getTag('Dummy').getData('ADReadoutData')
00101         myData.set("nChannels", nChannels       
00102             ).set("nHits", nHits
00103             ).set("chargeSum", chargeSum)
00104                     
00105         # or use Brett's preferred pythonic syntax
00106         #
00107         # myData = self.tagSet.Dummy.dataSet.ADReadoutData
00108         # paraSet = myData.paraSet
00109         # paraSet.nChannels = nChannels
00110         # paraSet.nHits = nHits
00111         # paraSet.chargeSum = chargeSum
00112         
00113         # you can print all branches of UserData
00114         # myData.dump()
00115         # or an individual branch
00116         # print 'nChannels', myData.get('nChannels')
00117                        
#####  Job Configuration for nuwa.py ########################################

def UserTagging::UserTaggingAlg::UserTaggingAlg::__init__ (   self,
  name 
) [inherited]

Definition at line 13 of file UserTaggingAlg.py.

00014                                                          :
00015     
00016                                 UserTaggingAlg
00017                                       |
00018                                       |
00019                                ----------------
00020                                |              |
00021                                |              |
00022                              tagSet      'other members ...'
                               |

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 23 of file UserTaggingAlg.py.

00055                            :
        DybPythonAlg.__init__(self,name)

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 72 of file UserTaggingAlg.py.

00072                              : return status
00073                 
00074         # self.tagSet = {}
00075         self.tagSet = TagSet()
00076         
00077         status = self.initTagList()
00078         if status == FAILURE: 
00079             self.error('error in initTagList() function')
00080             return FAILURE
00081         
00082         self.execNumber = 1
00083         

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 84 of file UserTaggingAlg.py.

00087                          :
00088         '''
00089         Child Class should overwrite this function.
00090         Child Class should initialize UserTag and UserData here
00091         
00092         example adding Tag:
00093         self.addTag('AD' , '/Event/UserTag/Detector/AD')
00094         
        or alternative (pythonic) syntax:

def UserTagging::UserTaggingAlg::UserTaggingAlg::tagIt (   self,
  name 
) [inherited]

Tag the named UserTag.

Can also do:

  self.tagSet.<name>.tagIt()

Definition at line 95 of file UserTaggingAlg.py.

00095                                         :
00096         self.tagSet.AD  = Tag('/Event/UserTag/Detector/AD')
00097         
00098         example adding a Dummy Tag and UserData:
00099         self.addTag('Dummy', ''
00100             ).addData('ADReadoutData', '/Event/UserData/AD/ADReadoutData'
00101             ).addInt('nChannels', 'nHits'
00102             ).addFloat('chargeSum')
00103         
00104         or alternative (pythonic) syntax:
00105         self.tagSet.Dummy = Tag()
        self.tagSet.Dummy.dataSet.ADReadoutData = Data('/Event/UserData/AD/ADReadoutData')

def UserTagging::UserTaggingAlg::UserTaggingAlg::reset (   self  )  [inherited]

Reset the Tag States

Definition at line 106 of file UserTaggingAlg.py.

00114                                    :
00115         """
00116         Add one UserTag by name, provide a path to cause the tag
00117         object to be sent through I/O.
00118 
00119         Can also do:

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 136 of file UserTaggingAlg.py.

00137                          :
00138         """
00139         Tag the named UserTag.
00140 
00141         Can also do:
00142         
00143           self.tagSet.<name>.tagIt()
00144         """
00145         return self.tagSet.get(name).tagIt()
00146             
00147     # --------------------------------------
00148     def reset(self):
00149         '''Reset the Tag States'''
00150         
00151         for tag in self.tagSet.all():
00152             if tag.isTagged:
00153                 if tag.path:
00154                     tag.header = gbl.DayaBay.HeaderObject()
00155                     ROOT.SetOwnership(tag.header,False)
00156                 for data in tag.dataSet.all():
00157                     data.header = gbl.DayaBay.UserDataHeader()
00158                     ROOT.SetOwnership(data.header,False)
00159                 tag.isTagged = False
00160                     
00161     # --------------------------------------
00162     def check(self, evt):
00163         '''Child Class should overwrie this function'''
00164         # all the real logics/algorithms happen here:
        # - check the properties of the event headers, run some algorithms.

def UserTagging::UserTaggingAlg::UserTaggingAlg::save (   self,
  evt 
) [inherited]

Save the UserTag and UserData objects

Most subclass should not override.

Definition at line 165 of file UserTaggingAlg.py.

00178                          :
00179         '''
00180         Configure the UserTagHeader and UserDataHeader object
00181         Child class can overwrite depends on the situation.
00182 
00183         The "evt" is the transient event store object.
        '''

def UserTagging::UserTaggingAlg::UserTaggingAlg::execute (   self  )  [inherited]

Definition at line 184 of file UserTaggingAlg.py.

00186                                     :
00187             if tag.isTagged:
00188                 baseHeader = evt[tag.baseHeader]
00189                 if not baseHeader:
00190                     self.error(tag.baseHeader + ' does not exist')
00191                     return FAILURE
00192                 if tag.path:
00193                     tagHeader = tag.header    
00194                     tagHeader.setExecNumber(baseHeader.execNumber())
00195                     tagHeader.setContext(baseHeader.context())
00196                     tagHeader.setEarliest(baseHeader.earliest())
00197                     tagHeader.setLatest(baseHeader.latest())
00198                     
00199                 for data in tag.dataSet.all():
00200                     dataHeader = data.header
00201                     dataHeader.setExecNumber(baseHeader.execNumber())
00202                     dataHeader.setContext(baseHeader.context())
00203                     dataHeader.setEarliest(baseHeader.earliest())
00204                     dataHeader.setLatest(baseHeader.latest())
00205 
00206     # --------------------------------------
00207     def save(self, evt):
00208         '''
00209         Save the UserTag and UserData objects
00210 
00211         Most subclass should not override.
00212         '''
        

def UserTagging::UserTaggingAlg::UserTaggingAlg::finalPrint (   self  )  [inherited]

Print how many tagged events

Definition at line 213 of file UserTaggingAlg.py.

00214                                     :
00215             if tag.isTagged:
00216                 tag.nTagged += 1
00217                 if tag.path:
00218                     evt[tag.path] = tag.header
00219                     del tag.header
00220                 for data in tag.dataSet.all():
00221                     data.save()
                    evt[data.path] = data.header

def UserTagging::UserTaggingAlg::UserTaggingAlg::finalize (   self  )  [inherited]

Definition at line 222 of file UserTaggingAlg.py.

00226                      :
00227         'Subclass should not override'
00228                     
00229         evt = self.evtSvc()
        


Member Data Documentation

UserTagging::UserData::ADReadoutData::ADReadoutData::cableSvc

Definition at line 36 of file ADReadoutData.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 20:10:48 2011 for UserTagging by doxygen 1.4.7