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 
15 
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
20 {
22  DDPolycone msol = (DDPolycone)(div_.parent().solid());
23  std::vector<double> localrMaxVec = msol.rMaxVec();
24  std::vector<double> localrMinVec = msol.rMinVec();
25 
26  setType( "DivisionPolyconeRho" );
27 
28  // in DDD we only have ONE representation
29  // in the case when rMinVec and rMaxVec
30  // are empty rVec and zVec are the r and z std::vectors.
31 
32  if( divisionType_ == DivWIDTH )
33  {
34  compNDiv_ = calculateNDiv( localrMaxVec[0] - localrMinVec[0], div_.width(), div_.offset());
35  }
36  else if( divisionType_ == DivNDIV )
37  {
38  compWidth_ = calculateWidth( localrMaxVec[0] - localrMinVec[0], div_.nReplicas(), div_.offset());
39  }
40 
41  DCOUT_V( 'P', " DDDividedPolyconeRho - # divisions " << compNDiv_ << " = " << div_.nReplicas() << "/n Offset " << div_.offset() << " Width " << compWidth_ << " = " << div_.width() << "\n" );
42 }
43 
45 {}
46 
47 void
49 {
51 
52  DDPolycone msol = (DDPolycone)(div_.parent().solid());
53 
55  {
56  std::cout << "WARNING - "
57  << "DDDividedPolyconeRho::checkParametersValidity()"
58  << std::endl
59  << " Solid " << msol << std::endl
60  << " Division along r will be done with a width "
61  << "different for each solid section." << std::endl
62  << " WIDTH will not be used !" << std::endl;
63  }
64  if( div_.offset() != 0. )
65  {
66  std::cout << "WARNING - "
67  << "DDDividedPolyconeRho::checkParametersValidity()"
68  << std::endl
69  << " Solid " << msol << std::endl
70  << " Division along R will be done with a width "
71  << "different for each solid section." << std::endl
72  << " OFFSET will not be used !" << std::endl;
73  }
74 }
75 
76 double
78 {
79  DDPolycone msol = (DDPolycone)(div_.parent().solid());
80  std::vector<double> localrMaxVec = msol.rMaxVec();
81  std::vector<double> localrMinVec = msol.rMinVec();
82 
83  return localrMaxVec[0] - localrMinVec[0];
84 }
85 
87 DDDividedPolyconeRho::makeDDRotation( const int copyNo ) const
88 {
89  DDRotation myddrot; // sets to identity.
90  DCOUT_V ('P', "DDDividedPolyconeRho::makeDDRotation : " << myddrot);
91  return myddrot;
92 }
93 
95 DDDividedPolyconeRho::makeDDTranslation( const int copyNo ) const
96 {
97  DDTranslation translation;
98  return translation;
99 }
100 
103 {
104  DDName solname;
105  DDSolid ddpolycone;
106  DDMaterial usemat(div_.parent().material());
107 
108  DDPolycone msol = (DDPolycone)(div_.parent().solid());
109  std::vector<double> localrMaxVec = msol.rMaxVec();
110  std::vector<double> localrMinVec = msol.rMinVec();
111  std::vector<double> localzVec = msol.zVec();
112 
113  int nZplanes = localzVec.size();
114 
115  std::vector<double> newrMinVec;
116  std::vector<double> newrMaxVec;
117 
118  double width = 0.;
119  for(int ii = 0; ii < nZplanes; ++ii)
120  {
121  width = calculateWidth( localrMaxVec[ii]
122  - localrMinVec[ii], compNDiv_, div_.offset() );
123  // hmmm different width every time... probably should use width
124  // not compWidth_
125  // newrMinVec[ii] = localrMinVec[ii]+div_.offset()+compWidth_*copyNo;
126  // newrMaxVec[ii] = localrMinVec[ii]+div_.offset()+compWidth_*(copyNo+1);
127  newrMinVec.push_back(localrMinVec[ii]+div_.offset()+width*copyNo);
128  newrMaxVec.push_back(localrMinVec[ii]+div_.offset()+width*(copyNo+1));
129  }
130  solname = DDName( div_.parent().ddname().name() + "_DIVCHILD" + DDXMLElement::itostr(copyNo),
131  div_.parent().ddname().ns());
132 
133  ddpolycone = DDSolidFactory::polycone( solname,
134  msol.startPhi(),
135  msol.deltaPhi(),
136  localzVec,
137  newrMinVec,
138  newrMaxVec );
139 
140  DDLogicalPart ddlp = DDLogicalPart( solname, usemat, ddpolycone );
141  DCOUT_V ('P', " DDDividedPolyconeRho::makeDDLogicalPart() lp:" << ddlp);
142  return ddlp;
143 }
144 
147 {
149  DDPolycone msol = (DDPolycone)(div_.parent().solid());
150  setType( "DivisionPolyconePhi" );
151  // this is the g4. what do we keep??? I think it is deltaPhi
152  // double deltaPhi = msol->GetEndPhi() - msol->GetStartPhi();
153  if( divisionType_ == DivWIDTH )
154  {
155  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
156  if( msol.deltaPhi() == 360.*deg ) {
157  compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
158  }else {
160  }
161  }
162  else if( divisionType_ == DivNDIV )
163  {
164  if( msol.deltaPhi() == 360.*deg ) {
165  compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
166  }else {
168  }
169  }
170 
171  DCOUT_V ('P', " DDDividedPolyconePhi - # divisions " << compNDiv_ << " = " << div_.nReplicas() << "/n Offset " << div_.offset() << " Width " << compWidth_ << " = " << div_.width() << "\n");
172 }
173 
175 {}
176 
177 void
179 {
181 }
182 
183 double
185 {
186  DDPolycone msol = (DDPolycone)(div_.parent().solid());
187  return msol.deltaPhi();
188 }
189 
191 DDDividedPolyconePhi::makeDDRotation( const int copyNo ) const
192 {
193  DDRotation myddrot; // sets to identity.
194  double posi = ( copyNo - 1 ) * compWidth_;
195  DDRotationMatrix* rotMat = changeRotMatrix( posi );
196  // how to name the rotation??
197  // i do not like this
198  DDName ddrotname( div_.parent().ddname().name() + "_DIVCHILD_ROT" + DDXMLElement::itostr( copyNo ),
199  div_.parent().ddname().ns());
200  myddrot = DDrot( ddrotname, rotMat );
201 
202  DCOUT_V( 'P', "DDDividedPolyconePhi::makeDDRotation : " << myddrot );
203  return myddrot;
204 }
205 
208 {
209  DDTranslation translation;
210  return translation;
211 }
212 
215 {
216  DDName solname;
217  DDSolid ddpolycone;
218  DDMaterial usemat(div_.parent().material());
219 
220  DDPolycone msol = (DDPolycone)(div_.parent().solid());
221  std::vector<double> localrMaxVec = msol.rMaxVec();
222  std::vector<double> localrMinVec = msol.rMinVec();
223  std::vector<double> localzVec = msol.zVec();
224 
225  solname = DDName(div_.parent().ddname().name() + "_DIVCHILD",
226  div_.parent().ddname().ns());
227  DDSolid sol( solname );
228  if( !sol.isDefined().second )
229  {
230  ddpolycone = DDSolidFactory::polycone( solname,
231  msol.startPhi()+div_.offset(),
232  compWidth_,
233  localzVec,
234  localrMinVec,
235  localrMaxVec );
236  }
237  DDLogicalPart ddlp( solname );
238  if( !ddlp.isDefined().second )
239  {
240  ddlp = DDLogicalPart( solname, usemat, ddpolycone );
241  }
242  DCOUT_V( 'P', " DDDividedPolyconePhi::makeDDLogicalPart() lp:" << ddlp );
243  return ddlp;
244 }
245 
248 {
250  DDPolycone msol = (DDPolycone)(div_.parent().solid());
251  std::vector<double> localrMaxVec = msol.rMaxVec();
252  std::vector<double> localrMinVec = msol.rMinVec();
253  std::vector<double> localzVec = msol.zVec();
254 
255  if( divisionType_ == DivWIDTH )
256  {
257  compNDiv_ =
258  calculateNDiv( localzVec[localzVec.size() - 1]
259  - localzVec[0] , div_.width(), div_.offset() );
260  }
261  else if( divisionType_ == DivNDIV )
262  {
263  compWidth_ =
264  calculateNDiv( localzVec[localzVec.size()-1]
265  - localzVec[0] , div_.nReplicas(), div_.offset() );
266  }
267 
268  DCOUT_V ('P', " DDDividedPolyconeZ - # divisions " << compNDiv_ << " = " << div_.nReplicas() << "/n Offset " << div_.offset() << " Width " << compWidth_ << " = " << div_.width() << "\n");
269 }
270 
272 {}
273 
274 void
276 {
278 
279  DDPolycone msol = (DDPolycone)(div_.parent().solid());
280  std::vector<double> localzVec = msol.zVec();
281  // CHANGE FROM G4 a polycone can be divided in Z by specifying
282  // nReplicas IF they happen to coincide with the number of
283  // z plans.
284  size_t tempNDiv = div_.nReplicas();
285  if (tempNDiv == 0)
286  tempNDiv = calculateNDiv( localzVec[localzVec.size() - 1] - localzVec[0]
287  , div_.width()
288  , div_.offset() );
289  if ((msol.zVec().size() - 1) != tempNDiv)
290  {
291  std::string s = "ERROR - DDDividedPolyconeZ::checkParametersValidity()";
292  s += "\n\tDivision along Z will be done splitting in the defined";
293  s += "\n\tz_planes, i.e, the number of division would be :";
294  s += "\n\t" + DDXMLElement::itostr( msol.zVec().size() - 1 );
295  s += "\n\tinstead of " + DDXMLElement::itostr(tempNDiv) + " !\n";
296 
297  throw cms::Exception("DDException") << s;
298  }
299 }
300 
301 double
303 {
304  DDPolycone msol = (DDPolycone)(div_.parent().solid());
305  std::vector<double> localzVec = msol.zVec();
306 
307  return (localzVec[ localzVec.size() - 1] - localzVec[0]);
308 }
309 
311 DDDividedPolyconeZ::makeDDRotation( const int copyNo ) const
312 {
313  DDRotation myddrot; // sets to identity.
314  DCOUT_V ('P', "DDDividedPolyconeZ::makeDDRotation : " << myddrot);
315  return myddrot;
316 }
317 
319 DDDividedPolyconeZ::makeDDTranslation( const int copyNo ) const
320 {
321  DDTranslation translation;
322  DDPolycone msol = (DDPolycone)(div_.parent().solid());
323  std::vector<double> localzVec = msol.zVec();
324  double posi = (localzVec[copyNo] + localzVec[copyNo+1]) / 2;
325  translation.SetZ(posi);
326  return translation;
327 }
328 
330 DDDividedPolyconeZ::makeDDLogicalPart( const int copyNo ) const
331 {
332  DDName solname;
333  DDSolid ddpolycone;
334  DDMaterial usemat(div_.parent().material());
335 
336  DDPolycone msol = (DDPolycone)(div_.parent().solid());
337  std::vector<double> localrMaxVec = msol.rMaxVec();
338  std::vector<double> localrMinVec = msol.rMinVec();
339  std::vector<double> localzVec = msol.zVec();
340 
341  solname = DDName( div_.parent().ddname().name() + "_DIVCHILD" + DDXMLElement::itostr(copyNo),
342  div_.parent().ddname().ns());
343  ddpolycone = DDSolidFactory::cons( solname,
344  compWidth_ / 2,
345  localrMinVec[copyNo],
346  localrMaxVec[copyNo],
347  localrMinVec[copyNo+1],
348  localrMaxVec[copyNo+1],
349  msol.startPhi(),
350  msol.deltaPhi());
351 
352  DDLogicalPart ddlp = DDLogicalPart( solname, usemat, ddpolycone );
353 
354  DCOUT_V( 'P', " DDDividedPolyconeZ::makeDDLogicalPart() lp:" << ddlp );
355 
356  return ddlp;
357 }
def_type isDefined() const
Definition: DDBase.h:115
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...
int nReplicas() const
Definition: DDDivision.cc:90
DDDividedPolyconeRho(const DDDivision &div, DDCompactView *cpv)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
std::vector< double > rMaxVec(void) const
Definition: DDSolid.cc:393
double offset() const
Definition: DDDivision.cc:100
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:763
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:656
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
virtual DDTranslation makeDDTranslation(const int copyNo) const
double calculateWidth(double motherDim, int nDiv, double offset) const
virtual DDRotation makeDDRotation(const int copyNo) const
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
virtual double getMaxParameter() const
int ii
Definition: cuy.py:588
virtual DDTranslation makeDDTranslation(const int copyNo) const
type of data representation of DDCompactView
Definition: DDCompactView.h:77
virtual void checkParametersValidity()
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 DDRotation makeDDRotation(const int copyNo) const
std::vector< double > rMinVec(void) const
Definition: DDSolid.cc:386
virtual void checkParametersValidity()
virtual DDRotation makeDDRotation(const int copyNo) const
double deltaPhi(void) const
Definition: DDSolid.cc:370
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
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
DDDividedPolyconeZ(const DDDivision &div, DDCompactView *cpv)
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
virtual void checkParametersValidity()
DDDividedPolyconePhi(const DDDivision &div, DDCompactView *cpv)
double width() const
Definition: DDDivision.cc:95
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
tuple cout
Definition: gather_cfg.py:121
const DDLogicalPart & parent() const
Definition: DDDivision.cc:105
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.
std::vector< double > zVec(void) const
Definition: DDSolid.cc:379
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
const N & ddname() const
Definition: DDBase.h:84
DDRotationMatrix * changeRotMatrix(double rotZ=0.) const