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

In This Package:

test.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # =============================================================================
00003 # minimal test of det desc based on VolumeCheck.py
00004 import os 
00005 import gaudimodule as gaudi
00006 
00007 
00008 def init(loc) :
00009 
00010     #gaudi.loaddict('DetDict')
00011     g=gaudi.AppMgr()
00012     #g.DLLs   += [ "XmlTools"   , "DetDescCnv"    ,
00013     #              "DetDescSvc" , "DetDescChecks" , "RootHistCnv" ]
00014 
00015     g.HistogramPersistency = "ROOT"
00016     g.config()
00017 
00018     hsvc = g.service('HistogramPersistencySvc')
00019     hsvc.OutputFile = "test.root"
00020 
00021 
00022     g.DLLs += [ "RootHistCnv" ]
00023     g.ExtSvc += [ "XmlCnvSvc" , "XmlParserSvc" ] 
00024     g.EvtSel = "NONE"
00025     
00026     det = g.service('DetectorPersistencySvc')
00027     det.CnvServices = ["XmlCnvSvc"]
00028 
00029     det = g.service('XmlCnvSvc')
00030     det.AllowGenericConversion = True
00031 
00032     det = g.service('DetectorDataSvc')
00033     det.UsePersistency = True
00034     det.DetDbRootName  = "dd"
00035     det.DetStorageType = 7
00036     #det.DetDbLocation  = '/home/bviren/work/dayabay/code/lhcb/Det/XmlDDDB/DDDB/lhcb.xml'
00037     #det.DetDbLocation  = '/home/bviren/work/dayabay/code/dddb/dayabay.xml'
00038     det.DetDbLocation  = loc
00039     
00040     
00041 
00042 def run( volume , event = 1 ) :
00043     g = gaudi.AppMgr() 
00044     g.TopAlg = ["VolumeCheckAlg/Check"]
00045     
00046     alg = g.algorithm('Check')
00047     alg.Shots3D = 10000
00048     alg.ShotsXY = 100000
00049     alg.ShotsYZ = 10000
00050     alg.ShotsZX = 10000
00051     alg.Volume  = volume
00052     g.run( event )
00053     
00054 def _dir_ ( self , node = None , level = -1 ) :
00055     """
00056     The simple tool to perform the inspection fo Data Store
00057     
00058     Usage:
00059     
00060     evtSvc = gaudi.evtSvc()
00061     evtSvc.dir('MC')
00062     data = evtSvc['Rec/Calo']
00063     evtSvc.dir( data)
00064     
00065     """
00066     if 0 == level          : return gaudi.SUCCESS ;
00067     if   str is type(node) : node = self.retrieveObject( node )
00068     elif  not node         : return self.dir('', level )
00069     if not node            : return gaudi.FAILURE
00070     if     hasattr ( node , 'registry'   ) : node = node.registry()
00071     if     hasattr ( node , 'identifier' ) :
00072         obj = node.object ()
00073         if not obj :
00074             obj = self.retrieveObject( node.identifier() ) 
00075             print  node.identifier()
00076         else :
00077             if hasattr( obj , 'size'    ) :
00078                 size = obj.size()
00079                 if 0 == size : print "%s (empty) %s" % (  node.identifier() , type( obj ) )
00080                 elif hasattr ( obj , 'containedObjects' ) :
00081                     c = obj.containedObjects()[0]
00082                     print "%s container of %d %s objects " % ( node.identifier() , obj.size() , type(c))
00083                 else : 
00084                     print  "%s %s " % (  node.identifier() , type( node.object()) )
00085             else :
00086                 print  "%s %s " % (  node.identifier() , type( node.object()) )
00087     else : print "The node has no 'identifier'"
00088     # start the recursion 
00089     for l in self.leaves( node ) :
00090         if l : self.dir( l , level - 1 )  
00091     return gaudi.SUCCESS 
00092 
00093 def _get_( self , node = None , cut = lambda x : True ) :
00094     if   str is type(node) : node = self.retrieveObject( node )
00095     elif  not node         : return _get_( self , '' , cut  )
00096     if not node            : return []
00097     if     hasattr ( node , 'registry'   ) : node = node.registry()
00098     result = []
00099     if     hasattr ( node , 'identifier' ) :
00100         obj = node.object()
00101         if cut( obj ) : result += [ obj ]
00102     for l in self.leaves ( node ) :
00103         if l : result += _get_( self , l , cut )
00104     return result 
00105     
00106 gaudi.iDataSvc.dir = _dir_ 
00107 gaudi.iDataSvc.DIR = _get_ 
00108 
00109 
00110 if "__main__" == __name__  :
00111     import sys
00112 
00113     try: 
00114         loc = sys.argv[1]
00115     except:
00116         loc='/home/bviren/work/dayabay/code/dddb/trivial.xml'
00117         print "Using default XML file:\n",loc
00118 
00119     try:
00120         vol = sys.argv[2]
00121     except:
00122         vol='/dd/Geometry/Trivial/lvWorld'
00123         print "using default volume:\n",vol
00124 
00125     init(loc)
00126     #run ("/dd/Geometry/Sites/lvNearSiteRock")
00127     run (vol)
00128 
00129 
00130 
00131 
00132 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:05:13 2011 for DetDescChecks by doxygen 1.4.7