CMS 3D CMS Logo

DDDividedTubs.cc
Go to the documentation of this file.
2 #include "CLHEP/Units/GlobalSystemOfUnits.h"
3 #include "CLHEP/Units/SystemOfUnits.h"
13 
14 #include <string>
15 #include <utility>
16 
17 class DDCompactView;
18 
21 {
23  setType( "DivisionTubsRho" );
24  DDTubs msol = (DDTubs)(div_.parent().solid());
25 
26  if( divisionType_ == DivWIDTH )
27  {
28  compNDiv_ = calculateNDiv( msol.rIn() - msol.rOut(),
29  div_.width(), div_.offset() );
30  }
31  else if( divisionType_ == DivNDIV )
32  {
33  compWidth_ = calculateWidth( msol.rIn() - msol.rOut(),
34  div_.nReplicas(), div_.offset() );
35  }
36 }
37 
38 double
40 {
41  DDTubs msol = (DDTubs)(div_.parent().solid());
42  return msol.rOut() - msol.rIn();
43 
44 }
45 
47 DDDividedTubsRho::makeDDRotation( const int copyNo ) const
48 {
49  DDRotation myddrot; // sets to identity.
50  return myddrot;
51 }
52 
54 DDDividedTubsRho::makeDDTranslation( const int copyNo ) const
55 {
56  DDTranslation translation;
57  return translation;
58 }
59 
61 DDDividedTubsRho::makeDDLogicalPart( const int copyNo ) const
62 {
63  // must always make new name and new solid
64  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
65  + std::to_string(copyNo),
66  div_.parent().ddname().ns());
67  DDSolid ddtubs(solname);
68  DDMaterial usemat(div_.parent().material());
69  DDTubs msol = (DDTubs) (div_.parent().solid());
70  DDLogicalPart ddlp;
71 
72  double pRMin = msol.rIn() + div_.offset() + compWidth_ * copyNo;
73  double pRMax = msol.rIn() + div_.offset() + compWidth_ * (copyNo+1);
74  double pDz = msol.zhalf();
75  double pSPhi = msol.startPhi();
76  double pDPhi = msol.deltaPhi();
77  ddtubs = DDSolidFactory::tubs(DDName(solname), pDz, pRMin, pRMax, pSPhi, pDPhi);
78  ddlp = DDLogicalPart(solname, usemat, ddtubs);
79  return ddlp;
80 }
81 
84 {
86  setType( "DivisionTubsPhi" );
87 
88  DDTubs msol = (DDTubs)(div_.parent().solid());
89  if( divisionType_ == DivWIDTH )
90  {
91  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
92  if( msol.deltaPhi() == 360.*deg ) {
93  compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
94  }else {
96  }
97 
98  }
99  else if( divisionType_ == DivNDIV )
100  {
101  if( msol.deltaPhi() == 360.*deg ) {
102  compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
103  }else {
105  }
106  }
107 }
108 
109 double
111 {
112  DDTubs msol = (DDTubs)(div_.parent().solid());
113  return msol.deltaPhi();
114 }
115 
117 DDDividedTubsPhi::makeDDRotation( const int copyNo ) const
118 {
119  DDRotation myddrot; // sets to identity.
120  double posi = ( copyNo - 1 ) * compWidth_; // This should put the first one at the 0 of the parent.
121  DDRotationMatrix * rotMat = changeRotMatrix( posi );
122  // how to name the rotation??
123  // i hate this crap :-)
124  DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT"
125  + std::to_string(copyNo),
126  div_.parent().ddname().ns());
127  myddrot = DDrot(ddrotname, rotMat);
128 
129  return myddrot;
130 }
131 
133 DDDividedTubsPhi::makeDDTranslation( const int copyNo ) const
134 {
135  DDTranslation translation;
136  return translation;
137 }
138 
140 DDDividedTubsPhi::makeDDLogicalPart( const int copyNo ) const
141 {
142  DDName solname(div_.name());
143  //- DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
144  DDSolid ddtubs(solname);
145  DDMaterial usemat(div_.parent().material());
146  DDTubs msol = (DDTubs) (div_.parent().solid());
147  DDLogicalPart ddlp(solname);
148 
149  if (!ddtubs.isDefined().second) // only if it is not defined, make new dimensions and solid.
150  {
151  double pRMin = msol.rIn();
152  double pRMax = msol.rOut();
153  double pDz = msol.zhalf();
154  double pSPhi = msol.startPhi()+div_.offset();
155  double pDPhi = compWidth_;
156  ddtubs = DDSolidFactory::tubs(DDName(solname), pDz, pRMin, pRMax, pSPhi, pDPhi);
157  ddlp = DDLogicalPart(solname, usemat, ddtubs);
158  }
159  return ddlp;
160 }
161 
164 {
166 
167  DDTubs msol = (DDTubs)(div_.parent().solid());
168 
169  setType( "DivisionTubsZ" );
170  if( divisionType_ == DivWIDTH )
171  {
172  compNDiv_ = calculateNDiv( 2*msol.zhalf(), div_.width(), div_.offset() );
173  }
174  else if( divisionType_ == DivNDIV )
175  {
177  }
178 }
179 
180 double
182 {
183  DDTubs msol = (DDTubs)(div_.parent().solid());
184  return 2*msol.zhalf();
185 
186 }
187 
189 DDDividedTubsZ::makeDDRotation( const int copyNo ) const
190 {
191  DDRotation myddrot; // sets to identity.
192  return myddrot;
193 }
194 
196 DDDividedTubsZ::makeDDTranslation( const int copyNo ) const
197 {
198  DDTranslation translation;
199 
200  DDTubs msol = (DDTubs)(div_.parent().solid());
201  double posi = - msol.zhalf() + div_.offset() + compWidth_/2 + copyNo*compWidth_;
202  translation.SetZ(posi);
203 
204  return translation;
205 }
206 
208 DDDividedTubsZ::makeDDLogicalPart( const int copyNo ) const
209 {
210  DDMaterial usemat(div_.parent().material());
211  DDTubs msol = (DDTubs) (div_.parent().solid());
212  DDLogicalPart ddlp;
213 
214  DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
215  DDSolid ddtubs(solname);
216 
217  if (!ddtubs.isDefined().second) // only if it is not defined, make new dimensions and solid.
218  {
219  double pRMin = msol.rIn();
220  double pRMax = msol.rOut();
221  double pDz = compWidth_/2.;
222  double pSPhi = msol.startPhi();
223  double pDPhi = msol.deltaPhi();
224  ddtubs = DDSolidFactory::tubs(DDName(solname), pDz, pRMin, pRMax, pSPhi, pDPhi);
225  ddlp = DDLogicalPart(solname, usemat, ddtubs);
226  }
227  else {
228  ddlp = DDLogicalPart(solname);
229  }
230  return ddlp;
231 }
const N & name() const
Definition: DDBase.h:78
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
int calculateNDiv(double motherDim, double width, double offset) const
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:104
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDDividedTubsRho(const DDDivision &div, DDCompactView *cpv)
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.
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
DDDividedTubsPhi(const DDDivision &div, DDCompactView *cpv)
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
DDRotation makeDDRotation(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
DDDividedTubsZ(const DDDivision &div, DDCompactView *cpv)
double getMaxParameter() const override
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:986
virtual void setType(const std::string &type)
double rOut(void) const
Definition: DDSolid.cc:611
DDTranslation makeDDTranslation(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
double getMaxParameter() const override
double deltaPhi(void) const
Definition: DDSolid.cc:617
DDTranslation makeDDTranslation(int copyNo) const override
double zhalf(void) const
Definition: DDSolid.cc:605
double width() const
Definition: DDDivision.cc:76
DDTranslation makeDDTranslation(int copyNo) const override
const DDLogicalPart & parent() const
Definition: DDDivision.cc:86
double rIn(void) const
Definition: DDSolid.cc:608
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.
DDRotation makeDDRotation(int copyNo) const override
DDRotation makeDDRotation(int copyNo) const override
const N & ddname() const
Definition: DDBase.h:80
DDRotationMatrix * changeRotMatrix(double rotZ=0.) const