CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDDividedPolycone.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // 25.04.04 - M. Case ddd-ize G4ParameterisationPolycone*
4 //---------------------------------------------------------------------
7 
12 
16 
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
21 {
23  DDPolycone msol = (DDPolycone)(div_.parent().solid());
24  std::vector<double> localrMaxVec = msol.rMaxVec();
25  std::vector<double> localrMinVec = msol.rMinVec();
26 
27  setType( "DivisionPolyconeRho" );
28 
29  // in DDD we only have ONE representation
30  // in the case when rMinVec and rMaxVec
31  // are empty rVec and zVec are the r and z std::vectors.
32 
33  if( divisionType_ == DivWIDTH )
34  {
35  compNDiv_ = calculateNDiv( localrMaxVec[0] - localrMinVec[0], div_.width(), div_.offset());
36  }
37  else if( divisionType_ == DivNDIV )
38  {
39  compWidth_ = calculateWidth( localrMaxVec[0] - localrMinVec[0], div_.nReplicas(), div_.offset());
40  }
41 
42  DCOUT_V( 'P', " DDDividedPolyconeRho - # divisions " << compNDiv_ << " = " << div_.nReplicas() << "/n Offset " << div_.offset() << " Width " << compWidth_ << " = " << div_.width() << "\n" );
43 }
44 
46 {}
47 
48 void
50 {
52 
53  DDPolycone msol = (DDPolycone)(div_.parent().solid());
54 
56  {
57  std::cout << "WARNING - "
58  << "DDDividedPolyconeRho::checkParametersValidity()"
59  << std::endl
60  << " Solid " << msol << std::endl
61  << " Division along r will be done with a width "
62  << "different for each solid section." << std::endl
63  << " WIDTH will not be used !" << std::endl;
64  }
65  if( div_.offset() != 0. )
66  {
67  std::cout << "WARNING - "
68  << "DDDividedPolyconeRho::checkParametersValidity()"
69  << std::endl
70  << " Solid " << msol << std::endl
71  << " Division along R will be done with a width "
72  << "different for each solid section." << std::endl
73  << " OFFSET will not be used !" << std::endl;
74  }
75 }
76 
77 double
79 {
80  DDPolycone msol = (DDPolycone)(div_.parent().solid());
81  std::vector<double> localrMaxVec = msol.rMaxVec();
82  std::vector<double> localrMinVec = msol.rMinVec();
83 
84  return localrMaxVec[0] - localrMinVec[0];
85 }
86 
88 DDDividedPolyconeRho::makeDDRotation( const int copyNo ) const
89 {
90  DDRotation myddrot; // sets to identity.
91  DCOUT_V ('P', "DDDividedPolyconeRho::makeDDRotation : " << myddrot);
92  return myddrot;
93 }
94 
96 DDDividedPolyconeRho::makeDDTranslation( const int copyNo ) const
97 {
98  DDTranslation translation;
99  return translation;
100 }
101 
104 {
105  DDName solname;
106  DDSolid ddpolycone;
107  DDMaterial usemat(div_.parent().material());
108 
109  DDPolycone msol = (DDPolycone)(div_.parent().solid());
110  std::vector<double> localrMaxVec = msol.rMaxVec();
111  std::vector<double> localrMinVec = msol.rMinVec();
112  std::vector<double> localzVec = msol.zVec();
113 
114  int nZplanes = localzVec.size();
115 
116  std::vector<double> newrMinVec;
117  std::vector<double> newrMaxVec;
118 
119  double width = 0.;
120  for(int ii = 0; ii < nZplanes; ++ii)
121  {
122  width = calculateWidth( localrMaxVec[ii]
123  - localrMinVec[ii], compNDiv_, div_.offset() );
124  // hmmm different width every time... probably should use width
125  // not compWidth_
126  // newrMinVec[ii] = localrMinVec[ii]+div_.offset()+compWidth_*copyNo;
127  // newrMaxVec[ii] = localrMinVec[ii]+div_.offset()+compWidth_*(copyNo+1);
128  newrMinVec.push_back(localrMinVec[ii]+div_.offset()+width*copyNo);
129  newrMaxVec.push_back(localrMinVec[ii]+div_.offset()+width*(copyNo+1));
130  }
131  solname = DDName( div_.parent().ddname().name() + "_DIVCHILD" + DDXMLElement::itostr(copyNo),
132  div_.parent().ddname().ns());
133 
134  ddpolycone = DDSolidFactory::polycone( solname,
135  msol.startPhi(),
136  msol.deltaPhi(),
137  localzVec,
138  newrMinVec,
139  newrMaxVec );
140 
141  DDLogicalPart ddlp = DDLogicalPart( solname, usemat, ddpolycone );
142  DCOUT_V ('P', " DDDividedPolyconeRho::makeDDLogicalPart() lp:" << ddlp);
143  return ddlp;
144 }
145 
148 {
150  DDPolycone msol = (DDPolycone)(div_.parent().solid());
151  setType( "DivisionPolyconePhi" );
152  // this is the g4. what do we keep??? I think it is deltaPhi
153  // double deltaPhi = msol->GetEndPhi() - msol->GetStartPhi();
154  if( divisionType_ == DivWIDTH )
155  {
156  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
157  if( msol.deltaPhi() == 360.*deg ) {
158  compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
159  }else {
161  }
162  }
163  else if( divisionType_ == DivNDIV )
164  {
165  if( msol.deltaPhi() == 360.*deg ) {
166  compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
167  }else {
169  }
170  }
171 
172  DCOUT_V ('P', " DDDividedPolyconePhi - # divisions " << compNDiv_ << " = " << div_.nReplicas() << "/n Offset " << div_.offset() << " Width " << compWidth_ << " = " << div_.width() << "\n");
173 }
174 
176 {}
177 
178 void
180 {
182 }
183 
184 double
186 {
187  DDPolycone msol = (DDPolycone)(div_.parent().solid());
188  return msol.deltaPhi();
189 }
190 
192 DDDividedPolyconePhi::makeDDRotation( const int copyNo ) const
193 {
194  DDRotation myddrot; // sets to identity.
195  double posi = ( copyNo - 1 ) * compWidth_;
196  DDRotationMatrix* rotMat = changeRotMatrix( posi );
197  // how to name the rotation??
198  // i do not like this
199  DDName ddrotname( div_.parent().ddname().name() + "_DIVCHILD_ROT" + DDXMLElement::itostr( copyNo ),
200  div_.parent().ddname().ns());
201  myddrot = DDrot( ddrotname, rotMat );
202 
203  DCOUT_V( 'P', "DDDividedPolyconePhi::makeDDRotation : " << myddrot );
204  return myddrot;
205 }
206 
209 {
210  DDTranslation translation;
211  return translation;
212 }
213 
216 {
217  DDName solname;
218  DDSolid ddpolycone;
219  DDMaterial usemat(div_.parent().material());
220 
221  DDPolycone msol = (DDPolycone)(div_.parent().solid());
222  std::vector<double> localrMaxVec = msol.rMaxVec();
223  std::vector<double> localrMinVec = msol.rMinVec();
224  std::vector<double> localzVec = msol.zVec();
225 
226  solname = DDName(div_.parent().ddname().name() + "_DIVCHILD",
227  div_.parent().ddname().ns());
228  DDSolid sol( solname );
229  if( !sol.isDefined().second )
230  {
231  ddpolycone = DDSolidFactory::polycone( solname,
232  msol.startPhi()+div_.offset(),
233  compWidth_,
234  localzVec,
235  localrMinVec,
236  localrMaxVec );
237  }
238  DDLogicalPart ddlp( solname );
239  if( !ddlp.isDefined().second )
240  {
241  ddlp = DDLogicalPart( solname, usemat, ddpolycone );
242  }
243  DCOUT_V( 'P', " DDDividedPolyconePhi::makeDDLogicalPart() lp:" << ddlp );
244  return ddlp;
245 }
246 
249 {
251  DDPolycone msol = (DDPolycone)(div_.parent().solid());
252  std::vector<double> localrMaxVec = msol.rMaxVec();
253  std::vector<double> localrMinVec = msol.rMinVec();
254  std::vector<double> localzVec = msol.zVec();
255 
256  if( divisionType_ == DivWIDTH )
257  {
258  compNDiv_ =
259  calculateNDiv( localzVec[localzVec.size() - 1]
260  - localzVec[0] , div_.width(), div_.offset() );
261  }
262  else if( divisionType_ == DivNDIV )
263  {
264  compWidth_ =
265  calculateNDiv( localzVec[localzVec.size()-1]
266  - localzVec[0] , div_.nReplicas(), div_.offset() );
267  }
268 
269  DCOUT_V ('P', " DDDividedPolyconeZ - # divisions " << compNDiv_ << " = " << div_.nReplicas() << "/n Offset " << div_.offset() << " Width " << compWidth_ << " = " << div_.width() << "\n");
270 }
271 
273 {}
274 
275 void
277 {
279 
280  DDPolycone msol = (DDPolycone)(div_.parent().solid());
281  std::vector<double> localzVec = msol.zVec();
282  // CHANGE FROM G4 a polycone can be divided in Z by specifying
283  // nReplicas IF they happen to coincide with the number of
284  // z plans.
285  size_t tempNDiv = div_.nReplicas();
286  if (tempNDiv == 0)
287  tempNDiv = calculateNDiv( localzVec[localzVec.size() - 1] - localzVec[0]
288  , div_.width()
289  , div_.offset() );
290  if ((msol.zVec().size() - 1) != tempNDiv)
291  {
292  std::string s = "ERROR - DDDividedPolyconeZ::checkParametersValidity()";
293  s += "\n\tDivision along Z will be done splitting in the defined";
294  s += "\n\tz_planes, i.e, the number of division would be :";
295  s += "\n\t" + DDXMLElement::itostr( msol.zVec().size() - 1 );
296  s += "\n\tinstead of " + DDXMLElement::itostr(tempNDiv) + " !\n";
297 
298  throw DDException(s);
299  }
300 }
301 
302 double
304 {
305  DDPolycone msol = (DDPolycone)(div_.parent().solid());
306  std::vector<double> localzVec = msol.zVec();
307 
308  return (localzVec[ localzVec.size() - 1] - localzVec[0]);
309 }
310 
312 DDDividedPolyconeZ::makeDDRotation( const int copyNo ) const
313 {
314  DDRotation myddrot; // sets to identity.
315  DCOUT_V ('P', "DDDividedPolyconeZ::makeDDRotation : " << myddrot);
316  return myddrot;
317 }
318 
320 DDDividedPolyconeZ::makeDDTranslation( const int copyNo ) const
321 {
322  DDTranslation translation;
323  DDPolycone msol = (DDPolycone)(div_.parent().solid());
324  std::vector<double> localzVec = msol.zVec();
325  double posi = (localzVec[copyNo] + localzVec[copyNo+1]) / 2;
326  translation.SetZ(posi);
327  return translation;
328 }
329 
331 DDDividedPolyconeZ::makeDDLogicalPart( const int copyNo ) const
332 {
333  DDName solname;
334  DDSolid ddpolycone;
335  DDMaterial usemat(div_.parent().material());
336 
337  DDPolycone msol = (DDPolycone)(div_.parent().solid());
338  std::vector<double> localrMaxVec = msol.rMaxVec();
339  std::vector<double> localrMinVec = msol.rMinVec();
340  std::vector<double> localzVec = msol.zVec();
341 
342  solname = DDName( div_.parent().ddname().name() + "_DIVCHILD" + DDXMLElement::itostr(copyNo),
343  div_.parent().ddname().ns());
344  ddpolycone = DDSolidFactory::cons( solname,
345  compWidth_ / 2,
346  localrMinVec[copyNo],
347  localrMaxVec[copyNo],
348  localrMinVec[copyNo+1],
349  localrMaxVec[copyNo+1],
350  msol.startPhi(),
351  msol.deltaPhi());
352 
353  DDLogicalPart ddlp = DDLogicalPart( solname, usemat, ddpolycone );
354 
355  DCOUT_V( 'P', " DDDividedPolyconeZ::makeDDLogicalPart() lp:" << ddlp );
356 
357  return ddlp;
358 }
def_type isDefined() const
Definition: DDBase.h:121
const int nReplicas() const
Definition: DDDivision.cc:90
virtual DDTranslation makeDDTranslation(const int copyNo) const
static std::string itostr(int i)
WARNING: abused by other classes in this system: yet another conversion from int to std::string...
DDDividedPolyconeRho(const DDDivision &div, DDCompactView *cpv)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
static DDSolid cons(const DDName &name, double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double phiFrom, double deltaPhi)
Definition: DDSolid.cc:766
virtual double getMaxParameter() const
static DDSolid polycone(const DDName &name, double startPhi, double deltaPhi, const std::vector< double > &z, const std::vector< double > &rmin, const std::vector< double > &rmax)
Creates a polycone (refere to Geant3 or Geant4 documentation)
Definition: DDSolid.cc:659
int calculateNDiv(double motherDim, double width, double offset) const
An exception for DDD errors.
Definition: DDException.h:23
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:101
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
virtual DDTranslation makeDDTranslation(const int copyNo) const
double calculateWidth(double motherDim, int nDiv, double offset) const
virtual DDRotation makeDDRotation(const int copyNo) const
virtual double getMaxParameter() const
virtual DDTranslation makeDDTranslation(const int copyNo) const
type of data representation of DDCompactView
Definition: DDCompactView.h:81
virtual void checkParametersValidity()
const DDMaterial & material() const
Returns a reference object of the material this LogicalPart is made of.
A DDSolid represents the shape of a part.
Definition: DDSolid.h:42
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 DDRotation makeDDRotation(const int copyNo) const
virtual void checkParametersValidity()
virtual DDRotation makeDDRotation(const int copyNo) const
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:95
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:94
DDDividedPolyconeZ(const DDDivision &div, DDCompactView *cpv)
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
std::vector< double > zVec() const
Definition: DDSolid.cc:382
const double width() const
Definition: DDDivision.cc:95
virtual void checkParametersValidity()
DDDividedPolyconePhi(const DDDivision &div, DDCompactView *cpv)
double deltaPhi() const
Definition: DDSolid.cc:373
std::vector< double > rMinVec() const
Definition: DDSolid.cc:389
const DDSolid & solid() const
Returns a reference object of the solid being the shape of this LogicalPart.
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
const double offset() const
Definition: DDDivision.cc:100
tuple cout
Definition: gather_cfg.py:41
const DDLogicalPart & parent() const
Definition: DDDivision.cc:105
virtual double getMaxParameter() const
string s
Definition: asciidump.py:422
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
std::vector< double > rMaxVec() const
Definition: DDSolid.cc:396
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
const N & ddname() const
Definition: DDBase.h:90
DDRotationMatrix * changeRotMatrix(double rotZ=0.) const