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

In This Package:

gen.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """
00003 Generate Pool geometry files
00004 """
00005 
00006 # All the boxy volumes
00007 pool_element_names = ["Dead","Liner","OWS", "Curtain", "IWS" ]
00008 
00009 # Those that matter to reconstruction
00010 pool_detelem_data = [
00011     ("OWS","pv%(nlf)sHallBot/pv%(nf)sPoolDead/pv%(nf)sPoolLiner/pv%(nf)sPoolOWS"),
00012     ("Curtain","pv%(nf)sPoolCurtain"),
00013     ("IWS","pv%(nf)sPoolIWS" )]
00014 
00015 
00016 gen_pool_pmts = True
00017 Eight = True
00018 suffix = ''
00019 style = '2-2-4'
00020 
00021 class Element:
00022     def __init__(self,name,nick,material,thickness="0*m",parent=None):
00023         self.name=name
00024         self.nick=nick
00025         self.thickness=thickness
00026         self.material=material
00027         self.parent=parent
00028         self.child=None
00029         if parent: parent.child = self
00030         self.params = {}
00031         self.logvol = {}
00032         self.physvol = {}
00033         return
00034 
00035     def param_fullname(self,param_name,site=""):
00036         if self.name == 'HallBot':
00037             return "%s%s%s"%(site,self.name,param_name)
00038         return "%sPool%s%s"%(site,self.name,param_name)
00039 
00040     def param_diffname(self,diffname,param_name,site=""):
00041         return "%sPool%s%s"%(site,diffname,param_name)
00042 
00043 
00044     def parameters(self):
00045         from XmlDetDescGen.parameter import Parameter
00046 
00047         if self.params: return self.params
00048 
00049         p = Parameter(self.param_fullname("Thickness"),self.thickness,"Thickness of %s"%self.nick)
00050         self.params[self.param_fullname("Thickness")] = p
00051         
00052 
00053         if self.parent.name == 'HallBot':
00054             parentThickness = "0*m"
00055         else:
00056             parentThickness = self.parent.param_fullname('Thickness')
00057         for site in ["Near","Far"]:
00058             for dim in ["X","Y"]:
00059                 pname = "Size"+dim
00060                 self.params[self.param_fullname(pname,site)] = \
00061                     Parameter(self.param_fullname(pname,site),
00062                               self.parent.param_fullname(pname,site)+"-2*"+parentThickness)
00063                 continue
00064             continue
00065 
00066         self.params[self.param_fullname('SizeZ')] = \
00067             Parameter(self.param_fullname('SizeZ'),
00068                       self.parent.param_fullname('SizeZ')+"-"+parentThickness)
00069 
00070         self.params[self.param_fullname('LiftSizeZ')] = \
00071             Parameter(self.param_fullname('LiftSizeZ'),"0.5*"+parentThickness)
00072 
00073         bevel = []
00074         elem = self
00075         while elem:
00076             bevel.append(elem.param_fullname('Thickness'))
00077             elem = elem.child
00078             continue
00079         self.params[self.param_fullname('BevelSize')] = \
00080             Parameter(self.param_fullname('BevelSize'),
00081                       "2*(sqrt(2)-1)*(%s)"%"+".join(bevel))
00082 
00083         return self.params
00084     
00085     def logical_volume(self,site):
00086         try:
00087             return self.logvol[site]
00088         except KeyError:
00089             pass
00090              
00091         from XmlDetDescGen.geometry import Box,Boolean,BooleanSecondary,Logvol,PosXYZ,RotXYZ
00092 
00093         # Make the subtracted ones first
00094         subtracted = []
00095         signX = ['0.5*%s', '0.5*%s','-0.5*%s','-0.5*%s']
00096         signY = ['0.5*%s','-0.5*%s', '0.5*%s','-0.5*%s']
00097         signX2 = ['0.5*%s', '0.5*%s','-0.5*%s','-0.5*%s']
00098         signY2 = ['0*%s', '0.5*%s','-0.5*%s', '0.5*%s','-0.5*%s']
00099         signR = ['0*%s', '0.5*%s','-0.5*%s', '0.5*%s','-0.5*%s']
00100 
00101         if self.name=="OWS":
00102             
00103             for ind in range(0,4):
00104                 subtracted.append(BooleanSecondary(
00105                     Box(site.lower()+'_pool_'+self.name.lower()+'_sub%d'%ind,
00106                         sizeX=self.param_diffname('Liner','BevelSize'),
00107                         sizeY=self.param_diffname('Liner','BevelSize'),
00108                         sizeZ="SubShift+" + self.param_fullname('SizeZ')),
00109                     PosXYZ(X=signX[ind]%self.param_diffname('Liner','SizeX',site),
00110                            Y=signY[ind]%self.param_diffname('Liner','SizeY',site),
00111                            Z="0*m"),
00112                     RotXYZ(rotZ="45*degree")))
00113 
00114             for ind in range(4,8):
00115                 subtracted.append(BooleanSecondary(
00116                     Box(site.lower()+'_pool_'+self.name.lower()+'_sub%d'%ind,
00117                         sizeX=self.param_fullname('BevelSize'),
00118                         sizeY=self.param_fullname('BevelSize'),
00119                         sizeZ=self.param_fullname('SizeZ')),
00120                     PosXYZ(X=signX[ind-4]%self.param_fullname('SizeX',site),
00121                            Y=signY[ind-4]%self.param_fullname('SizeY',site),
00122                            Z="-TopGapThickness"),
00123                     RotXYZ(rotZ="45*degree")))
00124                 
00125             subtracted.append(BooleanSecondary(
00126                 Box(site.lower()+'_pool_'+self.name.lower()+'_sub8',
00127                     sizeX=self.param_fullname('SizeX',site),
00128                     sizeY="SubShift",
00129                     sizeZ=self.param_fullname('SizeZ')),
00130                 PosXYZ(X="0*cm",
00131                        Y=self.param_fullname('SizeY',site)+"/2."+"+SubShift/2.-PoolLinerThickness",
00132                        Z="-TopGapThickness"),
00133                 RotXYZ(rotZ="0*degree")))
00134 
00135             subtracted.append(BooleanSecondary(
00136                 Box(site.lower()+'_pool_'+self.name.lower()+'_sub9',
00137                     sizeX=self.param_fullname('SizeX',site),
00138                     sizeY="SubShift",
00139                     sizeZ=self.param_fullname('SizeZ')),
00140                 PosXYZ(X="0*cm",
00141                        Y=self.param_fullname('SizeY',site)+"/(-2.)"+"-SubShift/2.+PoolLinerThickness",
00142                        Z="-TopGapThickness"),
00143                 RotXYZ(rotZ="0*degree")))
00144 
00145             subtracted.append(BooleanSecondary(
00146                 Box(site.lower()+'_pool_'+self.name.lower()+'_sub10',
00147                     sizeX=self.param_fullname('SizeX',site),
00148                     sizeY="SubShift",
00149                     sizeZ=self.param_fullname('SizeZ')),
00150                 PosXYZ(X=self.param_fullname('SizeX',site)+"/2."+"+SubShift/2.-PoolLinerThickness",
00151                        Y="0*cm",
00152                        Z="-TopGapThickness"),
00153                 RotXYZ(rotZ="90*degree")))
00154 
00155             subtracted.append(BooleanSecondary(
00156                 Box(site.lower()+'_pool_'+self.name.lower()+'_sub11',
00157                     sizeX=self.param_fullname('SizeX',site),
00158                     sizeY="SubShift",
00159                     sizeZ=self.param_fullname('SizeZ')),
00160                 PosXYZ(X=self.param_fullname('SizeX',site)+"/(-2.)"+"-SubShift/2.+PoolLinerThickness",
00161                        Y="0*cm",
00162                        Z="-TopGapThickness"),
00163                 RotXYZ(rotZ="90*degree")))
00164 
00165 
00166 
00167             # Make the subtraction
00168             sub = Boolean("subtraction",site.lower()+'_pool_'+self.name.lower()+'_box',
00169                           Box(site.lower()+'_pool_'+self.name.lower(),
00170                               sizeX=self.param_diffname('Liner','SizeX',site),
00171                               sizeY=self.param_diffname('Liner','SizeY',site),
00172                               sizeZ=self.param_fullname('SizeZ')),
00173                           subtracted)
00174 
00175         elif self.name=="IWS":
00176 
00177             for ind in range(0,4):
00178                 subtracted.append(BooleanSecondary(
00179                     Box(site.lower()+'_pool_'+self.name.lower()+'_sub%d'%ind,
00180                         sizeX=self.param_diffname('Curtain','BevelSize'),
00181                         sizeY=self.param_diffname('Curtain','BevelSize'),
00182                         sizeZ="SubShift+" + self.param_fullname('SizeZ')),
00183                     PosXYZ(X=signX[ind]%self.param_diffname('Curtain','SizeX',site),
00184                            Y=signY[ind]%self.param_diffname('Curtain','SizeY',site),
00185                            Z="0*m"),
00186                     RotXYZ(rotZ="45*degree")))
00187 
00188             for ind in range(4,8):
00189                 subtracted.append(BooleanSecondary(
00190                     Box(site.lower()+'_pool_'+self.name.lower()+'_sub%d'%ind,
00191                         sizeX=self.param_fullname('BevelSize'),
00192                         sizeY=self.param_fullname('BevelSize'),
00193                         sizeZ=self.param_fullname('SizeZ')),
00194                     PosXYZ(X=signX[ind-4]%self.param_fullname('SizeX',site),
00195                            Y=signY[ind-4]%self.param_fullname('SizeY',site),
00196                            Z="-TopGapThickness"),
00197                     RotXYZ(rotZ="45*degree")))
00198                 
00199             subtracted.append(BooleanSecondary(
00200                 Box(site.lower()+'_pool_'+self.name.lower()+'_sub8',
00201                     sizeX=self.param_fullname('SizeX',site),
00202                     sizeY="SubShift",
00203                     sizeZ=self.param_fullname('SizeZ')),
00204                 PosXYZ(X="0*cm",
00205                        Y=self.param_fullname('SizeY',site)+"/2."+"+SubShift/2.-PoolCurtainThickness",
00206                        Z="-TopGapThickness"),
00207                 RotXYZ(rotZ="0*degree")))
00208 
00209             subtracted.append(BooleanSecondary(
00210                 Box(site.lower()+'_pool_'+self.name.lower()+'_sub9',
00211                     sizeX=self.param_fullname('SizeX',site),
00212                     sizeY="SubShift",
00213                     sizeZ=self.param_fullname('SizeZ')),
00214                 PosXYZ(X="0*cm",
00215                        Y=self.param_fullname('SizeY',site)+"/(-2.)"+"-SubShift/2.+PoolCurtainThickness",
00216                        Z="-TopGapThickness"),
00217                 RotXYZ(rotZ="0*degree")))
00218 
00219             subtracted.append(BooleanSecondary(
00220                 Box(site.lower()+'_pool_'+self.name.lower()+'_sub10',
00221                     sizeX=self.param_fullname('SizeX',site),
00222                     sizeY="SubShift",
00223                     sizeZ=self.param_fullname('SizeZ')),
00224                 PosXYZ(X=self.param_fullname('SizeX',site)+"/2."+"+SubShift/2.-PoolCurtainThickness",
00225                        Y="0*cm",
00226                        Z="-TopGapThickness"),
00227                 RotXYZ(rotZ="90*degree")))
00228 
00229             subtracted.append(BooleanSecondary(
00230                 Box(site.lower()+'_pool_'+self.name.lower()+'_sub11',
00231                     sizeX=self.param_fullname('SizeX',site),
00232                     sizeY="SubShift",
00233                     sizeZ=self.param_fullname('SizeZ')),
00234                 PosXYZ(X=self.param_fullname('SizeX',site)+"/(-2.)"+"-SubShift/2.+PoolCurtainThickness",
00235                        Y="0*cm",
00236                        Z="-TopGapThickness"),
00237                 RotXYZ(rotZ="90*degree")))
00238 
00239 
00240 
00241             # Make the subtraction
00242             sub = Boolean("subtraction",site.lower()+'_pool_'+self.name.lower()+'_box',
00243                           Box(site.lower()+'_pool_'+self.name.lower(),
00244                               sizeX=self.param_diffname('Curtain','SizeX',site),
00245                               sizeY=self.param_diffname('Curtain','SizeY',site),
00246                               sizeZ=self.param_fullname('SizeZ')),
00247                           subtracted)
00248 
00249         else:
00250             for ind in range(0,4):
00251                 subtracted.append(BooleanSecondary(
00252                     Box(site.lower()+'_pool_'+self.name.lower()+'_sub%d'%ind,
00253                         sizeX=self.param_fullname('BevelSize'),
00254                         sizeY=self.param_fullname('BevelSize'),
00255                         sizeZ="1*cm+"+self.param_fullname('SizeZ')),
00256                     PosXYZ(X=signX[ind]%self.param_fullname('SizeX',site),
00257                            Y=signY[ind]%self.param_fullname('SizeY',site),
00258                            Z="0*m"),
00259                     RotXYZ(rotZ="45*degree")))
00260 
00261             # Make the subtraction
00262             sub = Boolean("subtraction",site.lower()+'_pool_'+self.name.lower()+'_box',
00263                           Box(site.lower()+'_pool_'+self.name.lower(),
00264                               sizeX=self.param_fullname('SizeX',site),
00265                               sizeY=self.param_fullname('SizeY',site),
00266                               sizeZ=self.param_fullname('SizeZ')),
00267                           subtracted)
00268                 
00269 
00270         if self.child: 
00271             from XmlDetDescGen.geometry import Physvol
00272 
00273             pvs = self.child.physical_volume(site)
00274             if gen_pool_pmts and site=="Far" and self.name == "OWS":
00275                 pvs.append(Physvol("pv%sOutPTE"%site,"/dd/Geometry/PmtPanel/lv%sOutPTE"%site))
00276             if gen_pool_pmts and site=="Near" and self.name == "OWS":
00277                 pvs.append(Physvol("pvVetoPmt%sOutFacein"%site,"/dd/Geometry/PmtPanel/lvVetoPmt%sOutFacein"%site, PosXYZ(Z="-PoolOWSSizeZ/2.")))
00278                 pvs.append(Physvol("pvVetoPmt%sOutFaceout"%site,"/dd/Geometry/PmtPanel/lvVetoPmt%sOutFaceout"%site, PosXYZ(Z="-PoolOWSSizeZ/2.")))
00279             
00280         else:                   # must be OWS, add ADEs
00281             #from XmlDetDescGen.util import ExternalEntity
00282             #pvs = [ ExternalEntity('AD%sPlacements'%site) ]
00283 
00284             from XmlDetDescGen.geometry import Physvol, PosXYZ, RotXYZ
00285 
00286             import sys
00287             print sys.argv[0],'Configuring for',style
00288 
00289             
00290             pvs = []
00291             ade_rotation = RotXYZ(rotZ="ADrotation")
00292             if site == 'Near':
00293                 pvs.append(Physvol("pvNearADE1","/dd/Geometry/AD/lvADE",
00294                                    PosXYZ(X="1*(0.5*NearPoolIWSSizeX-PoolIWSThickness)",
00295                                           Z="ADadeZplace"),
00296                                    ade_rotation));
00297                 if Eight :
00298                     pvs.append(Physvol("pvNearADE2","/dd/Geometry/AD/lvADE",
00299                                        PosXYZ(X="-1*(0.5*NearPoolIWSSizeX-PoolIWSThickness)",
00300                                               Z="ADadeZplace"),
00301                                        ade_rotation));
00302                 else:
00303                     print 'WARNING. Did not install NearADE2. Configuring for',style
00304             else:
00305                 # 5dec11 djaffe: swap ad1,ad2 to reflect actual deployment
00306                 pvs.append(Physvol("pvFarADE1","/dd/Geometry/AD/lvADE",
00307                                    PosXYZ(X="-1*(0.5*FarPoolIWSSizeX-PoolIWSThickness)",
00308                                           Y="1*(0.5*FarPoolIWSSizeY-PoolIWSThickness)",
00309                                           Z="ADadeZplace"),
00310                                    ade_rotation));
00311                 pvs.append(Physvol("pvFarADE2","/dd/Geometry/AD/lvADE",
00312                                    PosXYZ(X="1*(0.5*FarPoolIWSSizeX-PoolIWSThickness)",
00313                                           Y="1*(0.5*FarPoolIWSSizeY-PoolIWSThickness)",
00314                                           Z="ADadeZplace"),
00315                                    ade_rotation));
00316                 pvs.append(Physvol("pvFarADE3","/dd/Geometry/AD/lvADE",
00317                                    PosXYZ(X="-1*(0.5*FarPoolIWSSizeX-PoolIWSThickness)",
00318                                           Y="-1*(0.5*FarPoolIWSSizeY-PoolIWSThickness)",
00319                                           Z="ADadeZplace"),
00320                                    ade_rotation));
00321                 if Eight :
00322                     pvs.append(Physvol("pvFarADE4","/dd/Geometry/AD/lvADE",
00323                                        PosXYZ(X="1*(0.5*FarPoolIWSSizeX-PoolIWSThickness)",
00324                                               Y="-1*(0.5*FarPoolIWSSizeY-PoolIWSThickness)",
00325                                               Z="ADadeZplace"),
00326                                        ade_rotation));
00327                 else:
00328                     print 'WARNING: Did not install FarADE4. Configuring for',style
00329 
00330             if gen_pool_pmts and site=="Far":
00331                 pvs.append(Physvol("pv%sInPTE"%site,"/dd/Geometry/PmtPanel/lv%sInPTE"%site))
00332             if gen_pool_pmts and site=="Near":
00333                 pvs.append(Physvol("pvVetoPmt%sInn"%site,"/dd/Geometry/PmtPanel/lvVetoPmt%sInn"%site, PosXYZ(Z="(PoolIWSSizeZ-PoolOWSSizeZ)/2.-PoolOWSSizeZ/2.")))
00334 
00335         from XmlDetDescGen.util import ExternalEntity
00336         pvs.append(ExternalEntity("%sHandWrittenPhysVols"%site))
00337 
00338         lv = Logvol('lv'+site+'Pool'+self.name,self.material,sub,pvs)
00339         self.logvol[site] = lv;
00340         return lv;
00341 
00342     def physical_volume(self,site):
00343         try:
00344             return self.physvol[site]
00345         except KeyError:
00346             pass
00347 
00348         from XmlDetDescGen.geometry import Physvol,PosXYZ
00349             
00350         lv = self.logical_volume(site)
00351         #print site,self.name,lv.name
00352         pv = Physvol('pv'+site+'Pool'+self.name,lv,
00353                      PosXYZ(X="0*m",Y="0*m",Z=self.param_fullname('LiftSizeZ')))
00354         self.physvol[site] = [pv]
00355         return self.physvol[site]
00356     
00357 
00358 
00359 class Pool:
00360     def __init__(self):
00361         self.parameters_filename="parameters.xml"
00362         self.geometry_filename="geometry.xml"
00363         self.structure_filename="structure.xml"
00364 
00365         hallbot = Element("HallBot","bottom of hall","Rock")
00366         dead = Element("Dead","dead space","DeadWater","84*mm",hallbot)
00367 #        liner = Element("Liner","tyvek liner","Tyvek","50*micrometer",dead)
00368         liner = Element("Liner","tyvek liner","Tyvek","4*mm",dead)
00369         ows = Element("OWS","outer water shield","OwsWater","1.0*m",liner)
00370 #        curtain = Element("Curtain","tyvek curtain","Tyvek","50*micrometer",ows)
00371         curtain = Element("Curtain","tyvek curtain","Tyvek","4*mm",ows)
00372         iws = Element("IWS","inner water shield","IwsWater","4.037*m",curtain)
00373 
00374         self.pool_elements = { "Dead":dead, "Liner":liner, "OWS":ows, "Curtain":curtain, "IWS":iws }
00375 
00376         #self.general_parameters = [
00377         #    Parameter("PoolLipHeight","0.2*m","Height of concrete lip around pool")
00378         #    ]
00379 
00380         self.geometry_cat = None
00381         self.outdir = "."
00382         return
00383 
00384     def geometry_catalog(self):
00385         if self.geometry_cat: return self.geometry_cat
00386 
00387         from XmlDetDescGen.catalog import Catalog
00388         from XmlDetDescGen.reference import Reference
00389 
00390         topcat = Catalog('Geometry');
00391         poolcat = Catalog('Pool');
00392 
00393         # This is fake, just to get the right /dd/Geometry path
00394         topcat.refs = [ Reference("#Pool",poolcat) ]
00395 
00396         for name in pool_element_names:
00397             ele = self.pool_elements[name]
00398             for site in ["Near","Far"]:
00399                 lv = ele.logical_volume(site)
00400                 poolcat.refs.append(Reference("%s.xml#%s"%(name,lv.name),lv))
00401                 continue
00402             continue
00403 
00404         # Important, needed so full_paths can be set
00405         topcat.update()
00406 
00407         self.geometry_cat = poolcat
00408         return poolcat
00409 
00410 
00411     def get_param_header(self):
00412 
00413         from XmlDetDescGen.util import Comment
00414 
00415         s = []
00416         s.append('''
00417      Define the water pool.  This is done by subsequently placing
00418      these volumes inside the bootom of the hall and then placing each
00419      in the previous.
00420 ''')
00421         for thing in pool_element_names:
00422             s.append('    - %s'%thing)
00423             continue
00424         s.append('''
00425      Each of these elements are specified by their thickness relative
00426      to their parents and the assumptions that they are concentric in
00427      X and Y and are lifted by one thickness when placed so that all
00428      their tops are coplanar.  In addition, a bevel size is
00429      calculated.  This is used to subtract out the corners of the
00430      boxes to make octagonal shapes.  It is assumed that Z sizes are
00431      site-independent.
00432 
00433      This all results in parameters looking like:
00434 
00435      NearPool_THING_SizeX
00436      NearPool_THING_SizeY
00437       FarPool_THING_SizeX
00438       FarPool_THING_SizeY
00439          Pool_THING_SizeZ
00440          Pool_THING_LiftZ
00441          Pool_THING_BevelSize
00442 
00443      Where _THING_ is
00444 ''')
00445         for thing in pool_element_names:
00446             ele = self.pool_elements[thing]
00447             s.append('    %s - %s'%(ele.name,ele.nick))
00448             continue
00449         return Comment('\n'.join(s))
00450 
00451     def get_pool_parameters(self):
00452         from XmlDetDescGen.parameter import Parameter
00453         ret = [Parameter('TableHeight','2.5*m','Distance from pool floor to AD table'),
00454                Parameter("ADadeZplace",'TableHeight+0.5*ADadeHeight-0.5*PoolIWSSizeZ-PoolDeadThickness-PoolLinerThickness-PoolOWSThickness-PoolCurtainThickness','A position of AD adeelopes'),]
00455         
00456         for thing in pool_element_names:
00457             ele = self.pool_elements[thing]
00458             params = ele.parameters()
00459             p = params[ele.param_fullname('Thickness')]
00460             ret.append(p)
00461             continue
00462         for thing in pool_element_names:
00463             ele = self.pool_elements[thing]
00464             for name,param in ele.params.iteritems():
00465                 if name == ele.param_fullname('Thickness'):continue
00466                 ret.append(param)
00467                 continue
00468             continue
00469         return ret
00470 
00471     def parameters_file(self):
00472         from XmlDetDescGen.util import XmlFile
00473         objects = [self.get_param_header()]
00474         objects.extend(self.get_pool_parameters())
00475         file = XmlFile(objects=objects)
00476         file.write(self.outdir+"/"+self.parameters_filename)
00477         return
00478 
00479     def geometry_files(self):
00480         from XmlDetDescGen.util import XmlFile,ExternalEntity
00481         file = XmlFile(dtd="../DTD/geometry.dtd",
00482                        objects=[ExternalEntity("SiteParameters"),
00483                                 ExternalEntity("PoolParameters"),
00484                                 ExternalEntity("PoolDetailsParameters"),
00485                                 self.geometry_catalog()],
00486                        external_entities=[("SiteParameters","../Sites/parameters.xml"),("PoolDetailsParameters","../PoolDetails/parameters.xml"),
00487                                           ("PoolParameters","parameters.xml")])
00488         file.write(self.outdir+"/"+self.geometry_filename)
00489         return
00490 
00491 
00492     def thing_files(self):
00493         from XmlDetDescGen.util import XmlFile,ExternalEntity
00494         for name in pool_element_names:
00495             ele = self.pool_elements[name]
00496 
00497             ees = [("SiteParameters","../Sites/parameters.xml"),("PoolDetailsParameters","../PoolDetails/parameters.xml"),
00498                    ("PoolParameters","parameters.xml"),
00499                    ("FarHandWrittenPhysVols","../PoolDetails/Far%sPhysVols.xml"%name),
00500                    ("NearHandWrittenPhysVols","../PoolDetails/Near%sPhysVols.xml"%name)]
00501 
00502             objects = [ExternalEntity("SiteParameters"),ExternalEntity("PoolDetailsParameters"),
00503                        ExternalEntity("PoolParameters")]
00504 
00505             if name == "IWS":
00506                 ees += [("ADParameters","../AD/parameters.xml")]
00507                 objects += [ExternalEntity("ADParameters")]
00508                 pass
00509 
00510             objects += [ele.logical_volume("Near"),
00511                         ele.logical_volume("Far")]
00512 
00513             file = XmlFile(dtd="../DTD/geometry.dtd",
00514                            objects=objects,
00515                            external_entities=ees)
00516             file.write("%s/%s.xml"%(self.outdir,name))
00517             continue
00518         return
00519 
00520     def detid(self,loc,det):
00521         # All hard coded numbers from Conventions/DetectorId.h
00522         if loc.lower() == 'db':
00523             iloc = 0x01
00524         elif loc.lower() == 'la':
00525             iloc = 0x02
00526         elif loc.lower() == 'far':
00527             iloc = 0x04
00528         else:
00529             iloc = 0x00
00530         if det.lower() == 'iws':
00531             idet = 5
00532         elif det.lower() == 'ows':
00533             idet = 6
00534         else:
00535             idet = 0
00536         detid = ((iloc<<24)|(idet<<16))
00537         from XmlDetDescGen.structure import UserParameter
00538         return UserParameter("DetectorID","int", ['0x%x'%detid],
00539                              desc="Packed Detector ID")
00540 
00541 
00542         
00543     def structure_file(self):
00544         from XmlDetDescGen.util import XmlFile,ExternalEntity
00545         from XmlDetDescGen.reference import Reference
00546         from XmlDetDescGen.structure import DetElem
00547         from XmlDetDescGen.catalog import Catalog
00548 
00549         ees = [ ("dbInnFinpmts", "../PoolPmtStructure/dbInnFin.xml"),
00550                 ("dbOutFinpmts", "../PoolPmtStructure/dbOutFin.xml"),
00551                 ("dbOutFoutpmts", "../PoolPmtStructure/dbOutFout.xml"),
00552                 ("laInnFinpmts", "../PoolPmtStructure/laInnFin.xml"),
00553                 ("laOutFinpmts", "../PoolPmtStructure/laOutFin.xml"),
00554                 ("laOutFoutpmts", "../PoolPmtStructure/laOutFout.xml"),
00555                 ("farInnFinpmts", "../PoolPmtStructure/farInnFin.xml"),
00556                 ("farOutFinpmts", "../PoolPmtStructure/farOutFin.xml"),
00557                 ("farOutFoutpmts", "../PoolPmtStructure/farOutFout.xml") 
00558                 ]
00559 
00560         file = XmlFile(dtd="../DTD/structure.dtd",
00561                        external_entities=ees)
00562 
00563         # To assure logical volume's full_path is set
00564         gc = self.geometry_catalog()
00565         gc.update()
00566 
00567         topcat = Catalog('Structure');
00568         poolcat = Catalog('Pool');
00569         # Clear our refs because some how this is filled with the
00570         # contents of the /Geometry/Pool catalog!  Python bug???
00571         poolcat.refs = []       
00572         topcat.refs = [ poolcat ]
00573 
00574         base = "/dd/Structure/Pool/"
00575 
00576         delist = {"DB":[],"LA":[],"Far":[]}
00577 
00578         last_support = "/dd/Structure/Sites/%(loc)s-rock"
00579 
00580         import sys
00581         print sys.argv[0],'Structuring for',style
00582 
00583         for (thing,npath) in pool_detelem_data:
00584             ele = self.pool_elements[thing]
00585             nf="Near"
00586             nlf="Near"
00587             if Eight: 
00588                 ADnumbers = [2,2,4]
00589             else:
00590                 ADnumbers = [1,1,3]
00591 
00592             for loc,adn in zip(["DB","LA","Far"], ADnumbers ):
00593                 if loc == "LA" : 
00594                     nlf = "LA"
00595                 if loc == "Far": 
00596                     nf = "Far"
00597                     nlf = "Far"
00598                 lv_name = '/dd/Geometry/Pool/'+ele.logical_volume(nf).name
00599                 de = DetElem(loc.lower()+'-'+thing.lower(),
00600                              lv_name,
00601                              npath%{"loc":loc,"nf":nf,"nlf":nlf},
00602                              last_support%{'loc':loc.lower()})
00603                 de.refs = []
00604                 if thing == 'IWS':
00605                     for iad in range(0,adn):
00606                         iad+=1
00607                         href='../AD%s/structure.xml#%s-ade%d'%(suffix,loc.lower(),iad)
00608                         de.refs.append(Reference(href,de))
00609                         continue
00610                 if thing == 'IWS':
00611                     de.refs.append(ExternalEntity(loc.lower()+"InnFinpmts"))
00612                 if thing == 'OWS':
00613                     de.refs.append(ExternalEntity(loc.lower()+"OutFinpmts"))
00614                     de.refs.append(ExternalEntity(loc.lower()+"OutFoutpmts"))
00615 
00616                 if thing == 'IWS' or thing == 'OWS':
00617                     de.refs.append(self.detid(loc,thing))
00618                 poolcat.things.append(de)
00619                 delist[loc].append(de)
00620                 continue
00621             last_support = base+"%(loc)s-"+ thing.lower()
00622             continue
00623         
00624 
00625         # Fix up detelemrefs
00626         for (k,lst) in delist.iteritems():
00627             lst.reverse()
00628             while lst:
00629                 de = lst.pop()
00630                 try:
00631                     next_de = lst[-1]
00632                 except IndexError:
00633                     break
00634                 de.refs.insert(0,Reference("#%s"%next_de.name,next_de))
00635                 continue
00636             continue
00637 
00638         file.objects = [ poolcat ]
00639         file.write(self.outdir+"/"+self.structure_filename)
00640         return
00641 
00642 
00643 def main():
00644 
00645 
00646     import sys
00647     import os
00648 
00649     pool = Pool()
00650         
00651     try:
00652         xddroot = sys.argv[1]
00653     except IndexError:
00654         xddroot = os.getenv("XMLDETDESCROOT")
00655 
00656     if not xddroot:
00657         print "No XMLDETDESCROOT directory given by environment or command line"
00658         print "Using current working directory"
00659         xddroot="."
00660 
00661     outdir=xddroot + "/DDDB/Pool" + suffix
00662     if not os.path.exists(outdir):
00663         print "Directory does not exist, please make first"
00664         print outdir
00665         sys.exit(1)
00666 
00667     pool.outdir = outdir
00668 
00669     pool.parameters_file()
00670     pool.geometry_files()
00671     pool.thing_files()
00672     pool.structure_file()
00673 
00674 if '__main__' == __name__:
00675     main()
00676     
00677 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:56:07 for XmlDetDesc by doxygen 1.7.4