test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes
DDG4Builder Class Reference

#include <DDG4Builder.h>

Public Member Functions

DDGeometryReturnType BuildGeometry ()
 
 DDG4Builder (const DDCompactView *, bool check=false)
 
 ~DDG4Builder ()
 

Static Public Member Functions

static DDG4DispContainertheVectorOfDDG4Dispatchables ()
 

Protected Member Functions

G4LogicalVolume * convertLV (const DDLogicalPart &dLogical)
 
G4Material * convertMaterial (const DDMaterial &dMaterial)
 
G4VSolid * convertSolid (const DDSolid &dSolid)
 
double getDouble (const std::string &s, const DDLogicalPart &dLogical)
 
int getInt (const std::string &s, const DDLogicalPart &dLogical)
 

Protected Attributes

std::map< DDLogicalPart,
G4LogicalVolume * > 
logs_
 
std::map< DDMaterial,
G4Material * > 
mats_
 
DDG4SolidConvertersolidConverter_
 
std::map< DDSolid, G4VSolid * > sols_
 

Private Attributes

bool check_
 
const DDCompactViewcompactView
 
G4LogicalVolumeToDDLogicalPartMap map_
 

Static Private Attributes

static DDG4DispContainertheVectorOfDDG4Dispatchables_ = 0
 

Detailed Description

Definition at line 22 of file DDG4Builder.h.

Constructor & Destructor Documentation

DDG4Builder::DDG4Builder ( const DDCompactView cpv,
bool  check = false 
)

Definition at line 34 of file DDG4Builder.cc.

References theVectorOfDDG4Dispatchables_.

34  :
37 }
std::vector< DDG4Dispatchable * > DDG4DispContainer
const DDCompactView * compactView
Definition: DDG4Builder.h:44
static DDG4DispContainer * theVectorOfDDG4Dispatchables_
Definition: DDG4Builder.h:45
DDG4SolidConverter * solidConverter_
Definition: DDG4Builder.h:38
DDG4Builder::~DDG4Builder ( )

Definition at line 39 of file DDG4Builder.cc.

References solidConverter_.

39  {
40  delete solidConverter_;
41 }
DDG4SolidConverter * solidConverter_
Definition: DDG4Builder.h:38

Member Function Documentation

DDGeometryReturnType DDG4Builder::BuildGeometry ( )

Definition at line 108 of file DDG4Builder.cc.

References graph< N, E >::begin(), validate_alignment_devdb10_cfg::catalog, check_, compactView, convertLV(), DDBase< N, C >::ddname(), Exception, getInt(), DDCompactView::graph(), AnalysisDataFormats_SUSYBSMObjects::hr, i, DDMapper< KeyType, ValueType >::insert(), DDBase< N, C >::isDefined(), LogDebug, logs_, map_, hltrates_dqm_sourceclient-live_cfg::offset, submit::rm, DDCompactView::root(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, groupFilesInBlocks::temp, theVectorOfDDG4Dispatchables_, DDBase< N, C >::toString(), DDG4SensitiveConverter::upDate(), x, y, and z.

108  {
109  G4ReflectionFactory * refFact = G4ReflectionFactory::Instance();
110  refFact->SetScalePrecision(100.*refFact->GetScalePrecision());
111 
112  typedef DDCompactView::graph_type graph_type;
113  const graph_type & gra = compactView->graph();
114  typedef graph_type::const_adj_iterator adjl_iterator;
115  adjl_iterator git = gra.begin();
116  adjl_iterator gend = gra.end();
117 
118  graph_type::index_type i=0;
119  for (; git != gend; ++git) {
120  const DDLogicalPart & ddLP = gra.nodeData(git);
121  if ( !(ddLP.isDefined().second) ) {
122  edm::LogError("SimG4CoreGeometry") << "DDG4Builder::BuildGeometry() has encountered an undefined DDLogicalPart named " << ddLP.toString();
123  throw cms::Exception("SimG4CoreGeometry", " DDG4Builder::BuildGeometry() has encountered an undefined DDLogicalPart named " + ddLP.toString());
124  }
125  G4LogicalVolume * g4LV = convertLV(ddLP);
126  ++i;
127  if (git->size()) {
128  // ask for children of ddLP
129  graph_type::edge_list::const_iterator cit = git->begin();
130  graph_type::edge_list::const_iterator cend = git->end();
131  for (; cit != cend; ++cit) {
132  // fetch specific data
133  const DDLogicalPart & ddcurLP = gra.nodeData(cit->first);
134  if ( !ddcurLP.isDefined().second ) {
135  std::string err = " DDG4Builder::BuildGeometry() in processing \"children\" has ";
136  err += "encountered an undefined DDLogicalPart named " + ddLP.toString();
137  edm::LogError("SimG4CoreGeometry") << err;
138  throw cms::Exception("SimG4CoreGeometry", err) ;
139  }
140  int offset = getInt("CopyNoOffset",ddcurLP);
141  int tag = getInt("CopyNoTag",ddcurLP);
142  DDRotationMatrix rm(gra.edgeData(cit->second)->rot());
143  DD3Vector x, y, z;
144  rm.GetComponents(x, y, z);
145  if ((x.Cross(y)).Dot(z)<0)
146  LogDebug("SimG4CoreGeometry") << ">>Reflection encountered: " << gra.edgeData(cit->second)->rot_ << "\n";
147  LogDebug("SimG4CoreGeometry") << ">>Placement d=" << gra.nodeData(cit->first).ddname()
148  << " m=" << ddLP.ddname() << " cp=" << gra.edgeData(cit->second)->copyno_
149  << " r=" << gra.edgeData(cit->second)->rot_.ddname() << "\n" ;
150  G4ThreeVector tempTran(gra.edgeData(cit->second)->trans_.X(), gra.edgeData(cit->second)->trans_.Y(), gra.edgeData(cit->second)->trans_.Z());
151  G4Translate3D transl = tempTran;
152  CLHEP::HepRep3x3 temp( x.X(), x.Y(), x.Z(), y.X(), y.Y(), y.Z(), z.X(), z.Y(), z.Z() ); //matrix representation
153  CLHEP::HepRotation hr ( temp );
154 
155  // G3 convention of defining rot-matrices ...
156  G4Transform3D trfrm = transl * G4Rotate3D(hr.inverse());//.inverse();
157 
158  refFact->Place(trfrm, // transformation containing a possible reflection
159  gra.nodeData(cit->first).name().name(),
160  convertLV(gra.nodeData(cit->first)), // daugther
161  g4LV, // mother
162  false, // 'ONLY'
163  gra.edgeData(cit->second)->copyno_+offset+tag, // copy number
164  check_);
165  } // iterate over children
166  } // if (children)
167  } // iterate over graph nodes
168 
169  // Looking for in the G4ReflectionFactory secretly created reflected G4LogicalVolumes
170  std::map<DDLogicalPart, G4LogicalVolume*>::const_iterator ddg4_it = logs_.begin();
171  for (; ddg4_it != logs_.end(); ++ddg4_it) {
172  G4LogicalVolume * reflLogicalVolume = refFact->GetReflectedLV(ddg4_it->second);
173  if (reflLogicalVolume) {
174  DDLogicalPart ddlv = ddg4_it->first;
175  map_.insert(reflLogicalVolume,ddlv);
176  DDG4Dispatchable * disp = new DDG4Dispatchable(&(ddg4_it->first),reflLogicalVolume);
177  theVectorOfDDG4Dispatchables_->push_back(disp);
178  LogDebug("SimG4CoreGeometry") << "DDG4Builder: newEvent: dd="
179  << ddlv.ddname() << " g4="
180  << reflLogicalVolume->GetName() << "\n";
181  }
182  }
183 
184  G4LogicalVolume * world = logs_[compactView->root()];
185 
186  //
187  // needed for building sensitive detectors
188  //
191 
192  return DDGeometryReturnType(world,map_,catalog);
193 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
def_type isDefined() const
Definition: DDBase.h:110
G4LogicalVolume * convertLV(const DDLogicalPart &dLogical)
Definition: DDG4Builder.cc:43
std::map< DDLogicalPart, G4LogicalVolume * > logs_
Definition: DDG4Builder.h:41
const DDCompactView * compactView
Definition: DDG4Builder.h:44
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
static DDG4DispContainer * theVectorOfDDG4Dispatchables_
Definition: DDG4Builder.h:45
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
susybsm::HSCParticleRef hr
Definition: classes.h:26
string rm
Definition: submit.py:76
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
std::string toString() const
Definition: DDBase.h:82
SensitiveDetectorCatalog upDate(const DDG4DispContainer &ddg4s)
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
adj_iterator begin()
Definition: adjgraph.h:197
void insert(const KeyType &, const ValueType &)
insert a new key-value-pair
Definition: DDMapper.h:77
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
G4LogicalVolumeToDDLogicalPartMap map_
Definition: DDG4Builder.h:46
int getInt(const std::string &s, const DDLogicalPart &dLogical)
Definition: DDG4Builder.cc:195
const N & ddname() const
Definition: DDBase.h:80
G4LogicalVolume * DDG4Builder::convertLV ( const DDLogicalPart dLogical)
protected

Definition at line 43 of file DDG4Builder.cc.

References convertMaterial(), convertSolid(), DDBase< N, C >::ddname(), DDMapper< KeyType, ValueType >::insert(), LogDebug, logs_, visualization-live-secondInstance_cfg::m, map_, DDLogicalPart::material(), DDName::name(), DDBase< N, C >::name(), mps_fire::result, alignCSCRings::s, DDLogicalPart::solid(), and theVectorOfDDG4Dispatchables_.

Referenced by BuildGeometry().

43  {
44  LogDebug("SimG4CoreGeometry") << "DDG4Builder::convertLV(): DDLogicalPart = " << part << "\n";
45  G4LogicalVolume * result = logs_[part];
46  if (!result) {
47  G4VSolid * s = convertSolid(part.solid());
48  G4Material * m = convertMaterial(part.material());
49  result = new G4LogicalVolume(s,m,part.name().name());
50  map_.insert(result,part);
51  DDG4Dispatchable * disp = new DDG4Dispatchable(&part,result);
52  theVectorOfDDG4Dispatchables_->push_back(disp);
53  LogDebug("SimG4CoreGeometry") << "DDG4Builder::convertLV(): new G4LogicalVolume " << part.name().name()
54  << "\nDDG4Builder: newEvent: dd=" << part.ddname() << " g4=" << result->GetName() << "\n";
55  logs_[part] = result; // DDD -> GEANT4
56  }
57  return result;
58 }
#define LogDebug(id)
std::map< DDLogicalPart, G4LogicalVolume * > logs_
Definition: DDG4Builder.h:41
static DDG4DispContainer * theVectorOfDDG4Dispatchables_
Definition: DDG4Builder.h:45
tuple result
Definition: mps_fire.py:84
G4Material * convertMaterial(const DDMaterial &dMaterial)
Definition: DDG4Builder.cc:68
part
Definition: HCALResponse.h:20
G4VSolid * convertSolid(const DDSolid &dSolid)
Definition: DDG4Builder.cc:60
void insert(const KeyType &, const ValueType &)
insert a new key-value-pair
Definition: DDMapper.h:77
G4LogicalVolumeToDDLogicalPartMap map_
Definition: DDG4Builder.h:46
G4Material * DDG4Builder::convertMaterial ( const DDMaterial dMaterial)
protected

Definition at line 68 of file DDG4Builder.cc.

References DDMaterial::a(), EnergyCorrector::c, DDMaterial::constituent(), DDMaterial::density(), Exception, g, i, LogDebug, mats_, DDName::name(), DDBase< N, C >::name(), DDMaterial::noOfConstituents(), mps_fire::result, DDBase< N, C >::toString(), and DDMaterial::z().

Referenced by convertLV().

68  {
69  LogDebug("SimG4CoreGeometry") << "DDDetConstr::ConvertMaterial: material=" << material << "\n";
70  G4Material * result = 0;
71  if (material) {
72  // only if it's a valid DDD-material
73  if ((result = mats_[material])) {
74  LogDebug("SimG4CoreGeometry") << " is already converted" << "\n";
75  return result; }
76  } else {
77  // only if it's NOT a valid DDD-material
78  edm::LogError("SimG4CoreGeometry") << "DDG4Builder:: material " << material.toString() << " is not valid (in the DDD sense!)";
79  throw cms::Exception("SimG4CoreGeometry", " material is not valid from the Detector Description: " + material.toString());
80  }
81  int c = 0;
82  if ((c = material.noOfConstituents())) {
83  // it's a composite material
84  LogDebug("SimG4CoreGeometry") << " creating a G4-composite material. c=" << c
85  << " d=" << material.density()/g*mole << "\n";
86  result = new G4Material(material.name().name(),material.density(),c);
87  for (int i=0 ; i<c; ++i) {
88  // recursive building of constituents
89  LogDebug("SimG4CoreGeometry") << " adding the composite=" << material.name()
90  << " fm=" << material.constituent(i).second << "\n";
91  result->AddMaterial
92  (convertMaterial(material.constituent(i).first),
93  material.constituent(i).second);// fractionmass
94  }
95  } else {
96  // it's an elementary material
97  LogDebug("SimG4CoreGeometry") << " building an elementary material"
98  << " z=" << material.z()
99  << " a=" << material.a()/g*mole
100  << " d=" << material.density()/g*cm3 << "\n";
101  result = new G4Material
102  (material.name().name(),material.z(),material.a(),material.density());
103  }
104  mats_[material] = result;
105  return result;
106 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
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
Definition: Activities.doc:4
tuple result
Definition: mps_fire.py:84
G4Material * convertMaterial(const DDMaterial &dMaterial)
Definition: DDG4Builder.cc:68
std::map< DDMaterial, G4Material * > mats_
Definition: DDG4Builder.h:39
G4VSolid * DDG4Builder::convertSolid ( const DDSolid dSolid)
protected

Definition at line 60 of file DDG4Builder.cc.

References DDG4SolidConverter::convert(), mps_fire::result, solidConverter_, and sols_.

Referenced by convertLV().

60  {
61  G4VSolid * result = sols_[solid];
62  if (!result) {
63  result = solidConverter_->convert(solid); sols_[solid] = result;
64  }
65  return result;
66 }
std::map< DDSolid, G4VSolid * > sols_
Definition: DDG4Builder.h:40
tuple result
Definition: mps_fire.py:84
DDG4SolidConverter * solidConverter_
Definition: DDG4Builder.h:38
G4VSolid * convert(const DDSolid &)
double DDG4Builder::getDouble ( const std::string &  s,
const DDLogicalPart dLogical 
)
protected

Definition at line 216 of file DDG4Builder.cc.

References DDfetch(), Exception, mps_fire::result, alignCSCRings::s, DDLogicalPart::specifics(), AlCaHLTBitMon_QueryRunRegistry::string, DDValue::strings(), groupFilesInBlocks::temp, csvLumiCalc::unit, findQualityFiles::v, and SpecificationBuilder_cfi::val().

217  {
218  DDValue val(s);
219  std::vector<const DDsvalues_type *> result = part.specifics();
220  std::vector<const DDsvalues_type *>::iterator it = result.begin();
221  bool foundIt = false;
222  for (; it != result.end(); ++it) {
223  foundIt = DDfetch(*it,val);
224  if (foundIt) break;
225  }
226  if (foundIt) {
227  std::vector<std::string> temp = val.strings();
228  if (temp.size() != 1) {
229  edm::LogError("SimG4CoreGeometry") << " DDG4Builder - ERROR: I need only 1 " << s ;
230  throw cms::Exception("SimG4CoreGeometry", " DDG4Builder::getDouble() Problem with Region tags - one and only one allowed: " + s);
231  }
232  double v;
234  std::istringstream is(temp[0].c_str());
235  is >> v >> unit;
236  v = v*G4UnitDefinition::GetValueOf(unit.substr(1,unit.size()));
237  return v;
238  }
239  else return 0;
240 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:84
string unit
Definition: csvLumiCalc.py:46
part
Definition: HCALResponse.h:20
int DDG4Builder::getInt ( const std::string &  s,
const DDLogicalPart dLogical 
)
protected

Definition at line 195 of file DDG4Builder.cc.

References DDfetch(), DDValue::doubles(), Exception, mps_fire::result, alignCSCRings::s, DDLogicalPart::specifics(), groupFilesInBlocks::temp, and SpecificationBuilder_cfi::val().

Referenced by BuildGeometry().

196 {
197  DDValue val(s);
198  std::vector<const DDsvalues_type *> result = part.specifics();
199  std::vector<const DDsvalues_type *>::iterator it = result.begin();
200  bool foundIt = false;
201  for (; it != result.end(); ++it) {
202  foundIt = DDfetch(*it,val);
203  if (foundIt) break;
204  }
205  if (foundIt) {
206  std::vector<double> temp = val.doubles();
207  if (temp.size() != 1) {
208  edm::LogError("SimG4CoreGeometry") << " DDG4Builder - ERROR: I need only 1 " << s;
209  throw cms::Exception("SimG4CoreGeometry", " DDG4Builder::getInt() Problem with Region tags - one and only one allowed: " + s);
210  }
211  return int(temp[0]);
212  }
213  else return 0;
214 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple result
Definition: mps_fire.py:84
part
Definition: HCALResponse.h:20
DDG4DispContainer * DDG4Builder::theVectorOfDDG4Dispatchables ( )
static

Definition at line 30 of file DDG4Builder.cc.

References theVectorOfDDG4Dispatchables_.

30  {
32 }
static DDG4DispContainer * theVectorOfDDG4Dispatchables_
Definition: DDG4Builder.h:45

Member Data Documentation

bool DDG4Builder::check_
private

Definition at line 47 of file DDG4Builder.h.

Referenced by BuildGeometry().

const DDCompactView* DDG4Builder::compactView
private

Definition at line 44 of file DDG4Builder.h.

Referenced by BuildGeometry().

std::map<DDLogicalPart,G4LogicalVolume*> DDG4Builder::logs_
protected

Definition at line 41 of file DDG4Builder.h.

Referenced by BuildGeometry(), and convertLV().

G4LogicalVolumeToDDLogicalPartMap DDG4Builder::map_
private

Definition at line 46 of file DDG4Builder.h.

Referenced by BuildGeometry(), and convertLV().

std::map<DDMaterial,G4Material*> DDG4Builder::mats_
protected

Definition at line 39 of file DDG4Builder.h.

Referenced by convertMaterial().

DDG4SolidConverter* DDG4Builder::solidConverter_
protected

Definition at line 38 of file DDG4Builder.h.

Referenced by convertSolid(), and ~DDG4Builder().

std::map<DDSolid,G4VSolid*> DDG4Builder::sols_
protected

Definition at line 40 of file DDG4Builder.h.

Referenced by convertSolid().

DDG4DispContainer * DDG4Builder::theVectorOfDDG4Dispatchables_ = 0
staticprivate

Definition at line 45 of file DDG4Builder.h.

Referenced by BuildGeometry(), convertLV(), DDG4Builder(), and theVectorOfDDG4Dispatchables().