CMS 3D CMS Logo

DDDividedCons.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <string>
5 #include <utility>
6 
7 #include "CLHEP/Units/GlobalSystemOfUnits.h"
8 #include "CLHEP/Units/SystemOfUnits.h"
18 
19 class DDCompactView;
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  DDRotationMatrix* rotMat = changeRotMatrix( posi );
153  // how to name the rotation??
154  // i hate this crap :-)
155  DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT" + std::to_string(copyNo),
156  div_.parent().ddname().ns());
157  myddrot = DDrot(ddrotname, rotMat);
158 
159  return myddrot;
160 }
161 
163 DDDividedConsPhi::makeDDTranslation( const int copyNo ) const
164 {
165  DDTranslation translation;
166  return translation;
167 }
168 
170 DDDividedConsPhi::makeDDLogicalPart( const int copyNo ) const
171 {
172  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
173  , div_.parent().ddname().ns());
174  DDSolid ddcons(solname);
175  DDMaterial usemat(div_.parent().material());
176  DDCons msol = (DDCons)(div_.parent().solid());
177 
178  if (!ddcons.isDefined().second)
179  {
180  double pRMin1 = msol.rInMinusZ();
181  double pRMax1 = msol.rOutMinusZ();
182  double pRMin2 = msol.rInPlusZ();
183  double pRMax2 = msol.rOutPlusZ();
184  double pDz = msol.zhalf();
185 
186  //- already rotated double pSPhi = div_.offset() + copyNo*compWidth_;
187  double pSPhi = div_.offset() + msol.phiFrom();
188  double pDPhi = compWidth_;
189  ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1
190  , pRMin2, pRMax2, pSPhi, pDPhi);
191  }
192 
193  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
194 
195  return ddlp;
196 }
197 
200 {
202 
203  DDCons msol = (DDCons)(div_.parent().solid());
204  setType( "DivisionConsZ" );
205 
206  if( divisionType_ == DivWIDTH )
207  {
208  DDCons msol = (DDCons)(div_.parent().solid());
209  compNDiv_ = calculateNDiv( 2*msol.zhalf()
210  , div_.width(), div_.offset() );
211  }
212  else if( divisionType_ == DivNDIV )
213  {
214  DDCons msol = (DDCons)(div_.parent().solid());
215  compWidth_ = calculateWidth( 2*msol.zhalf()
216  , div_.nReplicas(), div_.offset() );
217  }
218 }
219 
220 double
222 {
223  DDCons msol = (DDCons)(div_.parent().solid());
224  return 2*msol.zhalf();
225 }
226 
228 DDDividedConsZ::makeDDRotation( const int copyNo ) const
229 {
230  DDRotation myddrot; // sets to identity.
231  return myddrot;
232 }
233 
235 DDDividedConsZ::makeDDTranslation( const int copyNo ) const
236 {
237  DDTranslation translation;
238 
239  DDCons motherCons = (DDCons)(div_.parent().solid());
240  double posi = - motherCons.zhalf() + div_.offset()
241  + compWidth_/2 + copyNo*compWidth_;
242  translation.SetZ(posi);
243 
244  return translation;
245 }
246 
248 DDDividedConsZ::makeDDLogicalPart( const int copyNo ) const
249 {
250  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo),
251  div_.parent().ddname().ns());
252  DDSolid ddcons(solname);
253  DDMaterial usemat(div_.parent().material());
254  DDCons msol = (DDCons)(div_.parent().solid());
255 
256  double mHalfLength = msol.zhalf();
257  double aRInner = (msol.rInPlusZ()
258  - msol.rInMinusZ()) / (2*mHalfLength);
259  double bRInner = (msol.rInPlusZ()
260  + msol.rInMinusZ()) / 2;
261  double aROuter = (msol.rOutPlusZ()
262  - msol.rOutMinusZ()) / (2*mHalfLength);
263  double bROuter = (msol.rOutPlusZ()
264  + msol.rOutMinusZ()) / 2;
265  double xMinusZ = -mHalfLength + div_.offset() + compWidth_*copyNo;
266  double xPlusZ = -mHalfLength + div_.offset() + compWidth_*(copyNo+1);
267 
268  double pDz = compWidth_ / 2.;
269  double pSPhi = msol.phiFrom();
270  double pDPhi = msol.deltaPhi();
271 
272  ddcons = DDSolidFactory::cons(DDName(solname)
273  , pDz
274  , aRInner * xMinusZ + bRInner
275  , aROuter * xMinusZ + bROuter
276  , aRInner * xPlusZ + bRInner
277  , aROuter * xPlusZ + bROuter
278  , pSPhi
279  , pDPhi
280  );
281 
282  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
283 
284  return ddlp;
285 }
double zhalf(void) const
Definition: DDSolid.cc:548
virtual double getMaxParameter() const override
virtual DDRotation makeDDRotation(const int copyNo) const override
virtual DDRotation makeDDRotation(const int copyNo) 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:956
int calculateNDiv(double motherDim, double width, double offset) const
virtual DDTranslation makeDDTranslation(const int copyNo) const override
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:104
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
virtual DDRotation makeDDRotation(const int copyNo) const override
double rOutMinusZ(void) const
Definition: DDSolid.cc:554
double calculateWidth(double motherDim, int nDiv, double offset) const
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const override
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const override
type of data representation of DDCompactView
Definition: DDCompactView.h:90
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:64
virtual double getMaxParameter() const override
DDDividedConsRho(const DDDivision &div, DDCompactView *cpv)
double rInMinusZ(void) const
Definition: DDSolid.cc:551
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
virtual void setType(const std::string &type)
virtual DDLogicalPart makeDDLogicalPart(const 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
virtual DDTranslation makeDDTranslation(const int copyNo) const override
double deltaPhi(void) const
Definition: DDSolid.cc:566
DDDividedConsPhi(const DDDivision &div, DDCompactView *cpv)
double width() const
Definition: DDDivision.cc:76
double rInPlusZ(void) const
Definition: DDSolid.cc:557
const DDLogicalPart & parent() const
Definition: DDDivision.cc:86
virtual DDTranslation makeDDTranslation(const int copyNo) const override
virtual 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:90
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