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 
23 {
25  setType( "DivisionConsRho" );
26  DDCons msol = (DDCons)(div_.parent().solid());
27 
28  if( msol.rInPlusZ() == 0. )
29  {
30  std::cout << "WARNING - DDDividedConsRho, rOutMinusZ = 0. "
31  << std::endl
32  << " Width is calculated as that of rOutMinusZ !"
33  << std::endl;
34  }
35 
36  if( divisionType_ == DivWIDTH )
37  {
39  - msol.rInMinusZ(), div_.width(), div_.offset() );
40  }
41  else if( divisionType_ == DivNDIV )
42  {
43  DDCons msol = (DDCons)(div_.parent().solid());
45  , div_.nReplicas()
46  , div_.offset() );
47  }
48 }
49 
50 double
52 {
53  DDCons msol = (DDCons)(div_.parent().solid());
54  return msol.rOutMinusZ() - msol.rInMinusZ();
55 }
56 
58 DDDividedConsRho::makeDDRotation( const int copyNo ) const
59 {
60  DDRotation myddrot; // sets to identity.
61  return myddrot;
62 }
63 
65 DDDividedConsRho::makeDDTranslation( const int copyNo ) const
66 {
67  DDTranslation translation;
68  return translation;
69 }
70 
72 DDDividedConsRho::makeDDLogicalPart( const int copyNo ) const
73 {
74  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
75  + std::to_string(copyNo),
76  div_.parent().ddname().ns());
77  DDSolid ddcons(solname);
78  DDMaterial usemat(div_.parent().material());
79  DDCons msol = (DDCons)(div_.parent().solid());
80 
81  double pRMin1 = msol.rInMinusZ() + div_.offset() + compWidth_ * copyNo;
82  double pRMax1 = msol.rInMinusZ() + div_.offset() + compWidth_ * (copyNo+1);
83 
84  //width at Z Plus
85  //- double compWidth_Plus =
86  // compWidth_ * ( msol.rOutPlusZ()/ msol.rInPlusZ())
87  //- / ( msol.rOutMinusZ() - msol.rInMinusZ());
88  double compWidth_Plus = calculateWidth( msol.rOutPlusZ()
89  - msol.rInPlusZ(), compNDiv_, div_.offset() );
90  double pRMin2 = msol.rInPlusZ()
91  + div_.offset() + compWidth_Plus * copyNo;
92  double pRMax2 = msol.rInPlusZ()
93  + div_.offset() + compWidth_Plus * (copyNo+1);
94  double pDz = msol.zhalf();
95 
96  double pSPhi = msol.phiFrom();
97  double pDPhi = msol.deltaPhi();
98 
99  ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1
100  , pRMin2, pRMax2, pSPhi, pDPhi);
101 
102  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
103  return ddlp;
104 }
105 
108 {
110  setType( "DivisionConsPhi" );
111  DDCons msol = (DDCons)(div_.parent().solid());
112 
113  if( divisionType_ == DivWIDTH )
114  {
115  DDCons msol = (DDCons)(div_.parent().solid());
116  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
117  if( msol.deltaPhi() == 360._deg )
118  {
119  compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
120  }
121  else
122  {
124  }
125  }
126  else if( divisionType_ == DivNDIV )
127  {
128  DDCons msol = (DDCons)(div_.parent().solid());
129  if( msol.deltaPhi() == 360._deg )
130  {
131  compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
132  }
133  else
134  {
136  }
137  }
138 }
139 
140 double
142 {
143  DDCons msol = (DDCons)(div_.parent().solid());
144  return msol.deltaPhi();
145 }
146 
148 DDDividedConsPhi::makeDDRotation( const int copyNo ) const
149 {
150  DDRotation myddrot; // sets to identity.
151  double posi = ( copyNo - 1 ) * compWidth_;
152  // how to name the rotation??
153  // i hate this crap :-)
154  DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT" + std::to_string(copyNo),
155  div_.parent().ddname().ns());
156  myddrot = DDrot( ddrotname, changeRotMatrix( posi ));
157 
158  return myddrot;
159 }
160 
162 DDDividedConsPhi::makeDDTranslation( const int copyNo ) const
163 {
164  DDTranslation translation;
165  return translation;
166 }
167 
169 DDDividedConsPhi::makeDDLogicalPart( const int copyNo ) const
170 {
171  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
172  , div_.parent().ddname().ns());
173  DDSolid ddcons(solname);
174  DDMaterial usemat(div_.parent().material());
175  DDCons msol = (DDCons)(div_.parent().solid());
176 
177  if (!ddcons.isDefined().second)
178  {
179  double pRMin1 = msol.rInMinusZ();
180  double pRMax1 = msol.rOutMinusZ();
181  double pRMin2 = msol.rInPlusZ();
182  double pRMax2 = msol.rOutPlusZ();
183  double pDz = msol.zhalf();
184 
185  //- already rotated double pSPhi = div_.offset() + copyNo*compWidth_;
186  double pSPhi = div_.offset() + msol.phiFrom();
187  double pDPhi = compWidth_;
188  ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1
189  , pRMin2, pRMax2, pSPhi, pDPhi);
190  }
191 
192  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
193 
194  return ddlp;
195 }
196 
199 {
201 
202  DDCons msol = (DDCons)(div_.parent().solid());
203  setType( "DivisionConsZ" );
204 
205  if( divisionType_ == DivWIDTH )
206  {
207  DDCons msol = (DDCons)(div_.parent().solid());
208  compNDiv_ = calculateNDiv( 2*msol.zhalf()
209  , div_.width(), div_.offset() );
210  }
211  else if( divisionType_ == DivNDIV )
212  {
213  DDCons msol = (DDCons)(div_.parent().solid());
214  compWidth_ = calculateWidth( 2*msol.zhalf()
215  , div_.nReplicas(), div_.offset() );
216  }
217 }
218 
219 double
221 {
222  DDCons msol = (DDCons)(div_.parent().solid());
223  return 2*msol.zhalf();
224 }
225 
227 DDDividedConsZ::makeDDRotation( const int copyNo ) const
228 {
229  DDRotation myddrot; // sets to identity.
230  return myddrot;
231 }
232 
234 DDDividedConsZ::makeDDTranslation( const int copyNo ) const
235 {
236  DDTranslation translation;
237 
238  DDCons motherCons = (DDCons)(div_.parent().solid());
239  double posi = - motherCons.zhalf() + div_.offset()
240  + compWidth_/2 + copyNo*compWidth_;
241  translation.SetZ(posi);
242 
243  return translation;
244 }
245 
247 DDDividedConsZ::makeDDLogicalPart( const int copyNo ) const
248 {
249  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo),
250  div_.parent().ddname().ns());
251  DDSolid ddcons(solname);
252  DDMaterial usemat(div_.parent().material());
253  DDCons msol = (DDCons)(div_.parent().solid());
254 
255  double mHalfLength = msol.zhalf();
256  double aRInner = (msol.rInPlusZ()
257  - msol.rInMinusZ()) / (2*mHalfLength);
258  double bRInner = (msol.rInPlusZ()
259  + msol.rInMinusZ()) / 2;
260  double aROuter = (msol.rOutPlusZ()
261  - msol.rOutMinusZ()) / (2*mHalfLength);
262  double bROuter = (msol.rOutPlusZ()
263  + msol.rOutMinusZ()) / 2;
264  double xMinusZ = -mHalfLength + div_.offset() + compWidth_*copyNo;
265  double xPlusZ = -mHalfLength + div_.offset() + compWidth_*(copyNo+1);
266 
267  double pDz = compWidth_ / 2.;
268  double pSPhi = msol.phiFrom();
269  double pDPhi = msol.deltaPhi();
270 
271  ddcons = DDSolidFactory::cons(DDName(solname)
272  , pDz
273  , aRInner * xMinusZ + bRInner
274  , aROuter * xMinusZ + bROuter
275  , aRInner * xPlusZ + bRInner
276  , aROuter * xPlusZ + bROuter
277  , pSPhi
278  , pDPhi
279  );
280 
281  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
282 
283  return ddlp;
284 }
double zhalf(void) const
Definition: DDSolid.cc:524
double getMaxParameter() const override
int nReplicas() const
Definition: DDDivision.cc:75
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
double offset() const
Definition: DDDivision.cc:87
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:838
int calculateNDiv(double motherDim, double width, double offset) const
DDTranslation makeDDTranslation(int copyNo) const override
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:67
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
double rOutMinusZ(void) const
Definition: DDSolid.cc:530
double calculateWidth(double motherDim, int nDiv, double offset) const
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
virtual void checkParametersValidity(void)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
double getMaxParameter() const override
DDDividedConsRho(const DDDivision &div, DDCompactView *cpv)
DDTranslation makeDDTranslation(int copyNo) const override
double rInMinusZ(void) const
Definition: DDSolid.cc:527
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:80
virtual void setType(const std::string &type)
DDTranslation makeDDTranslation(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
DDRotation makeDDRotation(int copyNo) const override
double deltaPhi(void) const
Definition: DDSolid.cc:542
DDDividedConsPhi(const DDDivision &div, DDCompactView *cpv)
std::unique_ptr< DDRotationMatrix > changeRotMatrix(double rotZ=0.) const
DDRotation makeDDRotation(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
double width() const
Definition: DDDivision.cc:81
double rInPlusZ(void) const
Definition: DDSolid.cc:533
const DDLogicalPart & parent() const
Definition: DDDivision.cc:93
DDRotation makeDDRotation(int copyNo) const override
double getMaxParameter() const override
const std::string & name() const
Returns the name.
Definition: DDName.cc:53
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
const N & ddname() const
Definition: DDBase.h:76