CMS 3D CMS Logo

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 
15 #include "CLHEP/Units/GlobalPhysicalConstants.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
18 
20  LogDebug("TIDGeom") << "DDTIDRingAlgo info: Creating an instance";
21 }
22 
24 
26  const DDVectorArguments & vArgs,
27  const DDMapArguments & ,
28  const DDStringArguments & sArgs,
29  const DDStringVectorArguments & vsArgs) {
30 
32  moduleName = vsArgs["ModuleName"];
33  iccName = sArgs["ICCName"];
34  DDName parentName = parent().name();
35  LogDebug("TIDGeom") << "DDTIDRingAlgo debug: Parent " << parentName
36  << "\tModule " << moduleName[0] << ", "
37  << moduleName[1] << "\tICC " << iccName
38  << "\tNameSpace " << idNameSpace;
39 
40  number = int (nArgs["Number"]);
41  startAngle = nArgs["StartAngle"];
42  rModule = nArgs["ModuleR"];
43  zModule = vArgs["ModuleZ"];
44  rICC = nArgs["ICCR"];
45  sICC = nArgs["ICCShift"];
46  zICC = vArgs["ICCZ"];
47 
48  LogDebug("TIDGeom") <<"DDTIDRingAlgo debug: Parameters for positioning--"
49  << " StartAngle " << startAngle/CLHEP::deg
50  << " Copy Numbers " << number << " Modules at R "
51  << rModule << " Z " << zModule[0] << ", " << zModule[1]
52  << " ICCs at R " << rICC << " Z " << zICC[0] << ", "
53  << zICC[1];
54 }
55 
57 
58  double theta = 90.*CLHEP::deg;
59  double phiy = 0.*CLHEP::deg;
60  double dphi = CLHEP::twopi/number;
61 
62  DDName mother = parent().name();
63  DDName module;
65 
66  //Loop over modules
67  for (int i=0; i<number; i++) {
68 
69  //First the module
70  double phiz = startAngle + i*dphi;
71  double xpos = rModule*cos(phiz);
72  double ypos = rModule*sin(phiz);
73  double zpos, thetay, phix;
74  if (i%2 == 0) {
75  phix = phiz + 90.*CLHEP::deg;
76  thetay = 0*CLHEP::deg;
77  zpos = zModule[0];
78  module = DDName(DDSplit(moduleName[0]).first,
79  DDSplit(moduleName[0]).second);
80  } else {
81  phix = phiz - 90.*CLHEP::deg;
82  thetay = 180*CLHEP::deg;
83  zpos = zModule[1];
84  module = DDName(DDSplit(moduleName[1]).first,
85  DDSplit(moduleName[1]).second);
86  }
87 
88  // stereo face inside toward structure, rphi face outside
89  phix = phix - 180.*CLHEP::deg;
90  thetay = thetay + 180.*CLHEP::deg;
91  //
92 
93  DDTranslation trmod(xpos, ypos, zpos);
94  double phideg = phiz/CLHEP::deg;
96  std::string rotstr = mother.name() + std::to_string(phideg*10.);
97  rotation = DDRotation(DDName(rotstr, idNameSpace));
98  if (!rotation) {
99  LogDebug("TIDGeom") << "DDTIDRingAlgo test: Creating a new rotation "
100  << rotstr << "\t" << theta/CLHEP::deg << ", "
101  << phix/CLHEP::deg << ", " << thetay/CLHEP::deg
102  << ", " << phiy/CLHEP::deg << ", "
103  << theta/CLHEP::deg << ", " << phiz/CLHEP::deg;
104  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, thetay, phiy,
105  theta, phiz);
106  }
107 
108  cpv.position(module, mother, i+1, trmod, rotation);
109  LogDebug("TIDGeom") << "DDTIDRingAlgo test: " << module << " number "
110  << i+1 << " positioned in " << mother << " at "
111  << trmod << " with " << rotation;
112 
113  //Now the ICC
114  if (i%2 == 0 ) {
115  zpos = zICC[0];
116  xpos = rICC*cos(phiz) + sICC*sin(phiz);
117  ypos = rICC*sin(phiz) - sICC*cos(phiz);
118  } else {
119  zpos = zICC[1];
120  xpos = rICC*cos(phiz) - sICC*sin(phiz);
121  ypos = rICC*sin(phiz) + sICC*cos(phiz);
122  }
123  DDTranslation tricc(xpos, ypos, zpos);
124  cpv.position(icc, mother, i+1, tricc, rotation);
125  LogDebug("TIDGeom") << "DDTIDRingAlgo test: " << icc << " number "
126  << i+1 << " positioned in " << mother << " at "
127  << tricc << " with " << rotation;
128 
129  }
130 }
#define LogDebug(id)
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:16
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:64
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:90