/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

expcalc.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 #  nuwa.py -m "expcalc -x 0.0*m -y 0.0*m -z 1.75*m -s DayaBay -d AD1"
00004 #
00005 
00006 # Load DybPythonAlg
00007 from DybPython.DybPythonAlg import DybPythonAlg
00008 from GaudiPython import SUCCESS, FAILURE
00009 from GaudiPython import gbl, loaddict
00010 from DybPython.Util import irange
00011 from GaudiKernel import SystemOfUnits as units
00012 
00013 import PyCintex
00014 import ROOT
00015 import re
00016 
00017 from array import array
00018 
00019 Detector = gbl.DayaBay.Detector
00020 Site = gbl.Site
00021 DetectorId = gbl.DetectorId
00022 
00023 CLHEP = gbl.CLHEP
00024 
00025 class expcalc(DybPythonAlg):
00026     "expcalc: calculate the expected charge pattern"
00027     def __init__(self,name):
00028         DybPythonAlg.__init__(self,name)
00029         
00030         self.vertex = CLHEP.Hep3Vector(0*units.mm, 0*units.mm, 0*units.mm)
00031         self.siteName = "DayaBay"
00032         self.detName = "AD1"
00033         self.siteIds = {
00034           'DayaBay' : gbl.Site.kDayaBay,
00035           'LingAo'  : gbl.Site.kLingAo,
00036           'Far'     : gbl.Site.kFar,
00037         }
00038         self.detIds = {
00039           'AD1'  :  gbl.DetectorId.kAD1,
00040           'AD2'  :  gbl.DetectorId.kAD2,
00041           'AD3'  :  gbl.DetectorId.kAD3,
00042           'AD4'  :  gbl.DetectorId.kAD4,
00043         }
00044         self.OutputFileName = "chargeMap.txt"
00045         return
00046 
00047     def initialize(self):
00048         status = DybPythonAlg.initialize(self)
00049         print "Init expcalc",self.name()
00050         if status.isFailure(): return status
00051 
00052         site = self.siteIds[self.siteName]
00053         detector = self.detIds[self.detName]
00054 
00055         qtool = self.tool('IReconHelperTool', 'ExpQCalcTool')
00056         expq = qtool.expqcalc(site, detector, self.vertex)
00057 
00058         tableLines = []
00059         normFactor = 1000.
00060         tableLines.append("# Vertex: %7.3fmm %7.3fmm %7.3fmm  \n"
00061                           % ( self.vertex.x(), self.vertex.y(), self.vertex.z())
00062                          )
00063         tableLines.append("# Expected Charge Map \n")
00064         tableLines.append("# Normalization Factor (total charge in the below map): %7.3f \n"
00065                           % normFactor)
00066         tableLines.append("#          [ring1] [ring2] [ring3] [ring4] [ring5] [ring6] [ring7] [ring8] \n")
00067         for col in range(0,24):
00068             line = ("#[column%2d] %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f \n"
00069                     % (col+1, 
00070                       expq[col]*normFactor, 
00071                       expq[col+24]*normFactor, 
00072                       expq[col+48]*normFactor,
00073                       expq[col+72]*normFactor, 
00074                       expq[col+96]*normFactor, 
00075                       expq[col+120]*normFactor,
00076                       expq[col+144]*normFactor, 
00077                       expq[col+168]*normFactor
00078                       )
00079                    )
00080             tableLines.append(line)
00081 
00082         outFile = open(self.OutputFileName,'w')
00083         outFile.writelines(tableLines)
00084         outFile.close()
00085 
00086         return SUCCESS
00087 
00088     def execute(self):
00089         print "Executing expcalc",self.name()
00090         return SUCCESS
00091         
00092     def finalize(self):        
00093         print "Finalizing expcalc",self.name()
00094         status = DybPythonAlg.finalize(self)
00095         return status
00096 
00097 #####  Job Configuration for nuwa.py ########################################
00098 options = None
00099 def configure(argv = []):
00100     # Process module options
00101     global options
00102     from optparse import OptionParser
00103     
00104     parser = OptionParser()
00105     parser.add_option("-s", "--siteName", type="string",
00106           default="DayaBay",
00107           help="site name")
00108     parser.add_option("-d", "--detName", type="string",
00109           default="AD1",
00110           help="detector name")
00111     parser.add_option("-x", "--vertex-x", type="string",
00112           default="0*m",
00113           help="X coordinate of the given vertex")
00114     parser.add_option("-y", "--vertex-y", type="string",
00115           default="0*m",
00116           help="Y coordinate of the given vertex")
00117     parser.add_option("-z", "--vertex-z", type="string",
00118           default="0*m",
00119           help="Z coordinate of the given vertex")
00120     (options, args) = parser.parse_args(args=argv)
00121 
00122 #    example for How to change the optical parameters 
00123 #    for expected charge calculation
00124 
00125 #    from AdRec.AdRecConf import ExpQCalcTool
00126 #    mytool = ExpQCalcTool("expcalc.ExpQCalcTool")
00127 #    mytool.AbsLength = 10470. # mm, default value in QMLFTool
00128 #    mytool.TopRefZ = 2104.55  # mm, default value in QMLFTool
00129 #    mytool.BotRefZ = -2027.5  # mm, default value in QMLFTool
00130 #    mytool.TopReflectivity = 0.9786 # mm, default value in QMLFTool
00131 #    mytool.TopReflectivity = 0.9786 # mm, default value in QMLFTool
00132     
00133 def run(app):
00134     '''
00135     Configure and add an algorithm to job
00136     '''
00137     from DybPython.Tools import unitify
00138     
00139     calcAlg = expcalc("expcalc")
00140     x = unitify(options.vertex_x)
00141     y = unitify(options.vertex_y)
00142     z = unitify(options.vertex_z)
00143     calcAlg.vertex = CLHEP.Hep3Vector(x, y, z)
00144     calcAlg.siteName = options.siteName
00145     calcAlg.detName = options.detName
00146     app.addAlgorithm(calcAlg)
00147     
00148     pass
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:13:25 for AdRec by doxygen 1.7.4