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 
15 #include "CLHEP/Units/GlobalPhysicalConstants.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
18 #include <string>
19 #include <vector>
20 
21 using namespace std;
22 
23 class DDTOBAxCableAlgo : public DDAlgorithm {
24 public:
25  //Constructor and Destructor
27  ~DDTOBAxCableAlgo() override;
28 
29  void initialize(const DDNumericArguments& nArgs,
30  const DDVectorArguments& vArgs,
31  const DDMapArguments& mArgs,
32  const DDStringArguments& sArgs,
33  const DDStringVectorArguments& vsArgs) override;
34 
35  void execute(DDCompactView& cpv) override;
36 
37 private:
38  string idNameSpace; // Namespace of this and ALL sub-parts
39 
40  vector<string> sectorNumber; // Id. Number of the sectors
41 
42  double sectorRin; // Inner radius of service sectors
43  double sectorRout; // Outer radius of service sectors
44  double sectorDz; // Sector half-length
45  double sectorDeltaPhi_B; // Sector B phi width [A=C=0.5*(360/sectors)]
46  vector<double> sectorStartPhi; // Starting phi for the service sectors
47  vector<string> sectorMaterial_A; // Material for the A sectors
48  vector<string> sectorMaterial_B; // Material for the B sectors
49  vector<string> sectorMaterial_C; // Material for the C sectors
50 };
51 
52 DDTOBAxCableAlgo::DDTOBAxCableAlgo() : sectorRin(0), sectorRout(0), sectorDeltaPhi_B(0) {
53  LogDebug("TOBGeom") << "DDTOBAxCableAlgo info: Creating an instance";
54 }
55 
57 
59  const DDVectorArguments& vArgs,
60  const DDMapArguments&,
61  const DDStringArguments& sArgs,
62  const DDStringVectorArguments& vsArgs) {
64  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Parent " << parent().name() << " NameSpace " << idNameSpace;
65 
66  sectorNumber = vsArgs["SectorNumber"];
67  sectorRin = nArgs["SectorRin"];
68  sectorRout = nArgs["SectorRout"];
69  sectorDz = nArgs["SectorDz"];
70  sectorDeltaPhi_B = nArgs["SectorDeltaPhi_B"];
71  sectorStartPhi = vArgs["SectorStartPhi"];
72  sectorMaterial_A = vsArgs["SectorMaterial_A"];
73  sectorMaterial_B = vsArgs["SectorMaterial_B"];
74  sectorMaterial_C = vsArgs["SectorMaterial_C"];
75 
76  for (int i = 0; i < (int)(sectorNumber.size()); i++)
77  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: sectorNumber[" << i << "] = " << sectorNumber[i];
78 
79  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Axial Service Sectors half-length " << sectorDz << "\tRin "
80  << sectorRin << "\tRout = " << sectorRout << "\tPhi of sectors position:";
81  for (int i = 0; i < (int)(sectorNumber.size()); i++)
82  LogDebug("TOBGeom") << "\t[" << i << "]\tPhi = " << sectorStartPhi[i];
83  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: List of materials for the sectors/3 parts";
84  //
85  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 A";
86  for (int i = 0; i < (int)(sectorNumber.size()); i++)
87  LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_A = " << sectorMaterial_A[i];
88  //
89  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 B";
90  for (int i = 0; i < (int)(sectorNumber.size()); i++)
91  LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_B = " << sectorMaterial_B[i];
92  //
93  LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 C";
94  for (int i = 0; i < (int)(sectorNumber.size()); i++)
95  LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_C = " << sectorMaterial_C[i];
96 }
97 
99  LogDebug("TOBGeom") << "==>> Constructing DDTOBAxCableAlgo...";
100  DDName tubsName(parent().name());
101 
102  // Loop over sectors (sectorNumber vector)
103  for (int i = 0; i < (int)(sectorNumber.size()); i++) {
104  DDSolid solid;
105  string name;
106  double dz, rin, rout, startphi, widthphi, deltaphi;
107 
108  // Axial Services
109  // Each sector is divided in 3 parts from phi[i] to phi[i+1]
110 
111  widthphi = ((i + 1 == (int)(sectorStartPhi.size())) ? (sectorStartPhi[0] + CLHEP::twopi) - sectorStartPhi[i]
112  : (sectorStartPhi[i + 1] - sectorStartPhi[i]));
113 
114  // First Part: A
115  name = "TOBAxService_" + sectorNumber[i] + "A";
116  dz = sectorDz;
117  rin = sectorRin;
118  rout = sectorRout;
119  startphi = sectorStartPhi[i];
120  deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
121 
122  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin, rout, startphi, deltaphi);
123 
124  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " Tubs made of "
125  << sectorMaterial_A[i] << " from " << startphi / CLHEP::deg << " to "
126  << (startphi + deltaphi) / CLHEP::deg << " with Rin " << rin << " Rout " << rout << " ZHalf "
127  << dz;
128 
130  DDMaterial sectorMatter(sectorMatName);
131  DDLogicalPart sectorLogic(DDName(name, idNameSpace), sectorMatter, solid);
132 
133  cpv.position(DDName(name, idNameSpace), tubsName, i + 1, DDTranslation(), DDRotation());
134  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
135  << " positioned in " << tubsName << " with no translation and no rotation";
136 
137  // Second Part: B
138  name = "TOBAxService_" + sectorNumber[i] + "B";
139  startphi += deltaphi;
140  deltaphi = sectorDeltaPhi_B;
141 
142  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin, rout, startphi, deltaphi);
143 
144  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " Tubs made of "
145  << sectorMaterial_B[i] << " from " << startphi / CLHEP::deg << " to "
146  << (startphi + deltaphi) / CLHEP::deg << " with Rin " << rin << " Rout " << rout << " ZHalf "
147  << dz;
148 
150  sectorMatter = DDMaterial(sectorMatName);
151  sectorLogic = DDLogicalPart(DDName(name, idNameSpace), sectorMatter, solid);
152 
153  cpv.position(DDName(name, idNameSpace), tubsName, i + 1, DDTranslation(), DDRotation());
154  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
155  << " positioned in " << tubsName << " with no translation and no rotation";
156 
157  // Third Part: C
158  name = "TOBAxService_" + sectorNumber[i] + "C";
159  startphi += deltaphi;
160  deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
161 
162  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin, rout, startphi, deltaphi);
163 
164  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " Tubs made of "
165  << sectorMaterial_C[i] << " from " << startphi / CLHEP::deg << " to "
166  << (startphi + deltaphi) / CLHEP::deg << " with Rin " << rin << " Rout " << rout << " ZHalf "
167  << dz;
168 
170  sectorMatter = DDMaterial(sectorMatName);
171  sectorLogic = DDLogicalPart(DDName(name, idNameSpace), sectorMatter, solid);
172 
173  cpv.position(DDName(name, idNameSpace), tubsName, i + 1, DDTranslation(), DDRotation());
174  LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: " << DDName(name, idNameSpace) << " number " << i + 1
175  << " positioned in " << tubsName << " with no translation and no rotation";
176  }
177 
178  LogDebug("TOBGeom") << "<<== End of DDTOBAxCableAlgo construction ...";
179 }
180 
181 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTOBAxCableAlgo, "track:DDTOBAxCableAlgo");
DDTOBAxCableAlgo::sectorRin
double sectorRin
Definition: DDTOBAxCableAlgo.cc:42
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDSplit.h
DDTOBAxCableAlgo::sectorMaterial_B
vector< string > sectorMaterial_B
Definition: DDTOBAxCableAlgo.cc:48
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDTOBAxCableAlgo::DDTOBAxCableAlgo
DDTOBAxCableAlgo()
Definition: DDTOBAxCableAlgo.cc:52
dqmdumpme.first
first
Definition: dqmdumpme.py:55
DDTOBAxCableAlgo::idNameSpace
string idNameSpace
Definition: DDTOBAxCableAlgo.cc:38
DDTOBAxCableAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDTOBAxCableAlgo.cc:58
DDTOBAxCableAlgo::sectorStartPhi
vector< double > sectorStartPhi
Definition: DDTOBAxCableAlgo.cc:46
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDTOBAxCableAlgo::sectorRout
double sectorRout
Definition: DDTOBAxCableAlgo.cc:43
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDTOBAxCableAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDTOBAxCableAlgo.cc:98
DDTOBAxCableAlgo::sectorDeltaPhi_B
double sectorDeltaPhi_B
Definition: DDTOBAxCableAlgo.cc:45
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDSolidFactory::tubs
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:653
DDSolid.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDTOBAxCableAlgo
Definition: DDTOBAxCableAlgo.cc:23
DDTOBAxCableAlgo::~DDTOBAxCableAlgo
~DDTOBAxCableAlgo() override
Definition: DDTOBAxCableAlgo.cc:56
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDTypes.h
DDMaterial.h
createfilelist.int
int
Definition: createfilelist.py:10
DDLogicalPart.h
DDTOBAxCableAlgo::sectorMaterial_C
vector< string > sectorMaterial_C
Definition: DDTOBAxCableAlgo.cc:49
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
PVValHelper::dz
Definition: PVValidationHelpers.h:50
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDTOBAxCableAlgo::sectorMaterial_A
vector< string > sectorMaterial_A
Definition: DDTOBAxCableAlgo.cc:47
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDTOBAxCableAlgo::sectorNumber
vector< string > sectorNumber
Definition: DDTOBAxCableAlgo.cc:40
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:76
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18
DDTOBAxCableAlgo::sectorDz
double sectorDz
Definition: DDTOBAxCableAlgo.cc:44