CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDDividedBox.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // 25.04.04 - M. Case ddd-ize G4ParameterisationBox*
4 // ********************************************************************
5 
7 
14 
16 
17 #include <iomanip>
18 
21 {
23  setType( "DivisionBoxX" );
24  DDBox mbox = (DDBox)(div_.parent().solid());
25 
26  if( divisionType_ == DivWIDTH ) {
27  compNDiv_ = calculateNDiv( 2*mbox.halfX(), div_.width(), div_.offset() );
28  } else if( divisionType_ == DivNDIV ) {
30  }
31 
32  // somehow here, I want to iterate over the nDivs or nReplicas
33  // and make the solid, make the logical part, then position it.
34  // since DDBox is special, I will not make the solid and logical
35  // part but once. We'll see how bad the others go.
36  // ihatethisihatethisihatethis
37  // for (int i = 0; i < compNDiv_; ++i)
38  // {
39  // DDpos(makeDDLogicalPart(i) // child logical part
40  // , div_.parent() // parent logical part
41  // , i // copy number
42  // , makeDDTranslation(i) // translation
43  // , makeDDRotation(i) // rotation. box is default (i.e. identity).
44  // );
45  // }
46 
47  DCOUT_V ('P', " DDDividedBoxX:DDDividedBoxX" << std::endl);
48 }
49 
51 {}
52 
53 double
55 {
56  DDBox msol = (DDBox)(div_.parent().solid());
57  return 2*msol.halfX();
58 }
59 
61 DDDividedBoxX::makeDDRotation( const int copyNo ) const
62 {
63  return DDRotation();
64 }
65 
67 DDDividedBoxX::makeDDTranslation( const int copyNo ) const
68 {
69  DDBox msol = (DDBox)(div_.parent().solid());
70  double mdx = msol.halfX();
71 
72  //----- translation
73  DDTranslation translation;
74  double posi = -mdx + div_.offset() + (copyNo+0.5) * compWidth_;
75  translation.SetX( posi );
76 
77  DCOUT_V ('P', " DDDividedBoxX: " << copyNo << "\n Position " << translation << " Axis " << DDAxesNames::name(div_.axis()) << "\n");
78  return translation;
79 }
80 
82 DDDividedBoxX::makeDDLogicalPart( const int copyNo ) const
83 {
84  // in other cases, this solid will have 1, 2, 3, etc. after it.
85  DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
86  DDSolid ddbox(solname);
87  DDMaterial usemat(div_.parent().material());
88  DDBox msol = (DDBox) (div_.parent().solid());
89  DDLogicalPart ddlp(solname);
90  if (!ddbox.isDefined().second) //This solid has NOT been defined.
91  {
92  double pDx = msol.halfX();
93  double pDy = compWidth_/2.;
94  double pDz = msol.halfZ();
95 
96  ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
97  ddlp = DDLogicalPart(solname, usemat, ddbox);
98  }
99  DCOUT_V ('P', " DDDividedBoxX::computeDimensions() lp:\n" << ddlp);
100  return ddlp;
101 }
102 
105 {
107  setType( "DivisionBoxY" );
108  DDBox mbox = (DDBox)(div_.parent().solid());
109 
110  if( divisionType_ == DivWIDTH ) {
111  compNDiv_ = calculateNDiv( 2*mbox.halfY(), div_.width(), div_.offset() );
112  } else if( divisionType_ == DivNDIV ) {
114  }
115 
116 
117  // somehow here, I want to iterate over the nDivs or nReplicas
118  // and make the solid, make the logical part, then position it.
119  // since DDBox is special, I will not make the solid and logical
120  // part but once. We'll see how bad the others go.
121  // ihatethisihatethisihatethis
122  // for (int i = 0; i < compNDiv_; ++i)
123  // {
124  // DDpos(makeDDLogicalPart(i) // child logical part
125  // , div_.parent() // parent logical part
126  // , i // copy number
127  // , makeDDTranslation(i) // translation
128  // , makeDDRotation(i) // rotation. box is default (i.e. identity).
129  // );
130  // }
131 
132  DCOUT_V ('P', " DDDividedBoxY:DDDividedBoxY" << std::endl);
133 }
134 
136 {}
137 
138 double
140 {
141  DDBox msol = (DDBox)(div_.parent().solid());
142  return 2*msol.halfY();
143 }
144 
146 DDDividedBoxY::makeDDRotation( const int copyNo ) const
147 {
148  return DDRotation();
149 }
150 
152 DDDividedBoxY::makeDDTranslation( const int copyNo ) const
153 {
154  DDBox msol = (DDBox)(div_.parent().solid());
155  double mdx = msol.halfY();
156 
157  //----- translation
158  DDTranslation translation;
159 
160  double posi = -mdx + div_.offset() + (copyNo+0.5) * compWidth_;
161  translation.SetY( posi );
162 
163  DCOUT_V ('P', " DDDividedBoxY: " << copyNo << "\n Position " << translation << " Axis " << DDAxesNames::name(div_.axis()) << "\n");
164  return translation;
165 }
166 
168 DDDividedBoxY::makeDDLogicalPart( const int copyNo ) const
169 {
170  // in other cases, this solid will have 1, 2, 3, etc. after it.
171  DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
172  DDSolid ddbox(solname);
173  DDMaterial usemat(div_.parent().material());
174  DDBox msol = (DDBox) (div_.parent().solid());
175  DDLogicalPart ddlp(solname);
176  if (!ddbox.isDefined().second) //This solid has NOT been defined.
177  {
178  double pDx = msol.halfX();
179  double pDy = compWidth_/2.;
180  double pDz = msol.halfZ();
181  ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
182  ddlp = DDLogicalPart(solname, usemat, ddbox);
183  }
184  DCOUT_V ('P', " DDDividedBoxY::computeDimensions() lp:\n" << ddlp);
185  return ddlp;
186 }
187 
190 {
192  setType( "DivisionBoxZ" );
193  DDBox mbox = (DDBox)(div_.parent().solid());
194 
195  if( divisionType_ == DivWIDTH ) {
196  compNDiv_ = calculateNDiv( 2*mbox.halfZ(), div_.width(), div_.offset() );
197  } else if( divisionType_ == DivNDIV ) {
199  }
200 
201  // somehow here, I want to iterate over the nDivs or nReplicas
202  // and make the solid, make the logical part, then position it.
203  // since DDBox is special, I will not make the solid and logical
204  // part but once. We'll see how bad the others go.
205  // ihatethisihatethisihatethis
206  // for (int i = 0; i < compNDiv_; ++i)
207  // {
208  // DDpos(makeDDLogicalPart(i) // child logical part
209  // , div_.parent() // parent logical part
210  // , i // copy number
211  // , makeDDTranslation(i) // translation
212  // , makeDDRotation(i) // rotation. box is default (i.e. identity).
213  // );
214  // }
215 
216  DCOUT_V ('P', " DDDividedBoxZ:DDDividedBoxZ" << std::endl);
217 }
218 
220 {}
221 
222 double
224 {
225  DDBox msol = (DDBox)(div_.parent().solid());
226  return 2*msol.halfZ();
227 }
228 
230 DDDividedBoxZ::makeDDRotation( const int copyNo ) const
231 {
232  return DDRotation();
233 }
234 
236 DDDividedBoxZ::makeDDTranslation( const int copyNo ) const
237 {
238  DDBox msol = (DDBox)(div_.parent().solid());
239  double mdx = msol.halfZ();
240 
241  //----- translation
242  DDTranslation translation;
243 
244  double posi = -mdx + div_.offset() + (copyNo+0.5) * compWidth_;
245  translation.SetZ( posi );
246 
247  DCOUT_V ('P', " DDDividedBoxZ: " << copyNo << "\n Position " << translation << " Axis " << DDAxesNames::name(div_.axis()) << "\n");
248  return translation;
249 }
250 
252 DDDividedBoxZ::makeDDLogicalPart( const int copyNo ) const
253 {
254  // in other cases, this solid will have 1, 2, 3, etc. after it.
255  DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
256  DDSolid ddbox(solname);
257  DDMaterial usemat(div_.parent().material());
258  DDBox msol = (DDBox) (div_.parent().solid());
259  DDLogicalPart ddlp(solname);
260  if (!ddbox.isDefined().second) //This solid has NOT been defined.
261  {
262  double pDx = msol.halfX();
263  double pDy = msol.halfY();
264  double pDz = compWidth_/2.;
265  ddbox = DDSolidFactory::box(solname, pDx, pDy, pDz);
266  ddlp = DDLogicalPart(solname, usemat, ddbox);
267  }
268  DCOUT_V ('P', " DDDividedBoxZ::computeDimensions() lp:\n" << ddlp);
269  return ddlp;
270 }
271 
272 
273 
virtual DDRotation makeDDRotation(const int copyNo) const
virtual DDRotation makeDDRotation(const int copyNo) const
double halfZ(void) const
Definition: DDSolid.cc:258
double halfY(void) const
Definition: DDSolid.cc:256
virtual double getMaxParameter() const
virtual ~DDDividedBoxY()
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
virtual DDTranslation makeDDTranslation(const int copyNo) const
virtual DDRotation makeDDRotation(const int copyNo) const
Definition: DDDividedBox.cc:61
int calculateNDiv(double motherDim, double width, double offset) const
virtual double getMaxParameter() const
virtual DDTranslation makeDDTranslation(const int copyNo) const
Definition: DDDividedBox.cc:67
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:14
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.
virtual ~DDDividedBoxX()
Definition: DDDividedBox.cc:50
type of data representation of DDCompactView
Definition: DDCompactView.h:77
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
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:66
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
static const std::string name(const DDAxes &s)
virtual void setType(const std::string &type)
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
Definition: DDSolid.cc:519
DDDividedBoxX(const DDDivision &div, DDCompactView *cpv)
Definition: DDDividedBox.cc:19
DDDividedBoxY(const DDDivision &div, DDCompactView *cpv)
virtual DDTranslation makeDDTranslation(const int copyNo) const
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
double halfX(void) const
Definition: DDSolid.cc:254
DDDividedBoxZ(const DDDivision &div, DDCompactView *cpv)
Interface to a Box.
Definition: DDSolid.h:162
DDAxes axis() const
Definition: DDDivision.cc:66
double width() const
Definition: DDDivision.cc:76
const DDLogicalPart & parent() const
Definition: DDDivision.cc:86
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
Definition: DDDividedBox.cc:82
virtual double getMaxParameter() const
Definition: DDDividedBox.cc:54
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
virtual ~DDDividedBoxZ()
const N & ddname() const
Definition: DDBase.h:80