Public Member Functions | |
def | __init__ |
def | initialize |
def | execute |
def | finalize |
Public Attributes | |
cableSvc | |
pmtGeomSvc |
Definition at line 39 of file PmtInfoExample.py.
def PmtInfoExample::PmtInfoExampleAlg::__init__ | ( | self, | ||
name | ||||
) |
Definition at line 41 of file PmtInfoExample.py.
00041 : 00042 DybPythonAlg.__init__(self,name) 00043 return 00044 def initialize(self):
def PmtInfoExample::PmtInfoExampleAlg::initialize | ( | self | ) |
Definition at line 45 of file PmtInfoExample.py.
00045 : 00046 status = DybPythonAlg.initialize(self) 00047 if status.isFailure(): return status 00048 self.info("initializing") 00049 00050 # Prepare the services here: 00051 00052 # Cable Service: This service provides a mapping between 00053 # electronics channels and pmts in the detector. 00054 self.cableSvc = self.svc('ICableSvc','StaticCableSvc') 00055 if self.cableSvc == None: 00056 self.error("Failed to get StaticCableSvc") 00057 return FAILURE 00058 00059 # PMT Geometry Service: This service gives you information 00060 # about the PMT positions in the detectors 00061 self.pmtGeomSvc = self.svc('IPmtGeomInfoSvc','PmtGeomInfoSvc') 00062 if self.pmtGeomSvc == None: 00063 self.error("Failed to get PmtGeomInfoSvc") 00064 return FAILURE 00065 00066 # Example histogram: Count of hits on PMTs in AD 00067 self.stats["/file1/myhists/pmtHits"] = TH2F("pmtHits", 00068 "Count of PMT hits", 00069 49,-3.25,360+3.25, 00070 19,-2.5+0.125,2.5-0.125) 00071 self.stats["/file1/myhists/pmtHits"].GetXaxis().SetLabelSize(0) 00072 self.stats["/file1/myhists/pmtHits"].GetXaxis().SetTitle("PMT columns") 00073 self.stats["/file1/myhists/pmtHits"].GetYaxis().SetTitle("PMT rings [m]") 00074 00075 # Example histogram: Sum of charge on PMTs in AD 00076 self.stats["/file1/myhists/pmtCharge"] = TH2F("pmtCharge", 00077 "Sum of charge on each PMT", 00078 48,-3.25,360+3.25, 00079 19,-2.5+0.125,2.5-0.125) 00080 self.stats["/file1/myhists/pmtCharge"].GetXaxis().SetLabelSize(0) 00081 self.stats["/file1/myhists/pmtHits"].GetXaxis().SetTitle("PMT columns") 00082 self.stats["/file1/myhists/pmtHits"].GetYaxis().SetTitle("PMT rings [m]") 00083 00084 return SUCCESS 00085 def execute(self):
def PmtInfoExample::PmtInfoExampleAlg::execute | ( | self | ) |
Definition at line 86 of file PmtInfoExample.py.
00086 : 00087 self.info("executing") 00088 00089 evt = self.evtSvc() 00090 00091 # Access the Readout Header. This is a container for the readout data 00092 readoutHdr = evt["/Event/Readout/ReadoutHeader"] 00093 if readoutHdr == None: 00094 self.error("Failed to get current readout header") 00095 return FAILURE 00096 00097 # Access the Readout. This is the data from one trigger. 00098 readout = readoutHdr.readout() 00099 if readout == None: 00100 self.error("Failed to get readout from header") 00101 return FAILURE 00102 00103 # The Service mode is used to get the correct cable mapping, etc. 00104 # You set it using the context (time, location) of the current data 00105 svcMode = ServiceMode( readoutHdr.context(), 0 ) 00106 00107 # Loop over each channel data in this trigger 00108 for channelPair in readout.channelReadout(): 00109 channel = channelPair.second 00110 channelId = channel.channelId() 00111 00112 # Get the PMT ID attached to this electronics channel 00113 pmtId = self.cableSvc.adPmtSensor(channelId, svcMode) 00114 00115 # The 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 # Must use tempPmtId since we don't have SAB geometry! 00124 tempPmtId = AdPmtSensor(pmtId.ring(), pmtId.column(), 00125 Site.kDayaBay, pmtId.detectorId()) 00126 pmtGeomInfo = self.pmtGeomSvc.get( tempPmtId.fullPackedData() ) 00127 pmtXYZ = pmtGeomInfo.localPosition() 00128 00129 # Make a new coordinate 'pmtPhiPrime'. Based on PMT Phi, 00130 # but in correct orientation 00131 pmtPhi = pmtXYZ.phi() * 180/math.pi 00132 pmtZ = pmtXYZ.z() 00133 if pmtId.ring()==0: 00134 pmtZ *= -1 00135 if pmtPhi<0: pmtPhi+= 360. 00136 pmtPhiPrime = 360-pmtPhi 00137 self.stats["/file1/myhists/pmtHits"].Fill(pmtPhiPrime, 00138 pmtZ/units.m) 00139 00140 # Add the adc charge to the histogram 00141 # Loop over each ADC value 00142 for adcIdx in range( channel.size() ): 00143 adc = channel.adc( adcIdx ) 00144 adcGain = channel.adcRange( adcIdx ) 00145 # Add to total ADC sum for this trigger 00146 if adcGain == 2: 00147 # Adjust low gain adc to high gain scale 00148 adc *= 20 00149 self.stats["/file1/myhists/pmtCharge"].Fill(pmtPhiPrime, 00150 pmtZ/units.m, 00151 adc) 00152 return SUCCESS 00153 def finalize(self):
def PmtInfoExample::PmtInfoExampleAlg::finalize | ( | self | ) |
Definition at line 154 of file PmtInfoExample.py.
00154 : 00155 self.info("finalizing") 00156 # Draw Figures: 00157 pmtHits = self.stats["/file1/myhists/pmtHits"].Draw("colz") 00158 gPad.SaveAs("pmtHits.png") 00159 self.stats["/file1/myhists/pmtCharge"].Draw("colz") 00160 gPad.SaveAs("pmtCharge.png") 00161 00162 status = DybPythonAlg.finalize(self) 00163 00164 return status 00165 ##### Job Configuration for nuwa.py ########################################
Definition at line 54 of file PmtInfoExample.py.
Definition at line 61 of file PmtInfoExample.py.