CMS 3D CMS Logo

DDDividedCons.cc
Go to the documentation of this file.
12 
13 #include <iostream>
14 #include <string>
15 #include <utility>
16 
17 class DDCompactView;
18 
19 using namespace geant_units::operators;
20 
24  setType("DivisionConsRho");
25  DDCons msol = (DDCons)(div_.parent().solid());
26 
27  if (msol.rInPlusZ() == 0.) {
28  std::cout << "WARNING - DDDividedConsRho, rOutMinusZ = 0. " << std::endl
29  << " Width is calculated as that of rOutMinusZ !" << std::endl;
30  }
31 
32  if (divisionType_ == DivWIDTH) {
34  } else if (divisionType_ == DivNDIV) {
35  DDCons msol = (DDCons)(div_.parent().solid());
37  }
38 }
39 
41  DDCons msol = (DDCons)(div_.parent().solid());
42  return msol.rOutMinusZ() - msol.rInMinusZ();
43 }
44 
46  DDRotation myddrot; // sets to identity.
47  return myddrot;
48 }
49 
51  DDTranslation translation;
52  return translation;
53 }
54 
56  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo), div_.parent().ddname().ns());
57  DDSolid ddcons(solname);
58  DDMaterial usemat(div_.parent().material());
59  DDCons msol = (DDCons)(div_.parent().solid());
60 
61  double pRMin1 = msol.rInMinusZ() + div_.offset() + compWidth_ * copyNo;
62  double pRMax1 = msol.rInMinusZ() + div_.offset() + compWidth_ * (copyNo + 1);
63 
64  //width at Z Plus
65  //- double compWidth_Plus =
66  // compWidth_ * ( msol.rOutPlusZ()/ msol.rInPlusZ())
67  //- / ( msol.rOutMinusZ() - msol.rInMinusZ());
68  double compWidth_Plus = calculateWidth(msol.rOutPlusZ() - msol.rInPlusZ(), compNDiv_, div_.offset());
69  double pRMin2 = msol.rInPlusZ() + div_.offset() + compWidth_Plus * copyNo;
70  double pRMax2 = msol.rInPlusZ() + div_.offset() + compWidth_Plus * (copyNo + 1);
71  double pDz = msol.zhalf();
72 
73  double pSPhi = msol.phiFrom();
74  double pDPhi = msol.deltaPhi();
75 
76  ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1, pRMin2, pRMax2, pSPhi, pDPhi);
77 
78  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
79  return ddlp;
80 }
81 
85  setType("DivisionConsPhi");
86  DDCons msol = (DDCons)(div_.parent().solid());
87 
88  if (divisionType_ == DivWIDTH) {
89  DDCons msol = (DDCons)(div_.parent().solid());
90  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
91  if (msol.deltaPhi() == 360._deg) {
92  compNDiv_ = calculateNDiv(msol.deltaPhi(), div_.width(), 0.);
93  } else {
95  }
96  } else if (divisionType_ == DivNDIV) {
97  DDCons msol = (DDCons)(div_.parent().solid());
98  if (msol.deltaPhi() == 360._deg) {
100  } else {
102  }
103  }
104 }
105 
107  DDCons msol = (DDCons)(div_.parent().solid());
108  return msol.deltaPhi();
109 }
110 
112  DDRotation myddrot; // sets to identity.
113  double posi = (copyNo - 1) * compWidth_;
114  // how to name the rotation??
115  // i hate this crap :-)
116  DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT" + std::to_string(copyNo),
117  div_.parent().ddname().ns());
118  myddrot = DDrot(ddrotname, changeRotMatrix(posi));
119 
120  return myddrot;
121 }
122 
124  DDTranslation translation;
125  return translation;
126 }
127 
129  DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
130  DDSolid ddcons(solname);
131  DDMaterial usemat(div_.parent().material());
132  DDCons msol = (DDCons)(div_.parent().solid());
133 
134  if (!ddcons.isDefined().second) {
135  double pRMin1 = msol.rInMinusZ();
136  double pRMax1 = msol.rOutMinusZ();
137  double pRMin2 = msol.rInPlusZ();
138  double pRMax2 = msol.rOutPlusZ();
139  double pDz = msol.zhalf();
140 
141  //- already rotated double pSPhi = div_.offset() + copyNo*compWidth_;
142  double pSPhi = div_.offset() + msol.phiFrom();
143  double pDPhi = compWidth_;
144  ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1, pRMin2, pRMax2, pSPhi, pDPhi);
145  }
146 
147  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
148 
149  return ddlp;
150 }
151 
155 
156  DDCons msol = (DDCons)(div_.parent().solid());
157  setType("DivisionConsZ");
158 
159  if (divisionType_ == DivWIDTH) {
160  DDCons msol = (DDCons)(div_.parent().solid());
161  compNDiv_ = calculateNDiv(2 * msol.zhalf(), div_.width(), div_.offset());
162  } else if (divisionType_ == DivNDIV) {
163  DDCons msol = (DDCons)(div_.parent().solid());
165  }
166 }
167 
169  DDCons msol = (DDCons)(div_.parent().solid());
170  return 2 * msol.zhalf();
171 }
172 
174  DDRotation myddrot; // sets to identity.
175  return myddrot;
176 }
177 
179  DDTranslation translation;
180 
181  DDCons motherCons = (DDCons)(div_.parent().solid());
182  double posi = -motherCons.zhalf() + div_.offset() + compWidth_ / 2 + copyNo * compWidth_;
183  translation.SetZ(posi);
184 
185  return translation;
186 }
187 
189  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo), div_.parent().ddname().ns());
190  DDSolid ddcons(solname);
191  DDMaterial usemat(div_.parent().material());
192  DDCons msol = (DDCons)(div_.parent().solid());
193 
194  double mHalfLength = msol.zhalf();
195  double aRInner = (msol.rInPlusZ() - msol.rInMinusZ()) / (2 * mHalfLength);
196  double bRInner = (msol.rInPlusZ() + msol.rInMinusZ()) / 2;
197  double aROuter = (msol.rOutPlusZ() - msol.rOutMinusZ()) / (2 * mHalfLength);
198  double bROuter = (msol.rOutPlusZ() + msol.rOutMinusZ()) / 2;
199  double xMinusZ = -mHalfLength + div_.offset() + compWidth_ * copyNo;
200  double xPlusZ = -mHalfLength + div_.offset() + compWidth_ * (copyNo + 1);
201 
202  double pDz = compWidth_ / 2.;
203  double pSPhi = msol.phiFrom();
204  double pDPhi = msol.deltaPhi();
205 
207  pDz,
208  aRInner * xMinusZ + bRInner,
209  aROuter * xMinusZ + bROuter,
210  aRInner * xPlusZ + bRInner,
211  aROuter * xPlusZ + bROuter,
212  pSPhi,
213  pDPhi);
214 
215  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
216 
217  return ddlp;
218 }
DDRotation makeDDRotation(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
double rInPlusZ(void) const
Definition: DDSolid.cc:420
int nReplicas() const
Definition: DDDivision.cc:51
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDDividedConsZ(const DDDivision &div, DDCompactView *cpv)
static DDSolid cons(const DDName &name, double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double phiFrom, double deltaPhi)
Definition: DDSolid.cc:650
double rOutMinusZ(void) const
Definition: DDSolid.cc:418
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
double getMaxParameter() const override
double offset() const
Definition: DDDivision.cc:55
DDLogicalPart makeDDLogicalPart(int copyNo) const override
double getMaxParameter() const override
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
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)
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDRotation makeDDRotation(int copyNo) const override
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
int calculateNDiv(double motherDim, double width, double offset) const
DDLogicalPart makeDDLogicalPart(int copyNo) const override
DDDividedConsRho(const DDDivision &div, DDCompactView *cpv)
double deltaPhi(void) const
Definition: DDSolid.cc:426
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
DDRotation makeDDRotation(int copyNo) const override
virtual void setType(const std::string &type)
std::unique_ptr< DDRotationMatrix > changeRotMatrix(double rotZ=0.) const
double rInMinusZ(void) const
Definition: DDSolid.cc:416
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
DDTranslation makeDDTranslation(int copyNo) const override
DDDividedConsPhi(const DDDivision &div, DDCompactView *cpv)
dd4hep::ConeSegment DDCons
const N & ddname() const
Definition: DDBase.h:61
DDTranslation makeDDTranslation(int copyNo) const override
DDTranslation makeDDTranslation(int copyNo) const override
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
double calculateWidth(double motherDim, int nDiv, double offset) const
double getMaxParameter() const override
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
double zhalf(void) const
Definition: DDSolid.cc:414
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52