Public Member Functions | |
def | __init__ |
def | initialize |
def | execute |
def | finalize |
Public Attributes | |
statsSvc | |
simTree | |
simTime | |
nSimHits | |
maxSimHits | |
simHitPmtId | |
simHitTime |
Definition at line 20 of file ExampleTree.py.
def ExampleTree::ExampleTreeAlg::__init__ | ( | self, | ||
name | ||||
) |
Definition at line 22 of file ExampleTree.py.
00022 : 00023 DybPythonAlg.__init__(self,name) 00024 return 00025 def initialize(self):
def ExampleTree::ExampleTreeAlg::initialize | ( | self | ) |
Definition at line 26 of file ExampleTree.py.
00026 : 00027 status = DybPythonAlg.initialize(self) 00028 if status.isFailure(): return status 00029 self.info("initializing") 00030 00031 # Initialize services 00032 # Statistics Service: Use for histograms, graphs, trees 00033 self.statsSvc = self.svc('IStatisticsSvc','StatisticsSvc') 00034 if self.statsSvc == None: 00035 self.error("Failed to initialize statistics service.") 00036 return FAILURE 00037 00038 # Make a tree 00039 self.simTree= TTree("simTree","Tree of Simulated Hits") 00040 00041 # Make branch addresses for single-numbers. 'i'=int, 'd'=double 00042 self.simTime = array('d',[0]) 00043 self.nSimHits = array('i',[0]) 00044 # Make branch addresses for array branches 00045 self.maxSimHits = 4096 00046 self.simHitPmtId = array('i',self.maxSimHits*[0]) 00047 self.simHitTime = array('d',self.maxSimHits*[0]) 00048 00049 # Make Branches 00050 self.simTree.Branch('simTime',self.simTime,'simTimeSec/D') 00051 self.simTree.Branch('nSimHits',self.nSimHits,'nSimHits/I') 00052 self.simTree.Branch('simHitPmtId',self.simHitPmtId, 00053 'simHitPmtId[nSimHits]/I') 00054 self.simTree.Branch('simHitTime',self.simHitTime, 00055 'simHitTime[nSimHits]/D') 00056 00057 status = self.statsSvc.put('/file0/sim/simTree', self.simTree) 00058 if status.isFailure(): return status 00059 00060 return SUCCESS 00061 def execute(self):
def ExampleTree::ExampleTreeAlg::execute | ( | self | ) |
Definition at line 62 of file ExampleTree.py.
00062 : 00063 self.info("executing") 00064 00065 # Access current data 00066 evt = self.evtSvc() 00067 simHdr = evt["/Event/Sim/SimHeader"] 00068 if simHdr == None: 00069 self.error("Failed to get current sim header") 00070 return FAILURE 00071 00072 # Set Branch values 00073 self.simTime[0] = simHdr.timeStamp().GetSeconds() 00074 # Loop over hits in each detector 00075 shh = simHdr.hits() 00076 hitCollectionMap = shh.hitCollection() 00077 nHits = 0 00078 for shcPair in irange(hitCollectionMap.begin(), 00079 hitCollectionMap.end()): 00080 detectorId = shcPair.first 00081 hitCollection = shcPair.second 00082 self.info( "Found %d hits for detector %d" 00083 % ( hitCollection.collection().size(), 00084 detectorId ) 00085 ) 00086 for hit in hitCollection.collection(): 00087 self.simHitPmtId[nHits] = hit.sensDetId() 00088 self.simHitTime[nHits] = hit.hitTime() 00089 nHits += 1 00090 self.nSimHits[0] = nHits 00091 00092 # Fill the tree with current branch values 00093 self.simTree.Fill() 00094 00095 return SUCCESS 00096 def finalize(self):
def ExampleTree::ExampleTreeAlg::finalize | ( | self | ) |
Definition at line 97 of file ExampleTree.py.
00097 : 00098 self.info("finalizing") 00099 status = DybPythonAlg.finalize(self) 00100 return status 00101 00102 ##### Job Configuration for nuwa.py ########################################
Definition at line 33 of file ExampleTree.py.
Definition at line 39 of file ExampleTree.py.
Definition at line 42 of file ExampleTree.py.
Definition at line 43 of file ExampleTree.py.
Definition at line 45 of file ExampleTree.py.
Definition at line 46 of file ExampleTree.py.
Definition at line 47 of file ExampleTree.py.