CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDDividedGeometryObject.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // 25.04.04 - M.Case ported algorithm from G4VDivisionParameterisation.cc. to
4 // DDD version
5 // ********************************************************************
6 
10 
11 #include <Math/RotationZ.h>
12 
14  : div_( div ),
15  ftype_(),
16  compNDiv_( div.nReplicas()),
17  compWidth_( div.width()),
18  divisionType_( DivNDIVandWIDTH ),
19  theVoluFirstCopyNo_( 1 ),
20  cpv_( cpv )
21 {
22  if( div_.nReplicas() == 0 || div_.width() < tolerance())
23  {
24  if( div_.width() < tolerance())
26  else
28  }
29  DCOUT_V( 'P', " DDDividedGeometryObject Divisions " << div_ << std::endl );
30 }
31 
33 {}
34 
37 {
38  DDRotationMatrix * rm = new DDRotationMatrix(ROOT::Math::RotationZ(rotZ));
39  return rm;
40 }
41 
42 int
43 DDDividedGeometryObject::calculateNDiv( double motherDim, double width, double offset ) const
44 {
45  DCOUT_V('P', " DDDividedGeometryObject::calculateNDiv: " << ( motherDim - offset ) / width << " Motherdim: " << motherDim << ", Offset: " << offset << ", Width: " << width << std::endl);
46  return int( ( motherDim - offset ) / width );
47 }
48 
49 double
50 DDDividedGeometryObject::calculateWidth( double motherDim, int nDiv, double offset ) const
51 {
52  DCOUT_V('P', " DDDividedGeometryObject::calculateWidth: " << ( motherDim - offset ) / nDiv << ", Motherdim: " << motherDim << ", Offset: " << offset << ", Number of divisions: " << nDiv << std::endl);
53 
54  return ( motherDim - offset ) / nDiv;
55 }
56 
57 void
59 {
60  double maxPar = getMaxParameter();
61  checkOffset( maxPar );
62  checkNDivAndWidth( maxPar );
63  if (!div_.parent().isDefined().second) {
64  std::string s = "DDDividedGeometryObject::checkParametersValidity() :";
65  s+= "\n ERROR - the LogicalPart of the parent must be ";
66  s+= "\n defined before a division can occur.";
67  s+= "\n Parent= " + div_.parent().toString();
68  throw cms::Exception("DDException") << s;
69  }
70 }
71 
72 void
74 {
75  if( div_.offset() >= maxPar )
76  {
77  DCOUT_V('P', "DDDividedGeometryObject::checkOffset() Division of LogicalPart " << div_.parent() << " offset=" << div_.offset() << " maxPar=" << maxPar << "\n");
78  std::string s = "DDDividedGeometryObject::checkOffset() IllegalConstruct";
79  s += "\nERROR - DDDividedGeometryObject::checkOffset()";
80  s += "\n failed.";
81  s += " Too big an offset.";
82  throw cms::Exception("DDException") << s;
83  }
84 }
85 
86 void
88 {
90  && (div_.offset() + compWidth_*compNDiv_ - maxPar > tolerance() ) )
91  {
92  std::string s = "ERROR - DDDividedGeometryObject::checkNDivAndWidth()";
93  s+= "\n Division of LogicalPart " + div_.parent();
94  s+= " has too big an offset.";
95  DCOUT_V('P', "DDDividedGeometryObject::checkNDivAndWidth has computed div_.offset() + compWidth_*compNDiv_ - maxPar =" << div_.offset() + compWidth_*compNDiv_ - maxPar << " and tolerance()=" << tolerance());
96  std::cout << compWidth_ << std::endl;
97  throw cms::Exception("DDException") << s;
98  }
99 }
100 
101 const double
103 {
104  // this can come from some global tolerance if you want.
105  static const double tol = 1.0/1000.00;
106  return tol;
107 }
108 
109 void
110 DDDividedGeometryObject::setType( const std::string& s)
111 {
112  ftype_ = s;
113 }
114 
115 const std::string&
117 {
118  return ftype_;
119 }
120 
121 void
123 {
124  DCOUT_V( 'D', "about to make " << compNDiv_ << " divisions." << std::endl );
126  {
127  DCOUT_V( 'D', "Parent Volume: " << div_.parent() << std::endl );
128  DCOUT_V( 'D', "Child Volume: " << makeDDLogicalPart(i) << std::endl );
129  DCOUT_V( 'D', " copyNo:" << i << std::endl );
130  DCOUT_V( 'D', " Translation: " << makeDDTranslation(i) << std::endl );
131  DCOUT_V( 'D', " rotation=" << makeDDRotation(i) << std::endl );
132 
134  div_.parent(),
135  i,
136  makeDDTranslation( i ),
137  makeDDRotation( i ),
138  &div_ );
139  }
140 }
141 
142 double
144 {
145  return 0.0;
146 }
147 
150 {
151  return DDRotation();
152 }
153 
156 {
157  return DDTranslation();
158 }
159 
162 {
163  // just return the parent... this is USELESS
164  return div_.parent();
165 }
virtual DDLogicalPart makeDDLogicalPart(const int copyNo) const
int i
Definition: DBlmapReader.cc:9
def_type isDefined() const
Definition: DDBase.h:115
int nReplicas() const
Definition: DDDivision.cc:90
double offset() const
Definition: DDDivision.cc:100
virtual double getMaxParameter(void) const
int calculateNDiv(double motherDim, double width, double offset) const
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
double calculateWidth(double motherDim, int nDiv, double offset) const
type of data representation of DDCompactView
Definition: DDCompactView.h:77
virtual void checkParametersValidity(void)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDDividedGeometryObject(const DDDivision &div, DDCompactView *cpv)
virtual DDTranslation makeDDTranslation(const int copyNo) const
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
static const double tolerance(void)
string rm
Definition: submit.py:76
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
virtual void setType(const std::string &type)
unsigned int offset(bool)
virtual const std::string & getType(void) const
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
std::string toString() const
Definition: DDBase.h:86
double width() const
Definition: DDDivision.cc:95
virtual DDRotation makeDDRotation(const int copyNo) const
tuple cout
Definition: gather_cfg.py:121
const DDLogicalPart & parent() const
Definition: DDDivision.cc:105
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
void checkNDivAndWidth(double maxPar)
DDRotationMatrix * changeRotMatrix(double rotZ=0.) const