CMS 3D CMS Logo

DDDividedPolycone.cc
Go to the documentation of this file.
2 #include "CLHEP/Units/GlobalSystemOfUnits.h"
3 #include "CLHEP/Units/SystemOfUnits.h"
13 
14 #include <cstddef>
15 #include <iostream>
16 #include <string>
17 #include <utility>
18 #include <vector>
19 
20 class DDCompactView;
21 
24 {
26  DDPolycone msol = (DDPolycone)(div_.parent().solid());
27  std::vector<double> localrMaxVec = msol.rMaxVec();
28  std::vector<double> localrMinVec = msol.rMinVec();
29 
30  setType( "DivisionPolyconeRho" );
31 
32  // in DDD we only have ONE representation
33  // in the case when rMinVec and rMaxVec
34  // are empty rVec and zVec are the r and z std::vectors.
35 
36  if( divisionType_ == DivWIDTH )
37  {
38  compNDiv_ = calculateNDiv( localrMaxVec[0] - localrMinVec[0], div_.width(), div_.offset());
39  }
40  else if( divisionType_ == DivNDIV )
41  {
42  compWidth_ = calculateWidth( localrMaxVec[0] - localrMinVec[0], div_.nReplicas(), div_.offset());
43  }
44 }
45 
46 void
48 {
50 
51  DDPolycone msol = (DDPolycone)(div_.parent().solid());
52 
54  {
55  std::cout << "WARNING - "
56  << "DDDividedPolyconeRho::checkParametersValidity()"
57  << std::endl
58  << " Solid " << msol << std::endl
59  << " Division along r will be done with a width "
60  << "different for each solid section." << std::endl
61  << " WIDTH will not be used !" << std::endl;
62  }
63  if( div_.offset() != 0. )
64  {
65  std::cout << "WARNING - "
66  << "DDDividedPolyconeRho::checkParametersValidity()"
67  << std::endl
68  << " Solid " << msol << std::endl
69  << " Division along R will be done with a width "
70  << "different for each solid section." << std::endl
71  << " OFFSET will not be used !" << std::endl;
72  }
73 }
74 
75 double
77 {
78  DDPolycone msol = (DDPolycone)(div_.parent().solid());
79  std::vector<double> localrMaxVec = msol.rMaxVec();
80  std::vector<double> localrMinVec = msol.rMinVec();
81 
82  return localrMaxVec[0] - localrMinVec[0];
83 }
84 
86 DDDividedPolyconeRho::makeDDRotation( const int copyNo ) const
87 {
88  DDRotation myddrot; // sets to identity.
89  return myddrot;
90 }
91 
93 DDDividedPolyconeRho::makeDDTranslation( const int copyNo ) const
94 {
95  DDTranslation translation;
96  return translation;
97 }
98 
101 {
102  DDName solname;
103  DDSolid ddpolycone;
104  DDMaterial usemat(div_.parent().material());
105 
106  DDPolycone msol = (DDPolycone)(div_.parent().solid());
107  std::vector<double> localrMaxVec = msol.rMaxVec();
108  std::vector<double> localrMinVec = msol.rMinVec();
109  std::vector<double> localzVec = msol.zVec();
110 
111  int nZplanes = localzVec.size();
112 
113  std::vector<double> newrMinVec;
114  std::vector<double> newrMaxVec;
115 
116  double width = 0.;
117  for(int ii = 0; ii < nZplanes; ++ii)
118  {
119  width = calculateWidth( localrMaxVec[ii]
120  - localrMinVec[ii], compNDiv_, div_.offset() );
121  // hmmm different width every time... probably should use width
122  // not compWidth_
123  // newrMinVec[ii] = localrMinVec[ii]+div_.offset()+compWidth_*copyNo;
124  // newrMaxVec[ii] = localrMinVec[ii]+div_.offset()+compWidth_*(copyNo+1);
125  newrMinVec.emplace_back(localrMinVec[ii]+div_.offset()+width*copyNo);
126  newrMaxVec.emplace_back(localrMinVec[ii]+div_.offset()+width*(copyNo+1));
127  }
128  solname = DDName( div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo),
129  div_.parent().ddname().ns());
130 
131  ddpolycone = DDSolidFactory::polycone( solname,
132  msol.startPhi(),
133  msol.deltaPhi(),
134  localzVec,
135  newrMinVec,
136  newrMaxVec );
137 
138  DDLogicalPart ddlp = DDLogicalPart( solname, usemat, ddpolycone );
139  return ddlp;
140 }
141 
144 {
146  DDPolycone msol = (DDPolycone)(div_.parent().solid());
147  setType( "DivisionPolyconePhi" );
148  // this is the g4. what do we keep??? I think it is deltaPhi
149  // double deltaPhi = msol->GetEndPhi() - msol->GetStartPhi();
150  if( divisionType_ == DivWIDTH )
151  {
152  //If you divide a tube of 360 degrees the offset displaces the starting angle, but you still fill the 360 degrees
153  if( msol.deltaPhi() == 360.*deg ) {
154  compNDiv_ = calculateNDiv( msol.deltaPhi(), div_.width(), 0. );
155  }else {
157  }
158  }
159  else if( divisionType_ == DivNDIV )
160  {
161  if( msol.deltaPhi() == 360.*deg ) {
162  compWidth_ = calculateWidth( msol.deltaPhi(), div_.nReplicas(), 0. );
163  }else {
165  }
166  }
167 }
168 
169 void
171 {
173 }
174 
175 double
177 {
178  DDPolycone msol = (DDPolycone)(div_.parent().solid());
179  return msol.deltaPhi();
180 }
181 
183 DDDividedPolyconePhi::makeDDRotation( const int copyNo ) const
184 {
185  DDRotation myddrot; // sets to identity.
186  double posi = ( copyNo - 1 ) * compWidth_;
187  DDRotationMatrix* rotMat = changeRotMatrix( posi );
188  // how to name the rotation??
189  // i do not like this
190  DDName ddrotname( div_.parent().ddname().name() + "_DIVCHILD_ROT" + std::to_string( copyNo ),
191  div_.parent().ddname().ns());
192  myddrot = DDrot( ddrotname, rotMat );
193 
194  return myddrot;
195 }
196 
199 {
200  DDTranslation translation;
201  return translation;
202 }
203 
206 {
207  DDName solname;
208  DDSolid ddpolycone;
209  DDMaterial usemat(div_.parent().material());
210 
211  DDPolycone msol = (DDPolycone)(div_.parent().solid());
212  std::vector<double> localrMaxVec = msol.rMaxVec();
213  std::vector<double> localrMinVec = msol.rMinVec();
214  std::vector<double> localzVec = msol.zVec();
215 
216  solname = DDName(div_.parent().ddname().name() + "_DIVCHILD",
217  div_.parent().ddname().ns());
218  DDSolid sol( solname );
219  if( !sol.isDefined().second )
220  {
221  ddpolycone = DDSolidFactory::polycone( solname,
222  msol.startPhi()+div_.offset(),
223  compWidth_,
224  localzVec,
225  localrMinVec,
226  localrMaxVec );
227  }
228  DDLogicalPart ddlp( solname );
229  if( !ddlp.isDefined().second )
230  {
231  ddlp = DDLogicalPart( solname, usemat, ddpolycone );
232  }
233 
234  return ddlp;
235 }
236 
239 {
241  DDPolycone msol = (DDPolycone)(div_.parent().solid());
242  std::vector<double> localrMaxVec = msol.rMaxVec();
243  std::vector<double> localrMinVec = msol.rMinVec();
244  std::vector<double> localzVec = msol.zVec();
245 
246  if( divisionType_ == DivWIDTH )
247  {
248  compNDiv_ =
249  calculateNDiv( localzVec[localzVec.size() - 1]
250  - localzVec[0] , div_.width(), div_.offset() );
251  }
252  else if( divisionType_ == DivNDIV )
253  {
254  compWidth_ =
255  calculateNDiv( localzVec[localzVec.size()-1]
256  - localzVec[0] , div_.nReplicas(), div_.offset() );
257  }
258 }
259 
260 void
262 {
264 
265  DDPolycone msol = (DDPolycone)(div_.parent().solid());
266  std::vector<double> localzVec = msol.zVec();
267  // CHANGE FROM G4 a polycone can be divided in Z by specifying
268  // nReplicas IF they happen to coincide with the number of
269  // z plans.
270  size_t tempNDiv = div_.nReplicas();
271  if (tempNDiv == 0)
272  tempNDiv = calculateNDiv( localzVec[localzVec.size() - 1] - localzVec[0]
273  , div_.width()
274  , div_.offset() );
275  if ((msol.zVec().size() - 1) != tempNDiv)
276  {
277  std::string s = "ERROR - DDDividedPolyconeZ::checkParametersValidity()";
278  s += "\n\tDivision along Z will be done splitting in the defined";
279  s += "\n\tz_planes, i.e, the number of division would be :";
280  s += "\n\t" + std::to_string( msol.zVec().size() - 1 );
281  s += "\n\tinstead of " + std::to_string(tempNDiv) + " !\n";
282 
283  throw cms::Exception("DDException") << s;
284  }
285 }
286 
287 double
289 {
290  DDPolycone msol = (DDPolycone)(div_.parent().solid());
291  std::vector<double> localzVec = msol.zVec();
292 
293  return (localzVec[ localzVec.size() - 1] - localzVec[0]);
294 }
295 
297 DDDividedPolyconeZ::makeDDRotation( const int copyNo ) const
298 {
299  DDRotation myddrot; // sets to identity.
300  return myddrot;
301 }
302 
304 DDDividedPolyconeZ::makeDDTranslation( const int copyNo ) const
305 {
306  DDTranslation translation;
307  DDPolycone msol = (DDPolycone)(div_.parent().solid());
308  std::vector<double> localzVec = msol.zVec();
309  double posi = (localzVec[copyNo] + localzVec[copyNo+1]) / 2;
310  translation.SetZ(posi);
311  return translation;
312 }
313 
315 DDDividedPolyconeZ::makeDDLogicalPart( const int copyNo ) const
316 {
317  DDName solname;
318  DDSolid ddpolycone;
319  DDMaterial usemat(div_.parent().material());
320 
321  DDPolycone msol = (DDPolycone)(div_.parent().solid());
322  std::vector<double> localrMaxVec = msol.rMaxVec();
323  std::vector<double> localrMinVec = msol.rMinVec();
324  std::vector<double> localzVec = msol.zVec();
325 
326  solname = DDName( div_.parent().ddname().name() + "_DIVCHILD" + std::to_string(copyNo),
327  div_.parent().ddname().ns());
328  ddpolycone = DDSolidFactory::cons( solname,
329  compWidth_ / 2,
330  localrMinVec[copyNo],
331  localrMaxVec[copyNo],
332  localrMinVec[copyNo+1],
333  localrMaxVec[copyNo+1],
334  msol.startPhi(),
335  msol.deltaPhi());
336 
337  DDLogicalPart ddlp = DDLogicalPart( solname, usemat, ddpolycone );
338 
339  return ddlp;
340 }
void checkParametersValidity() override
void checkParametersValidity() override
int nReplicas() const
Definition: DDDivision.cc:71
DDLogicalPart makeDDLogicalPart(int copyNo) const override
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:379
DDRotation makeDDRotation(int copyNo) const override
double offset() const
Definition: DDDivision.cc:81
static DDSolid cons(const DDName &name, double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double phiFrom, double deltaPhi)
Definition: DDSolid.cc:836
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:714
int calculateNDiv(double motherDim, double width, double offset) const
DDRotation makeDDRotation(int copyNo) const override
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:102
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
double getMaxParameter() const override
double calculateWidth(double motherDim, int nDiv, double offset) const
double getMaxParameter() const override
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
DDTranslation makeDDTranslation(int copyNo) const override
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:83
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
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:67
DDTranslation makeDDTranslation(int copyNo) const override
double getMaxParameter() const override
DDLogicalPart makeDDLogicalPart(int copyNo) const override
std::vector< double > rMinVec(void) const
Definition: DDSolid.cc:371
void checkParametersValidity() override
double deltaPhi(void) const
Definition: DDSolid.cc:353
DDTranslation makeDDTranslation(int copyNo) const override
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
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
ii
Definition: cuy.py:589
DDDividedPolyconeZ(const DDDivision &div, DDCompactView *cpv)
DDDividedPolyconePhi(const DDDivision &div, DDCompactView *cpv)
double width() const
Definition: DDDivision.cc:76
const DDLogicalPart & parent() const
Definition: DDDivision.cc:86
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
DDLogicalPart makeDDLogicalPart(int copyNo) const override
std::vector< double > zVec(void) const
Definition: DDSolid.cc:363
DDRotation makeDDRotation(int copyNo) const override
const N & ddname() const
Definition: DDBase.h:80
DDRotationMatrix * changeRotMatrix(double rotZ=0.) const