File indexing completed on 2025-01-18 09:14:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
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
0023 def dumpData(det):
0024 try:
0025 dat = DDRec.FixedPadSizeTPCData(det)
0026 logger.info(dat.toString())
0027 except Exception:
0028 pass
0029 try:
0030 dat = DDRec.ZPlanarData(det)
0031 logger.info(dat.toString())
0032 except Exception:
0033 pass
0034 try:
0035 dat = DDRec.ZDiskPetalsData(det)
0036 logger.info(dat.toString())
0037 except Exception:
0038 pass
0039 try:
0040 dat = DDRec.ConicalSupportData(det)
0041 logger.info(dat.toString())
0042 except Exception:
0043 pass
0044 try:
0045 dat = DDRec.LayeredCalorimeterData(det)
0046 logger.info(dat.toString())
0047 except Exception:
0048 pass
0049 try:
0050 dat = DDRec.NeighbourSurfacesStruct(det)
0051 logger.info(dat.toString())
0052 except Exception:
0053 pass
0054
0055
0056 parser = optparse.OptionParser()
0057 parser.formatter.width = 132
0058 parser.description = "Dump detector data objects from DDRec"
0059 parser.add_option("-c", "--compact", dest="compact", default=None,
0060 help="Define LCCDD style compact xml input",
0061 metavar="<FILE>")
0062
0063 (opts, args) = parser.parse_args()
0064
0065 if opts.compact is None:
0066 logger.info(" %s", parser.format_help())
0067 sys.exit(1)
0068
0069 try:
0070 from ROOT import gROOT
0071 gROOT.SetBatch(1)
0072 except ImportError as X:
0073 logger.error('PyROOT interface not accessible: %s', str(X))
0074 logger.error("%s", parser.format_help())
0075 sys.exit(errno.ENOENT)
0076
0077 try:
0078 import dd4hep
0079 except ImportError as X:
0080 logger.error('dd4hep python interface not accessible: %s', str(X))
0081 logger.error("%s", parser.format_help())
0082 sys.exit(errno.ENOENT)
0083
0084 try:
0085 import DDRec
0086 except ImportError as X:
0087 logger.error('ddrec python interface not accessible: %s', str(X))
0088 logger.error("%s", parser.format_help())
0089 sys.exit(errno.ENOENT)
0090
0091
0092 dd4hep.setPrintLevel(dd4hep.OutputLevel.ERROR)
0093 logger.info('+++%s\n+++ Loading compact geometry:%s\n+++%s', 120 * '=', opts.compact, 120 * '=')
0094
0095
0096 description = dd4hep.Detector.getInstance()
0097 description.fromXML(opts.compact)
0098
0099
0100
0101
0102 for n, d in description.detectors():
0103
0104 logger.info("")
0105 logger.info(" ------------- detector : %s", d.name())
0106 logger.info("")
0107
0108 det = description.detector(n)
0109
0110 dumpData(det)
0111
0112
0113
0114
0115 logger.info('+++ Execution finished...')
0116 sys.exit(0)