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

List of all members.

Public Member Functions

def __init__
def initialize
def execute
def finalize
def findPromptReadouts
def markForStorage
def findRegistrations
def addInputHeaders
def makeStorageList

Public Attributes

 ReadoutLocation
 RegSeqLocation
 StorePaths
 CoincidenceWindow
 DetectorNames
 AdOnly
 SameDetectorOnly
 SaveIntermediate
 SaveNeighbors
 NeighborWindow
 detectors

Detailed Description

Definition at line 99 of file FilterAlgs.py.


Constructor & Destructor Documentation

def DybAlg::FilterAlgs::CoincidenceFilterAlg::__init__ (   self,
  name 
)

Definition at line 101 of file FilterAlgs.py.

00102                            :
00103         DybPythonAlg.__init__(self,name)
00104         # Properties
00105         self.ReadoutLocation = ReadoutHeader.defaultLocation()
00106         self.RegSeqLocation = RegistrationSequence.defaultLocation()
00107         self.StorePaths = [ ReadoutHeader.defaultLocation() ]
00108         self.CoincidenceWindow = 1.0 * units.millisecond
00109         self.DetectorNames = []
00110         self.AdOnly = False
00111         self.SameDetectorOnly = False
00112         self.SaveIntermediate = False
00113         self.SaveNeighbors = False
00114         self.NeighborWindow = 1000.0 * units.nanosecond
00115         # Internal variables
00116         self.detectors = []
00117         return


Member Function Documentation

def DybAlg::FilterAlgs::CoincidenceFilterAlg::initialize (   self)

Definition at line 118 of file FilterAlgs.py.

00119                         :
00120         status = DybPythonAlg.initialize(self)
00121         self.info("initializing")
00122         for detName in self.DetectorNames:
00123             self.detectors.append(Detector(detName))
00124         return status

def DybAlg::FilterAlgs::CoincidenceFilterAlg::execute (   self)

Definition at line 125 of file FilterAlgs.py.

00126                      :
00127         self.info("executing")
00128         # Get the readout headers in the archive
00129         readoutArchive = self.getAES(self.ReadoutLocation)
00130         if readoutArchive == None: return FAILURE
00131         if len(readoutArchive)<1: return SUCCESS # No ReadoutHeaders in archive
00132         # Get current readout (first in archive list)
00133         currentReadout = readoutArchive[0].readout()
00134         if currentReadout == None: return SUCCESS # No readout this cycle
00135         currentDet = currentReadout.detector()
00136         if self.AdOnly and not currentDet.isAD(): # Select AD coincidence only
00137             return SUCCESS
00138         if len(self.detectors)>0: # Use list of selected detectors
00139             if currentDet not in self.detectors:
00140                 return SUCCESS  # Detector not in selected list 
00141         # Get previous readouts from archive
00142         previousReadouts = []
00143         for readoutHdr in readoutArchive[1:]:
00144             readout = readoutHdr.readout()
00145             if readout != None: previousReadouts.append(readout)
00146         if len(previousReadouts)<1: return SUCCESS # No preceeding readouts
00147         # Look for coincidences with the current readout
00148         promptReadouts = self.findPromptReadouts(currentReadout,
00149                                                  previousReadouts)
00150         if len(promptReadouts)==0: return SUCCESS # No prompts
00151         # Make the list of readouts we want to store in the output file
00152         storageReadoutHeaders = self.makeStorageList(currentReadout,
00153                                                      promptReadouts,
00154                                                      previousReadouts)
00155         # Mark the readouts (and associated data) for storage
00156         status = self.markForStorage(storageReadoutHeaders)
00157         return status
        
def DybAlg::FilterAlgs::CoincidenceFilterAlg::finalize (   self)

Definition at line 158 of file FilterAlgs.py.

00159                       :
00160         self.info("finalizing")
00161         status = DybPythonAlg.finalize(self)
00162         return status

def DybAlg::FilterAlgs::CoincidenceFilterAlg::findPromptReadouts (   self,
  currentReadout,
  previousReadouts 
)

Definition at line 163 of file FilterAlgs.py.

00164                                                                   :
00165         # Use the coincidence time to find the prompt readouts
00166         promptReadouts = []
00167         for previousReadout in previousReadouts:
00168             if ( (self.SameDetectorOnly or self.AdOnly) 
00169                 and currentReadout.detector() != previousReadout.detector()):
00170                 continue  # Limited to the same detector?            
00171             if len(self.detectors)>0: # Use list of selected detectors
00172                 if currentReadout.detector() not in self.detectors: continue
00173             # Check time between readouts
00174             deltaTime = TimeStamp(currentReadout.triggerTime().GetSec()
00175                                   - previousReadout.triggerTime().GetSec(),
00176                                   currentReadout.triggerTime().GetNanoSec()
00177                                   - previousReadout.triggerTime().GetNanoSec())
00178             self.verbose("dT readout: "+str(deltaTime.GetSeconds()))
00179             if deltaTime.GetSeconds()*units.second <= self.CoincidenceWindow:
00180                 # Found coincidence
00181                 self.debug("Found coincidence dT [s]: "
00182                            +str(deltaTime.GetSeconds()) )
00183                 promptReadouts.append(previousReadout)
00184         return promptReadouts

def DybAlg::FilterAlgs::CoincidenceFilterAlg::markForStorage (   self,
  storageHeaders 
)

Definition at line 185 of file FilterAlgs.py.

00186                                             :
00187         # Mark the headers (and associated data) for storage
00188         # First, recursively add input headers to storage list
00189         for header in storageHeaders:
00190             self.addInputHeaders( header, storageHeaders )
00191         # Second, loop over RegistrationSequences, and find header Registrations
00192         registrations = []
00193         status = self.findRegistrations( storageHeaders, registrations )
00194         if not status.isSuccess(): return status
00195         for header, registration in zip( storageHeaders, registrations ):
00196             if registration == None:
00197                 self.error("Failed to find registration for header "
00198                            +header.name())
00199                 return FAILURE
00200             if registration.path() in self.StorePaths:
00201                 self.debug("Storing header at "+registration.path())
00202                 registration.setStore(True) # Mark header for storage
00203         return SUCCESS

def DybAlg::FilterAlgs::CoincidenceFilterAlg::findRegistrations (   self,
  headers,
  registrations 
)

Definition at line 204 of file FilterAlgs.py.

00205                                                        :
00206         # Find the ObjectReg registrations for each header in list
00207         # Initialize registration list with 'None'
00208         for header in headers:
00209             registrations.append(None)
00210         # Get Registration Archive
00211         regSeqArchive = self.getAES(self.RegSeqLocation)
00212         if regSeqArchive == None: return FAILURE
00213         for regSequence in regSeqArchive:
00214             for registration in regSequence.registrations():
00215                 hdrObj = registration.object()
00216                 if hdrObj == None:
00217                     self.error("Failed to retrieve object at "
00218                                +registration.path())
00219                     return FAILURE
00220                 if hdrObj in headers:
00221                     # Found the registration for this header
00222                     hdrIndex = headers.index(hdrObj)
00223                     registrations[hdrIndex] = regSequence.registration(hdrObj)
00224         return SUCCESS
    
def DybAlg::FilterAlgs::CoincidenceFilterAlg::addInputHeaders (   self,
  header,
  headerList 
)

Definition at line 225 of file FilterAlgs.py.

00226                                                  :
00227         # Recurse up the header.inputHeaders and add to headerList
00228         for inputHeader in header.inputHeaders():
00229             if inputHeader not in headerList:
00230                 headerList.append(inputHeader)
00231                 self.addInputHeaders(inputHeader, headerList)
00232         return

def DybAlg::FilterAlgs::CoincidenceFilterAlg::makeStorageList (   self,
  delayedReadout,
  promptReadouts,
  previousReadouts 
)

Definition at line 233 of file FilterAlgs.py.

00234                                                                                :
00235         # Generate the list of readouts for storage
00236         storageHeaders = [delayedReadout.header()]
00237         storageHeaders += [readout.header() for readout in promptReadouts]
00238         if not self.SaveIntermediate and not self.SaveNeighbors:
00239             return storageHeaders
00240         # Save all readouts between or near prompt/delayed pair
00241         delayedTime = delayedReadout.triggerTime()
00242         earliestTime = TimeStamp(promptReadouts[0].triggerTime())
00243         # First, find earliest prompt readout
00244         for promptReadout in promptReadouts:
00245             if promptReadout.triggerTime() < earliestTime:
00246                 earliestTime = promptReadout.triggerTime()
00247         # Add time window to catch readouts just before prompt?
00248         if self.SaveNeighbors:
00249             earliestTime.Add(TimeStamp(0,
00250                                        int(-self.NeighborWindow
00251                                            /units.nanosecond)))
00252         # Catch intermediate and neigboring readouts
00253         for previousReadout in previousReadouts:
00254             prevTime = previousReadout.triggerTime() 
00255             deltaT_earliest = TimeStamp( prevTime.GetSec()
00256                                          - earliestTime.GetSec(),
00257                                          prevTime.GetNanoSec()
00258                                          - earliestTime.GetNanoSec())
00259             deltaT_delayed = TimeStamp( prevTime.GetSec()
00260                                         - delayedTime.GetSec(),
00261                                         prevTime.GetNanoSec()
00262                                         - delayedTime.GetNanoSec())
00263             if (deltaT_earliest.GetSeconds() >= 0
00264                 and deltaT_delayed.GetSeconds() <= 0):
00265                 if previousReadout.header() not in storageHeaders:
00266                     storageHeaders.append(previousReadout.header())
00267         return storageHeaders
00268 

Member Data Documentation

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.py.

Definition at line 101 of file FilterAlgs.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:09:44 for DybAlg by doxygen 1.7.4