11 #include "G4LogicalVolume.hh"
12 #include "G4Material.hh"
13 #include "G4PVPlacement.hh"
14 #include "G4ReflectionFactory.hh"
15 #include "G4VPhysicalVolume.hh"
16 #include "G4VSolid.hh"
18 #include "G4SystemOfUnits.hh"
19 #include "G4UnitsTable.hh"
26 : solidConverter_(new
DDG4SolidConverter), compactView_(cpv), map_(lvmap), check_(check) {
38 result =
new G4LogicalVolume(g4s, g4m, part.
name().
name());
43 <<
"DDG4Builder::convertLV(): new G4LogicalVolume " << part.
name().
name()
44 <<
"\nDDG4Builder: newEvent: dd=" << part.
ddname() <<
" g4=" << result->GetName();
60 edm::LogVerbatim(
"SimG4CoreGeometry") <<
"DDDetConstr::ConvertMaterial: material=" << material;
61 G4Material *
result =
nullptr;
64 if ((result =
mats_[material])) {
71 " material is not valid from the Detector Description: " + material.
toString());
77 <<
" creating a G4-composite material. c=" << c <<
" d=" << material.
density() /
CLHEP::g * CLHEP::mole;
79 for (
int i = 0;
i <
c; ++
i) {
82 <<
" adding the composite=" << material.
name() <<
" fm=" << material.
constituent(
i).second;
89 <<
" z=" << material.
z() <<
" a=" << material.
a() /
CLHEP::g * CLHEP::mole
91 result =
new G4Material(material.
name().
name(), material.
z(), material.
a(), material.
density());
98 G4ReflectionFactory *refFact = G4ReflectionFactory::Instance();
99 refFact->SetScalePrecision(100. * refFact->GetScalePrecision());
108 for (; git != gend; ++git) {
112 " DDG4Builder::BuildGeometry() has encountered an "
113 "undefined DDLogicalPart named " +
120 Graph::edge_list::const_iterator cit = git->begin();
121 Graph::edge_list::const_iterator cend = git->end();
122 for (; cit != cend; ++cit) {
126 std::string err =
" DDG4Builder::BuildGeometry() in processing \"children\" has ";
127 err +=
"encountered an undefined DDLogicalPart named " + ddcurLP.
toString() +
" is a child of " +
135 rm.GetComponents(x, y, z);
136 if ((x.Cross(y)).Dot(z) < 0)
138 <<
"DDG4Builder: Reflection: " << gra.edgeData(cit->second)->ddrot()
139 <<
">>Placement d=" << gra.nodeData(cit->first).ddname() <<
" m=" << ddLP.
ddname()
140 <<
" cp=" << gra.edgeData(cit->second)->copyno() <<
" r=" << gra.edgeData(cit->second)->ddrot().ddname();
141 G4ThreeVector tempTran(gra.edgeData(cit->second)->trans().X(),
142 gra.edgeData(cit->second)->trans().Y(),
143 gra.edgeData(cit->second)->trans().Z());
144 G4Translate3D transl = tempTran;
145 CLHEP::HepRep3x3
temp(x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z());
146 CLHEP::HepRotation hr(
temp);
148 <<
"Position " << gra.nodeData(cit->first).name().name() <<
":"
149 << gra.edgeData(cit->second)->copyno() + offset + tag <<
" in " << g4LV->GetName() <<
" at " << tempTran
150 <<
" with rotation matrix (" << x.X() <<
", " << x.Y() <<
", " << x.Z() <<
", " << y.X() <<
", " << y.Y()
151 <<
", " << y.Z() <<
", " << z.X() <<
", " << z.Y() <<
", " << z.Z() <<
")";
154 G4Transform3D trfrm = transl * G4Rotate3D(hr.inverse());
156 refFact->Place(trfrm,
157 gra.nodeData(cit->first).name().name(),
161 gra.edgeData(cit->second)->copyno() + offset +
tag,
169 std::map<DDLogicalPart, G4LogicalVolume *>::const_iterator ddg4_it =
logs_.begin();
170 for (; ddg4_it !=
logs_.end(); ++ddg4_it) {
171 G4LogicalVolume *reflLogicalVolume = refFact->GetReflectedLV(ddg4_it->second);
172 if (reflLogicalVolume) {
178 <<
"DDG4Builder: dd=" << ddlv.
ddname() <<
" g4=" << reflLogicalVolume->GetName();
196 bool foundIt =
false;
197 for (
auto stype : result) {
204 if (temp.size() != 1) {
206 " DDG4Builder::getInt() Problem with Region tags - "
207 "one and only one allowed: " +
218 bool foundIt =
false;
219 for (
auto stype : result) {
226 if (temp.size() != 1) {
228 " DDG4Builder::getDouble() Problem with Region tags "
229 "- one and only one allowed: " +
234 std::istringstream is(temp[0]);
236 v = v * G4UnitDefinition::GetValueOf(unit.substr(1, unit.size()));
Log< level::Info, true > LogVerbatim
double a() const
returns the atomic mass
std::map< DDLogicalPart, G4LogicalVolume * > logs_
math::Graph< DDLogicalPart, DDPosData * > Graph
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
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >> DD3Vector
const edm::EventSetup & c
std::vector< double >::size_type index_type
double getDouble(const std::string &s, const DDLogicalPart &dLogical)
DDMaterial is used to define and access material information.
G4LogicalVolumeToDDLogicalPartMap & map_
G4LogicalVolume * BuildGeometry(SensitiveDetectorCatalog &)
std::vector< DDG4Dispatchable * > DDG4DispContainer
void upDate(const DDG4DispContainer &ddg4s, SensitiveDetectorCatalog &)
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
std::map< DDSolid, G4VSolid * > sols_
const DDCompactView * compactView_
Compact representation of the geometrical detector hierarchy.
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::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
DDG4Builder(const DDCompactView *, G4LogicalVolumeToDDLogicalPartMap &, bool check)
std::map< DDMaterial, G4Material * > mats_
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 ...
Graph::const_adj_iterator adjl_iterator
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
std::string toString() const
double density() const
returns the density
DDG4SolidConverter * solidConverter_
G4VSolid * convert(const DDSolid &)
int noOfConstituents() const
returns the number of compound materials or 0 for elementary materials
G4VSolid * convertSolid(const DDSolid &dSolid)
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
adj_list::const_iterator const_adj_iterator
void insert(const KeyType &, const ValueType &)
insert a new key-value-pair
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.
DDG4DispContainer * theVectorOfDDG4Dispatchables_
Basic3DVector unit() const
int getInt(const std::string &s, const DDLogicalPart &dLogical)