Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:40

0001 #!/usr/bin/env python
0002 # ==========================================================================
0003 #  AIDA Detector description implementation
0004 # --------------------------------------------------------------------------
0005 # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0006 # All rights reserved.
0007 #
0008 # For the licensing terms see $DD4hepINSTALL/LICENSE.
0009 # For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0010 #
0011 # ==========================================================================
0012 
0013 from __future__ import absolute_import, unicode_literals
0014 import sys
0015 import errno
0016 import argparse
0017 import logging
0018 
0019 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0020 logger = logging.getLogger(__name__)
0021 
0022 parser = argparse.ArgumentParser()
0023 parser.description = "Check TGeo geometries for overlaps."
0024 parser.add_argument("-c", "--compact", dest="compact", default=None, nargs='+',
0025                     help="Define LCCDD style compact xml input",
0026                     metavar="<FILE>")
0027 parser.add_argument("-p", "--print",
0028                     dest="print_overlaps", default=True,
0029                     help="Print overlap information to standard output (default:True)",
0030                     metavar="<boolean>")
0031 parser.add_argument("-q", "--quiet",
0032                     action="store_false", dest="print_overlaps",
0033                     help="Do not print (disable --print)")
0034 parser.add_argument("-t", "--tolerance", dest="tolerance", default=0.1,
0035                     type=float,
0036                     help="Overlap checking tolerance. Unit is in [mm]. (default:0.1 mm)",
0037                     metavar="<double number>")
0038 parser.add_argument("-o", "--option", dest="option", default='',
0039                     help="Overlap checking option ('' or 's')",
0040                     metavar="<string>")
0041 
0042 args = parser.parse_args()
0043 
0044 if args.compact is None:
0045   logger.info("    %s", parser.format_help())
0046   sys.exit(1)
0047 
0048 try:
0049   from ROOT import gROOT
0050   gROOT.SetBatch(1)
0051 except ImportError as X:
0052   logger.error('PyROOT interface not accessible: %s', str(X))
0053   logger.error("%s", parser.format_help())
0054   sys.exit(errno.ENOENT)
0055 
0056 try:
0057   import dd4hep
0058 except ImportError as X:
0059   logger.error('dd4hep python interface not accessible: %s', str(X))
0060   logger.error("%s", parser.format_help())
0061   sys.exit(errno.ENOENT)
0062 #
0063 #
0064 dd4hep.setPrintLevel(dd4hep.OutputLevel.ERROR)
0065 logger.info('+++%s', 120 * '=')
0066 logger.info('+++ Loading compact geometry:')
0067 for xmlfile in args.compact:
0068   logger.info('+++ ' + xmlfile)
0069 logger.info('+++ tolerance: %f, option: %s', args.tolerance, args.option)
0070 logger.info('+++%s\n', 120 * '=')
0071 description = dd4hep.Detector.getInstance()
0072 for xmlfile in args.compact:
0073   description.fromXML(xmlfile)
0074 
0075 logger.info(str(description.constants()))
0076 
0077 description.manager().CheckOverlaps(args.tolerance, args.option)
0078 #
0079 #
0080 if args.print_overlaps:
0081   logger.info('+++%s', 120 * '=')
0082   logger.info('+++ Printing overlaps of geometry:')
0083   for xmlfile in args.compact:
0084     logger.info('+++ %s', xmlfile)
0085   logger.info('+++%s\n', 120 * '=')
0086   description.manager().PrintOverlaps()
0087 #
0088 #
0089 logger.info('+++ Execution finished...')
0090 sys.exit(0)