CMS 3D CMS Logo

DDDividedPolycone.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 
26  DDPolycone msol = (DDPolycone)(div_.parent().solid());
27  std::vector<double> localrMaxVec = msol.rMaxVec();
28  std::vector<double> localrMinVec = msol.rMinVec();
29 
30  setType("DivisionPolyconeRho");
31 
32  // in DDD we only have ONE representation
33  // in the case when rMinVec and rMaxVec
34  // are empty rVec and zVec are the r and z std::vectors.
35 
36  if (divisionType_ == DivWIDTH) {
37  compNDiv_ = calculateNDiv(localrMaxVec[0] - localrMinVec[0], div_.width(), div_.offset());
38  } else if (divisionType_ == DivNDIV) {
39  compWidth_ = calculateWidth(localrMaxVec[0] - localrMinVec[0], div_.nReplicas(), div_.offset());
40  }
41 }
42 
45 
46  DDPolycone msol = (DDPolycone)(div_.parent().solid());
47 
49  std::cout << "WARNING - "
50  << "DDDividedPolyconeRho::checkParametersValidity()" << std::endl
51  << " Solid " << msol << std::endl
52  << " Division along r will be done with a width "
53  << "different for each solid section." << std::endl
54  << " WIDTH will not be used !" << std::endl;
55  }
56  if (div_.offset() != 0.) {
57  std::cout << "WARNING - "
58  << "DDDividedPolyconeRho::checkParametersValidity()" << std::endl
59  << " Solid " << msol << std::endl
60  << " Division along R will be done with a width "
61  << "different for each solid section." << std::endl
62  << " OFFSET will not be used !" << std::endl;
63  }
64 }
65 
67  DDPolycone msol = (DDPolycone)(div_.parent().solid());
68  std::vector<double> localrMaxVec = msol.rMaxVec();
69  std::vector<double> localrMinVec = msol.rMinVec();
70 
71  return localrMaxVec[0] - localrMinVec[0];
72 }
73 
75  DDRotation myddrot; // sets to identity.
76  return myddrot;
77 }
78 
80  DDTranslation translation;
81  return translation;
82 }
83 
85  DDSolid ddpolycone;
86  DDMaterial usemat(div_.parent().material());
87 
88  DDPolycone msol = (DDPolycone)(div_.parent().solid());
89  std::vector<double> localrMaxVec = msol.rMaxVec();
90  std::vector<double> localrMinVec = msol.rMinVec();
91  std::vector<double> localzVec = msol.zVec();
92 
93  int nZplanes = localzVec.size();
94 
95  std::vector<double> newrMinVec;
96  std::vector<double> newrMaxVec;
97 
98  double width = 0.;
99  for (int ii = 0; ii < nZplanes; ++ii) {
100  width = calculateWidth(localrMaxVec[ii] - localrMinVec[ii], compNDiv_, div_.offset());
101  newrMinVec.emplace_back(localrMinVec[ii] + div_.offset() + width * copyNo);
102  newrMaxVec.emplace_back(localrMinVec[ii] + div_.offset() + width * (copyNo + 1));
103  }
104  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo), div_.parent().ddname().ns());
105 
106  ddpolycone = DDSolidFactory::polycone(solname, msol.startPhi(), msol.deltaPhi(), localzVec, newrMinVec, newrMaxVec);
107 
108  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddpolycone);
109  return ddlp;
110 }
111 
115  DDPolycone msol = (DDPolycone)(div_.parent().solid());
116  setType("DivisionPolyconePhi");
117  // this is the g4. what do we keep??? I think it is deltaPhi
118  // double deltaPhi = msol->GetEndPhi() - msol->GetStartPhi();
119  if (divisionType_ == DivWIDTH) {
120  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
121  if (msol.deltaPhi() == 360._deg) {
122  compNDiv_ = calculateNDiv(msol.deltaPhi(), div_.width(), 0.);
123  } else {
125  }
126  } else if (divisionType_ == DivNDIV) {
127  if (msol.deltaPhi() == 360._deg) {
129  } else {
131  }
132  }
133 }
134 
136 
138  DDPolycone msol = (DDPolycone)(div_.parent().solid());
139  return msol.deltaPhi();
140 }
141 
143  DDRotation myddrot; // sets to identity.
144  double posi = (copyNo - 1) * compWidth_;
145  // how to name the rotation??
146  // i do not like this
147  DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT" + std::to_string(copyNo),
148  div_.parent().ddname().ns());
149  myddrot = DDrot(ddrotname, changeRotMatrix(posi));
150 
151  return myddrot;
152 }
153 
155  DDTranslation translation;
156  return translation;
157 }
158 
160  DDSolid ddpolycone;
161  DDMaterial usemat(div_.parent().material());
162 
163  DDPolycone msol = (DDPolycone)(div_.parent().solid());
164  std::vector<double> localrMaxVec = msol.rMaxVec();
165  std::vector<double> localrMinVec = msol.rMinVec();
166  std::vector<double> localzVec = msol.zVec();
167 
168  DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
169  DDSolid sol(solname);
170  if (!sol.isDefined().second) {
171  ddpolycone = DDSolidFactory::polycone(
172  solname, msol.startPhi() + div_.offset(), compWidth_, localzVec, localrMinVec, localrMaxVec);
173  }
174  DDLogicalPart ddlp(solname);
175  if (!ddlp.isDefined().second) {
176  ddlp = DDLogicalPart(solname, usemat, ddpolycone);
177  }
178 
179  return ddlp;
180 }
181 
185  DDPolycone msol = (DDPolycone)(div_.parent().solid());
186  std::vector<double> localrMaxVec = msol.rMaxVec();
187  std::vector<double> localrMinVec = msol.rMinVec();
188  std::vector<double> localzVec = msol.zVec();
189 
190  if (divisionType_ == DivWIDTH) {
191  compNDiv_ = calculateNDiv(localzVec[localzVec.size() - 1] - localzVec[0], div_.width(), div_.offset());
192  } else if (divisionType_ == DivNDIV) {
193  compWidth_ = calculateNDiv(localzVec[localzVec.size() - 1] - localzVec[0], div_.nReplicas(), div_.offset());
194  }
195 }
196 
199 
200  DDPolycone msol = (DDPolycone)(div_.parent().solid());
201  std::vector<double> localzVec = msol.zVec();
202  // CHANGE FROM G4 a polycone can be divided in Z by specifying
203  // nReplicas IF they happen to coincide with the number of
204  // z plans.
205  size_t tempNDiv = div_.nReplicas();
206  if (tempNDiv == 0)
207  tempNDiv = calculateNDiv(localzVec[localzVec.size() - 1] - localzVec[0], div_.width(), div_.offset());
208  if ((msol.zVec().size() - 1) != tempNDiv) {
209  std::string s = "ERROR - DDDividedPolyconeZ::checkParametersValidity()";
210  s += "\n\tDivision along Z will be done splitting in the defined";
211  s += "\n\tz_planes, i.e, the number of division would be :";
212  s += "\n\t" + std::to_string(msol.zVec().size() - 1);
213  s += "\n\tinstead of " + std::to_string(tempNDiv) + " !\n";
214 
215  throw cms::Exception("DDException") << s;
216  }
217 }
218 
220  DDPolycone msol = (DDPolycone)(div_.parent().solid());
221  std::vector<double> localzVec = msol.zVec();
222 
223  return (localzVec[localzVec.size() - 1] - localzVec[0]);
224 }
225 
227  DDRotation myddrot; // sets to identity.
228  return myddrot;
229 }
230 
232  DDTranslation translation;
233  DDPolycone msol = (DDPolycone)(div_.parent().solid());
234  std::vector<double> localzVec = msol.zVec();
235  double posi = (localzVec[copyNo] + localzVec[copyNo + 1]) / 2;
236  translation.SetZ(posi);
237  return translation;
238 }
239 
241  DDSolid ddpolycone;
242  DDMaterial usemat(div_.parent().material());
243 
244  DDPolycone msol = (DDPolycone)(div_.parent().solid());
245  std::vector<double> localrMaxVec = msol.rMaxVec();
246  std::vector<double> localrMinVec = msol.rMinVec();
247  std::vector<double> localzVec = msol.zVec();
248 
249  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo), div_.parent().ddname().ns());
250  ddpolycone = DDSolidFactory::cons(solname,
251  compWidth_ / 2,
252  localrMinVec[copyNo],
253  localrMaxVec[copyNo],
254  localrMinVec[copyNo + 1],
255  localrMaxVec[copyNo + 1],
256  msol.startPhi(),
257  msol.deltaPhi());
258 
259  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddpolycone);
260 
261  return ddlp;
262 }
DDTranslation makeDDTranslation(int copyNo) const override
void checkParametersValidity() override
DDTranslation makeDDTranslation(int copyNo) const override
void checkParametersValidity() override
int nReplicas() const
Definition: DDDivision.cc:51
DDDividedPolyconeRho(const DDDivision &div, DDCompactView *cpv)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
static DDSolid cons(const DDName &name, double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double phiFrom, double deltaPhi)
Definition: DDSolid.cc:650
std::vector< double > rMinVec(void) const
Definition: DDSolid.cc:293
static DDSolid polycone(const DDName &name, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polycone (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:551
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
double offset() const
Definition: DDDivision.cc:55
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDRotation makeDDRotation(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
const DDLogicalPart & parent() const
Definition: DDDivision.cc:57
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
static std::string to_string(const XMLCh *ch)
virtual void checkParametersValidity(void)
DDRotation makeDDRotation(int copyNo) const override
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
double getMaxParameter() const override
int calculateNDiv(double motherDim, double width, double offset) const
DDRotation makeDDRotation(int copyNo) const override
void checkParametersValidity() override
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
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
virtual void setType(const std::string &type)
double getMaxParameter() const override
std::unique_ptr< DDRotationMatrix > changeRotMatrix(double rotZ=0.) const
DDTranslation makeDDTranslation(int copyNo) const override
ii
Definition: cuy.py:589
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
DDDividedPolyconeZ(const DDDivision &div, DDCompactView *cpv)
constexpr float sol
Definition: Config.h:13
DDDividedPolyconePhi(const DDDivision &div, DDCompactView *cpv)
DDLogicalPart makeDDLogicalPart(int copyNo) const override
const N & ddname() const
Definition: DDBase.h:61
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
double width() const
Definition: DDDivision.cc:53
std::vector< double > zVec(void) const
Definition: DDSolid.cc:286
std::vector< double > rMaxVec(void) const
Definition: DDSolid.cc:300
double deltaPhi(void) const
Definition: DDSolid.cc:277
double calculateWidth(double motherDim, int nDiv, double offset) const
double getMaxParameter() const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
def_type isDefined() const
Definition: DDBase.h:90
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52