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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 618812f7..8316ba67 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,6 +46,7 @@ ENDIF()
#############################################################
ENABLE_LANGUAGE(CXX)
+ENABLE_LANGUAGE(C)
# Set C++ standard
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard used for compiling")
diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp
index fab6267f..581f535f 100644
--- a/DDCore/src/plugins/Compact2Objects.cpp
+++ b/DDCore/src/plugins/Compact2Objects.cpp
@@ -805,21 +805,48 @@ template <> void Converter<PropertyTable>::operator()(xml_h e) const {
}
#endif
-/** Convert compact visualization attribute to Detector visualization attribute
+/** Convert compact visualization attribute to Detector visualization attribute.
*
* <vis name="SiVertexBarrelModuleVis"
* alpha="1.0" r="1.0" g="0.75" b="0.76"
* drawingStyle="wireframe"
* showDaughters="false"
* visible="true"/>
+ *
+ * Optionally inherit an already defined VisAttr and override other properties.
+ *
+ * <vis name="SiVertexEndcapModuleVis"
+ * ref="SiVertexBarrelModuleVis"
+ * alpha="0.5"/>
*/
template <> void Converter<VisAttr>::operator()(xml_h e) const {
VisAttr attr(e.attr<string>(_U(name)));
+ float alpha = 1.0;
+ float red = 1.0;
+ float green = 1.0;
+ float blue = 1.0;
+ bool use_ref = false;
+ if(e.hasAttr(_U(ref))) {
+ use_ref = true;
+ auto refName = e.attr<string>(_U(ref));
+ const auto refAttr = description.visAttributes(refName);
+ if(!refAttr.isValid() ) {
+ throw runtime_error("reference VisAttr " + refName + " does not exist");
+ }
+ // Just copying things manually.
+ // I think a handle's copy constructor/assignment would reuse the underlying pointer... maybe?
+ refAttr.argb(alpha,red,green,blue);
+ attr.setColor(alpha,red,green,blue);
+ attr.setDrawingStyle( refAttr.drawingStyle());
+ attr.setLineStyle( refAttr.lineStyle());
+ attr.setShowDaughters(refAttr.showDaughters());
+ attr.setVisible(refAttr.visible());
+ }
xml_dim_t dim(e);
- float alpha = dim.alpha(1.0);
- float red = dim.r(1.0);
- float green = dim.g(1.0);
- float blue = dim.b(1.0);
+ alpha = dim.alpha(alpha);
+ red = dim.r(red );
+ green = dim.g(green);
+ blue = dim.b(blue );
printout(s_debug.visattr ? ALWAYS : DEBUG, "Compact",
"++ Converting VisAttr structure: %-16s. Alpha=%.2f R=%.3f G=%.3f B=%.3f",
@@ -835,7 +862,8 @@ template <> void Converter<VisAttr>::operator()(xml_h e) const {
attr.setLineStyle(VisAttr::DASHED);
}
else {
- attr.setLineStyle(VisAttr::SOLID);
+ if (!use_ref)
+ attr.setLineStyle(VisAttr::SOLID);
}
if (e.hasAttr(_U(drawingStyle))) {
string ds = e.attr<string>(_U(drawingStyle));
@@ -845,12 +873,15 @@ template <> void Converter<VisAttr>::operator()(xml_h e) const {
attr.setDrawingStyle(VisAttr::SOLID);
}
else {
- attr.setDrawingStyle(VisAttr::SOLID);
+ if (!use_ref)
+ attr.setDrawingStyle(VisAttr::SOLID);
}
if (e.hasAttr(_U(showDaughters)))
attr.setShowDaughters(e.attr<bool>(_U(showDaughters)));
- else
- attr.setShowDaughters(true);
+ else {
+ if (!use_ref)
+ attr.setShowDaughters(true);
+ }
description.addVisAttribute(attr);
}
diff --git a/DDG4/edm4hep/Geant4Output2EDM4hep.cpp b/DDG4/edm4hep/Geant4Output2EDM4hep.cpp
index 555e4e52..504fb8e4 100644
--- a/DDG4/edm4hep/Geant4Output2EDM4hep.cpp
+++ b/DDG4/edm4hep/Geant4Output2EDM4hep.cpp
@@ -20,6 +20,7 @@
#include "DDG4/Geant4HitCollection.h"
#include "DDG4/Geant4OutputAction.h"
#include "DDG4/Geant4SensDetAction.h"
+#include "DDG4/Geant4DataConversion.h"
#include "DDG4/EventParameters.h"
// Geant4 headers
@@ -563,16 +564,23 @@ void Geant4Output2EDM4hep::createCollections(OutputContext<G4Event>& ctxt){
continue ;
}
+ Geant4Sensitive* sd = coll->sensitive();
+ string sd_enc = dd4hep::sim::Geant4ConversionHelper::encoding(sd->sensitiveDetector());
+
if( typeid( Geant4Tracker::Hit ) == coll->type().type() ){
- m_store->create<edm4hep::SimTrackerHitCollection>(colName);
+ auto& sthc = m_store->create<edm4hep::SimTrackerHitCollection>(colName);
m_file->registerForWrite(colName);
+ auto& sthc_md = m_store->getCollectionMetaData( sthc.getID() );
+ sthc_md.setValue("CellIDEncodingString", sd_enc);
printout(DEBUG,"Geant4Output2EDM4hep","+++ created collection %s",colName.c_str() );
}
else if( typeid( Geant4Calorimeter::Hit ) == coll->type().type() ){
- m_store->create<edm4hep::SimCalorimeterHitCollection>(colName);
+ auto& schc = m_store->create<edm4hep::SimCalorimeterHitCollection>(colName);
m_file->registerForWrite(colName);
+ auto& schc_md = m_store->getCollectionMetaData( schc.getID() );
+ schc_md.setValue("CellIDEncodingString", sd_enc);
printout(DEBUG,"Geant4Output2EDM4hep","+++ created collection %s",colName.c_str() );
colName += "Contributions" ;
diff --git a/DDG4/src/Geant4ShapeConverter.cpp b/DDG4/src/Geant4ShapeConverter.cpp
index 2a79a69a..6f4af522 100644
--- a/DDG4/src/Geant4ShapeConverter.cpp
+++ b/DDG4/src/Geant4ShapeConverter.cpp
@@ -205,8 +205,9 @@ namespace dd4hep {
template <> G4VSolid* convertShape<TGeoSphere>(const TGeoShape* shape) {
const TGeoSphere* sh = (const TGeoSphere*) shape;
- return new G4Sphere(sh->GetName(), sh->GetRmin() * CM_2_MM, sh->GetRmax() * CM_2_MM, sh->GetPhi1() * DEGREE_2_RAD,
- sh->GetPhi2() * DEGREE_2_RAD, sh->GetTheta1() * DEGREE_2_RAD, sh->GetTheta2() * DEGREE_2_RAD);
+ return new G4Sphere(sh->GetName(), sh->GetRmin() * CM_2_MM, sh->GetRmax() * CM_2_MM,
+ sh->GetPhi1() * DEGREE_2_RAD, (sh->GetPhi2()-sh->GetPhi1()) * DEGREE_2_RAD,
+ sh->GetTheta1() * DEGREE_2_RAD, (sh->GetTheta2()- sh->GetTheta1()) * DEGREE_2_RAD);
}
template <> G4VSolid* convertShape<TGeoTorus>(const TGeoShape* shape) {