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

List of all members.

Public Member Functions

def __init__
def initialize
def execute
def finalize

Public Attributes

 location
 dTCut
 dTMuonVeto
 unphysicalRun
 unphysicalMultiplicity
 maxCoincFraction
 nCoincidences
 nSeen
 nKept
 currentJobId
 tagName
 adList
 lastTimeStamp
 inputHeaders

Detailed Description

AD Coincidence Events

Definition at line 20 of file ADRoughCoincTag.py.


Constructor & Destructor Documentation

def Tagger::Filters::ADRoughCoincTag::ADRoughCoincTag::__init__ (   self,
  name 
)

Definition at line 22 of file ADRoughCoincTag.py.

00023                            :
00024         DybPythonAlg.__init__(self,name)
00025         self.location = "/Event/Rec/AdSimple"
00026         self.dTCut = 250 * units.microsecond
00027         self.dTMuonVeto = 10 * units.microsecond
00028         self.unphysicalRun = False
00029         self.unphysicalMultiplicity = 10
00030         self.maxCoincFraction = 0.2
00031         self.nCoincidences = 0
00032         self.nSeen = 0
00033         self.nKept = 0
00034         return
    

Member Function Documentation

def Tagger::Filters::ADRoughCoincTag::ADRoughCoincTag::initialize (   self)

Definition at line 36 of file ADRoughCoincTag.py.

00037                         :
00038         status = DybPythonAlg.initialize(self)
00039         if status.isFailure(): return status
00040         # Catch current Job ID
00041         jobInfoSvc = self.svc("IJobInfoSvc","JobInfoSvc")
00042         if not jobInfoSvc:
00043             self.error("Failed to initialize JobInfoSvc")
00044             return FAILURE
00045         self.currentJobId = jobInfoSvc.currentJobInfo().jobId()
00046         # Prepare list of rough tags
00047         self.tagName = { DetectorId.kAD1:'/Event/Tag/AD1RoughCoinc',
00048                          DetectorId.kAD2:'/Event/Tag/AD2RoughCoinc',
00049                          DetectorId.kAD3:'/Event/Tag/AD3RoughCoinc',
00050                          DetectorId.kAD4:'/Event/Tag/AD4RoughCoinc'}
00051         self.adList = self.tagName.keys()
00052 
00053         self.lastTimeStamp = {}
00054         # initialize lists of recent headers for each AD
00055         self.inputHeaders = {}
00056         for adId in self.adList:
00057             self.inputHeaders[adId] = []
00058         return SUCCESS
        
def Tagger::Filters::ADRoughCoincTag::ADRoughCoincTag::execute (   self)
Look for the next coincidence

Definition at line 60 of file ADRoughCoincTag.py.

00061                      :
00062         """Look for the next coincidence"""
00063         if self.unphysicalRun:
00064             return SUCCESS
00065         evt = self.evtSvc()
00066         header = evt[self.location]
00067         if not header:
00068             self.warning('cannot find header at '+self.location)
00069             return FAILURE
00070 
00071         timeStamp = header.timeStamp()
00072         detectorId = header.context().GetDetId()
00073         if not self.lastTimeStamp.has_key(detectorId):
00074             # Add new detector
00075             self.lastTimeStamp[detectorId] = TimeStamp(timeStamp)
00076 
00077         for adId in self.adList:
00078             dTS = TimeStamp(timeStamp)
00079             dT_AD = 0
00080             if self.lastTimeStamp.has_key(adId):
00081                 dTS.Subtract(self.lastTimeStamp[adId])
00082                 dT_AD = dTS.GetSeconds() * units.second
00083             if dT_AD > self.dTCut:
00084                 # Done with with AD, Process tag
00085                 inputHeaders = self.inputHeaders[adId]
00086                 if len( inputHeaders ) >= 2:
00087                     # Save this coincidence
00088                     tagName = self.tagName[adId]
00089                     currentTag = gbl.DayaBay.HeaderObject()
00090                     gbl.SetOwnership(currentTag,False)
00091                     # Set header basic info
00092                     currentTag.setExecNumber(inputHeaders[0].execNumber())
00093                     currentTag.setContext(inputHeaders[0].context())
00094                     currentTag.setEarliest(inputHeaders[0].earliest())
00095                     currentTag.setLatest(inputHeaders[0].latest())
00096                     currentTag.setJobId(self.currentJobId)
00097                     # Add references to tagged events
00098                     for inputHeader in inputHeaders:
00099                         currentTag.addInputHeader( inputHeader )
00100                         # Extend time range if needed
00101                         if inputHeader.earliest()<currentTag.earliest():
00102                             currentTag.setEarliest(inputHeader.earliest())
00103                         if inputHeader.latest()>currentTag.latest():
00104                             currentTag.setLatest(inputHeader.latest())
00105                     evt[tagName] = currentTag
00106                     self.nCoincidences+=1
00107                     self.nKept += len(inputHeaders)
00108                 for inputHeader in inputHeaders:
00109                     inputHeader.release()
00110                 self.inputHeaders[adId] = []
00111 
00112         if detectorId in self.adList:
00113             # Add AD events to recent headers
00114             # First, apply rough prompt muon veto
00115             muonVeto = False
00116             if (self.lastTimeStamp.has_key(DetectorId.kIWS)
00117                 and self.lastTimeStamp.has_key(DetectorId.kOWS)):
00118                 # Calculate time to last IWS/OWS triggers
00119                 dTS = TimeStamp(timeStamp)
00120                 dTS.Subtract( self.lastTimeStamp[DetectorId.kIWS] )
00121                 dT_IWS = dTS.GetSeconds() * units.second
00122                 dTS = TimeStamp(timeStamp)
00123                 dTS.Subtract( self.lastTimeStamp[DetectorId.kOWS] )
00124                 dT_OWS = dTS.GetSeconds() * units.second
00125                 # Check prompt time veto
00126                 if dT_IWS < self.dTMuonVeto and dT_OWS < self.dTMuonVeto:
00127                     muonVeto = True
00128             # If it's not a prompt muon, keep it
00129             if not muonVeto:
00130                 header.addRef()
00131                 self.inputHeaders[detectorId] += [ header ]
00132                 self.nSeen += 1
00133                 # Catch unphysical run conditions
00134                 isHighMultiplicity = (self.nCoincidences<5
00135                                       and ( len(self.inputHeaders[detectorId])
00136                                             >self.unphysicalMultiplicity) )
00137                 isHighCoincFraction = (self.nSeen>100
00138                                        and ( (self.nKept/float(self.nSeen))
00139                                              >self.maxCoincFraction) )       
00140                 if (isHighMultiplicity or isHighCoincFraction):
00141                     for adId in self.adList:
00142                         for iHeader in self.inputHeaders[adId]:
00143                             iHeader.release()
00144                         self.inputHeaders[adId]=[]
00145                         self.warning("Disabling AD Rough Coincidence tag due to unphysical AD event rate after %d triggers" % self.nSeen)
00146                         self.unphysicalRun=True
00147 
00148         # Record last trigger time from each detector        
00149         self.lastTimeStamp[detectorId] = TimeStamp(timeStamp)
00150         return SUCCESS
00151 

def Tagger::Filters::ADRoughCoincTag::ADRoughCoincTag::finalize (   self)

Definition at line 152 of file ADRoughCoincTag.py.

00153                       :
00154         self.info("finalizing")
00155         for adId in self.adList:
00156             for inputHeader in self.inputHeaders[adId]:
00157                 inputHeader.release()
00158             self.inputHeaders[adId] = []
00159         status = DybPythonAlg.finalize(self)
00160         
00161         return status
00162 
        

Member Data Documentation

Definition at line 22 of file ADRoughCoincTag.py.

Definition at line 22 of file ADRoughCoincTag.py.

Definition at line 22 of file ADRoughCoincTag.py.

Definition at line 22 of file ADRoughCoincTag.py.

Definition at line 22 of file ADRoughCoincTag.py.

Definition at line 22 of file ADRoughCoincTag.py.

Definition at line 22 of file ADRoughCoincTag.py.

Definition at line 22 of file ADRoughCoincTag.py.

Definition at line 22 of file ADRoughCoincTag.py.

Definition at line 36 of file ADRoughCoincTag.py.

Definition at line 36 of file ADRoughCoincTag.py.

Definition at line 36 of file ADRoughCoincTag.py.

Definition at line 36 of file ADRoughCoincTag.py.

Definition at line 36 of file ADRoughCoincTag.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 09:54:18 for Tagger by doxygen 1.7.4