Newer
Older
Markus Frank
committed
#==========================================================================
Markus Frank
committed
#--------------------------------------------------------------------------
# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
Markus Frank
committed
# All rights reserved.
#
# For the licensing terms see $DD4hepINSTALL/LICENSE.
# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
#
#==========================================================================
Markus Frank
committed
import sys, errno, optparse, logging
Markus Frank
committed
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
parser.description = "Check TGeo geometries for overlaps."
parser.add_option("-c", "--compact", dest="compact", default=None,
help="Define LCCDD style compact xml input",
metavar="<FILE>")
parser.add_option("-p", "--print",
dest="print_overlaps", default=True,
help="Print overlap information to standard output (default:True)",
metavar="<boolean>")
parser.add_option("-q", "--quiet",
action="store_false", dest="print_overlaps",
help="Do not print (disable --print)")
parser.add_option("-t", "--tolerance", dest="tolerance", default=0.1,
help="Overlap checking tolerance. Unit is in [mm]. (default:0.1 mm)",
metavar="<double number>")
parser.add_option("-o", "--option", dest="option", default='',
help="Overlap checking option ('' or 's')",
metavar="<string>")
(opts, args) = parser.parse_args()
if opts.compact is None:
Markus Frank
committed
logging.info(" %s",parser.format_help())
try:
import ROOT
from ROOT import gROOT
gROOT.SetBatch(1)
except ImportError,X:
Markus Frank
committed
logging.error('PyROOT interface not accessible: %s',str(X))
logging.error("%s",parser.format_help())
Markus Frank
committed
logging.error('dd4hep python interface not accessible: %s',str(X))
logging.error("%s",parser.format_help())
sys.exit(errno.ENOENT)
#
#
opts.tolerance = float(opts.tolerance)
DD4hep.setPrintLevel(DD4hep.OutputLevel.ERROR)
Markus Frank
committed
logging.info('+++%s\n+++ Loading compact geometry:%s\n+++%s',120*'=',opts.compact,120*'=')
description = DD4hep.Detector.getInstance()
Markus Frank
committed
logging.info('+++%s\n+++ Checking overlaps of geometry:%s tolerance:%f option:%s\n+++%s',120*'=',opts.compact,opts.tolerance,opts.option,120*'=')
description.manager().CheckOverlaps(opts.tolerance,opts.option)
Markus Frank
committed
logging.info('+++%s\n+++ Printing overlaps of geometry:%s\n+++%s',120*'=',opts.compact,120*'=')
Markus Frank
committed
logging.info('+++ Execution finished...')