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

In This Package:

de_search::MyAlg Class Reference

Inheritance diagram for de_search::MyAlg:
[legend]
Collaboration diagram for de_search::MyAlg:
[legend]
List of all members.

Public Member Functions

def __init__
def tab
def out
def dump_all
def initialize
def do_one
def fix_th
def th2de
def support_path
def support_check
def find_child_de
def find_de
def dump_de
def execute

Public Attributes

 depth
 det

Detailed Description

Definition at line 14 of file de_search.py.


Member Function Documentation

def de_search::MyAlg::__init__ (   self,
  name 
)

Definition at line 15 of file de_search.py.

00015                            :
00016         GaudiAlgo.__init__(self,name)
00017         print "Making MyAlg",name
00018         self.depth = 0
00019 
    def tab(self):

def de_search::MyAlg::tab (   self  ) 

Definition at line 20 of file de_search.py.

00020                  :
00021         return "  "*self.depth
    def out(self,*stuff):

def de_search::MyAlg::out (   self,
  stuff 
)

Definition at line 22 of file de_search.py.

00022                         :
00023         #print self.tab()+" ".join(stuff)
00024         return
00025 
    def dump_all(self):

def de_search::MyAlg::dump_all (   self  ) 

Definition at line 26 of file de_search.py.

00026                       :
00027         from GaudiPython import AppMgr
00028         app = AppMgr()
00029         det = app.detsvc()
00030         lar = det['/dd/Structure/Sites/la-rock']
00031         self.dump_de(lar,None)
00032         return
00033 
    def initialize(self):

def de_search::MyAlg::initialize (   self  ) 

Definition at line 34 of file de_search.py.

00034                         :
00035         status = GaudiAlgo.initialize(self)
00036         print "Init MyAlg",self.name
00037         if status.isFailure(): return status
00038 
00039         app = AppMgr()
00040         self.det = app.detsvc()
00041 
00042         import time
00043         for n in range(0,10):
00044             start = time.time()
00045             self.do_one()
00046             stop = time.time()
00047             print "Run %d all AD PMTs in %f seconds"%(n,stop-start)
00048 
00049         return SUCCESS
00050 
    def do_one(self):

def de_search::MyAlg::do_one (   self  ) 

Definition at line 51 of file de_search.py.

00051                     :
00052 
00053         touchable_history_template = [
00054             "/dd/Geometry/PMT/lvPmtHemiVacuum#pvPmtHemiCathode",
00055             "/dd/Geometry/PMT/lvPmtHemi#pvPmtHemiVacuum",
00056             "/dd/Geometry/AD/lvOIL#pvAdPmtArray#pvAdPmtArrayRotated#pvAdPmtRingInCyl:%(ring)d#pvAdPmtInRing:%(col)d#pvAdPmtUnit",
00057             "/dd/Geometry/AD/lvSST#pvOIL",
00058             "/dd/Geometry/AD/lvADE#pvSST",
00059             "/dd/Geometry/Pool/lvNearPoolIWS#pvNearADE%(nad)d",
00060             "/dd/Geometry/Pool/lvNearPoolCurtain#pvNearPoolIWS",
00061             "/dd/Geometry/Pool/lvNearPoolOWS#pvNearPoolCurtain",
00062             "/dd/Geometry/Pool/lvNearPoolLiner#pvNearPoolOWS",
00063             "/dd/Geometry/Pool/lvNearPoolDead#pvNearPoolLiner",
00064             "/dd/Geometry/Sites/lvNearHallBot#pvNearPoolDead",
00065             "/dd/Geometry/Sites/lvNearSiteRock#pvNearHallBot",
00066             "/dd/Structure/Sites/%(site)s-rock"
00067             ]
00068 
00069 
00070         for site in ['la','db']:
00071             for nad in range(0,2):
00072                 nad += 1
00073                 for ring in range(0,8):
00074                     ring += 1
00075                     for col in range(0,24):
00076                         col += 1
00077                         
00078                         params = { 'ring':ring,'col':col,'nad':nad,'site':site }
00079                         
00080                         th = " ".join(touchable_history_template)%params
00081                         touchableHistory = th.split(" ")
00082                         
00083                         self.fix_th(touchableHistory)
00084                         de = self.th2de(touchableHistory)
00085                         if not de:
00086                             print "Failed, remaining TH is:\n%s"%"\n".join(touchableHistory)
00087                             continue
00088                         continue
00089                     continue
00090                 continue
00091         return
00092 
    def fix_th(self,th):

def de_search::MyAlg::fix_th (   self,
  th 
)

Definition at line 93 of file de_search.py.

00093                        :
00094         "Expand multiple pv chains"
00095 
00096         th.reverse()
00097 
00098         index = 0
00099         for entry in th:
00100             index += 1
00101             names = entry.split("#")
00102             if len(names) <= 2: continue
00103             th.pop(index-1)
00104             th.insert(index-1,"%s#%s"%(names[0],names[1]))
00105 
00106             lv = self.det[names[0]]
00107             pv = lv[names[1]]
00108             lv = pv.lvolume()
00109 
00110             for pvname in names[2:]:
00111                 pv = lv[pvname]
00112                 th.insert(index,"%s#%s"%(lv.name(),pv.name()))
00113                 index += 1
00114                 lv = pv.lvolume()
00115                 continue
00116             continue
00117         return
00118 
    def th2de(self,th):

def de_search::MyAlg::th2de (   self,
  th 
)

Definition at line 119 of file de_search.py.

00119                       :
00120         "Return the DetectorElement matching the TouchableHistory"
00121 
00122         if not "/dd/Structure" in th[0]:
00123             print "TouchableHistory not grounded in a structure:",th[0]
00124 
00125             return None
00126         from GaudiPython import AppMgr
00127         de = self.det[th.pop(0)]
00128         return self.find_de(de,th)
00129 
    def support_path(self,gi):

def de_search::MyAlg::support_path (   self,
  gi 
)

Definition at line 130 of file de_search.py.

00130                              :
00131         "Returns a list of (lv,pv) tuples that is the support path"
00132         if not gi.hasSupport(): return []
00133         support_gi = gi.supportIGeometryInfo()
00134         rpath = gi.supportPath()
00135         lv = support_gi.lvolume()
00136 
00137         sp = []
00138         for depth in range(0,rpath.size()):
00139             pv = lv.pvolumes()[rpath[depth]]
00140             sp.append((lv,pv))
00141             self.out("sp: %d %s#%s"%(depth,lv.name(),pv.name()))
00142             lv = pv.lvolume()
00143             continue
00144         return sp
00145 
    def support_check(self,sp,th):

def de_search::MyAlg::support_check (   self,
  sp,
  th 
)

Definition at line 146 of file de_search.py.

00146                                  :
00147         "Return index of  history the support path sp spans, o.w. -1"
00148 
00149         index = 0
00150         for lv,pv in sp:
00151             self.out("lv#pv=%s#%s th[%d]=%s"%(lv.name(),pv.name(),index,th[index]))
00152             names = th[index].split("#")
00153             if not lv.name() == names[0]: return -1
00154             if not pv.name() == names[1]: return -1
00155             index += 1
00156             continue
00157         self.out("passed with index %d"%index)
00158         return index
00159 
    def find_child_de(self,de,th):

def de_search::MyAlg::find_child_de (   self,
  de,
  th 
)

Definition at line 160 of file de_search.py.

00160                                  :
00161         """
00162         Find the immediate child of de that has a support consistent
00163         with upper parts of th and remove those parts from th.
00164         
00165         """
00166         self.out("Checking children of %s(%s)"%(de.name(),de.geometry().lvolumeName()))
00167         self.depth += 1
00168         children = de.childIDetectorElements()
00169         for ichild in range(0,children.size()):
00170             child = children[ichild]
00171             self.out("child %s(%s)"%(child.name(),child.geometry().lvolumeName()))
00172             sp = self.support_path(child.geometry())
00173             index = self.support_check(sp,th)
00174 
00175             if index < 0: continue
00176 
00177             del th[:index]
00178 
00179             self.out("remaining th:\n%s"%"\n".join(th))
00180             self.depth -= 1
00181             return child
00182 
        self.depth -= 1

def de_search::MyAlg::find_de (   self,
  de,
  th 
)

Definition at line 183 of file de_search.py.

00187                            :
00188         # Exhausted the th so current DE must be the one
00189         if not th: return de
00190 
00191         names = th[0].split("#")
00192         lvname = names.pop(0)
00193 
00194         de_lvname = de.geometry().lvolumeName()
00195 
00196         self.out('de="%s"("%s") th="%s"[%s]'%(de.name(),de_lvname,lvname,",".join(names)))
00197 
00198         if lvname != de_lvname:
00199             print 'Given mismatched DE and TH top "%s" != "%s"'%(lvname,de_lvname)
00200             return None
00201 
00202         # The touchable history to match the next child DE
00203         child_de = self.find_child_de(de,th)
00204         if child_de: return self.find_de(child_de,th)
00205 
00206         # if we get here, we have reached the end of possible DEs.
00207         # Pop off the touchable history coresponding to current DE
00208         th.pop(0)
        return de

def de_search::MyAlg::dump_de (   self,
  de,
  parent_de 
)

Definition at line 209 of file de_search.py.

00213                                   :
00214         gi = de.geometry()
00215         self.out(de.name(),gi.lvolumeName())
00216 
00217         self.depth += 1
00218         count = 0
00219         for lv,pv in self.support_path(gi):
00220             self.out("%d:%s#%s"%(count,lv.name(),pv.name()))
00221             count += 1
00222         self.depth -= 1
00223 
00224         self.depth += 2
00225         children = de.childIDetectorElements()
00226         for ichild in range(0,children.size()):
00227             child = children[ichild]
00228             self.dump_de(child,de)
        self.depth -= 2

def de_search::MyAlg::execute (   self  ) 

Definition at line 229 of file de_search.py.

00233                      :
        print "execute"


Member Data Documentation

de_search::MyAlg::depth

Definition at line 18 of file de_search.py.

de_search::MyAlg::det

Definition at line 40 of file de_search.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:32:10 2011 for G4DataHelpers by doxygen 1.4.7