| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

PrintReconData.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Example script for printing reconstructed data to the terminal, and makes one histogram
00004 #
00005 # This script contains comments describing the contents of the raw data. 
00006 #
00007 #  Usage:
00008 #   nuwa.py -A None -n -1 -m"Quickstart.Calibrate" -m"Quickstart.Reconstruct" -m"Quickstart.PrintReconData" daq.NoTag.....data
00009 #
00010 #
00011 
00012 # Load DybPython
00013 from DybPython.DybPythonAlg import DybPythonAlg
00014 from GaudiPython import SUCCESS, FAILURE
00015 from GaudiPython import gbl
00016 from DybPython.Util import irange
00017 import GaudiKernel.SystemOfUnits as units
00018 
00019 # Make shortcuts to any ROOT classes you want to use
00020 TH1F = gbl.TH1F
00021 TimeStamp = gbl.TimeStamp
00022 FeeChannelId = gbl.DayaBay.FeeChannelId
00023 Detector = gbl.DayaBay.Detector
00024 
00025 #change default ROOT style
00026 gbl.gStyle.SetHistLineColor(4)
00027 gbl.gStyle.SetHistLineWidth(2)
00028 gbl.gStyle.SetMarkerColor(4)
00029 gbl.gStyle.SetMarkerStyle(8)
00030 gbl.gStyle.SetPalette(1)
00031 
00032 # Make your algorithm
00033 class PrintReconDataAlg(DybPythonAlg):
00034     "Print Reconstructed Data Example Algorithm"
00035     def __init__(self,name):
00036         DybPythonAlg.__init__(self,name)
00037         return
00038 
00039     def initialize(self):
00040         status = DybPythonAlg.initialize(self)
00041         if status.isFailure(): return status
00042         self.info("initializing")
00043 
00044         # Example histogram: Total raw ADC sum for each trigger
00045         self.stats["/file1/myhists/energy"] = TH1F("energy",
00046                                    "Reconstructed energy for each trigger",
00047                                    2000,0,20000)
00048         return SUCCESS
00049 
00050     def execute(self):
00051         self.info("executing")
00052 
00053         evt = self.evtSvc()
00054 
00055         # Access the Recon Header.  This is a container for the reconstructed data
00056         reconHdr = evt["/Event/Rec/AdSimple"]
00057         if reconHdr == None:
00058             self.error("Failed to get current recon header")
00059             return FAILURE
00060 
00061         result = reconHdr.recTrigger()
00062 
00063         # Get the detector ID for this trigger
00064         detector = result.detector()
00065         self.info("Detector Name: "+detector.detName())
00066         
00067         # Trigger Type: This is an integer of the type for this trigger
00068         self.info("Trigger Type: "+str( result.triggerType() ))
00069         # Trigger Number: A count of the trigger, according to the DAQ
00070         self.info("Trigger Number: "+str( result.triggerNumber() ))
00071         
00072         # Trigger Time: Absolute time of trigger for this raw data
00073         triggerTime = result.triggerTime()
00074         # Trigger Time [Seconds]: Trigger time in seconds from some day in 1990
00075         self.info("Trigger Time [Seconds part]: "
00076                   +str( triggerTime.GetSec() ))
00077         # Trigger Time [Nanoseconds]: Nanoseconds part of trigger time
00078         self.info("Trigger Time [Nanoseconds part]: "
00079                   +str( triggerTime.GetNanoSec() ))
00080         # Full Trigger Time: Seconds + nanoseconds
00081         # Warning: When you add this together, it will lose some precision.
00082         self.info("Full Trigger Time: "
00083                   +str( triggerTime.GetSec()
00084                         +triggerTime.GetNanoSec()*1.0e-9 ))
00085         
00086         # Energy information
00087         self.info("Energy Status: "+str( result.energyStatus() ))
00088         self.info("Energy: "+str( result.energy()/units.MeV )+" MeV")
00089         self.info("Energy Quality: "+str( result.energyQuality() ))
00090         # Add this trigger to histogram of energy
00091         self.stats["/file1/myhists/energy"].Fill( result.energy()/units.MeV )
00092         
00093         # Position information
00094         self.info("Position Status: "+str( result.positionStatus() ))
00095         self.info("Position (X,Y,Z): %f, %f, %f [mm]" % (result.position().x()/units.mm,
00096                                                          result.position().y()/units.mm,
00097                                                          result.position().z()/units.mm) )
00098         self.info("Position Quality: "+str( result.positionQuality() ))
00099         
00100         # Direction information, for tracks
00101         self.info("Direction Status: "+str( result.directionStatus() ))
00102         self.info("Direction (X,Y,Z): %f, %f, %f" % (result.direction().x(),
00103                                                      result.direction().y(),
00104                                                      result.direction().z()) )
00105         self.info("Direction Quality: "+str( result.directionQuality() ))
00106         
00107         
00108         # Covariance Matrix, if one is generated
00109         result.errorMatrix()
00110 
00111         return SUCCESS
00112         
00113     def finalize(self):
00114         self.info("finalizing")
00115         status = DybPythonAlg.finalize(self)
00116         return status
00117 
00118 #####  Job Configuration for nuwa.py ########################################
00119 
00120 def configure( argv=[] ):
00121     """ Example of processing reconstructed data """
00122 
00123     # Setup root file for output histograms
00124     from StatisticsSvc.StatisticsSvcConf import StatisticsSvc
00125     statsSvc = StatisticsSvc()
00126     statsSvc.Output = {"file1":"reconDataResult.root"}
00127     return
00128 
00129 def run(app):
00130     '''
00131     Configure and add the algorithm to job
00132     '''
00133     app.ExtSvc += ["StatisticsSvc"]
00134     myAlg = PrintReconDataAlg("MyPrintReconDataAlg")
00135     app.addAlgorithm(myAlg)
00136     pass
00137 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:11:13 2011 for Quickstart by doxygen 1.4.7