11 #include "G4VSolid.hh"
16 #include "G4Material.hh"
17 #include "G4LogicalVolume.hh"
18 #include "G4VPhysicalVolume.hh"
19 #include "G4PVPlacement.hh"
20 #include "G4ReflectionFactory.hh"
22 #include "G4UnitsTable.hh"
23 #include "G4SystemOfUnits.hh"
45 LogDebug(
"SimG4CoreGeometry") <<
"DDG4Builder::convertLV(): DDLogicalPart = " <<
part;
50 result =
new G4LogicalVolume(s,m,part.
name().
name());
54 LogDebug(
"SimG4CoreGeometry") <<
"DDG4Builder::convertLV(): new G4LogicalVolume " << part.
name().
name()
55 <<
"\nDDG4Builder: newEvent: dd=" << part.
ddname() <<
" g4=" << result->GetName();
70 LogDebug(
"SimG4CoreGeometry") <<
"DDDetConstr::ConvertMaterial: material=" << material;
74 if ((result =
mats_[material])) {
75 LogDebug(
"SimG4CoreGeometry") <<
" is already converted";
79 edm::LogError(
"SimG4CoreGeometry") <<
"DDG4Builder:: material " << material.
toString() <<
" is not valid (in the DDD sense!)";
80 throw cms::Exception(
"SimG4CoreGeometry",
" material is not valid from the Detector Description: " + material.
toString());
85 LogDebug(
"SimG4CoreGeometry") <<
" creating a G4-composite material. c=" << c
86 <<
" d=" << material.
density()/
g*mole ;
88 for (
int i=0 ;
i<
c; ++
i) {
90 LogDebug(
"SimG4CoreGeometry") <<
" adding the composite=" << material.
name()
98 LogDebug(
"SimG4CoreGeometry") <<
" building an elementary material"
99 <<
" z=" << material.
z()
100 <<
" a=" << material.
a()/
g*mole
101 <<
" d=" << material.
density()/
g*cm3 ;
102 result =
new G4Material
110 G4ReflectionFactory * refFact = G4ReflectionFactory::Instance();
111 refFact->SetScalePrecision(100.*refFact->GetScalePrecision());
115 typedef graph_type::const_adj_iterator adjl_iterator;
116 adjl_iterator git = gra.
begin();
117 adjl_iterator gend = gra.end();
119 graph_type::index_type
i=0;
120 for (; git != gend; ++git) {
123 edm::LogError(
"SimG4CoreGeometry") <<
"DDG4Builder::BuildGeometry() has encountered an undefined DDLogicalPart named " << ddLP.
toString();
124 throw cms::Exception(
"SimG4CoreGeometry",
" DDG4Builder::BuildGeometry() has encountered an undefined DDLogicalPart named " + ddLP.
toString());
126 G4LogicalVolume * g4LV =
convertLV(ddLP);
130 graph_type::edge_list::const_iterator cit = git->begin();
131 graph_type::edge_list::const_iterator cend = git->end();
132 for (; cit != cend; ++cit) {
136 std::string err =
" DDG4Builder::BuildGeometry() in processing \"children\" has ";
137 err +=
"encountered an undefined DDLogicalPart named " + ddLP.
toString();
145 rm.GetComponents(x, y, z);
146 if ((x.Cross(y)).Dot(z)<0)
147 LogDebug(
"SimG4CoreGeometry") <<
">>Reflection encountered: " << gra.edgeData(cit->second)->rot_ ;
148 LogDebug(
"SimG4CoreGeometry") <<
">>Placement d=" << gra.nodeData(cit->first).ddname()
149 <<
" m=" << ddLP.
ddname() <<
" cp=" << gra.edgeData(cit->second)->copyno_
150 <<
" r=" << gra.edgeData(cit->second)->rot_.ddname() ;
151 G4ThreeVector tempTran(gra.edgeData(cit->second)->trans_.X(), gra.edgeData(cit->second)->trans_.Y(), gra.edgeData(cit->second)->trans_.Z());
152 G4Translate3D transl = tempTran;
153 CLHEP::HepRep3x3
temp( x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z() );
154 CLHEP::HepRotation
hr (
temp );
157 G4Transform3D trfrm = transl * G4Rotate3D(hr.inverse());
159 refFact->Place(trfrm,
160 gra.nodeData(cit->first).name().name(),
164 gra.edgeData(cit->second)->copyno_+offset+
tag,
171 std::map<DDLogicalPart, G4LogicalVolume*>::const_iterator ddg4_it =
logs_.begin();
172 for (; ddg4_it !=
logs_.end(); ++ddg4_it) {
173 G4LogicalVolume * reflLogicalVolume = refFact->GetReflectedLV(ddg4_it->second);
174 if (reflLogicalVolume) {
179 LogDebug(
"SimG4CoreGeometry") <<
"DDG4Builder: newEvent: dd="
180 << ddlv.
ddname() <<
" g4="
181 << reflLogicalVolume->GetName();
200 std::vector<const DDsvalues_type *>::iterator it = result.begin();
201 bool foundIt =
false;
202 for (; it != result.end(); ++it) {
208 if (temp.size() != 1) {
209 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4Builder - ERROR: I need only 1 " <<
s ;
210 throw SimG4Exception(
"DDG4Builder: Problem with Region tags - one and only one allowed");
221 std::vector<const DDsvalues_type *>::iterator it = result.begin();
222 bool foundIt =
false;
223 for (; it != result.end(); ++it) {
229 if (temp.size() != 1) {
230 edm::LogError(
"SimG4CoreGeometry") <<
" DDG4Builder - ERROR: I need only 1 " <<
s ;
231 throw SimG4Exception(
"DDG4Builder: Problem with Region tags - one and only one allowed");
235 std::istringstream is(temp[0].c_str());
237 v = v*G4UnitDefinition::GetValueOf(unit.substr(1,unit.size()));
double a() const
returns the atomic mass
std::vector< DDG4Dispatchable * > DDG4DispContainer
def_type isDefined() const
G4LogicalVolume * convertLV(const DDLogicalPart &dLogical)
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
std::map< DDSolid, G4VSolid * > sols_
double getDouble(const std::string &s, const DDLogicalPart &dLogical)
DDMaterial is used to define and access material information.
std::map< DDLogicalPart, G4LogicalVolume * > logs_
const DDCompactView * compactView
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
static DDG4DispContainer * theVectorOfDDG4Dispatchables_
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
type of data representation of DDCompactView
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
A DDSolid represents the shape of a part.
std::vector< const DDsvalues_type * > specifics(void) const
returns the specific-data attached to the LogicalPart only (not to a DDExpandedNode) ...
double z() const
retruns the atomic number
G4Material * convertMaterial(const DDMaterial &dMaterial)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
FractionV::value_type constituent(int i) const
returns the i-th compound material and its fraction-mass
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
static DDG4DispContainer * theVectorOfDDG4Dispatchables()
std::string toString() const
double density() const
returns the density
DDG4SolidConverter * solidConverter_
G4VSolid * convert(const DDSolid &)
SensitiveDetectorCatalog upDate(const DDG4DispContainer &ddg4s)
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
DDGeometryReturnType BuildGeometry()
G4VSolid * convertSolid(const DDSolid &dSolid)
DDG4Builder(const DDCompactView *, bool check=false)
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
std::map< DDMaterial, G4Material * > mats_
void insert(const KeyType &, const ValueType &)
insert a new key-value-pair
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
G4LogicalVolumeToDDLogicalPartMap map_
int getInt(const std::string &s, const DDLogicalPart &dLogical)