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

List of all members.

Public Member Functions

def __init__
def initialize
def execute
def finalize

Public Attributes

 cableSvc

Detailed Description

Definition at line 28 of file EnergyStats.py.


Constructor & Destructor Documentation

def EnergyStats::EnergyStatsAlg::__init__ (   self,
  name 
)

Definition at line 30 of file EnergyStats.py.

00031                            :
00032         DybPythonAlg.__init__(self,name)
00033         return


Member Function Documentation

def EnergyStats::EnergyStatsAlg::initialize (   self)

Definition at line 34 of file EnergyStats.py.

00035                         :
00036         status = DybPythonAlg.initialize(self)
00037         if status.isFailure(): return status
00038         self.info("initializing")
00039 
00040         self.cableSvc = self.svc('ICableSvc','CableSvc')
00041         if self.cableSvc == None:
00042             self.error("Failed to get CableSvc")
00043             return FAILURE
00044 
00045         # Make energy histograms
00046         hist = TH1F("genEnergy","Generated Particle Energy",100,937.0,940.0)
00047         hist.GetXaxis().SetTitle("Particle Energy [MeV]")
00048         hist.GetYaxis().SetTitle("Generated Particles")
00049         hist.SetLineColor(4)
00050         self.stats["/file0/energy/genEnergy"] = hist
00051 
00052          
00053         hist = TH1F("genKineticEnergy","Generated Particle Kinetic Energy",
00054                     100,0.0,10.0)
00055         hist.GetXaxis().SetTitle("Particle Kinetic Energy [MeV]")
00056         hist.GetYaxis().SetTitle("Generated Particles")
00057         hist.SetLineColor(4)
00058         self.stats["/file0/energy/genKineticEnergy"] = hist
00059 
00060         hist = TH1F("simScintEnergy","Energy deposited in Scintillator",
00061                     500,0.0,10.0)
00062         hist.GetXaxis().SetTitle("Ionization Energy [MeV]")
00063         hist.GetYaxis().SetTitle("Simulated Events")
00064         hist.SetLineColor(4)
00065         self.stats["/file0/energy/simScintEnergy"] = hist
00066         
00067         hist = TH1F("simQuenchedEnergy","Quenched Energy in Scintillator",
00068                     500,0.0,10.0)
00069         hist.GetXaxis().SetTitle("Quenched Ionization Energy [MeV]")
00070         hist.GetYaxis().SetTitle("Simulated Events")
00071         hist.SetLineColor(4)
00072         self.stats["/file0/energy/simQuenchedEnergy"] = hist
00073         
00074         hist = TH2F("simQuenching",
00075                     "Quenching vs. Total Energy in Scintillator",
00076                     300,0.0,10.0,
00077                     300,0.0,1.5)
00078         hist.GetXaxis().SetTitle("Ionization Energy [MeV]")
00079         hist.GetYaxis().SetTitle("Quenched Energy / Ionization Energy")
00080         self.stats["/file0/energy/simQuenching"] = hist
00081 
00082         hist = TH1F("simHits","Number of Simulated Hits on PMTs",
00083                     500,0.0,2000)
00084         hist.GetXaxis().SetTitle("Simulated Number of Photoelectrons [NPE]")
00085         hist.GetYaxis().SetTitle("Simulated Events")
00086         hist.SetLineColor(4)
00087         self.stats["/file0/energy/simHits"] = hist
00088 
00089         hist = TH2F("simHitsVsQE",
00090                     "Number of Simulated Hits vs. Quenched Energy",
00091                     200,0.0,10.0,
00092                     200,0.0,200)
00093         hist.GetXaxis().SetTitle("Quenched Energy [MeV]")
00094         hist.GetYaxis().SetTitle("Photelectrons / Quenched Energy")
00095         self.stats["/file0/energy/simHitsVsQE"] = hist
00096 
00097         hist = TH2F("adcSumVsSimHits",
00098                     "Sum of Raw ADC vs. Number of Simulated PMT Hits",
00099                     200,0.0,2000,
00100                     200,0.0,1000.0)
00101         hist.GetXaxis().SetTitle("Simulated Number of Photoelectrons [NPE]")
00102         hist.GetYaxis().SetTitle("Raw ADC Sum / Photoelectrons")
00103         self.stats["/file0/energy/adcSumVsSimHits"] = hist
00104         
00105         hist = TH1F("calibAdcSum","Sum of Calibrated ADC",500,0.0,2000.)
00106         hist.GetXaxis().SetTitle("Sum of calibrated ADC values in AD [ADC_SPE]")
00107         hist.GetYaxis().SetTitle("Simulated Triggered Readouts")
00108         hist.SetLineColor(4)
00109         self.stats["/file0/energy/calibAdcSum"] = hist
00110         
00111         hist = TH2F("calibAdcSumVsSimHits",
00112                     "Sum of Calibrated ADC vs. Number of Simulated PMT Hits",
00113                     200,0.0,2000.0,
00114                     200,0.0,2.)
00115         hist.GetXaxis().SetTitle("Simulated Number of Photoelectrons [NPE]")
00116         hist.GetYaxis().SetTitle("Calibrated ADC Sum / Photoelectrons")
00117         self.stats["/file0/energy/calibAdcSumVsSimHits"] = hist
00118         
00119         hist = TH1F("reconEnergy","Reconstructed Energy",500,0.0,10.0)
00120         hist.GetXaxis().SetTitle("Reconstructed Visible Energy [E_rec]")
00121         hist.GetYaxis().SetTitle("Triggered Readouts")
00122         hist.SetLineColor(4)
00123         self.stats["/file0/energy/reconEnergy"] = hist
00124 
00125         hist = TH2F("calibAdcSumVsReconEnergy",
00126                     "Sum of Calibrated ADC vs. Reconstructed Energy",
00127                     200,0.0,10.0,
00128                     200,0.0,150.)
00129         hist.GetXaxis().SetTitle("Reconstructed Visible Energy [E_rec]")
00130         hist.GetYaxis().SetTitle("Calibrated ADC Sum / Reconstructed Energy")
00131         self.stats["/file0/energy/calibAdcSumVsReconEnergy"] = hist
00132         
00133         hist = TH2F("reconEnergyVsQE","Reconstructed vs. Quenched Energy",
00134                     200,0.0,10.0,
00135                     200,0.0,1.5)
00136         hist.GetXaxis().SetTitle("Quenched Energy [MeV]")
00137         hist.GetYaxis().SetTitle("Reconstructed Energy / Quenched Energy")
00138         self.stats["/file0/energy/reconEnergyVsQE"] = hist
00139 
00140         return SUCCESS

def EnergyStats::EnergyStatsAlg::execute (   self)

Definition at line 141 of file EnergyStats.py.

00142                      :
00143         self.info("executing")
00144         
00145         evt = self.evtSvc()
00146 
00147         # Generated Particle Data
00148         genHdr = evt["/Event/Gen/GenHeader"]
00149         if genHdr == None:
00150             self.error("Failed to get GenHeader")
00151             return FAILURE
00152         # Fill particle histograms
00153         totalGenEnergy = 0
00154         totalGenKineticEnergy = 0
00155         genEvt = genHdr.event()
00156         for vertex in irange(genEvt.vertices_begin(),
00157                              genEvt.vertices_end()):
00158             for particle in irange(vertex.particles_out_const_begin(),
00159                                    vertex.particles_out_const_end()):
00160                 totalGenEnergy += particle.momentum().e()
00161                 totalGenKineticEnergy += (particle.momentum().e()
00162                                           - particle.momentum().m())
00163         self.stats["/file0/energy/genEnergy"].Fill(totalGenEnergy)
00164         self.stats["/file0/energy/genKineticEnergy"].Fill(totalGenKineticEnergy)
00165 
00166         # Simulated Particle Data
00167         simHdr = evt["/Event/Sim/SimHeader"]
00168         if simHdr == None:
00169             self.error("Failed to get SimHeader")
00170             return FAILURE
00171         statsHdr = simHdr.unobservableStatistics()
00172         simScintEnergy = 0
00173         simQuenchedEnergy = 0
00174         if statsHdr == None:
00175             self.warning("No SimStatistics for this event")
00176         else:    
00177             simStats = statsHdr.stats()
00178             simScintEnergy = (simStats["EDepInGdLS"].sum()
00179                               + simStats["EDepInLS"].sum())
00180             simQuenchedEnergy = (simStats["QEDepInGdLS"].sum()
00181                                  + simStats["QEDepInLS"].sum())
00182             self.stats["/file0/energy/simScintEnergy"].Fill( simScintEnergy )
00183             self.stats["/file0/energy/simQuenchedEnergy"].Fill(
00184                                                           simQuenchedEnergy )
00185             if simScintEnergy > 0:
00186                 self.stats["/file0/energy/simQuenching"].Fill( simScintEnergy,
00187                                            simQuenchedEnergy/simScintEnergy )
00188         # Simulated Hits    
00189         hitCollectionMap = simHdr.hits().hitCollection()
00190         detector = Detector("DayaBayAD1")
00191         hitCollection = hitCollectionMap[detector.siteDetPackedData()]
00192         if hitCollection == None:
00193             self.info("No Hit Collection for "+detector.detName())
00194             return SUCCESS
00195         hits = hitCollectionMap[detector.siteDetPackedData()].collection()
00196         nSimHits = 0
00197         for hit in hits:
00198             pmtId = AdPmtSensor( hit.sensDetId() )
00199             if pmtId.ring() < 1: continue  # Skip calibration PMTs
00200             nSimHits += 1
00201         self.stats["/file0/energy/simHits"].Fill( nSimHits )
00202         if simQuenchedEnergy > 0:
00203             self.stats["/file0/energy/simHitsVsQE"].Fill( simQuenchedEnergy,
00204                                                     nSimHits/simQuenchedEnergy)
00205                                                        
00206         # Raw Readout Data
00207         readoutHdr = evt["/Event/Readout/ReadoutHeader"]
00208         if readoutHdr == None:
00209             self.error("Failed to get ReadoutHeader")
00210             return FAILURE
00211         readout = readoutHdr.readout()
00212         if readout == None:
00213             self.info("No Triggered Readout for this event")
00214             return SUCCESS
00215         adcSum = 0
00216         svcMode = ServiceMode( readoutHdr.context(), 0 )
00217         for channelPair in readout.channelReadout():
00218             channel = channelPair.second
00219             chanId = channel.channelId()
00220             pmtId = self.cableSvc.adPmtSensor( chanId, svcMode )
00221             if pmtId.ring() < 1: continue  # Skip calibration PMTs
00222             #adcSum += channel.peakAdc()
00223             adcSum += channel.peakAdc()
00224         if nSimHits > 0:
00225             self.stats["/file0/energy/adcSumVsSimHits"].Fill( nSimHits,
00226                                                           adcSum/nSimHits )
00227 
00228         # Calibrated Readout Data
00229         calibReadoutHdr = evt["/Event/CalibReadout/CalibReadoutHeader"]
00230         if calibReadoutHdr == None:
00231             self.error("Failed to get CalibReadoutHeader")
00232             return FAILURE
00233         calibReadout = calibReadoutHdr.calibReadout()
00234         if calibReadout == None:
00235             self.info("No Calibrate Readout for this event")
00236             return SUCCESS
00237         calibAdcSum = 0
00238         svcMode = ServiceMode( calibReadoutHdr.context(), 0 )
00239         for channelPair in calibReadout.channelReadout():
00240             channel = channelPair.second
00241             chanId = channel.channelId()
00242             pmtId = self.cableSvc.adPmtSensor( chanId, svcMode )
00243             if pmtId.ring() < 1: continue  # Skip calibration PMTs
00244             calibAdcSum += channel.peakAdc()
00245         self.stats["/file0/energy/calibAdcSum"].Fill( calibAdcSum )
00246         if nSimHits > 0:
00247             self.stats["/file0/energy/calibAdcSumVsSimHits"].Fill(
00248                                                           nSimHits,
00249                                                           calibAdcSum/nSimHits
00250                                                           )
00251 
00252         recHdr = evt["/Event/Rec/RecHeader"]
00253         if recHdr == None:
00254             self.error("Failed to get RecHeader")
00255             return FAILURE
00256         recResults = recHdr.recResults()
00257         recTrigger = recResults["AdSimple"]
00258         if recTrigger.energyStatus() == ReconStatus.kGood:
00259             reconEnergy = recTrigger.energy()
00260             self.stats["/file0/energy/reconEnergy"].Fill(reconEnergy)
00261             self.stats["/file0/energy/calibAdcSumVsReconEnergy"].Fill(
00262                                                        reconEnergy,
00263                                                        calibAdcSum/reconEnergy )
00264             if simQuenchedEnergy > 0:
00265                 self.stats["/file0/energy/reconEnergyVsQE"].Fill(
00266                                                 simQuenchedEnergy,
00267                                                 reconEnergy/simQuenchedEnergy )
00268             
00269         return SUCCESS
        
def EnergyStats::EnergyStatsAlg::finalize (   self)

Definition at line 270 of file EnergyStats.py.

00271                       :
00272         self.info("finalizing")
00273         status = DybPythonAlg.finalize(self)
00274         return status
00275 


Member Data Documentation

Definition at line 34 of file EnergyStats.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:49:49 for UnderstandingEnergy by doxygen 1.7.4