test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDTIDRingAlgo.cc
Go to the documentation of this file.
1 // File: DDTIDRingAlgo.cc
3 // Description: Position n copies of detectors in alternate positions and
4 // also associated ICC's
5 // Em 17Sep07: Cool inserts moved to DDTIDModulePosAlgo.h
7 
8 #include <cmath>
9 #include <algorithm>
10 
16 #include "CLHEP/Units/GlobalPhysicalConstants.h"
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
19 
21  LogDebug("TIDGeom") << "DDTIDRingAlgo info: Creating an instance";
22 }
23 
25 
27  const DDVectorArguments & vArgs,
28  const DDMapArguments & ,
29  const DDStringArguments & sArgs,
30  const DDStringVectorArguments & vsArgs) {
31 
33  moduleName = vsArgs["ModuleName"];
34  iccName = sArgs["ICCName"];
35  DDName parentName = parent().name();
36  LogDebug("TIDGeom") << "DDTIDRingAlgo debug: Parent " << parentName
37  << "\tModule " << moduleName[0] << ", "
38  << moduleName[1] << "\tICC " << iccName
39  << "\tNameSpace " << idNameSpace;
40 
41  number = int (nArgs["Number"]);
42  startAngle = nArgs["StartAngle"];
43  rModule = nArgs["ModuleR"];
44  zModule = vArgs["ModuleZ"];
45  rICC = nArgs["ICCR"];
46  sICC = nArgs["ICCShift"];
47  zICC = vArgs["ICCZ"];
48 
49  LogDebug("TIDGeom") <<"DDTIDRingAlgo debug: Parameters for positioning--"
50  << " StartAngle " << startAngle/CLHEP::deg
51  << " Copy Numbers " << number << " Modules at R "
52  << rModule << " Z " << zModule[0] << ", " << zModule[1]
53  << " ICCs at R " << rICC << " Z " << zICC[0] << ", "
54  << zICC[1];
55 }
56 
58 
59  double theta = 90.*CLHEP::deg;
60  double phiy = 0.*CLHEP::deg;
61  double dphi = CLHEP::twopi/number;
62 
63  DDName mother = parent().name();
64  DDName module;
66 
67  //Loop over modules
68  for (int i=0; i<number; i++) {
69 
70  //First the module
71  double phiz = startAngle + i*dphi;
72  double xpos = rModule*cos(phiz);
73  double ypos = rModule*sin(phiz);
74  double zpos, thetay, phix;
75  if (i%2 == 0) {
76  phix = phiz + 90.*CLHEP::deg;
77  thetay = 0*CLHEP::deg;
78  zpos = zModule[0];
79  module = DDName(DDSplit(moduleName[0]).first,
80  DDSplit(moduleName[0]).second);
81  } else {
82  phix = phiz - 90.*CLHEP::deg;
83  thetay = 180*CLHEP::deg;
84  zpos = zModule[1];
85  module = DDName(DDSplit(moduleName[1]).first,
86  DDSplit(moduleName[1]).second);
87  }
88 
89  // stereo face inside toward structure, rphi face outside
90  phix = phix - 180.*CLHEP::deg;
91  thetay = thetay + 180.*CLHEP::deg;
92  //
93 
94  DDTranslation trmod(xpos, ypos, zpos);
95  double phideg = phiz/CLHEP::deg;
97  std::string rotstr = mother.name() + dbl_to_string(phideg*10.);
98  rotation = DDRotation(DDName(rotstr, idNameSpace));
99  if (!rotation) {
100  LogDebug("TIDGeom") << "DDTIDRingAlgo test: Creating a new rotation "
101  << rotstr << "\t" << theta/CLHEP::deg << ", "
102  << phix/CLHEP::deg << ", " << thetay/CLHEP::deg
103  << ", " << phiy/CLHEP::deg << ", "
104  << theta/CLHEP::deg << ", " << phiz/CLHEP::deg;
105  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, thetay, phiy,
106  theta, phiz);
107  }
108 
109  cpv.position(module, mother, i+1, trmod, rotation);
110  LogDebug("TIDGeom") << "DDTIDRingAlgo test: " << module << " number "
111  << i+1 << " positioned in " << mother << " at "
112  << trmod << " with " << rotation;
113 
114  //Now the ICC
115  if (i%2 == 0 ) {
116  zpos = zICC[0];
117  xpos = rICC*cos(phiz) + sICC*sin(phiz);
118  ypos = rICC*sin(phiz) - sICC*cos(phiz);
119  } else {
120  zpos = zICC[1];
121  xpos = rICC*cos(phiz) - sICC*sin(phiz);
122  ypos = rICC*sin(phiz) + sICC*cos(phiz);
123  }
124  DDTranslation tricc(xpos, ypos, zpos);
125  cpv.position(icc, mother, i+1, tricc, rotation);
126  LogDebug("TIDGeom") << "DDTIDRingAlgo test: " << icc << " number "
127  << i+1 << " positioned in " << mother << " at "
128  << tricc << " with " << rotation;
129 
130  }
131 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
list parent
Definition: dbtoconf.py:74
double startAngle
Definition: DDTIDRingAlgo.h:32
std::vector< double > zICC
Definition: DDTIDRingAlgo.h:37
std::string idNameSpace
Definition: DDTIDRingAlgo.h:27
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
Geom::Theta< T > theta() const
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:14
static std::string & ns()
std::string dbl_to_string(const double &in)
Converts only the integer part of a double to a string.
Definition: DDutils.cc:12
type of data representation of DDCompactView
Definition: DDCompactView.h:77
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
U second(std::pair< T, U > const &p)
std::vector< std::string > moduleName
Definition: DDTIDRingAlgo.h:28
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::string iccName
Definition: DDTIDRingAlgo.h:29
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
void execute(DDCompactView &cpv)
std::vector< double > zModule
Definition: DDTIDRingAlgo.h:34
virtual ~DDTIDRingAlgo()
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
const std::string & name() const
Returns the name.
Definition: DDName.cc:87