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 optparse
0017 import logging
0018 
0019 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0020 logger = logging.getLogger(__name__)
0021 
0022 parser = optparse.OptionParser()
0023 parser.description = "TGeo Geometry checking."
0024 parser.formatter.width = 132
0025 parser.add_option("-c", "--compact", dest="compact", default=None,
0026                   help="Define LCCDD style compact xml input",
0027                   metavar="<FILE>")
0028 
0029 parser.add_option("-f", "--full",
0030                   dest="full", default=False,
0031                   help="Full geometry checking",
0032                   metavar="<boolean>")
0033 
0034 parser.add_option("-n", "--ntracks",
0035                   dest="num_tracks", default=1000000,
0036                   help="Number of tracks [requires '--full']",
0037                   metavar="<integer>")
0038 
0039 parser.add_option("-x", "--vx",
0040                   dest="vx", default=0.0,
0041                   help="X-position of track origine vertex [requires '--full']",
0042                   metavar="<double>")
0043 
0044 parser.add_option("-y", "--vy",
0045                   dest="vy", default=0.0,
0046                   help="Y-position of track origine vertex [requires '--full']",
0047                   metavar="<double>")
0048 
0049 parser.add_option("-z", "--vz",
0050                   dest="vz", default=0.0,
0051                   help="Z-position of track origine vertex [requires '--full']",
0052                   metavar="<double>")
0053 
0054 parser.add_option("-o", "--option", dest="option", default='ob',
0055                   help="TGeoManager geometry check option default:ob",
0056                   metavar="<string>")
0057 
0058 (opts, args) = parser.parse_args()
0059 
0060 if opts.compact is None:
0061   logger.info("   %s", parser.format_help())
0062   sys.exit(1)
0063 
0064 try:
0065   from ROOT import gROOT
0066   gROOT.SetBatch(1)
0067 except ImportError as X:
0068   logger.error('PyROOT interface not accessible: %s', str(X))
0069   sys.exit(errno.ENOENT)
0070 
0071 try:
0072   import dd4hep
0073 except ImportError as X:
0074   logger.error('dd4hep python interface not accessible: %s', str(X))
0075   sys.exit(errno.ENOENT)
0076 
0077 dd4hep.setPrintLevel(dd4hep.OutputLevel.ERROR)
0078 logger.info('+++%s\n+++ Loading compact geometry:%s\n+++%s', 120 * '=', opts.compact, 120 * '=')
0079 description = dd4hep.Detector.getInstance()
0080 description.fromXML(opts.compact)
0081 opts.num_tracks = int(opts.num_tracks)
0082 opts.vx = float(opts.vx)
0083 opts.vy = float(opts.vy)
0084 opts.vz = float(opts.vz)
0085 logger.info('+++%s\n+++ Checking geometry:%s full-check:%s\n+++%s', 120 * '=', opts.compact, opts.full, 120 * '=')
0086 if opts.full:
0087   logger.info('+++ # tracks:%d vertex:(%7.3f, %7.3f, %7.3f) [cm]', opts.num_tracks, opts.vx, opts.vy, opts.vz)
0088   description.manager().CheckGeometryFull(opts.num_tracks, opts.vx, opts.vy, opts.vz, opts.option)
0089 else:
0090   description.manager().CheckGeometry()
0091 #
0092 #
0093 logger.info('+++ Execution finished...')
0094 sys.exit(0)