CMS 3D CMS Logo

DDDividedCons.cc
Go to the documentation of this file.
2 #include "CLHEP/Units/GlobalSystemOfUnits.h"
3 #include "CLHEP/Units/SystemOfUnits.h"
13 
14 #include <iostream>
15 #include <string>
16 #include <utility>
17 
18 class DDCompactView;
19 
22 {
24  setType( "DivisionConsRho" );
25  DDCons msol = (DDCons)(div_.parent().solid());
26 
27  if( msol.rInPlusZ() == 0. )
28  {
29  std::cout << "WARNING - DDDividedConsRho, rOutMinusZ = 0. "
30  << std::endl
31  << " Width is calculated as that of rOutMinusZ !"
32  << std::endl;
33  }
34 
35  if( divisionType_ == DivWIDTH )
36  {
38  - msol.rInMinusZ(), div_.width(), div_.offset() );
39  }
40  else if( divisionType_ == DivNDIV )
41  {
42  DDCons msol = (DDCons)(div_.parent().solid());
44  , div_.nReplicas()
45  , div_.offset() );
46  }
47 }
48 
49 double
51 {
52  DDCons msol = (DDCons)(div_.parent().solid());
53  return msol.rOutMinusZ() - msol.rInMinusZ();
54 }
55 
57 DDDividedConsRho::makeDDRotation( const int copyNo ) const
58 {
59  DDRotation myddrot; // sets to identity.
60  return myddrot;
61 }
62 
64 DDDividedConsRho::makeDDTranslation( const int copyNo ) const
65 {
66  DDTranslation translation;
67  return translation;
68 }
69 
71 DDDividedConsRho::makeDDLogicalPart( const int copyNo ) const
72 {
73  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
74  + std::to_string(copyNo),
75  div_.parent().ddname().ns());
76  DDSolid ddcons(solname);
77  DDMaterial usemat(div_.parent().material());
78  DDCons msol = (DDCons)(div_.parent().solid());
79 
80  double pRMin1 = msol.rInMinusZ() + div_.offset() + compWidth_ * copyNo;
81  double pRMax1 = msol.rInMinusZ() + div_.offset() + compWidth_ * (copyNo+1);
82 
83  //width at Z Plus
84  //- double compWidth_Plus =
85  // compWidth_ * ( msol.rOutPlusZ()/ msol.rInPlusZ())
86  //- / ( msol.rOutMinusZ() - msol.rInMinusZ());
87  double compWidth_Plus = calculateWidth( msol.rOutPlusZ()
88  - msol.rInPlusZ(), compNDiv_, div_.offset() );
89  double pRMin2 = msol.rInPlusZ()
90  + div_.offset() + compWidth_Plus * copyNo;
91  double pRMax2 = msol.rInPlusZ()
92  + div_.offset() + compWidth_Plus * (copyNo+1);
93  double pDz = msol.zhalf();
94 
95  double pSPhi = msol.phiFrom();
96  double pDPhi = msol.deltaPhi();
97 
98  ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1
99  , pRMin2, pRMax2, pSPhi, pDPhi);
100 
101  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
102  return ddlp;
103 }
104 
107 {
109  setType( "DivisionConsPhi" );
110  DDCons msol = (DDCons)(div_.parent().solid());
111 
112  if( divisionType_ == DivWIDTH )
113  {
114  DDCons msol = (DDCons)(div_.parent().solid());
115  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
116  if( msol.deltaPhi() == 360.*deg )
117  {
118  compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
119  }
120  else
121  {
123  }
124  }
125  else if( divisionType_ == DivNDIV )
126  {
127  DDCons msol = (DDCons)(div_.parent().solid());
128  if( msol.deltaPhi() == 360.*deg )
129  {
130  compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
131  }
132  else
133  {
135  }
136  }
137 }
138 
139 double
141 {
142  DDCons msol = (DDCons)(div_.parent().solid());
143  return msol.deltaPhi();
144 }
145 
147 DDDividedConsPhi::makeDDRotation( const int copyNo ) const
148 {
149  DDRotation myddrot; // sets to identity.
150  double posi = ( copyNo - 1 ) * compWidth_;
151  DDRotationMatrix* rotMat = changeRotMatrix( posi );
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, rotMat);
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:71
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
double offset() const
Definition: DDDivision.cc:81
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:836
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:102
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:83
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
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:67
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:92
virtual void setType(const std::string &type)
DDTranslation makeDDTranslation(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
DDRotation makeDDRotation(int copyNo) const override
double deltaPhi(void) const
Definition: DDSolid.cc:542
DDDividedConsPhi(const DDDivision &div, DDCompactView *cpv)
DDRotation makeDDRotation(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
double width() const
Definition: DDDivision.cc:76
double rInPlusZ(void) const
Definition: DDSolid.cc:533
const DDLogicalPart & parent() const
Definition: DDDivision.cc:86
DDRotation makeDDRotation(int copyNo) const override
double getMaxParameter() const override
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
const N & ddname() const
Definition: DDBase.h:80
DDRotationMatrix * changeRotMatrix(double rotZ=0.) const