CMS 3D CMS Logo

DDDividedPolyhedra.cc
Go to the documentation of this file.
12 
13 #include <cstddef>
14 #include <iostream>
15 #include <string>
16 #include <utility>
17 #include <vector>
18 
19 class DDCompactView;
20 
21 using namespace geant_units::operators;
22 
24  : DDDividedGeometryObject(div, cpv) {
26  setType("DivisionPolyhedraRho");
27 
28  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
29 
30  if (divisionType_ == DivWIDTH) {
31  compNDiv_ = calculateNDiv(msol.rMaxVec()[0] - msol.rMinVec()[0], div_.width(), div_.offset());
32  } else if (divisionType_ == DivNDIV) {
33  compWidth_ = calculateWidth(msol.rMaxVec()[0] - msol.rMinVec()[0], div_.nReplicas(), div_.offset());
34  }
35 }
36 
39 
40  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
41 
43  std::cout << "WARNING - "
44  << "DDDividedPolyhedraRho::checkParametersValidity()" << std::endl
45  << " Solid " << msol << std::endl
46  << " Division along R will be done with a width "
47  << "different for each solid section." << std::endl
48  << " WIDTH will not be used !" << std::endl;
49  }
50  if (div_.offset() != 0.) {
51  std::cout << "WARNING - "
52  << "DDDividedPolyhedraRho::checkParametersValidity()" << std::endl
53  << " Solid " << msol << std::endl
54  << " Division along R will be done with a width "
55  << "different for each solid section." << std::endl
56  << " OFFSET will not be used !" << std::endl;
57  }
58 }
59 
61  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
62  return msol.rMaxVec()[0] - msol.rMinVec()[0];
63 }
64 
66 
67 DDRotation DDDividedPolyhedraRho::makeDDRotation(const int copyNo) const { return DDRotation(); }
68 
70  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
71  DDMaterial usemat = div_.parent().material();
72 
73  std::vector<double> localrMaxVec = msol.rMaxVec();
74  std::vector<double> localrMinVec = msol.rMinVec();
75  std::vector<double> localzVec = msol.zVec();
76  std::vector<double> newrMinVec;
77  std::vector<double> newrMaxVec;
78  int nZplanes = localzVec.size();
79 
80  double width = 0.;
81  for (int ii = 0; ii < nZplanes; ++ii) {
82  // width = CalculateWidth( origparamMother->Rmax[ii]
83  // - origparamMother->Rmin[ii], compNDiv_, foffset );
84  // origparam.Rmin[ii] = origparamMother->Rmin[ii]+foffset+width*copyNo;
85  // origparam.Rmax[ii] = origparamMother->Rmin[ii]+foffset+width*(copyNo+1);
86  width = calculateWidth(localrMaxVec[ii] - localrMinVec[ii], compNDiv_, div_.offset());
87  newrMinVec[ii] = localrMinVec[ii] + div_.offset() + width * copyNo;
88  newrMaxVec[ii] = localrMaxVec[ii] + div_.offset() + width * (copyNo + 1);
89  }
90 
91  // phedra.SetOriginalParameters(&origparam); // copy values & transfer pointers
92  // phedra.Reset(); // reset to new solid parameters
93 
94  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo), div_.parent().ddname().ns());
95 
97  solname, msol.sides(), msol.startPhi(), msol.deltaPhi(), localzVec, newrMinVec, newrMaxVec);
98  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, dsol);
99  return ddlp;
100 }
101 
103  : DDDividedGeometryObject(div, cpv) {
105  setType("DivisionPolyhedraPhi");
106 
107  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
108 
109  if (divisionType_ == DivWIDTH) {
110  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
111  if (msol.deltaPhi() == 360._deg) {
112  compNDiv_ = calculateNDiv(msol.deltaPhi(), div_.width(), 0.);
113  } else {
115  }
116  } else if (divisionType_ == DivNDIV) {
117  if (msol.deltaPhi() == 360._deg) {
119  } else {
120  // original line looks wrong!
122  }
123  }
124 }
125 
127  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
128  return msol.deltaPhi(); //msol->GetEndPhi() - msol->GetStartPhi();
129 }
130 
133 
134  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
135 
137  std::cout << "WARNING - "
138  << "DDDividedPolyhedraPhi::checkParametersValidity()" << std::endl
139  << " Solid " << msol << std::endl
140  << " Division along PHI will be done splitting "
141  << "in the defined numSide." << std::endl
142  << " WIDTH will not be used !" << std::endl;
143  }
144  if (div_.offset() != 0.) {
145  std::cout << "WARNING - "
146  << "DDDividedPolyhedraPhi::checkParametersValidity()" << std::endl
147  << " Solid " << msol << std::endl
148  << " Division along PHI will be done splitting "
149  << "in the defined numSide." << std::endl
150  << " OFFSET will not be used !" << std::endl;
151  }
152 
153  if (msol.sides() != compNDiv_) {
154  std::cout << "ERROR - "
155  << "DDDividedPolyhedraPhi::checkParametersValidity()" << std::endl
156  << " Division along PHI will be done splitting in the defined" << std::endl
157  << " numSide, i.e, the number of division would be :"
158  << " " << msol.sides() << " instead of " << compNDiv_ << " !" << std::endl;
159  std::string s = "DDDividedPolyhedraPhi::checkParametersValidity() Not supported configuration.";
160  throw cms::Exception("DDException") << s;
161  }
162 }
163 
165 
167  DDRotation myddrot; // sets to identity.
168  double posi = (copyNo - 1) * compWidth_;
169  DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT" + std::to_string(copyNo),
170  div_.parent().ddname().ns());
171  myddrot = DDrot(ddrotname, changeRotMatrix(posi));
172 
173  return myddrot;
174 }
175 
177  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
178  DDMaterial usemat = div_.parent().material();
179 
180  DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
181  DDSolid dsol(solname);
182  if (!dsol.isDefined().second) {
184  solname, msol.sides(), msol.startPhi() + div_.offset(), compWidth_, msol.zVec(), msol.rMinVec(), msol.rMaxVec());
185  }
186  DDLogicalPart ddlp(solname);
187  if (!ddlp.isDefined().second)
188  DDLogicalPart ddlp2 = DDLogicalPart(solname, usemat, dsol);
189  return ddlp;
190 }
191 
193  : DDDividedGeometryObject(div, cpv) {
195  setType("DivisionPolyhedraZ");
196 
197  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
198 
199  std::vector<double> zvec = msol.zVec();
200 
201  if (divisionType_ == DivWIDTH) {
202  compNDiv_ = calculateNDiv(zvec[zvec.size() - 1] - zvec[0], div_.width(), div_.offset());
203  } else if (divisionType_ == DivNDIV) {
204  compWidth_ = calculateWidth(zvec[zvec.size() - 1] - zvec[0], div_.nReplicas(), div_.offset());
205  }
206 }
207 
209  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
210 
211  std::vector<double> zvec = msol.zVec();
212  return (zvec[zvec.size() - 1] - zvec[0]);
213 }
214 
217 
218  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
219 
221  std::cout << "WARNING - "
222  << "DDDividedPolyhedraZ::checkParametersValidity()" << std::endl
223  << " Solid " << msol << std::endl
224  << " Division along Z will be done splitting "
225  << "in the defined z_planes." << std::endl
226  << " WIDTH will not be used !" << std::endl;
227  }
228 
229  if (div_.offset() != 0.) {
230  std::cout << "WARNING - "
231  << "DDDividedPolyhedraZ::checkParametersValidity()" << std::endl
232  << " Solid " << msol << std::endl
233  << " Division along Z will be done splitting "
234  << "in the defined z_planes." << std::endl
235  << " OFFSET will not be used !" << std::endl;
236  }
237 
238  std::vector<double> zvec = msol.zVec();
239 
240  if (zvec.size() - 1 != size_t(compNDiv_)) {
241  std::cout << "ERROR - "
242  << "DDDividedPolyhedraZ::checkParametersValidity()" << std::endl
243  << " Division along Z can only be done by splitting in the defined" << std::endl
244  << " z_planes, i.e, the number of division would be :"
245  << " " << zvec.size() - 1 << " instead of " << compNDiv_ << " !" << std::endl;
246  std::string s = "DDDividedPolyhedraZ::checkParametersValidity()";
247  s += "Illegal Construct. Not a supported configuration.";
248  throw cms::Exception("DDException") << s;
249  }
250 }
251 
253  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
254  std::vector<double> zvec = msol.zVec();
255 
256  //----- set translation: along Z axis
257  double posi = (zvec[copyNo] + zvec[copyNo + 1]) / 2;
258 
259  DDTranslation tr(0, 0, posi);
260  //----- calculate rotation matrix: unit
261  return tr;
262 }
263 
264 DDRotation DDDividedPolyhedraZ::makeDDRotation(const int copyNo) const { return DDRotation(); }
265 
267  // only for mother number of planes = 2!!
268  // mec: what? why? comment above and = 2 below straight from G4 impl.
269  DDPolyhedra msol = (DDPolyhedra)(div_.parent().solid());
270  DDMaterial usemat = div_.parent().material();
271 
272  std::vector<double> zvec = msol.zVec();
273  std::vector<double> rminvec = msol.rMinVec();
274  std::vector<double> rmaxvec = msol.rMaxVec();
275 
276  double posi = (zvec[copyNo] + zvec[copyNo + 1]) / 2.0;
277 
278  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo), div_.parent().ddname().ns());
279  std::vector<double> newRmin, newRmax, newZ;
280  newZ.emplace_back(zvec[copyNo] - posi);
281  newZ.emplace_back(zvec[copyNo + 1] - posi);
282  newRmin.emplace_back(rminvec[copyNo]);
283  newRmin.emplace_back(rminvec[copyNo + 1]);
284  newRmax.emplace_back(rmaxvec[copyNo]);
285  newRmax.emplace_back(rmaxvec[copyNo + 1]);
286 
287  DDSolid dsol =
288  DDSolidFactory::polyhedra(solname, msol.sides(), msol.startPhi(), msol.deltaPhi(), newZ, newRmin, newRmax);
289  DDLogicalPart lp(solname, usemat, dsol);
290  return lp;
291 }
DDDividedPolyhedraPhi::makeDDLogicalPart
DDLogicalPart makeDDLogicalPart(int copyNo) const override
Definition: DDDividedPolyhedra.cc:176
DDDividedPolyhedraRho::DDDividedPolyhedraRho
DDDividedPolyhedraRho(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedPolyhedra.cc:23
DDDividedGeometryObject::compWidth_
double compWidth_
Definition: DDDividedGeometryObject.h:56
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
DDPolyhedra::rMaxVec
std::vector< double > rMaxVec(void) const
Definition: DDSolid.cc:338
DDTransform.h
MessageLogger.h
DDrot
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
DDDivision::width
double width() const
Definition: DDDivision.cc:53
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDBase::isDefined
def_type isDefined() const
Definition: DDBase.h:90
DDPolyhedra::zVec
std::vector< double > zVec(void) const
Definition: DDSolid.cc:324
DDDividedPolyhedraZ::makeDDRotation
DDRotation makeDDRotation(int copyNo) const override
Definition: DDDividedPolyhedra.cc:264
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DDLogicalPart::material
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
Definition: DDLogicalPart.cc:118
DDPolyhedra::rMinVec
std::vector< double > rMinVec(void) const
Definition: DDSolid.cc:331
DDDividedPolyhedraZ::DDDividedPolyhedraZ
DDDividedPolyhedraZ(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedPolyhedra.cc:192
geant_units::operators
Definition: GeantUnits.h:18
DDDividedPolyhedraRho::makeDDRotation
DDRotation makeDDRotation(int copyNo) const override
Definition: DDDividedPolyhedra.cc:67
DDDividedGeometryObject
Definition: DDDividedGeometryObject.h:20
DivWIDTH
Definition: DDDividedGeometryObject.h:14
DDDividedPolyhedraRho::checkParametersValidity
void checkParametersValidity() override
Definition: DDDividedPolyhedra.cc:37
DDDividedPolyhedraRho::getMaxParameter
double getMaxParameter() const override
Definition: DDDividedPolyhedra.cc:60
DDDividedPolyhedraPhi::DDDividedPolyhedraPhi
DDDividedPolyhedraPhi(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedPolyhedra.cc:102
DDDividedPolyhedraPhi::checkParametersValidity
void checkParametersValidity() override
Definition: DDDividedPolyhedra.cc:131
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDDividedPolyhedraRho::makeDDLogicalPart
DDLogicalPart makeDDLogicalPart(int copyNo) const override
Definition: DDDividedPolyhedra.cc:69
DDDividedGeometryObject::checkParametersValidity
virtual void checkParametersValidity(void)
Definition: DDDividedGeometryObject.cc:41
DDPolyhedra::sides
int sides(void) const
Definition: DDSolid.cc:311
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDSolidFactory::polyhedra
static DDSolid polyhedra(const DDName &name, int sides, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polyhedra (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:551
DivNDIV
Definition: DDDividedGeometryObject.h:14
DivNDIVandWIDTH
Definition: DDDividedGeometryObject.h:14
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDSolid.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDDividedGeometryObject::calculateNDiv
int calculateNDiv(double motherDim, double width, double offset) const
Definition: DDDividedGeometryObject.cc:33
DDDividedGeometryObject::div_
DDDivision div_
Definition: DDDividedGeometryObject.h:53
DDDividedGeometryObject::changeRotMatrix
std::unique_ptr< DDRotationMatrix > changeRotMatrix(double rotZ=0.) const
Definition: DDDividedGeometryObject.cc:29
DDDividedGeometryObject::compNDiv_
int compNDiv_
Definition: DDDividedGeometryObject.h:55
DDDividedPolyhedraZ::makeDDLogicalPart
DDLogicalPart makeDDLogicalPart(int copyNo) const override
Definition: DDDividedPolyhedra.cc:266
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
DDDividedPolyhedraZ::makeDDTranslation
DDTranslation makeDDTranslation(int copyNo) const override
Definition: DDDividedPolyhedra.cc:252
GeantUnits.h
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDDividedGeometryObject::divisionType_
DivisionType divisionType_
Definition: DDDividedGeometryObject.h:57
DDDividedPolyhedraPhi::makeDDTranslation
DDTranslation makeDDTranslation(int copyNo) const override
Definition: DDDividedPolyhedra.cc:164
DDMaterial.h
DDDividedGeometryObject::setType
virtual void setType(const std::string &type)
Definition: DDDividedGeometryObject.cc:81
DDDividedGeometryObject.h
DDDividedPolyhedra.h
DDDivision::offset
double offset() const
Definition: DDDivision.cc:55
DDDividedPolyhedraZ::checkParametersValidity
void checkParametersValidity() override
Definition: DDDividedPolyhedra.cc:215
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDLogicalPart.h
DDDivision::nReplicas
int nReplicas() const
Definition: DDDivision.cc:51
DDDividedPolyhedraPhi::makeDDRotation
DDRotation makeDDRotation(int copyNo) const override
Definition: DDDividedPolyhedra.cc:166
DDPolyhedra
Definition: DDSolid.h:224
DDDivision
Definition: DDDivision.h:78
DDPolyhedra::deltaPhi
double deltaPhi(void) const
Definition: DDSolid.cc:315
DDDividedPolyhedraPhi::getMaxParameter
double getMaxParameter() const override
Definition: DDDividedPolyhedra.cc:126
DDRotationMatrix.h
DDName::ns
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52
DDName.h
Exception
Definition: hltDiff.cc:246
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
Exception.h
DDDividedPolyhedraRho::makeDDTranslation
DDTranslation makeDDTranslation(int copyNo) const override
Definition: DDDividedPolyhedra.cc:65
DDPolyhedra::startPhi
double startPhi(void) const
Definition: DDSolid.cc:313
DDLogicalPart::solid
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Definition: DDLogicalPart.cc:120
cuy.ii
ii
Definition: cuy.py:590
DDDivision::parent
const DDLogicalPart & parent() const
Definition: DDDivision.cc:57
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18
DDDividedPolyhedraZ::getMaxParameter
double getMaxParameter() const override
Definition: DDDividedPolyhedra.cc:208
DDDividedGeometryObject::calculateWidth
double calculateWidth(double motherDim, int nDiv, double offset) const
Definition: DDDividedGeometryObject.cc:37