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

In This Package:

Public Member Functions | Public Attributes
de_search::MyAlg Class Reference
Inheritance diagram for de_search::MyAlg:
Inheritance graph
[legend]
Collaboration diagram for de_search::MyAlg:
Collaboration graph
[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.


Constructor & Destructor Documentation

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

Definition at line 15 of file de_search.py.

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


Member Function Documentation

def de_search::MyAlg::tab (   self)

Definition at line 20 of file de_search.py.

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

Definition at line 22 of file de_search.py.

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

def de_search::MyAlg::dump_all (   self)

Definition at line 26 of file de_search.py.

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

def de_search::MyAlg::initialize (   self)

Definition at line 34 of file de_search.py.

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

def de_search::MyAlg::do_one (   self)

Definition at line 51 of file de_search.py.

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

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

Definition at line 93 of file de_search.py.

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

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

Definition at line 119 of file de_search.py.

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

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

Definition at line 130 of file de_search.py.

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

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

Definition at line 146 of file de_search.py.

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

def de_search::MyAlg::find_child_de (   self,
  de,
  th 
)
Find the immediate child of de that has a support consistent
with upper parts of th and remove those parts from th.

Definition at line 160 of file de_search.py.

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

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

Definition at line 187 of file de_search.py.

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

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

Definition at line 213 of file de_search.py.

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

def de_search::MyAlg::execute (   self)

Definition at line 233 of file de_search.py.

00234                      :
00235         print "execute"
00236         return SUCCESS


Member Data Documentation

Definition at line 15 of file de_search.py.

Definition at line 34 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 Fri May 16 2014 10:05:42 for G4DataHelpers by doxygen 1.7.4