Public Member Functions | |
def | __init__ |
def | initialize |
def | execute |
def | finalize |
Public Attributes | |
hist | |
target_de_name | |
coorSvc | |
histSvc | |
statsSvc |
Definition at line 20 of file __init__.py.
def chkGamma::__init__::plotGammaBasics::__init__ | ( | self, | ||
name | ||||
) |
Definition at line 22 of file __init__.py.
00022 : 00023 GaudiAlgo.__init__(self,name) 00024 self.hist = {} 00025 return 00026 def initialize(self):
def chkGamma::__init__::plotGammaBasics::initialize | ( | self | ) |
Definition at line 27 of file __init__.py.
00027 : 00028 print "Initializing the gamma basic ploter", self.name() 00029 status = GaudiAlgo.initialize(self) 00030 if status.isFailure(): return status 00031 self.target_de_name = '/dd/Structure/AD/db-ade1/db-sst1/db-oil1' 00032 # self.target_de_name = '/dd/Structure/AD/db-oil1' 00033 00034 # What services do you need? 00035 self.coorSvc = self.svc('ICoordSysSvc', 'CoordSysSvc') 00036 if not self.coorSvc: 00037 print 'Failed to get CoordSysSvc' 00038 return FAILURE 00039 00040 # self.histSvc = self.svc('ITHistSvc', 'THistSvc') 00041 00042 self.statsSvc = self.svc('IStatisticsSvc','StatisticsSvc') 00043 if self.statsSvc == None: 00044 self.error("Failed to initialize IStat service.") 00045 return FAILURE 00046 00047 self.hist["genRZ"] = TH2D("genRZ", "Generation Vertex R-Z", \ 00048 100, 0.0, 6.1504, 100, -2.48, 2.48) 00049 status = self.statsSvc.put('/file1/basics/genRZ', \ 00050 self.hist["genRZ"]) 00051 if status.isFailure(): return status 00052 00053 self.hist["genXY"] = TH2D("genXY", "Generation Vertex X-Y", \ 00054 100, -2.48, 2.48, 100, -2.48, 2.48) 00055 status = self.statsSvc.put('/file1/basics/genXY', \ 00056 self.hist["genXY"]) 00057 if status.isFailure(): return status 00058 00059 self.hist["HitTime"] = TH1F("HitTime", "Hit Time", 00060 100, 0.0, 100) 00061 status = self.statsSvc.put('/file1/basics/HitTime', 00062 self.hist["HitTime"]) 00063 if status.isFailure(): return status 00064 00065 self.hist["peGen_GdLS"] = TH1F("peGen_GdLS", "pe of a gamma (in GdLS)", 00066 500, 0, 1400) 00067 status = self.statsSvc.put('/file1/basics/peGen_GdLS', 00068 self.hist["peGen_GdLS"]) 00069 if status.isFailure(): return status 00070 00071 self.hist["peGen_LS"] = TH1F("peGen_LS", 00072 "pe of a gamma(in LS)", 00073 500, 0, 1400) 00074 status = self.statsSvc.put('/file1/basics/peGen_LS', 00075 self.hist["peGen_LS"]) 00076 if status.isFailure(): return status 00077 00078 self.hist["peGen_inLS"] = TH1F("peGen_inLS", 00079 "pe of a gamma (within LS)", 00080 500, 0, 1400) 00081 status = self.statsSvc.put('/file1/basics/peGen_inLS', 00082 self.hist["peGen_inLS"]) 00083 if status.isFailure(): return status 00084 00085 self.hist["peGen_MO"] = TH1F("peGen_MO", 00086 "pe of a gamma (in MO)", 00087 500, 0, 1400) 00088 status = self.statsSvc.put('/file1/basics/peGen_MO', 00089 self.hist["peGen_MO"]) 00090 if status.isFailure(): return status 00091 00092 self.hist["peGen_all"] = TH1F("peGen_all", 00093 "pe of a gamma (in AD)", 00094 500, 0, 1400) 00095 status = self.statsSvc.put('/file1/basics/peGen_all', 00096 self.hist["peGen_all"]) 00097 if status.isFailure(): return status 00098 00099 self.hist["peCap_GdLS"] = TH1F("peCap_GdLS", 00100 "pe of a gamma stop in GdLS", 00101 500, 0, 1400) 00102 status = self.statsSvc.put('/file1/basics/peCap_GdLS', 00103 self.hist["peCap_GdLS"]) 00104 if status.isFailure(): return status 00105 00106 self.hist["peCap_LS"] = TH1F("peCap_LS", 00107 "pe of a gamma stop in LS", 00108 500, 0, 1400) 00109 status = self.statsSvc.put('/file1/basics/peCap_LS', 00110 self.hist["peCap_LS"]) 00111 if status.isFailure(): return status 00112 00113 self.hist["peCap_MO"] = TH1F("peCap_MO", 00114 "pe of a gamma stop in MO", 00115 500, 0, 1400) 00116 status = self.statsSvc.put('/file1/basics/peCap_MO', 00117 self.hist["peCap_MO"]) 00118 if status.isFailure(): return status 00119 00120 self.hist["peGenCap_GdLS"] = TH1F("peGenCap_GdLS", 00121 "pe of a gamma in AD", 00122 500, 0, 1400) 00123 status = self.statsSvc.put('/file1/basics/peGenCap_GdLS', 00124 self.hist["peGenCap_GdLS"]) 00125 if status.isFailure(): return status 00126 00127 self.hist["eDepInGdLS"] = TH1D("eDepInGdLS", "Deposited Energy [MeV]", 00128 70, 0, 7) 00129 status = self.statsSvc.put('/file1/basics/eDepInGdLS', 00130 self.hist["eDepInGdLS"]) 00131 if status.isFailure(): return status 00132 00133 self.hist["eDepInLS"] = TH1D("eDepInLS", "Deposited Energy [MeV]", 00134 70, 0, 7) 00135 status = self.statsSvc.put('/file1/basics/eDepInLS', 00136 self.hist["eDepInLS"]) 00137 if status.isFailure(): return status 00138 00139 self.hist["eDepInAD"] = TH1D("eDepInAD", "Deposited Energy [MeV]", 00140 700, 0, 7) 00141 status = self.statsSvc.put('/file1/basics/eDepInAD', 00142 self.hist["eDepInAD"]) 00143 if status.isFailure(): return status 00144 00145 self.hist["eInitial"] = TH1D("eInitial", "Intial Energy [MeV]", 00146 70, 0, 7) 00147 status = self.statsSvc.put('/file1/basics/eInitial', 00148 self.hist["eInitial"]) 00149 if status.isFailure(): return status 00150 00151 self.hist["drift_Gamma"] = TH1F("drift_Gamma", 00152 "Gamma Drift Distance [cm]", 00153 250, 0, 250) 00154 status = self.statsSvc.put('/file1/basics/drift_Gamma', 00155 self.hist["drift_Gamma"]) 00156 if status.isFailure(): return status 00157 00158 self.hist["drift_GdLS"] = TH1F("drift_GdLS", 00159 "Gamma Drift Distance in GdLS [cm]", 00160 250, 0, 250) 00161 status = self.statsSvc.put('/file1/basics/drift_GdLS', 00162 self.hist["drift_GdLS"]) 00163 if status.isFailure(): return status 00164 00165 self.hist["drift_LS"] = TH1F("drift_LS", 00166 "Gamma Drift Distance in LS [cm]", 00167 250, 0, 250) 00168 status = self.statsSvc.put('/file1/basics/drift_LS', 00169 self.hist["drift_LS"]) 00170 if status.isFailure(): return status 00171 00172 self.hist["time_GdLS"] = TH1F("time_GdLS", 00173 "Gamma drift time in GdLS [ns]", 00174 40, 0, 20) 00175 status = self.statsSvc.put('/file1/basics/time_GdLS', 00176 self.hist["time_GdLS"]) 00177 if status.isFailure(): return status 00178 00179 self.hist["time_LS"] = TH1F("time_LS", 00180 "Gamma Capture Time in LS [ns]", 00181 40, 0, 20) 00182 status = self.statsSvc.put('/file1/basics/time_LS', 00183 self.hist["time_LS"]) 00184 if status.isFailure(): return status 00185 00186 return SUCCESS 00187 def execute(self):
def chkGamma::__init__::plotGammaBasics::execute | ( | self | ) |
Definition at line 188 of file __init__.py.
00188 : 00189 print "Executing plotGammaBasics", self.name() 00190 evt = self.evtSvc() 00191 simhdr = evt['/Event/Sim/SimHeader'] 00192 00193 det = self.detSvc(self.target_de_name) 00194 00195 # Unobservables 00196 statshdr = simhdr.unobservableStatistics() 00197 stats = statshdr.stats() 00198 tGen = stats["t_Trk1"].sum() 00199 xGen = stats["x_Trk1"].sum() 00200 yGen = stats["y_Trk1"].sum() 00201 zGen = stats["z_Trk1"].sum() 00202 00203 tCap = stats["tEnd_Trk1"].sum() 00204 xCap = stats["xEnd_Trk1"].sum() 00205 yCap = stats["yEnd_Trk1"].sum() 00206 zCap = stats["zEnd_Trk1"].sum() 00207 00208 # Get underlying DE object 00209 de = self.getDet(self.target_de_name) 00210 if not de: 00211 print 'Failed to get DE',self.target_de_name 00212 return FAILURE 00213 00214 # Get the AD coordinates of the vertexes 00215 import PyCintex 00216 Gaudi = PyCintex.makeNamespace('Gaudi') 00217 genGlbPoint = Gaudi.XYZPoint(xGen, yGen, zGen) 00218 capGlbPoint = Gaudi.XYZPoint(xCap, yCap, zCap) 00219 # point = de.geometry().toGlobal(point) 00220 genLclPoint = de.geometry().toLocal(genGlbPoint) 00221 capLclPoint = de.geometry().toLocal(capGlbPoint) 00222 # print 'Current point is [',point.x(),point.y(),point.z(),']' 00223 # print 'In global coordinate [',gpoint.x(),gpoint.y(),gpoint.z(),']' 00224 00225 ndrift = ROOT.TVector3(xCap-xGen, yCap-yGen, zCap-zGen) 00226 00227 capTime = tCap - tGen 00228 capDis = ndrift.Mag() 00229 00230 print 'Generation locations', \ 00231 '[', genGlbPoint.x(), genGlbPoint.y(), genGlbPoint.z(),']', \ 00232 '[', genLclPoint.x()/units.cm, genLclPoint.y()/units.cm, genLclPoint.z()/units.cm,']' 00233 00234 self.hist["genRZ"].Fill(genLclPoint.x()/units.meter * genLclPoint.x()/units.meter + genLclPoint.y()/units.meter * genLclPoint.y()/units.meter, genLclPoint.z()/units.meter) 00235 00236 self.hist["genXY"].Fill(genLclPoint.x()/units.meter,genLclPoint.y()/units.meter) 00237 00238 self.hist["drift_Gamma"].Fill(capDis/units.cm) 00239 00240 # Find the interesting volumes 00241 genDE = self.coorSvc.coordSysDE(genGlbPoint) 00242 capDE = self.coorSvc.coordSysDE(capGlbPoint) 00243 if not genDE: 00244 print 'Failed to find coordinate system DE for generation', \ 00245 '[', genGlbPoint.x(), genGlbPoint.y(), genGlbPoint.z(),']', \ 00246 '[', genLclPoint.x()/units.mm, genLclPoint.y()/units.mm, genLclPoint.z()/units.mm,']' 00247 return FAILURE 00248 else: 00249 gendmvol = genDE.geometry().belongsToPath(genGlbPoint,-1) 00250 00251 if not capDE: 00252 print 'Failed to find coordinate system DE for capture'\ 00253 '[',capGlbPoint.x(),capGlbPoint.y(),capGlbPoint.z(),']' 00254 return FAILURE 00255 else: 00256 capdmvol = capDE.geometry().belongsToPath(capGlbPoint,-1) 00257 00258 import re 00259 genDM = re.split('/', gendmvol).pop() 00260 capDM = re.split('/', capdmvol).pop() 00261 print "Generated in ", genDM 00262 print "Captured in ", capDM 00263 00264 pmtHits = 0 00265 simhits = simhdr.hits() 00266 for detector in simhits.hitDetectors(): 00267 hitCollection = simhits.hitsByDetector(detector) 00268 if hitCollection == None: 00269 print "No hits in ", detector 00270 hits = hitCollection.collection() 00271 for hit in hits: 00272 # print " PMT", hit.sensDetId(), "hit @ time: ", \ 00273 # hit.hitTime()/units.nanosecond 00274 self.hist["HitTime"].Fill(hit.hitTime()/units.nanosecond) 00275 pmtHits += 1 00276 00277 # Unobservables 00278 PID_trk1 = stats["pdgId_Trk1"].sum() 00279 00280 if PID_trk1 != 22: 00281 print "PID of track 1 is", PID_trk1 00282 print "Not an gamma event." 00283 return FAILURE 00284 00285 self.hist["peGen_all"].Fill(pmtHits) 00286 00287 if genDM == 'db-gds1': 00288 self.hist["peGen_GdLS"].Fill(pmtHits) 00289 00290 if genDM == 'db-lso1': 00291 self.hist["peGen_LS"].Fill(pmtHits) 00292 00293 if re.search('db-lso1',gendmvol): 00294 self.hist["peGen_inLS"].Fill(pmtHits) 00295 00296 if genDM == 'db-oil1': 00297 self.hist["peGen_MO"].Fill(pmtHits) 00298 00299 if capDM == 'db-lso1': 00300 self.hist["peCap_LS"].Fill(pmtHits) 00301 00302 if capDM == 'db-oil1': 00303 self.hist["peCap_MO"].Fill(pmtHits) 00304 00305 if capDM == 'db-gds1': 00306 self.hist["peCap_GdLS"].Fill(pmtHits) 00307 00308 if genDM == 'db-gds1' and capDM == 'db-gds1': 00309 self.hist["peGenCap_GdLS"].Fill(pmtHits) 00310 self.hist["time_GdLS"].Fill(capTime/units.nanosecond) 00311 self.hist["drift_GdLS"].Fill(capDis/units.cm) 00312 00313 if genDM == 'db-lso1' and capDM == 'db-lso1': 00314 self.hist["time_LS"].Fill(capTime/units.nanosecond) 00315 self.hist["drift_LS"].Fill(capDis/units.cm) 00316 00317 eDepInGdLS = stats["EDepInGdLS"].sum() 00318 eDepInLS = stats["EDepInLS"].sum() 00319 self.hist["eDepInGdLS"].Fill(eDepInGdLS/units.MeV) 00320 self.hist["eDepInLS"].Fill(eDepInLS/units.MeV) 00321 00322 self.hist["eDepInAD"].Fill((eDepInLS+eDepInGdLS)/units.MeV) 00323 00324 if eDepInLS+eDepInGdLS > 6: print "Accumulative: ", str(eDepInLS+eDepInGdLS) 00325 00326 eInitial = stats["e_Trk1"].sum() 00327 self.hist["eInitial"].Fill(eInitial/units.MeV) 00328 00329 return SUCCESS 00330 def finalize(self):
def chkGamma::__init__::plotGammaBasics::finalize | ( | self | ) |
Definition at line 331 of file __init__.py.
00331 : 00332 print "Finalizing ", self.name() 00333 status = GaudiAlgo.finalize(self) 00334 return status 00335 def configure(argv = []):
Definition at line 24 of file __init__.py.
Definition at line 31 of file __init__.py.
Definition at line 35 of file __init__.py.
Definition at line 40 of file __init__.py.
Definition at line 42 of file __init__.py.