Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/python
#==========================================================================
# AIDA Detector description implementation
#--------------------------------------------------------------------------
# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
# All rights reserved.
#
# For the licensing terms see $DD4hepINSTALL/LICENSE.
# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
#
#==========================================================================
import sys, errno, optparse, logging
def dumpData( det ):
try:
dat = DDRec.FixedPadSizeTPCData(det)
print dat.toString()
except:
pass
try:
dat = DDRec.ZPlanarData(det)
print dat.toString()
except:
pass
try:
dat = DDRec.ZDiskPetalsData(det)
print dat.toString()
except:
pass
try:
dat = DDRec.ConicalSupportData(det)
print dat.toString()
except:
pass
try:
dat = DDRec.LayeredCalorimeterData(det)
print dat.toString()
except:
pass
try:
dat = DDRec.NeighbourSurfacesStruct(det)
print dat.toString()
except:
pass
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
parser = optparse.OptionParser()
parser.formatter.width = 132
parser.description = "Dump detector data objects from DDRec"
parser.add_option("-c", "--compact", dest="compact", default=None,
help="Define LCCDD style compact xml input",
metavar="<FILE>")
(opts, args) = parser.parse_args()
if opts.compact is None:
logging.info(" %s",parser.format_help())
sys.exit(1)
try:
import ROOT
from ROOT import gROOT
gROOT.SetBatch(1)
except ImportError,X:
logging.error('PyROOT interface not accessible: %s',str(X))
logging.error("%s",parser.format_help())
sys.exit(errno.ENOENT)
try:
import DD4hep
except ImportError,X:
logging.error('dd4hep python interface not accessible: %s',str(X))
logging.error("%s",parser.format_help())
sys.exit(errno.ENOENT)
#
try:
import DDRec
except ImportError,X:
logging.error('ddrec python interface not accessible: %s',str(X))
logging.error("%s",parser.format_help())
sys.exit(errno.ENOENT)
#
DD4hep.setPrintLevel(DD4hep.OutputLevel.ERROR)
logging.info('+++%s\n+++ Loading compact geometry:%s\n+++%s',120*'=',opts.compact,120*'=')
description = DD4hep.Detector.getInstance()
description.fromXML(opts.compact)
## ------ loop over detectors and print their detector data objects
for n,d in description.detectors():
print
print " ------------- detector : " , d.name()
print
det = description.detector( n )
dumpData(det)
##-----------------------------------------------------------------
logging.info('+++ Execution finished...')
sys.exit(0)