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

List of all members.

Public Member Functions

def __init__
def initTagList
def check

Public Attributes

 dTCut
 vertexCut
 ratioQCut
 location
 muonVetoTime
 adMuonEnergyCut
 promptLowCut
 promptHighCut
 delayedLowCut
 delayedHighCut
 timeWindowLow
 timeWindowHigh
 tRmsCut
 detId
 inputHeaders
 lastTriggerTime
 lastPromptTime
 lastDelayedTime
 lastMuonTime
 lastWasPrompt
 stage
 freshStart

Detailed Description

Definition at line 19 of file AmCTag.py.


Constructor & Destructor Documentation

def CalibrationTagging::AmCTag::AmCTag::__init__ (   self,
  name 
)

Definition at line 22 of file AmCTag.py.

00023                             :
00024         UserTaggingAlg.__init__(self, name)
00025         
00026         self.dTCut = 200*units.microsecond
00027         self.vertexCut = 1*units.meter
00028         self.ratioQCut = 0.25
00029         self.location = "/Event/Rec/AdSimple"
00030         self.muonVetoTime = 1000*units.microsecond
00031         self.adMuonEnergyCut = 20*units.MeV
00032         self.promptLowCut   = 0.5*units.MeV
00033         self.promptHighCut  = 2.0*units.MeV
00034         self.delayedLowCut  = 6.5*units.MeV
00035         self.delayedHighCut = 9.5*units.MeV
00036         self.timeWindowLow  = -1640 #ns
00037         self.timeWindowHigh = -1450 #ns
00038         self.tRmsCut = 30 
            

Member Function Documentation

def CalibrationTagging::AmCTag::AmCTag::initTagList (   self)

Definition at line 40 of file AmCTag.py.

00041                          :
00042         self.detId = [
00043             gbl.DetectorId.kAD1,
00044             gbl.DetectorId.kAD2,
00045             gbl.DetectorId.kAD3,
00046             gbl.DetectorId.kAD4]
00047         self.inputHeaders = {}
00048         self.lastTriggerTime = {}  # dict
00049         self.lastPromptTime = {}  # dict
00050         self.lastDelayedTime = {} # dict
00051         self.lastMuonTime = {}
00052         self.lastWasPrompt = {}
00053         self.stage = {}  # 0: looking for prompt
00054                          # 1: prompt found, looking for delayed
00055                          # 2: delayed found, ensuring clearance
00056                          # 3: pair found!
00057         self.freshStart = {}
00058         for id in self.detId:
00059             self.inputHeaders[id] = []
00060             self.freshStart[id] = True
00061             self.lastWasPrompt[id] = False
00062             self.stage[id] = 0
00063 
00064         self.addTag('AmC' , '/Event/Tag/Calib/AmC')
00065         return
        
def CalibrationTagging::AmCTag::AmCTag::check (   self,
  evt 
)

Definition at line 67 of file AmCTag.py.

00068                         :
00069         print '='*80
00070         recHeader = evt['/Event/Rec/AdSimple']
00071         if not recHeader:
00072             self.warning('Failed to get current recon header')
00073             return FAILURE
00074 
00075         # Access the Calib Readout Header.
00076         # This is a container for calibrated data
00077         calibHdr = evt["/Event/CalibReadout/CalibReadoutHeader"]
00078         if calibHdr == None:
00079             self.error("Failed to get current calib readout header")
00080             return FAILURE
00081 
00082         # Access the Readout.  This is the calibrated data from one trigger.
00083         calibReadout = calibHdr.calibReadout()
00084         if calibReadout == None:
00085             self.error("Failed to get calibrated readout from header")
00086             return FAILURE
00087 
00088         recResult = recHeader.recTrigger()
00089         triggerTime = recResult.triggerTime()
00090         detectorId = recHeader.context().GetDetId()
00091 
00092         # Fresh start: assume first event is muon
00093         if not detectorId in self.lastMuonTime.keys(): #self.detId and self.freshStart[detectorId]:
00094             self.lastMuonTime[detectorId] = triggerTime
00095             self.lastTriggerTime[detectorId] = triggerTime
00096             self.freshStart[detectorId] = False
00097             print 'Fresh Start!',detectorId
00098             return SUCCESS
00099 
00100         # Treat all non-AD triggers as muons
00101         if not detectorId in self.detId:
00102 #            for id in self.detId:
00103 #              self.lastMuonTime[id] = triggerTime
00104 #            print 'Treat all non-AD triggers as muons.'
00105             print 'Ignore all non-AD triggers.'
00106             return SUCCESS
00107 
00108         print triggerTime.AsString(), detectorId
00109         print 'Last trigger time:',self.lastTriggerTime[detectorId].AsString()
00110         print 'Last muon time:',self.lastMuonTime[detectorId].AsString()
00111         timeSinceMu = gbl.TimeStamp( recResult.triggerTime() )
00112         timeSinceMu.Subtract(self.lastMuonTime[detectorId])
00113         timeSinceTrig = gbl.TimeStamp( recResult.triggerTime() )
00114         timeSinceTrig.Subtract(self.lastTriggerTime[detectorId])
00115 
00116         reject = False
00117         # Get Recon info
00118         recES = recResult.energyStatus() 
00119         recE = recResult.energy()
00120         recPS = recResult.positionStatus()
00121         recX = recResult.position().x()
00122         recY = recResult.position().y()
00123         recZ = recResult.position().z()
00124 
00125         # Fix for wrong energy scale
00126         recE *= 184./160.
00127 
00128         # Ignore triggers with failed recon
00129         if not reject and recPS != 1:
00130           print 'Position recon failed. Trigger ignored'
00131           reject = True
00132         if not reject and recES != 1:
00133           print 'Energy recon failed. Trigger ignored'
00134           reject = True
00135 
00136         # Calculate charge sum and other quantities
00137         maxQ = None
00138         sumQ = 0 
00139         nChan = 0 
00140         meanT = 0 
00141         meanT2 = 0 
00142         for channel in calibReadout.channelReadout():
00143           q = 0 
00144           for hitIdx in range( channel.size() ):
00145             hitTime = channel.time( hitIdx )
00146             hitCharge = channel.charge( hitIdx )
00147             if hitTime > self.timeWindowLow and hitTime < self.timeWindowHigh:
00148               nChan += 1
00149               q = hitCharge
00150               meanT += hitTime
00151               meanT2 += hitTime * hitTime
00152               break
00153           if not maxQ or maxQ < q: maxQ = q 
00154           sumQ += q
00155         if sumQ != 0 and nChan > 0:
00156           ratioQ = maxQ/sumQ
00157           meanT /= nChan
00158           meanT2 /= nChan
00159           Trms = math.sqrt(meanT2-meanT*meanT)
00160         else:
00161           ratioQ = meanT = meanT2 = Trms = -1
00162 
00163 #        # Get ratio Max(Q)/Sum(Q)
00164 #        #ratioMaxQ < 0.25
00165 #        maxQ = None
00166 #        sumQ = 0
00167 #        for channel in calibReadout.channelReadout():
00168 #          q = 0
00169 #          for hitIdx in range( channel.size() ):
00170 #            hitTime = channel.time( hitIdx )
00171 #            hitCharge = channel.charge( hitIdx )
00172 #            if hitTime > -1640 and hitTime < -1450:
00173 #              q = hitCharge
00174 #              break
00175 #          if not maxQ or maxQ < q: maxQ = q
00176 #          sumQ += q
00177 #        if sumQ != 0:
00178 #          ratioQ = maxQ/sumQ
00179 #        else:
00180 #          ratioQ = 0
00181 
00182 #        # Max/Sum cut
00183 #        if not reject and (ratioQ > self.ratioQCut or sumQ == 0):
00184 #          print 'Max(Q)/Sum(Q)','=', ratioQ,'>', self.ratioQCut, '. Trigger ignored.'
00185 #          reject = True
00186 
00187         # Muon trigger? If so, start veto
00188         isMuon = False
00189         #isMuon = evt['/Event/Tag/Physics/MuonLoose']
00190         if recE > self.adMuonEnergyCut:
00191           isMuon = True
00192           
00193         if isMuon:
00194           print 'Loose Muon in',detectorId, '. Start veto:', self.muonVetoTime
00195           reject = True
00196 
00197         # Muon veto
00198         if not reject:
00199           if timeSinceMu.GetSeconds() * units.second < self.muonVetoTime:
00200             print 'Muon veto on. Trigger ignored', detectorId
00201             reject = True
00202 
00203         # Discard non-physics events
00204         if not reject and nChan == 0:
00205           print 'No hits selected in hit time window. Ignored.'
00206           reject = True
00207         if not reject and ratioQ > self.ratioQCut:
00208           print 'Max(Q)/Sum(Q)','=', ratioQ,'>', self.ratioQCut, '. Ignored.'
00209           reject = True
00210         if not reject and Trms > self.tRmsCut:
00211           print 'tRms =', Trms,'>',self.tRmsCut, '. Ignored.'
00212           reject = True
00213 
00214 
00215         # Energy cut for identifying prompt or delayed signal
00216         isPrompt = False
00217         isDelayed = False
00218         if not reject:
00219           if recE > self.promptLowCut and recE < self.promptHighCut:
00220             isPrompt = True
00221             print 'Prompt candidate'
00222           if recE > self.delayedLowCut and recE < self.delayedHighCut: 
00223             if self.stage[detectorId] == 1:
00224               promptRecResult = self.inputHeaders[detectorId][0].recTrigger() 
00225               pRecX = promptRecResult.position().x()
00226               pRecY = promptRecResult.position().y()
00227               pRecZ = promptRecResult.position().z()
00228               deltaX = (pRecX - recX)
00229               deltaY = (pRecY - recY)
00230               deltaZ = (pRecZ - recZ)
00231               deltaVertex2 = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ
00232               if deltaVertex2 < self.vertexCut*self.vertexCut:
00233                 isDelayed = True
00234               else:
00235                 print 'rejected by vertex cut'
00236             else:
00237               isDelayed = True
00238             if isDelayed: print 'Delayed candidate'
00239 
00240         # Timing coincidence 
00241         print 'Stage', self.stage
00242         if reject:
00243           if self.stage[detectorId] == 1:
00244             self.stage[detectorId] = 0
00245             self.inputHeaders[detectorId] = []
00246             print '1->0'
00247         else:
00248 #          print 'Current trigger time:',triggerTime.AsString()
00249 #          print 'Last trigger time:',self.lastTriggerTime[detectorId].AsString()
00250 #          print 'Last muon time:',self.lastMuonTime[detectorId].AsString()
00251           print 'dT =', timeSinceTrig.GetSeconds(), 'second'
00252           # Stage 1->2/0
00253           if self.stage[detectorId] == 1:
00254             if isDelayed and timeSinceTrig.GetSeconds() * units.second < self.dTCut:
00255               self.inputHeaders[detectorId].append(recHeader)
00256               self.stage[detectorId] = 2
00257               print '1->2'
00258             else:
00259               self.stage[detectorId] = 0
00260               self.inputHeaders[detectorId] = []
00261               print '1->0'
00262           # Stage 2->3/0 
00263           elif self.stage[detectorId] == 2:
00264             if timeSinceTrig.GetSeconds() * units.second > self.dTCut:
00265               self.stage[detectorId] = 3
00266               print '2->3'
00267               # save tag
00268               myTag = self.getTag('AmC')
00269               print 'Length of self.inputheaders', len(self.inputHeaders[detectorId])
00270               myTag.setInputHeaders(self.inputHeaders[detectorId])
00271               myTag.tagIt()
00272               self.inputHeaders[detectorId] = []
00273               self.stage[detectorId] = 0
00274               print 'Tag saved!'
00275               print '3->0'
00276             else:
00277               self.stage[detectorId] = 0
00278               self.inputHeaders[detectorId] = []
00279               print '2->0'
00280           # Stage 0->1
00281           if isPrompt and self.stage[detectorId] == 0 and timeSinceTrig.GetSeconds() * units.second > self.dTCut:
00282             self.inputHeaders[detectorId].append(recHeader)
00283             self.stage[detectorId] = 1
00284             print '0->1'
00285 
00286 
00287         if isMuon:
00288             self.lastMuonTime[detectorId] = triggerTime
00289         self.lastTriggerTime[detectorId] = recResult.triggerTime()
00290         return SUCCESS
        

Member Data Documentation

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 22 of file AmCTag.py.

Definition at line 40 of file AmCTag.py.

Definition at line 40 of file AmCTag.py.

Definition at line 40 of file AmCTag.py.

Definition at line 40 of file AmCTag.py.

Definition at line 40 of file AmCTag.py.

Definition at line 40 of file AmCTag.py.

Definition at line 40 of file AmCTag.py.

Definition at line 40 of file AmCTag.py.

Definition at line 40 of file AmCTag.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:08 for CalibrationTagging by doxygen 1.7.4