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

List of all members.

Public Member Functions

def __init__
def initialize
def execute
def finalize

Public Attributes

 cableSvc
 pmtGeomSvc

Detailed Description

Definition at line 39 of file PmtInfoExample.py.


Constructor & Destructor Documentation

def PmtInfoExample::PmtInfoExampleAlg::__init__ (   self,
  name 
)

Definition at line 41 of file PmtInfoExample.py.

00042                            :
00043         DybPythonAlg.__init__(self,name)
00044         return


Member Function Documentation

def PmtInfoExample::PmtInfoExampleAlg::initialize (   self)

Definition at line 45 of file PmtInfoExample.py.

00046                         :
00047         status = DybPythonAlg.initialize(self)
00048         if status.isFailure(): return status
00049         self.info("initializing")
00050 
00051         # Prepare the services here:
00052 
00053         # Cable Service: This service provides a mapping between
00054         # electronics channels and pmts in the detector.
00055         self.cableSvc = self.svc('ICableSvc','CableSvc')
00056         if self.cableSvc == None:
00057             self.error("Failed to get CableSvc")
00058             return FAILURE
00059 
00060         # PMT Geometry Service: This service gives you information
00061         # about the PMT positions in the detectors
00062         self.pmtGeomSvc = self.svc('IPmtGeomInfoSvc','PmtGeomInfoSvc')
00063         if self.pmtGeomSvc == None:
00064             self.error("Failed to get PmtGeomInfoSvc")
00065             return FAILURE
00066 
00067         # Example histogram: Count of hits on PMTs in AD
00068         self.stats["/file1/myhists/pmtHits"] = TH2F("pmtHits",
00069                                                     "Count of PMT hits",
00070                                                     49,-3.25,360+3.25,
00071                                                     19,-2.5+0.125,2.5-0.125)
00072         self.stats["/file1/myhists/pmtHits"].GetXaxis().SetLabelSize(0)
00073         self.stats["/file1/myhists/pmtHits"].GetXaxis().SetTitle("PMT columns")
00074         self.stats["/file1/myhists/pmtHits"].GetYaxis().SetTitle("PMT rings [m]")
00075 
00076         return SUCCESS

def PmtInfoExample::PmtInfoExampleAlg::execute (   self)
Process one triggered AD Readout

Definition at line 77 of file PmtInfoExample.py.

00078                      :
00079         """Process one triggered AD Readout"""
00080         evt = self.evtSvc()
00081 
00082         # Access the Readout Header.  This is a container for the readout data
00083         readoutHdr = evt["/Event/Readout/ReadoutHeader"]
00084         if readoutHdr == None:
00085             self.error("Failed to get current readout header")
00086             return FAILURE
00087 
00088         # Access the Readout.  This is the data from one trigger.
00089         readout = readoutHdr.daqCrate().asPmtCrate()
00090         if readout == None:
00091             self.info("No PMT readout this cycle")
00092             return SUCCESS
00093 
00094         # The Service mode is used to get the correct cable mapping, etc.
00095         # You set it using the context (time, location) of the current data
00096         svcMode = ServiceMode( readoutHdr.context(), 0 )
00097 
00098         # Loop over each channel data in this trigger
00099         for channel in readout.channelReadouts():
00100             channelId = channel.channelId()
00101 
00102             # Get the PMT ID attached to this electronics channel
00103             pmtId = None
00104             if channelId.isAD():
00105                 pmtId = self.cableSvc.adPmtSensor(channelId, svcMode)
00106             elif channelId.isWaterShield():
00107                 pmtId = self.cableSvc.poolPmtSensor(channelId, svcMode)
00108                 
00109             # Skip channels not connected to a PMT
00110             if pmtId.sensorId()==0: continue
00111 
00112             # Skip water pool pmts in this example script
00113             if pmtId.isWaterShield(): continue
00114 
00115             # The AD PMT ID gives you information about the PMT:
00116             # pmtId.ring()        Ring in AD
00117             # pmtId.column()      Column in AD
00118             # pmtId.detectorId()  Detector ID 
00119             # pmtId.site()        Site ID
00120             # pmtId.detName()     Combined detector name: "SiteDetector"
00121 
00122             # Get the position of this PMT:
00123             pmtGeomInfo = self.pmtGeomSvc.get( pmtId.fullPackedData() )
00124             pmtXYZ = pmtGeomInfo.localPosition()
00125 
00126             # The PMT position is a vector of the PMT 
00127             # pmtXYZ.x()          X position in AD or water pool
00128             # pmtXYZ.y()          Y position in AD or water pool
00129             # pmtXYZ.z()          Z position in AD or water pool
00130 
00131             # Make a new coordinate 'pmtPhiPrime'.  Based on PMT Phi,
00132             # but in correct orientation
00133             pmtPhi = pmtXYZ.phi() * 180/math.pi
00134             pmtZ = pmtXYZ.z()
00135             if pmtId.ring()==0:
00136                 pmtZ *= -1
00137             if pmtPhi<0: pmtPhi+= 360.
00138             pmtPhiPrime = 360-pmtPhi
00139             self.stats["/file1/myhists/pmtHits"].Fill(pmtPhiPrime,
00140                                                       pmtZ/units.m)
00141         return SUCCESS
        
def PmtInfoExample::PmtInfoExampleAlg::finalize (   self)

Definition at line 142 of file PmtInfoExample.py.

00143                       :
00144         self.info("finalizing")
00145         # Draw Figures:
00146         pmtHits = self.stats["/file1/myhists/pmtHits"].Draw("colz")
00147         gPad.SaveAs("pmtHits.png")
00148 
00149         status = DybPythonAlg.finalize(self)
00150         
00151         return status


Member Data Documentation

Definition at line 45 of file PmtInfoExample.py.

Definition at line 45 of file PmtInfoExample.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:33 for Quickstart by doxygen 1.7.4