CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDDividedTubs.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // 25.04.04 - M. Case ddd-ize G4ParameterisationTubs*
4 // ********************************************************************
5 
8 
14 
17 
18 #include "CLHEP/Units/GlobalSystemOfUnits.h"
19 
22 {
24  setType( "DivisionTubsRho" );
25  DDTubs msol = (DDTubs)(div_.parent().solid());
26 
27  if( divisionType_ == DivWIDTH )
28  {
29  compNDiv_ = calculateNDiv( msol.rIn() - msol.rOut(),
30  div_.width(), div_.offset() );
31  }
32  else if( divisionType_ == DivNDIV )
33  {
34  compWidth_ = calculateWidth( msol.rIn() - msol.rOut(),
35  div_.nReplicas(), div_.offset() );
36  }
37 
38  DCOUT_V ('P', " DDDividedTubsRho - no divisions " << compNDiv_ << " = " << div_.nReplicas() << "\n Offset " << div_.offset() << "\n Width " << compWidth_ << " = " << div_.width() << "\n DivType " << divisionType_);
39 
40 }
41 
43 {}
44 
45 double
47 {
48  DDTubs msol = (DDTubs)(div_.parent().solid());
49  return msol.rOut() - msol.rIn();
50 
51 }
52 
54 DDDividedTubsRho::makeDDRotation( const int copyNo ) const
55 {
56  DDRotation myddrot; // sets to identity.
57  DCOUT_V ('P', "DDDividedTubsRho::makeDDRotation made a rotation: " << myddrot);
58  return myddrot;
59 }
60 
61 
63 DDDividedTubsRho::makeDDTranslation( const int copyNo ) const
64 {
65  //----- translation
66  DDTranslation translation;
67 
68  DCOUT_V ('P', " DDDividedTubsRho " << "\n\t Position: " << translation << " - Width: " << compWidth_ << " - Axis " << DDAxesNames::name(div_.axis()));
69  return translation;
70 }
71 
73 DDDividedTubsRho::makeDDLogicalPart( const int copyNo ) const
74 {
75  // must always make new name and new solid
76  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
77  + DDXMLElement::itostr(copyNo)
78  , div_.parent().ddname().ns());
79  DDSolid ddtubs(solname);
80  DDMaterial usemat(div_.parent().material());
81  DDTubs msol = (DDTubs) (div_.parent().solid());
82  DDLogicalPart ddlp;
83 
84  double pRMin = msol.rIn() + div_.offset() + compWidth_ * copyNo;
85  double pRMax = msol.rIn() + div_.offset() + compWidth_ * (copyNo+1);
86  double pDz = msol.zhalf();
87  double pSPhi = msol.startPhi();
88  double pDPhi = msol.deltaPhi();
89  ddtubs = DDSolidFactory::tubs(DDName(solname), pDz, pRMin, pRMax, pSPhi, pDPhi);
90  ddlp = DDLogicalPart(solname, usemat, ddtubs);
91 
92  DCOUT_V ('P', " DDDividedTubsRho::computeDimensions() lp:" << ddlp);
93  return ddlp;
94 }
95 
98 {
100  setType( "DivisionTubsPhi" );
101 
102  DDTubs msol = (DDTubs)(div_.parent().solid());
103  if( divisionType_ == DivWIDTH )
104  {
105  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
106  if( msol.deltaPhi() == 360.*deg ) {
107  compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
108  }else {
110  }
111 
112  }
113  else if( divisionType_ == DivNDIV )
114  {
115  if( msol.deltaPhi() == 360.*deg ) {
116  compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
117  }else {
119  }
120  }
121 }
122 
124 {}
125 
126 double
128 {
129  DDTubs msol = (DDTubs)(div_.parent().solid());
130  return msol.deltaPhi();
131 }
132 
134 DDDividedTubsPhi::makeDDRotation( const int copyNo ) const
135 {
136  DDRotation myddrot; // sets to identity.
137  double posi = ( copyNo - 1 ) * compWidth_; // This should put the first one at the 0 of the parent.
138  DDRotationMatrix * rotMat = changeRotMatrix( posi );
139  // how to name the rotation??
140  // i hate this crap :-)
141  DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT"
142  + DDXMLElement::itostr(copyNo)
143  , div_.parent().ddname().ns());
144  myddrot = DDrot(ddrotname, rotMat);
145 
146  return myddrot;
147 }
148 
150 DDDividedTubsPhi::makeDDTranslation( const int copyNo ) const
151 {
152  //----- translation
153  DDTranslation translation;
154 
155  DCOUT_V ('P', " DDDividedTubsPhi " << "\n\t Position: " << translation << " - Width: " << compWidth_ << " - Axis " << DDAxesNames::name(div_.axis()));
156  return translation;
157 }
158 
160 DDDividedTubsPhi::makeDDLogicalPart( const int copyNo ) const
161 {
162  DDName solname(div_.name());
163  //- DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
164  DDSolid ddtubs(solname);
165  DDMaterial usemat(div_.parent().material());
166  DDTubs msol = (DDTubs) (div_.parent().solid());
167  DDLogicalPart ddlp(solname);
168 
169  if (!ddtubs.isDefined().second) // only if it is not defined, make new dimensions and solid.
170  {
171  double pRMin = msol.rIn();
172  double pRMax = msol.rOut();
173  double pDz = msol.zhalf();
174  double pSPhi = msol.startPhi()+div_.offset();
175  double pDPhi = compWidth_;
176  ddtubs = DDSolidFactory::tubs(DDName(solname), pDz, pRMin, pRMax, pSPhi, pDPhi);
177  ddlp = DDLogicalPart(solname, usemat, ddtubs);
178  }
179 
180  DCOUT_V ('P', " DDDividedTubsPhi::computeDimensions() lp:" << ddlp);
181  return ddlp;
182 }
183 
186 {
188 
189  DDTubs msol = (DDTubs)(div_.parent().solid());
190 
191  setType( "DivisionTubsZ" );
192  if( divisionType_ == DivWIDTH )
193  {
194  compNDiv_ = calculateNDiv( 2*msol.zhalf(), div_.width(), div_.offset() );
195  }
196  else if( divisionType_ == DivNDIV )
197  {
199  }
200 
201  DCOUT_V ('P', " DDDividedTubsZ - no divisions " << compNDiv_ << " = " << div_.nReplicas() << "\n Offset " << div_.offset() << "\n Width " << compWidth_ << " = " << div_.width() << "\n DivType " << divisionType_);
202 
203 }
204 
206 {}
207 
208 double
210 {
211  DDTubs msol = (DDTubs)(div_.parent().solid());
212  return 2*msol.zhalf();
213 
214 }
215 
217 DDDividedTubsZ::makeDDRotation( const int copyNo ) const
218 {
219  DDRotation myddrot; // sets to identity.
220  DCOUT_V ('P', "DDDividedTubsZ::makeDDRotation made a rotation: " << myddrot);
221  return myddrot;
222 }
223 
225 DDDividedTubsZ::makeDDTranslation( const int copyNo ) const
226 {
227  //----- translation
228  DDTranslation translation;
229 
230  DDTubs msol = (DDTubs)(div_.parent().solid());
231  double posi = - msol.zhalf() + div_.offset() + compWidth_/2 + copyNo*compWidth_;
232  translation.SetZ(posi);
233 
234  DCOUT_V ('P', " DDDividedTubsZ " << "\n\t Position: " << translation << " - Width: " << compWidth_ << " - Axis " << DDAxesNames::name(div_.axis()));
235  return translation;
236 }
237 
239 DDDividedTubsZ::makeDDLogicalPart( const int copyNo ) const
240 {
241  DDMaterial usemat(div_.parent().material());
242  DDTubs msol = (DDTubs) (div_.parent().solid());
243  DDLogicalPart ddlp;
244 
245  DDName solname(div_.parent().ddname().name() + "_DIVCHILD", div_.parent().ddname().ns());
246  DDSolid ddtubs(solname);
247 
248  if (!ddtubs.isDefined().second) // only if it is not defined, make new dimensions and solid.
249  {
250  double pRMin = msol.rIn();
251  double pRMax = msol.rOut();
252  double pDz = compWidth_/2.;
253  double pSPhi = msol.startPhi();
254  double pDPhi = msol.deltaPhi();
255  ddtubs = DDSolidFactory::tubs(DDName(solname), pDz, pRMin, pRMax, pSPhi, pDPhi);
256  ddlp = DDLogicalPart(solname, usemat, ddtubs);
257  }
258  else {
259  ddlp = DDLogicalPart(solname);
260  }
261 
262  DCOUT_V ('P', " DDDividedTubsZ::computeDimensions() lp:" << ddlp);
263  return ddlp;
264 }
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
virtual ~DDDividedTubsZ()
const N & name() const
Definition: DDBase.h:82
virtual ~DDDividedTubsPhi()
virtual ~DDDividedTubsRho()
static std::string itostr(int i)
WARNING: abused by other classes in this system: yet another conversion from int to std::string...
int nReplicas() const
Definition: DDDivision.cc:90
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
double offset() const
Definition: DDDivision.cc:100
virtual DDTranslation makeDDTranslation(const int copyNo) const
int calculateNDiv(double motherDim, double width, double offset) const
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
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:77
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
virtual void checkParametersValidity(void)
virtual DDRotation makeDDRotation(const int copyNo) const
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:66
virtual DDTranslation makeDDTranslation(const int copyNo) const
virtual double getMaxParameter() const
virtual double getMaxParameter() const
DDDividedTubsZ(const DDDivision &div, DDCompactView *cpv)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
virtual DDRotation makeDDRotation(const int copyNo) const
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:788
virtual void setType(const std::string &type)
double rOut(void) const
Definition: DDSolid.cc:509
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:93
virtual double getMaxParameter() const
double deltaPhi(void) const
Definition: DDSolid.cc:513
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
double zhalf(void) const
Definition: DDSolid.cc:505
DDAxes axis() const
Definition: DDDivision.cc:85
double width() const
Definition: DDDivision.cc:95
virtual DDRotation makeDDRotation(const int copyNo) const
const DDLogicalPart & parent() const
Definition: DDDivision.cc:105
static const std::string name(const DDAxes &s)
Definition: DDAxes.cc:37
double rIn(void) const
Definition: DDSolid.cc:507
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
virtual DDTranslation makeDDTranslation(const int copyNo) const
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.
const N & ddname() const
Definition: DDBase.h:84
DDRotationMatrix * changeRotMatrix(double rotZ=0.) const