CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDDividedCons.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // 25.04.04 - M. Case ddd-ize G4ParameterisationCons*
4 // ********************************************************************
5 
8 
14 
17 
18 #include "CLHEP/Units/GlobalSystemOfUnits.h"
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  DCOUT_V( 'P', " DDDividedConsRho - no divisions " << compNDiv_ << " = " << div_.nReplicas()
49  << "\n Offset " << div_.offset()
50  << "\n Width " << compWidth_ << " = " << div_.width()
51  << "\n DivType " << divisionType_);
52 }
53 
55 {}
56 
57 double
59 {
60  DDCons msol = (DDCons)(div_.parent().solid());
61  return msol.rOutMinusZ() - msol.rInMinusZ();
62 
63 }
64 
66 DDDividedConsRho::makeDDRotation( const int copyNo ) const
67 {
68  DDRotation myddrot; // sets to identity.
69  DCOUT_V ('P', "DDDividedConsRho::makeDDRotation : " << myddrot);
70  return myddrot;
71 }
72 
74 DDDividedConsRho::makeDDTranslation( const int copyNo ) const
75 {
76  //----- translation
77  DDTranslation translation;
78  DCOUT_V ('P', " DDDividedConsRho " << "\n\t Position: " << translation << " - Width: " << compWidth_ << " - Axis " << DDAxesNames::name(div_.axis()));
79  return translation;
80 }
81 
83 DDDividedConsRho::makeDDLogicalPart( const int copyNo ) const
84 {
85  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
86  + DDXMLElement::itostr(copyNo)
87  , div_.parent().ddname().ns());
88  DDSolid ddcons(solname);
89  DDMaterial usemat(div_.parent().material());
90  DDCons msol = (DDCons)(div_.parent().solid());
91 
92  double pRMin1 = msol.rInMinusZ() + div_.offset() + compWidth_ * copyNo;
93  double pRMax1 = msol.rInMinusZ() + div_.offset() + compWidth_ * (copyNo+1);
94 
95  //width at Z Plus
96  //- double compWidth_Plus =
97  // compWidth_ * ( msol.rOutPlusZ()/ msol.rInPlusZ())
98  //- / ( msol.rOutMinusZ() - msol.rInMinusZ());
99  double compWidth_Plus = calculateWidth( msol.rOutPlusZ()
100  - msol.rInPlusZ(), compNDiv_, div_.offset() );
101  double pRMin2 = msol.rInPlusZ()
102  + div_.offset() + compWidth_Plus * copyNo;
103  double pRMax2 = msol.rInPlusZ()
104  + div_.offset() + compWidth_Plus * (copyNo+1);
105  double pDz = msol.zhalf();
106 
107  double pSPhi = msol.phiFrom();
108  double pDPhi = msol.deltaPhi();
109 
110  ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1
111  , pRMin2, pRMax2, pSPhi, pDPhi);
112 
113  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
114  DCOUT_V( 'P', " DDDividedConsRho::makeDDLogicalPart() lp:" << ddlp );
115  return ddlp;
116 }
117 
118 //--------------------------------------------------------------------------
119 //--------------------------------------------------------------------------
122 {
124  setType( "DivisionConsPhi" );
125  DDCons msol = (DDCons)(div_.parent().solid());
126 
127  if( divisionType_ == DivWIDTH )
128  {
129  DDCons msol = (DDCons)(div_.parent().solid());
130  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
131  if( msol.deltaPhi() == 360.*deg )
132  {
133  compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
134  }
135  else
136  {
138  }
139  }
140  else if( divisionType_ == DivNDIV )
141  {
142  DDCons msol = (DDCons)(div_.parent().solid());
143  if( msol.deltaPhi() == 360.*deg )
144  {
145  compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
146  }
147  else
148  {
150  }
151  }
152 
153  DCOUT_V( 'P', " DDDividedConsPhi - no divisions " << compNDiv_ << " = " << div_.nReplicas()
154  << "\n Offset " << div_.offset()
155  << "\n Width " << compWidth_ << " = " << div_.width()
156  << "\n DivType " << divisionType_);
157 }
158 
160 {}
161 
162 double
164 {
165  DDCons msol = (DDCons)(div_.parent().solid());
166  return msol.deltaPhi();
167 }
168 
170 DDDividedConsPhi::makeDDRotation( const int copyNo ) const
171 {
172  DDRotation myddrot; // sets to identity.
173  double posi = ( copyNo - 1 ) * compWidth_;
174  DDRotationMatrix* rotMat = changeRotMatrix( posi );
175  // how to name the rotation??
176  // i hate this crap :-)
177  DDName ddrotname(div_.parent().ddname().name() + "_DIVCHILD_ROT" + DDXMLElement::itostr(copyNo)
178  , div_.parent().ddname().ns());
179  myddrot = DDrot(ddrotname, rotMat);
180 
181  DCOUT_V ('P', "DDDividedConsPhi::makeDDRotation : " << myddrot);
182  return myddrot;
183 }
184 
186 DDDividedConsPhi::makeDDTranslation( const int copyNo ) const
187 {
188  //----- translation
189  DDTranslation translation;
190  DCOUT_V( 'P', " DDDividedConsPhi " << "\n\t Position: " << translation
191  << " - Width: " << compWidth_
192  << " - Axis " << DDAxesNames::name(div_.axis()));
193  return translation;
194 }
195 
197 DDDividedConsPhi::makeDDLogicalPart( const int copyNo ) const
198 {
199  DDName solname(div_.parent().ddname().name() + "_DIVCHILD"
200  , div_.parent().ddname().ns());
201  DDSolid ddcons(solname);
202  DDMaterial usemat(div_.parent().material());
203  DDCons msol = (DDCons)(div_.parent().solid());
204 
205  if (!ddcons.isDefined().second)
206  {
207  double pRMin1 = msol.rInMinusZ();
208  double pRMax1 = msol.rOutMinusZ();
209  double pRMin2 = msol.rInPlusZ();
210  double pRMax2 = msol.rOutPlusZ();
211  double pDz = msol.zhalf();
212 
213  //- already rotated double pSPhi = div_.offset() + copyNo*compWidth_;
214  double pSPhi = div_.offset() + msol.phiFrom();
215  double pDPhi = compWidth_;
216  ddcons = DDSolidFactory::cons(DDName(solname), pDz, pRMin1, pRMax1
217  , pRMin2, pRMax2, pSPhi, pDPhi);
218  }
219 
220  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
221  DCOUT_V ('P', " DDDividedConsPhi::makeDDLogicalPart() lp:" << ddlp);
222  return ddlp;
223 }
224 
227 {
229 
230  DDCons msol = (DDCons)(div_.parent().solid());
231  setType( "DivisionConsZ" );
232 
233  if( divisionType_ == DivWIDTH )
234  {
235  DDCons msol = (DDCons)(div_.parent().solid());
236  compNDiv_ = calculateNDiv( 2*msol.zhalf()
237  , div_.width(), div_.offset() );
238  }
239  else if( divisionType_ == DivNDIV )
240  {
241  DDCons msol = (DDCons)(div_.parent().solid());
242  compWidth_ = calculateWidth( 2*msol.zhalf()
243  , div_.nReplicas(), div_.offset() );
244  }
245 
246  DCOUT_V( 'P', " DDDividedConsZ - no divisions " << compNDiv_ << " = " << div_.nReplicas()
247  << "\n Offset " << div_.offset()
248  << "\n Width " << compWidth_ << " = " << div_.width()
249  << "\n DivType " << divisionType_ );
250 }
251 
253 {}
254 
255 double
257 {
258  DDCons msol = (DDCons)(div_.parent().solid());
259  return 2*msol.zhalf();
260 }
261 
263 DDDividedConsZ::makeDDRotation( const int copyNo ) const
264 {
265  DDRotation myddrot; // sets to identity.
266  DCOUT_V ('P', "DDDividedConsZ::makeDDRotation : " << myddrot);
267  return myddrot;
268 }
269 
271 DDDividedConsZ::makeDDTranslation( const int copyNo ) const
272 {
273  //----- translation
274  DDTranslation translation;
275 
276  DDCons motherCons = (DDCons)(div_.parent().solid());
277  double posi = - motherCons.zhalf() + div_.offset()
278  + compWidth_/2 + copyNo*compWidth_;
279  translation.SetZ(posi);
280 
281  DCOUT_V ('P', " DDDividedConsZ " << "\n\t Position: " << translation << " - Width: " << compWidth_ << " - Axis " << DDAxesNames::name(div_.axis()));
282  return translation;
283 }
284 
286 DDDividedConsZ::makeDDLogicalPart( const int copyNo ) const
287 {
288  DDName solname(div_.parent().ddname().name() + "_DIVCHILD" + DDXMLElement::itostr(copyNo)
289  , div_.parent().ddname().ns());
290  DDSolid ddcons(solname);
291  DDMaterial usemat(div_.parent().material());
292  DDCons msol = (DDCons)(div_.parent().solid());
293 
294  double mHalfLength = msol.zhalf();
295  double aRInner = (msol.rInPlusZ()
296  - msol.rInMinusZ()) / (2*mHalfLength);
297  double bRInner = (msol.rInPlusZ()
298  + msol.rInMinusZ()) / 2;
299  double aROuter = (msol.rOutPlusZ()
300  - msol.rOutMinusZ()) / (2*mHalfLength);
301  double bROuter = (msol.rOutPlusZ()
302  + msol.rOutMinusZ()) / 2;
303  double xMinusZ = -mHalfLength + div_.offset() + compWidth_*copyNo;
304  double xPlusZ = -mHalfLength + div_.offset() + compWidth_*(copyNo+1);
305 
306  double pDz = compWidth_ / 2.;
307  double pSPhi = msol.phiFrom();
308  double pDPhi = msol.deltaPhi();
309 
310  ddcons = DDSolidFactory::cons(DDName(solname)
311  , pDz
312  , aRInner * xMinusZ + bRInner
313  , aROuter * xMinusZ + bROuter
314  , aRInner * xPlusZ + bRInner
315  , aROuter * xPlusZ + bROuter
316  , pSPhi
317  , pDPhi
318  );
319 
320  DDLogicalPart ddlp = DDLogicalPart(solname, usemat, ddcons);
321  DCOUT_V( 'P', " DDDividedConsZ::makeDDLogicalPart() lp:" << ddlp );
322  return ddlp;
323 }
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
double zhalf(void) const
Definition: DDSolid.cc:458
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:71
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
virtual double getMaxParameter() const
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:763
virtual ~DDDividedConsPhi()
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:14
double rOutMinusZ(void) const
Definition: DDSolid.cc:462
double calculateWidth(double motherDim, int nDiv, double offset) const
virtual DDTranslation makeDDTranslation(const int copyNo) const
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
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 ~DDDividedConsRho()
virtual DDTranslation makeDDTranslation(const int copyNo) const
DDDividedConsRho(const DDDivision &div, DDCompactView *cpv)
virtual double getMaxParameter() const
virtual ~DDDividedConsZ()
double rInMinusZ(void) const
Definition: DDSolid.cc:460
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)
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
virtual DDRotation makeDDRotation(const int copyNo) const
double deltaPhi(void) const
Definition: DDSolid.cc:470
DDDividedConsPhi(const DDDivision &div, DDCompactView *cpv)
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
virtual DDRotation makeDDRotation(const int copyNo) const
DDAxes axis() const
Definition: DDDivision.cc:66
double width() const
Definition: DDDivision.cc:76
virtual DDTranslation makeDDTranslation(const int copyNo) const
virtual DDRotation makeDDRotation(const int copyNo) const
double rInPlusZ(void) const
Definition: DDSolid.cc:464
tuple cout
Definition: gather_cfg.py:145
const DDLogicalPart & parent() const
Definition: DDDivision.cc:86
virtual double getMaxParameter() const
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
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:80
DDRotationMatrix * changeRotMatrix(double rotZ=0.) const