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 }
DDDividedGeometryObject::compWidth_
double compWidth_
Definition: DDDividedGeometryObject.h:56
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
DDDividedPolyconePhi::makeDDLogicalPart
DDLogicalPart makeDDLogicalPart(int copyNo) const override
Definition: DDDividedPolycone.cc:159
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
DDDividedPolyconeZ::DDDividedPolyconeZ
DDDividedPolyconeZ(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedPolycone.cc:182
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
DDDividedPolyconeRho::getMaxParameter
double getMaxParameter() const override
Definition: DDDividedPolycone.cc:66
DDDividedPolyconeRho::makeDDTranslation
DDTranslation makeDDTranslation(int copyNo) const override
Definition: DDDividedPolycone.cc:79
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
DDPolycone::deltaPhi
double deltaPhi(void) const
Definition: DDSolid.cc:273
DDDividedPolyconeZ::makeDDTranslation
DDTranslation makeDDTranslation(int copyNo) const override
Definition: DDDividedPolycone.cc:231
DDSolidFactory::cons
static DDSolid cons(const DDName &name, double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double phiFrom, double deltaPhi)
Definition: DDSolid.cc:636
geant_units::operators
Definition: GeantUnits.h:18
DDDividedPolyconeZ::makeDDRotation
DDRotation makeDDRotation(int copyNo) const override
Definition: DDDividedPolycone.cc:226
DDDividedGeometryObject
Definition: DDDividedGeometryObject.h:20
DivWIDTH
Definition: DDDividedGeometryObject.h:14
DDDividedPolyconePhi::getMaxParameter
double getMaxParameter() const override
Definition: DDDividedPolycone.cc:137
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDDividedGeometryObject::checkParametersValidity
virtual void checkParametersValidity(void)
Definition: DDDividedGeometryObject.cc:41
DDDividedPolyconeRho::makeDDRotation
DDRotation makeDDRotation(int copyNo) const override
Definition: DDDividedPolycone.cc:74
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DivNDIV
Definition: DDDividedGeometryObject.h:14
DivNDIVandWIDTH
Definition: DDDividedGeometryObject.h:14
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
DDPolycone::zVec
std::vector< double > zVec(void) const
Definition: DDSolid.cc:282
DDSolid.h
DDPolycone::rMaxVec
std::vector< double > rMaxVec(void) const
Definition: DDSolid.cc:296
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
DDDividedPolyconeRho::checkParametersValidity
void checkParametersValidity() override
Definition: DDDividedPolycone.cc:43
DDDividedGeometryObject::changeRotMatrix
std::unique_ptr< DDRotationMatrix > changeRotMatrix(double rotZ=0.) const
Definition: DDDividedGeometryObject.cc:29
DDDividedGeometryObject::compNDiv_
int compNDiv_
Definition: DDDividedGeometryObject.h:55
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
DDDividedPolycone.h
GeantUnits.h
DDDividedPolyconePhi::checkParametersValidity
void checkParametersValidity() override
Definition: DDDividedPolycone.cc:135
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDDividedGeometryObject::divisionType_
DivisionType divisionType_
Definition: DDDividedGeometryObject.h:57
DDMaterial.h
DDDividedGeometryObject::setType
virtual void setType(const std::string &type)
Definition: DDDividedGeometryObject.cc:81
DDDividedGeometryObject.h
DDDivision::offset
double offset() const
Definition: DDDivision.cc:55
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:40
DDSolidFactory::polycone
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:537
DDLogicalPart.h
DDDivision::nReplicas
int nReplicas() const
Definition: DDDivision.cc:51
DDDivision
Definition: DDDivision.h:78
DDDividedPolyconePhi::makeDDRotation
DDRotation makeDDRotation(int copyNo) const override
Definition: DDDividedPolycone.cc:142
DDName::ns
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:51
DDName.h
Exception
Definition: hltDiff.cc:246
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDPolycone
Definition: DDSolid.h:211
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
Exception.h
DDDividedPolyconePhi::DDDividedPolyconePhi
DDDividedPolyconePhi(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedPolycone.cc:112
DDDividedPolyconeRho::makeDDLogicalPart
DDLogicalPart makeDDLogicalPart(int copyNo) const override
Definition: DDDividedPolycone.cc:84
DDDividedPolyconeZ::makeDDLogicalPart
DDLogicalPart makeDDLogicalPart(int copyNo) const override
Definition: DDDividedPolycone.cc:240
DDPolycone::rMinVec
std::vector< double > rMinVec(void) const
Definition: DDSolid.cc:289
DDDividedPolyconeZ::getMaxParameter
double getMaxParameter() const override
Definition: DDDividedPolycone.cc:219
DDDividedPolyconePhi::makeDDTranslation
DDTranslation makeDDTranslation(int copyNo) const override
Definition: DDDividedPolycone.cc:154
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
DDDividedPolyconeRho::DDDividedPolyconeRho
DDDividedPolyconeRho(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedPolycone.cc:23
DDDividedPolyconeZ::checkParametersValidity
void checkParametersValidity() override
Definition: DDDividedPolycone.cc:197
DDRotationMatrix.h
DDDividedGeometryObject::calculateWidth
double calculateWidth(double motherDim, int nDiv, double offset) const
Definition: DDDividedGeometryObject.cc:37