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

List of all members.

Public Member Functions

def __init__
def initialize
def execute
def finalize
def fillNextTrigger
 Helper functions.
def getNextTrigger
def ableToTrigger
def setDtLastTrigger
def setTriggerNumber
def updateSources
def findNextSource
def nextSourceTime

Public Attributes

 sources
 execNumber
 minRetriggerTime
 startTime
 lastTriggerTime
 triggerCount

Detailed Description

Definition at line 597 of file TestCoinc.py.


Constructor & Destructor Documentation

def TestCoinc::TestCoincAlg::__init__ (   self,
  name 
)

Definition at line 599 of file TestCoinc.py.

00600                            :
00601         DybPythonAlg.__init__(self,name)
00602         self.sources = []
00603         self.execNumber = 0
00604         self.minRetriggerTime = 750.0e-9 # minimum retrigger time in nanoseconds
00605         self.startTime = TimeStamp() # Set default start time to 'now'
00606         self.lastTriggerTime = {DetectorId.kAD1:TimeStamp.GetBOT(),
00607                                 DetectorId.kAD2:TimeStamp.GetBOT(),
00608                                 DetectorId.kAD3:TimeStamp.GetBOT(),
00609                                 DetectorId.kAD4:TimeStamp.GetBOT(),
00610                                 DetectorId.kIWS:TimeStamp.GetBOT(),
00611                                 DetectorId.kOWS:TimeStamp.GetBOT(),
00612                                 DetectorId.kRPC:TimeStamp.GetBOT()
00613                                 }
00614         self.triggerCount = {DetectorId.kAD1:0,
00615                              DetectorId.kAD2:0,
00616                              DetectorId.kAD3:0,
00617                              DetectorId.kAD4:0,
00618                              DetectorId.kIWS:0,
00619                              DetectorId.kOWS:0,
00620                              DetectorId.kRPC:0
00621                              }
00622         return


Member Function Documentation

def TestCoinc::TestCoincAlg::initialize (   self)

Definition at line 623 of file TestCoinc.py.

00624                         :
00625         status = DybPythonAlg.initialize(self)
00626         if status.isFailure(): return status
00627         self.info("initializing")
00628         # Synchronize the start time for sources
00629         for source in self.sources:
00630             source.sourceTime = self.startTime
00631         return SUCCESS

def TestCoinc::TestCoincAlg::execute (   self)

Definition at line 632 of file TestCoinc.py.

00633                      :
00634         status = self.fillNextTrigger()
00635         if status.isFailure(): return status
00636         return SUCCESS
        
def TestCoinc::TestCoincAlg::finalize (   self)

Definition at line 637 of file TestCoinc.py.

00638                       :
00639         self.info("finalizing")
00640         status = DybPythonAlg.finalize(self)
00641         return status

def TestCoinc::TestCoincAlg::fillNextTrigger (   self)

Helper functions.

Place the next fake trigger into the event store 

Definition at line 645 of file TestCoinc.py.

00646                              :
00647         """ Place the next fake trigger into the event store """
00648         nextTrigger = self.getNextTrigger()
00649         if not nextTrigger: return FAILURE
00650         evt = self.evtSvc()
00651         headerPaths = ["/Event/CalibReadout/CalibReadoutHeader",
00652                        "/Event/Data/CalibStats",
00653                        "/Event/Rec/AdSimple",
00654                        "/Event/Rec/AdScaled"
00655                        ]
00656         headers = nextTrigger['headers']
00657         for headerPath in headerPaths:
00658             # Add item to event store
00659             if headerPath in headers:
00660                 evt[headerPath] = headers[headerPath]
00661         return SUCCESS

def TestCoinc::TestCoincAlg::getNextTrigger (   self)
Get the data headers for the next trigger 

Definition at line 662 of file TestCoinc.py.

00663                             :
00664         """ Get the data headers for the next trigger """
00665         status = self.updateSources()
00666         if status.isFailure(): return None
00667         source = self.findNextSource()
00668         if not source: return None
00669         nextTrigger = source.getNextTrigger()
00670         if not self.ableToTrigger(nextTrigger):
00671             # If trigger system unable to issue trigger, try again
00672             nextTrigger = self.getNextTrigger()
00673         # Set exec number
00674         for header in nextTrigger['headers'].values():
00675             header.setExecNumber(self.execNumber)
00676         # Set dt last trigger
00677         status = self.setDtLastTrigger(nextTrigger)
00678         if status.isFailure(): return None
00679         # Set trigger number for this detector
00680         status = self.setTriggerNumber(nextTrigger)
00681         if status.isFailure(): return None
00682         # Update time since this detector last triggered
00683         triggerTime = TimeStamp(nextTrigger['triggerTime'])
00684         detectorId = nextTrigger['detectorId']
00685         self.lastTriggerTime[detectorId] = triggerTime
00686         self.execNumber += 1
00687         self.triggerCount[detectorId] += 1
00688         return nextTrigger

def TestCoinc::TestCoincAlg::ableToTrigger (   self,
  nextTrigger 
)

Definition at line 689 of file TestCoinc.py.

00690                                         :
00691         "Check if trigger system is able to issue trigger"
00692         detectorId = nextTrigger['detectorId']
00693         lastTriggerTime = self.lastTriggerTime[detectorId]
00694         nextTriggerTime = nextTrigger['triggerTime']
00695         if lastTriggerTime >= nextTriggerTime:
00696             # Catch case where next trigger time == last trigger time
00697             return False
00698         dtTrigger = TimeStamp(nextTriggerTime)
00699         dtTrigger.Subtract(lastTriggerTime)
00700         if dtTrigger.GetSeconds() < self.minRetriggerTime:
00701             return False
00702         return True

def TestCoinc::TestCoincAlg::setDtLastTrigger (   self,
  nextTrigger 
)

Definition at line 703 of file TestCoinc.py.

00704                                            :
00705         "Set the CalibStats time since last trigger"
00706         detectorId = nextTrigger['detectorId']
00707         site = nextTrigger['site']
00708         triggerTime = nextTrigger['triggerTime']
00709         calibStats = nextTrigger['headers']['/Event/Data/CalibStats']
00710         for detectorId in self.lastTriggerTime:
00711             if (site != Site.kFar
00712                 and (DetectorId.kAD3 <= detectorId <= DetectorId.kAD4)):
00713                 continue
00714             if self.lastTriggerTime[detectorId] > TimeStamp.GetBOT():
00715                 dtLast = TimeStamp(triggerTime)
00716                 dtLast.Subtract(self.lastTriggerTime[detectorId])
00717                 calibStats.setFloat('dtLast%s_ms'% detectorNames[detectorId],
00718                                     dtLast.GetSeconds()*1e3)
00719         return SUCCESS

def TestCoinc::TestCoincAlg::setTriggerNumber (   self,
  nextTrigger 
)

Definition at line 720 of file TestCoinc.py.

00721                                            :
00722         "Set the trigger number"
00723         detectorId = nextTrigger['detectorId']
00724         headers = nextTrigger['headers']
00725         triggerNumber = self.triggerCount[detectorId]
00726         calibHeader = headers['/Event/CalibReadout/CalibReadoutHeader']
00727         calibHeader.calibReadout().setTriggerNumber(triggerNumber)
00728         adSimple = headers['/Event/Rec/AdSimple']
00729         adSimple.recTrigger().setTriggerNumber(triggerNumber)
00730         adScaled = headers['/Event/Rec/AdScaled']
00731         adScaled.recTrigger().setTriggerNumber(triggerNumber)
00732         return SUCCESS

def TestCoinc::TestCoincAlg::updateSources (   self)
Ask each source to update to next trigger time 

Definition at line 733 of file TestCoinc.py.

00734                            :
00735         """ Ask each source to update to next trigger time """
00736         nextSourceTime = self.nextSourceTime()
00737         upToDate = False
00738         while not upToDate:
00739             upToDate = True
00740             for source in self.sources:
00741                 if source.currentTime() <= nextSourceTime:
00742                     status = source.makeNextEvent()
00743                     if status.isFailure(): return status
00744                     nextSourceTime = self.nextSourceTime()
00745                     upToDate = False
00746                     break
00747         return SUCCESS

def TestCoinc::TestCoincAlg::findNextSource (   self)
Determine which source will provide the next trigger 

Definition at line 748 of file TestCoinc.py.

00749                             :
00750         """ Determine which source will provide the next trigger """
00751         if len(self.sources)<1:
00752             self.error("No Sources have been defined")
00753             return None
00754         curSource = self.sources[0]
00755         for source in self.sources[1:]:
00756             if source.nextTriggerTime() < curSource.nextTriggerTime():
00757                 curSource = source
00758         return curSource

def TestCoinc::TestCoincAlg::nextSourceTime (   self)
Find the time of the next source 

Definition at line 759 of file TestCoinc.py.

00760                             :
00761         """ Find the time of the next source """
00762         nextSource = self.findNextSource()
00763         if not nextSource:
00764             return TimeStamp.GetEOT()
00765         return nextSource.nextTriggerTime()
        

Member Data Documentation

Definition at line 599 of file TestCoinc.py.

Definition at line 599 of file TestCoinc.py.

Definition at line 599 of file TestCoinc.py.

Definition at line 599 of file TestCoinc.py.

Definition at line 599 of file TestCoinc.py.

Definition at line 599 of file TestCoinc.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:10:46 for ADCoincTagging by doxygen 1.7.4