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

In This Package:

ACUNeutronCaptureVertex.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # 
00003 # Usage :
00004 #       nuwa.py -n -1 -m "CaptureVertex -a CalibrationAxis[A,B,C] -s Scale[>0]" SimAndRecData.root
00005 #
00006 # Comments :
00007 # Scale = 43200 / The Number of the Neutrons Generated at the Specified ACU 
00008 # 43200 is the number of neutrons generated at the ACU per day,
00009 # so multiplying a number by "Scale" gives the number per day. 
00010 
00011 # Load DybPython
00012 import math
00013 from DybPython.DybPythonAlg import DybPythonAlg
00014 from GaudiPython import SUCCESS, FAILURE
00015 from GaudiPython import gbl, loaddict
00016 from DybPython.Util import irange
00017 
00018 TH1F = gbl.TH1F
00019 TH2F = gbl.TH2F
00020 
00021 loaddict("libCLHEPRflx")
00022 loaddict("libHepMCRflx")
00023 Detector = gbl.DayaBay.Detector
00024 AdPmtSensor = gbl.DayaBay.AdPmtSensor
00025 ServiceMode = gbl.ServiceMode
00026 ReconStatus = gbl.ReconStatus
00027 
00028 
00029 class CaptureVertexAlg(DybPythonAlg):
00030 
00031     #Upload the list of possible capture targets
00032     Isotopes = [[1,1,'1H'],[12,6,'12C'],[13,6,'13C'],[14,7,'14N'],
00033                 [16,8,'16O'],[28,14,'28Si'],[31,15,'31P'],[32,16,'32S'],
00034                 [35,17,'35Cl'],[37,17,'37Cl'],[50,24,'50Cr'],[52,24,'52Cr'],
00035                 [53,24,'53Cr'],[54,24,'54Cr'],[55,25,'55Mn'],[54,26,'54Fe'],
00036                 [56,26,'56Fe'],[57,26,'57Fe'],[58,26,'58Fe'],[58,28,'58Ni'],
00037                 [60,28,'60Ni'],[62,28,'62Ni'],[107,47,'107Ag'],[155,64,'155Gd'],[157,64,'157Gd']]
00038 
00039     def captureIsotope(instance, a,z,reconE,isotopes = Isotopes):
00040         for i in range(0,len(isotopes)):
00041             if ((isotopes[i][0] == a) & (isotopes[i][1] == z)):
00042                 instance.stats["/file0/hcap/isotopes"].Fill(isotopes[i][2],scale)
00043                 if reconE >= 6:
00044                     instance.stats["/file0/hcap/isotopes6MeV"].Fill(isotopes[i][2],scale)
00045 
00046     def makeIsotopeHistogram(instance, hist,isotopes = Isotopes):
00047         hist.GetXaxis().SetTitle("Isotopes")
00048         hist.GetYaxis().SetTitle("Neutron Capture Events/Day")
00049         # Set Bin Labels for Isotopes
00050         for i in range(0,len(isotopes)):
00051             hist.GetXaxis().SetBinLabel(2 + i,isotopes[i][2])
00052 
00053     def __init__(self,name):
00054         DybPythonAlg.__init__(self,name)
00055         return
00056 
00057     def initialize(self):
00058         status = DybPythonAlg.initialize(self)
00059         if status.isFailure(): return status
00060         self.info("initializing")
00061 
00062         self.cableSvc = self.svc('ICableSvc','StaticCableSvc')
00063         if self.cableSvc == None:
00064             self.error("Failed to get StaticCableSvc")
00065             return FAILURE
00066 
00067         ###Generate Histograms ##
00068         ## Hadron Capture events
00069 
00070         hist = TH1F("Events","Total Number of Neutron Capture Events" +
00071                 " for Each Neutron Generated in ACU  "+acuAxis,500, 0.0,5.0)
00072         hist.GetXaxis().SetTitle("Neutron Captures")
00073         hist.GetYaxis().SetTitle("Events")
00074         self.stats["/file0/hcap/nHcap"] = hist
00075         
00076         hist = TH1F("Isotopes","The Capture Target for Neutrons"+
00077                 " at ACU  " + acuAxis + " that Generate Signals In AD"
00078                 ,26,0.0,26.0)
00079         self.makeIsotopeHistogram(hist)
00080         self.stats["/file0/hcap/isotopes"] = hist
00081 
00082         hist = TH1F("Isotopes","The Capture Target for Neutrons"+
00083                 " at ACU  " + acuAxis + " with Reconstructed E > 6MeV"
00084                 ,26,0.0,26.0)
00085         self.makeIsotopeHistogram(hist)
00086         self.stats["/file0/hcap/isotopes6MeV"] = hist
00087 
00088         hist = TH2F("EGamma","Z of the Capture Target vs Total Gamma Energy" +
00089                 " for the Neutrons at ACU  " + acuAxis +
00090                 " that Generate Signals in AD" ,500,0.0,12.0,81,-0.5,80.5 )
00091         hist.GetXaxis().SetTitle("E/Neutron (MeV)")
00092         hist.GetYaxis().SetTitle("Z")
00093         hist.SetMarkerStyle(2)
00094         self.stats["/file0/hcap/ZvsTotalGamma"] = hist
00095 
00096         hist = TH2F("EGamma","Z of the Capture Target vs Total Gamma Energy" + 
00097                 " for the Neutrons at ACU  " + acuAxis + 
00098                 "  with Reconstructed E > 6MeV" ,500,0.0,12.0,81,-0.5,80.5 )
00099         hist.GetXaxis().SetTitle("E/Neutron (MeV)")
00100         hist.GetYaxis().SetTitle("Z")
00101         hist.SetMarkerStyle(2)
00102         self.stats["/file0/hcap/ZvsTotalGamma6MeV"] = hist
00103 
00104         hist = TH2F("ZvsA", "Z vs A of target atoms for the Neutrons at ACU "+
00105                         acuAxis,500, -0.5, 210.5, 500,-0.5,80.5)
00106         hist.GetXaxis().SetTitle("A")
00107         hist.GetYaxis().SetTitle("Z")
00108         hist.SetMarkerStyle(2)
00109         self.stats["/file0/hcap/ZvsA"]= hist
00110         
00111         ##Gamma-ray energy
00112         hist = TH1F("EGamma","Individual Gamma-Ray Energy for" +
00113                 " the Neutrons at ACU  " + acuAxis + 
00114                 " that Generate Signals in AD",500,0.0,12.0)
00115         hist.GetXaxis().SetTitle("E (MeV)")
00116         hist.GetYaxis().SetTitle("Events/Day")
00117         self.stats["/file0/gamma/individual"] = hist
00118 
00119         hist = TH1F("EGamma","Individual Gamma Ray Energy for the Neutrons"
00120                 + " at ACU  " + acuAxis + 
00121                 " with Reconstructed E > 6MeV",500,0.0,12.0)
00122         hist.GetXaxis().SetTitle("E (MeV)")
00123         hist.GetYaxis().SetTitle("Events/Day")
00124         self.stats["/file0/gamma/individual6MeV"] = hist
00125         
00126         hist = TH1F("EGamma", "Total Gamma Ray Energy Emitted from the Capture "
00127                 + "a Neutron Generated in ACU  " + acuAxis
00128                 ,500,0.0,12.0)
00129         hist.GetXaxis().SetTitle("E/Neutron (MeV)")
00130         hist.GetYaxis().SetTitle("Events/Day")
00131         self.stats["/file0/gamma/totalCaptureGamma"] = hist
00132         
00133         hist = TH1F("EGamma", "Total Gamma Ray Energy Emitted from the Capture "
00134                         + "a Neutron Generated in ACU  " + acuAxis +
00135                         "with ReconEnergy > 6MeV"
00136                         ,500,0.0,12.0)
00137         hist.GetXaxis().SetTitle("E/Neutron (MeV)")
00138         hist.GetYaxis().SetTitle("Events/Day")
00139         self.stats["/file0/gamma/totalCaptureGamma6MeV"] = hist
00140         
00141         hist = TH1F("EGamma","Gamma Ray Energy from Inelastic Collisions"
00142                         + "of Neutrons Generated In ACU  " + 
00143                         acuAxis ,500,0.0,12.0)
00144         hist.GetXaxis().SetTitle("E (MeV)")
00145         hist.GetYaxis().SetTitle("Events/Day")
00146         self.stats["/file0/gamma/inelastic"] = hist
00147 
00148 
00149         
00150         return SUCCESS
00151 
00152     def execute(self):
00153         self.info("executing")
00154         evt = self.evtSvc()
00155 
00156         recHdr = evt["/Event/Rec/RecHeader"]
00157         if recHdr == None:
00158             self.error("Failed to get RecHeader")
00159             return FAILURE
00160 
00161         simHdr = evt["/Event/Sim/SimHeader"]
00162         if simHdr == None:
00163             self.error("Failed to get SimHeader")
00164             return FAILURE
00165         
00166         recResults = recHdr.recResults()
00167         recTrigger = recResults["AdSimple"]
00168         if recTrigger.positionStatus() == ReconStatus.kGood:
00169             if recTrigger.energyStatus() == ReconStatus.kGood:
00170                 reconEnergy = recTrigger.energy()
00171                 phis = simHdr.particleHistory()
00172                 vtx = phis.vertexVector()
00173                 nvtx = vtx.size()
00174                 nHcap = 0       #Total number of hadron capture events
00175                 for i in range(0,nvtx):
00176                     vsec = vtx[i].secondaries()
00177                     vproc = vtx[i].process().name()
00178                     PDG = vtx[i].track().track().particle()
00179                     totalGammaE = 0 #Total gamma energy for each hadron capture
00180                     
00181                     # Hadron capture events analysis
00182                     if PDG == 2112 and ((vproc == "HadronCapture") or (vproc == "nCapture")):
00183                         eachGammaE = 0
00184                         Z = 0
00185                         A = 0   
00186                         for j in range(0,vsec.size()):
00187                             if vsec[j].track().vertices().size() > 0:
00188                                 vertex1 = vsec[j].track().vertices()[0]
00189                                 pdg = vsec[j].track().particle()
00190                                 eachGammaE = vertex1.kineticEnergy()
00191                                 if pdg > 1000000000: #code is 10LZZZAAAI
00192                                     Z = (int(pdg/10000)%1000)
00193                                     # The atomic mass of the daughter atom has been increased by 1
00194                                     # so 1 is subtracted to get A of the parent atom
00195                                     A = (int(pdg/10)%1000)-1
00196                                     nHcap += 1
00197                                     self.captureIsotope(A,Z,reconEnergy)
00198                                     self.stats["/file0/hcap/ZvsA"].Fill(A,Z)
00199                                 if pdg == 22:
00200                                     totalGammaE += eachGammaE
00201                         if ((Z > 0) & (A > 0)):
00202                             self.stats["/file0/hcap/ZvsTotalGamma"].Fill(totalGammaE,Z)
00203                             self.stats["/file0/gamma/totalCaptureGamma"].Fill(totalGammaE,scale)        
00204                             if reconEnergy > 6:
00205                                 self.stats["/file0/hcap/ZvsTotalGamma6MeV"].Fill(totalGammaE,Z)
00206                                 self.stats["/file0/gamma/totalCaptureGamma6MeV"].Fill(totalGammaE,scale)        
00207                     
00208                     # Loop over all the vertices as well to get the energy of all gammas                        
00209                     for j in range(0,vsec.size()):
00210                         eachGammaE = 0
00211                         if vsec[j].track().vertices().size() > 0:
00212                             vertex1 = vsec[j].track().vertices()[0]
00213                             pdg = vsec[j].track().particle()
00214                             eachGammaE = vertex1.kineticEnergy()
00215                             if pdg == 22:
00216                                 self.stats["/file0/gamma/individual"].Fill(eachGammaE,scale)
00217                                 if reconEnergy >= 6:
00218                                     self.stats["/file0/gamma/individual6MeV"].Fill(eachGammaE,scale)
00219                                 if vertex1.process().name() == "NeutronInelastic":
00220                                     self.stats["/file0/gamma/inelastic"].Fill(eachGammaE,scale) 
00221                 self.stats["/file0/hcap/nHcap"].Fill(nHcap)
00222         
00223         return SUCCESS
00224         
00225     def finalize(self):
00226         self.info("finalizing")
00227         status = DybPythonAlg.finalize(self)
00228         return status
00229 
00230 
00231 #####  Job Configuration for nuwa.py ########################################
00232 acuAxis = 'A'
00233 scale = 1.0
00234 
00235 def configure(argv = []):
00236     """Configure this module with ACU unit""" 
00237     import sys, getopt
00238     opts,args = getopt.getopt(argv,"a:s:;")
00239     for opt,arg in opts:
00240         if opt == "-a":
00241             global acuAxis
00242             acuAxis = arg
00243             print acuAxis
00244         if opt == "-s":
00245             global scale
00246             scale = float(arg)
00247             print scale
00248 
00249 
00250     from StatisticsSvc.StatisticsSvcConf import StatisticsSvc
00251     statsSvc = StatisticsSvc()
00252     statsSvc.Output ={"file0":"CaptureVertex.root"}
00253     import DataSvc
00254     DataSvc.Configure()
00255     
00256     return
00257 
00258 def run(app):
00259     '''
00260     Configure and add an algorithm to job
00261     '''
00262     app.ExtSvc += ["StaticCableSvc", "StatisticsSvc"]
00263     captureVertexAlg = CaptureVertexAlg("MyCaptureVertex")
00264     app.addAlgorithm(captureVertexAlg)
00265     pass
00266 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:11:24 2011 for Calibration by doxygen 1.4.7