CMS 3D CMS Logo

DDTOBAxCableAlgo.cc
Go to the documentation of this file.
1 // File: DDTOBAxCableAlgo.cc
3 // Description: Equipping the axial cylinder of TOB with cables etc
5 
6 #include <cmath>
7 #include <algorithm>
8 
16 #include "CLHEP/Units/GlobalPhysicalConstants.h"
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
19 
21  sectorRin(0),sectorRout(0),sectorDeltaPhi_B(0) {
22  LogDebug("TOBGeom") <<"DDTOBAxCableAlgo info: Creating an instance";
23 }
24 
26 
28  const DDVectorArguments & vArgs,
29  const DDMapArguments &,
30  const DDStringArguments & sArgs,
31  const DDStringVectorArguments & vsArgs) {
32 
34  DDName parentName = parent().name();
35  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Parent " << parentName
36  << " NameSpace " << idNameSpace;
37 
38  sectorNumber = vsArgs["SectorNumber"];
39  sectorRin = nArgs["SectorRin"];
40  sectorRout = nArgs["SectorRout"];
41  sectorDz = nArgs["SectorDz"];
42  sectorDeltaPhi_B = nArgs["SectorDeltaPhi_B"];
43  sectorStartPhi = vArgs["SectorStartPhi"];
44  sectorMaterial_A = vsArgs["SectorMaterial_A"];
45  sectorMaterial_B = vsArgs["SectorMaterial_B"];
46  sectorMaterial_C = vsArgs["SectorMaterial_C"];
47 
48  for (int i=0; i<(int)(sectorNumber.size()); i++)
49  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: sectorNumber[" << i
50  << "] = " << sectorNumber[i];
51 
52  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Axial Service Sectors half-length " << sectorDz
53  << "\tRin " << sectorRin << "\tRout = " << sectorRout
54  << "\tPhi of sectors position:";
55  for (int i=0; i<(int)(sectorNumber.size()); i++)
56  LogDebug("TOBGeom") << "\t[" << i << "]\tPhi = " << sectorStartPhi[i];
57  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: List of materials for the sectors/3 parts";
58  //
59  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 A";
60  for (int i=0; i<(int)(sectorNumber.size()); i++)
61  LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_A = " << sectorMaterial_A[i];
62  //
63  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 B";
64  for (int i=0; i<(int)(sectorNumber.size()); i++)
65  LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_B = " << sectorMaterial_B[i];
66  //
67  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 C";
68  for (int i=0; i<(int)(sectorNumber.size()); i++)
69  LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_C = " << sectorMaterial_C[i];
70 
71 }
72 
74 
75  LogDebug("TOBGeom") << "==>> Constructing DDTOBAxCableAlgo...";
76  DDName tubsName = parent().name();
77 
78  // Loop over sectors (sectorNumber vector)
79  for (int i=0; i<(int)(sectorNumber.size()); i++) {
80 
81  DDSolid solid;
83  double dz, rin, rout, startphi, widthphi, deltaphi;
84 
85  // Axial Services
86  // Each sector is divided in 3 parts from phi[i] to phi[i+1]
87 
88  widthphi = ( (i+1 == (int)(sectorStartPhi.size())) ?
89  (sectorStartPhi[0]+CLHEP::twopi)-sectorStartPhi[i] :
91 
92  // First Part: A
93  name = "TOBAxService_" + sectorNumber[i] + "A";
94  dz = sectorDz;
95  rin = sectorRin;
96  rout = sectorRout;
97  startphi = sectorStartPhi[i];
98  deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
99 
100  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin,
101  rout, startphi, deltaphi);
102 
103  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
104  << DDName(name, idNameSpace) << " Tubs made of "
105  << sectorMaterial_A[i] << " from "
106  << startphi/CLHEP::deg << " to "
107  << (startphi+deltaphi)/CLHEP::deg << " with Rin "
108  << rin << " Rout " << rout << " ZHalf " << dz;
109 
110  DDName sectorMatName(DDSplit(sectorMaterial_A[i]).first,
112  DDMaterial sectorMatter(sectorMatName);
113  DDLogicalPart sectorLogic(DDName(name, idNameSpace), sectorMatter, solid);
114 
115  cpv.position(DDName(name,idNameSpace), tubsName, i+1, DDTranslation(),
116  DDRotation());
117  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
118  << DDName(name,idNameSpace) << " number " << i+1
119  << " positioned in " << tubsName
120  << " with no translation and no rotation";
121 
122  // Second Part: B
123  name = "TOBAxService_" + sectorNumber[i] + "B";
124  startphi += deltaphi;
125  deltaphi = sectorDeltaPhi_B;
126 
127  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin,
128  rout, startphi, deltaphi);
129 
130  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
131  << DDName(name, idNameSpace) << " Tubs made of "
132  << sectorMaterial_B[i] << " from " << startphi/CLHEP::deg << " to " << (startphi+deltaphi)/CLHEP::deg
133  << " with Rin " << rin << " Rout " << rout
134  << " ZHalf " << dz;
135 
136  sectorMatName = DDName(DDSplit(sectorMaterial_B[i]).first,
137  DDSplit(sectorMaterial_B[i]).second);
138  sectorMatter = DDMaterial(sectorMatName);
139  sectorLogic = DDLogicalPart(DDName(name, idNameSpace), sectorMatter,
140  solid);
141 
142  cpv.position(DDName(name,idNameSpace), tubsName, i+1, DDTranslation(),
143  DDRotation());
144  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
145  << DDName(name,idNameSpace) << " number " << i+1
146  << " positioned in " << tubsName
147  << " with no translation and no rotation";
148 
149  // Third Part: C
150  name = "TOBAxService_" + sectorNumber[i] + "C";
151  startphi += deltaphi;
152  deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
153 
154  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin,
155  rout, startphi, deltaphi);
156 
157  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
158  << DDName(name, idNameSpace) << " Tubs made of "
159  << sectorMaterial_C[i] << " from "
160  << startphi/CLHEP::deg << " to "
161  << (startphi+deltaphi)/CLHEP::deg << " with Rin "
162  << rin << " Rout " << rout << " ZHalf " << dz;
163 
164  sectorMatName = DDName(DDSplit(sectorMaterial_C[i]).first,
165  DDSplit(sectorMaterial_C[i]).second);
166  sectorMatter = DDMaterial(sectorMatName);
167  sectorLogic = DDLogicalPart(DDName(name, idNameSpace), sectorMatter,
168  solid);
169 
170  cpv.position(DDName(name,idNameSpace), tubsName, i+1, DDTranslation(),
171  DDRotation());
172  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
173  << DDName(name,idNameSpace) << " number " << i+1
174  << " positioned in " << tubsName
175  << " with no translation and no rotation";
176  }
177 
178  LogDebug("TOBGeom") << "<<== End of DDTOBAxCableAlgo construction ...";
179 }
#define LogDebug(id)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
std::vector< std::string > sectorMaterial_A
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:15
std::vector< std::string > sectorNumber
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
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::string idNameSpace
std::vector< std::string > sectorMaterial_C
std::vector< double > sectorStartPhi
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:983
void execute(DDCompactView &cpv)
virtual ~DDTOBAxCableAlgo()
std::vector< std::string > sectorMaterial_B
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4