CMS 3D CMS Logo

DDPixBarLayerUpgradeAlgo.cc
Go to the documentation of this file.
1 // File: DDPixBarLayerUpgradeAlgo.cc
3 // Description: Make one layer of pixel barrel detector for Upgrading.
5 
15 #include "CLHEP/Units/PhysicalConstants.h"
16 #include "CLHEP/Units/SystemOfUnits.h"
17 
18 #include <cmath>
19 #include <algorithm>
20 #include <map>
21 #include <string>
22 #include <vector>
23 
24 using namespace std;
25 
26 class DDPixBarLayerUpgradeAlgo : public DDAlgorithm {
27 public:
28  //Constructor and Destructor
30  ~DDPixBarLayerUpgradeAlgo() override;
31 
32  void initialize(const DDNumericArguments& nArgs,
33  const DDVectorArguments& vArgs,
34  const DDMapArguments& mArgs,
35  const DDStringArguments& sArgs,
36  const DDStringVectorArguments& vsArgs) override;
37 
38  void execute(DDCompactView& cpv) override;
39 
40 private:
41  string idNameSpace; //Namespace of this and ALL sub-parts
42  string genMat; //Name of general material
43  int number; //Number of ladders in phi
44  double layerDz; //Length of the layer
45  double coolDz; //Length of the cooling piece
46  double coolThick; //Thickness of the shell
47  double coolRadius; //Cool tube external radius
48  double coolDist; //Radial distance between centres of 2
49  double cool1Offset; //cooling pipe 1 offset for ladder at interface
50  double cool2Offset; //cooling pipe 2 offset for ladder at interface
51  string coolMat; //Cooling fluid material name
52  string tubeMat; //Cooling piece material name
53  string coolMatHalf; //Cooling fluid material name
54  string tubeMatHalf; //Cooling piece material name
55  string ladder; //Name of ladder
56  double ladderWidth; //Width of ladder
57  double ladderThick; //Thicknes of ladder
58  double ladderOffset; //ladder dispacement at interface
59  int outerFirst; //Controller of the placement of ladder
60  double phiFineTune; //Fine-tuning pitch of first ladder
61  double rOuterFineTune; //Fine-tuning r offset for outer ladders
62  double rInnerFineTune; //Fine-tuning r offset for inner ladders
63 };
64 
66  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo info: Creating an instance";
67 }
68 
70 
72  const DDVectorArguments& vArgs,
73  const DDMapArguments&,
74  const DDStringArguments& sArgs,
75  const DDStringVectorArguments& vsArgs) {
76  idNameSpace = DDCurrentNamespace::ns();
77  DDName parentName = parent().name();
78 
79  genMat = sArgs["GeneralMaterial"];
80  number = int(nArgs["Ladders"]);
81  layerDz = nArgs["LayerDz"];
82  coolDz = nArgs["CoolDz"];
83  coolThick = nArgs["CoolThick"];
84  coolRadius = nArgs["CoolRadius"];
85  coolDist = nArgs["CoolDist"];
86  cool1Offset = nArgs["Cool1Offset"];
87  cool2Offset = nArgs["Cool2Offset"];
88  coolMat = sArgs["CoolMaterial"];
89  tubeMat = sArgs["CoolTubeMaterial"];
90  coolMatHalf = sArgs["CoolMaterialHalf"];
91  tubeMatHalf = sArgs["CoolTubeMaterialHalf"];
92  phiFineTune = nArgs["PitchFineTune"];
93  rOuterFineTune = nArgs["OuterOffsetFineTune"];
94  rInnerFineTune = nArgs["InnerOffsetFineTune"];
95 
96  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace
97  << "\n"
98  << "\tLadders " << number << "\tGeneral Material " << genMat << "\tLength " << layerDz
99  << "\tSpecification of Cooling Pieces:\n"
100  << "\tLength " << coolDz << " Thickness of Shell " << coolThick << " Radial distance "
101  << coolDist << " Materials " << coolMat << ", " << tubeMat;
102 
103  ladder = sArgs["LadderName"];
104  ladderWidth = nArgs["LadderWidth"];
105  ladderThick = nArgs["LadderThick"];
106  ladderOffset = nArgs["LadderOffset"];
107  outerFirst = int(nArgs["OuterFirst"]);
108 
109  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo debug: Full Ladder " << ladder << " width/thickness "
110  << ladderWidth << ", " << ladderThick;
111 }
112 
114  DDName mother = parent().name();
115  const string& idName = mother.name();
116 
117  double dphi = CLHEP::twopi / number;
118  double x2 = coolDist * sin(0.5 * dphi);
119  double rtmi = coolDist * cos(0.5 * dphi) - (coolRadius + ladderThick) + rInnerFineTune;
120  double rmxh = coolDist * cos(0.5 * dphi) + (coolRadius + ladderThick + ladderOffset) + rOuterFineTune;
121  double rtmx = sqrt(rmxh * rmxh + ladderWidth * ladderWidth / 4);
122  DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace), 0.5 * layerDz, rtmi, rtmx, 0, CLHEP::twopi);
123  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << DDName(idName, idNameSpace) << " Tubs made of "
124  << genMat << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rtmi << " Rout "
125  << rtmx << " ZHalf " << 0.5 * layerDz;
126  DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
127  DDMaterial matter(matname);
128  DDLogicalPart layer(solid.ddname(), matter, solid);
129 
130  // Full Tubes
131  string name = idName + "CoolTube";
132  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * coolDz, 0, coolRadius, 0, CLHEP::twopi);
133  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMat
134  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rout " << coolRadius << " ZHalf "
135  << 0.5 * coolDz;
136  matter = DDMaterial(DDName(DDSplit(tubeMat).first, DDSplit(tubeMat).second));
137  DDLogicalPart coolTube(solid.ddname(), matter, solid);
138 
139  // Half Tubes
140  name = idName + "CoolTubeHalf";
141  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * coolDz, 0, coolRadius, 0, CLHEP::pi);
142  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMatHalf
143  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rout " << coolRadius << " ZHalf "
144  << 0.5 * coolDz;
145  matter = DDMaterial(DDName(DDSplit(tubeMatHalf).first, DDSplit(tubeMatHalf).second));
146  DDLogicalPart coolTubeHalf(solid.ddname(), matter, solid);
147 
148  // Full Coolant
149  name = idName + "Coolant";
150  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * coolDz, 0, coolRadius - coolThick, 0, CLHEP::twopi);
151  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMat
152  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rout " << coolRadius - coolThick
153  << " ZHalf " << 0.5 * coolDz;
154  matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
155  DDLogicalPart cool(solid.ddname(), matter, solid);
156  cpv.position(cool, coolTube, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
157  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name() << " number 1 positioned in "
158  << coolTube.name() << " at (0,0,0) with no rotation";
159 
160  // Half Coolant
161  name = idName + "CoolantHalf";
162  solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * coolDz, 0, coolRadius - coolThick, 0, CLHEP::pi);
163  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << solid.name() << " Tubs made of " << tubeMatHalf
164  << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rout " << coolRadius - coolThick
165  << " ZHalf " << 0.5 * coolDz;
166  matter = DDMaterial(DDName(DDSplit(coolMatHalf).first, DDSplit(coolMatHalf).second));
167  DDLogicalPart coolHalf(solid.ddname(), matter, solid);
168  cpv.position(coolHalf, coolTubeHalf, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
169  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << cool.name() << " number 1 positioned in "
170  << coolTube.name() << " at (0,0,0) with no rotation";
171 
172  DDName ladderFull(DDSplit(ladder).first, DDSplit(ladder).second);
173  int copy = 1, iup = (-1) * outerFirst;
174  int copyoffset = number + 2;
175  for (int i = 1; i < number + 1; i++) {
176  double phi = i * dphi + 90 * CLHEP::deg - 0.5 * dphi + phiFineTune; //to start with the interface ladder
177  double phix, phiy, rrr, rrroffset;
178  string rots;
179  DDTranslation tran;
180  DDRotation rot;
181  iup = -iup;
182  double dr;
183  if ((i == 1) || (i == number / 2 + 1)) {
184  dr = coolRadius + 0.5 * ladderThick + ladderOffset; //interface ladder offset
185  } else {
186  dr = coolRadius + 0.5 * ladderThick;
187  }
188  if (i % 2 == 1) {
189  rrr = coolDist * cos(0.5 * dphi) + iup * dr + rOuterFineTune;
190  } else {
191  rrr = coolDist * cos(0.5 * dphi) + iup * dr + rInnerFineTune;
192  }
193  tran = DDTranslation(rrr * cos(phi), rrr * sin(phi), 0);
194  rots = idName + to_string(copy);
195  if (iup > 0)
196  phix = phi - 90 * CLHEP::deg;
197  else
198  phix = phi + 90 * CLHEP::deg;
199  phiy = phix + 90. * CLHEP::deg;
200  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
201  << "rotation: " << rots << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
202  << ", 0, 0";
203  rot = DDrot(DDName(rots, idNameSpace), 90 * CLHEP::deg, phix, 90 * CLHEP::deg, phiy, 0., 0.);
204  cpv.position(ladderFull, layer, copy, tran, rot);
205  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << ladderFull << " number " << copy << " positioned in "
206  << layer.name() << " at " << tran << " with " << rot;
207  copy++;
208  rrr = coolDist * cos(0.5 * dphi) + coolRadius / 2.;
209  rots = idName + to_string(i + 100);
210  phix = phi + 90. * CLHEP::deg;
211  if (iup < 0)
212  phix += dphi;
213  phiy = phix + 90. * CLHEP::deg;
214  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: Creating a new "
215  << "rotation: " << rots << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
216  << ", 0, 0";
217  tran = DDTranslation(rrr * cos(phi) - x2 * sin(phi), rrr * sin(phi) + x2 * cos(phi), 0);
218  rot = DDrot(DDName(rots, idNameSpace), 90 * CLHEP::deg, phix, 90 * CLHEP::deg, phiy, 0., 0.);
219  cpv.position(coolTubeHalf, layer, i + 1, tran, rot);
220  if ((i == 1) || (i == number / 2 + 1)) {
221  rrroffset = coolDist * cos(0.5 * dphi) + iup * ladderOffset + rOuterFineTune;
222  tran = DDTranslation(
223  rrroffset * cos(phi) - cool1Offset * sin(phi), rrroffset * sin(phi) + cool1Offset * cos(phi), 0);
224  cpv.position(coolTube, layer, copyoffset, tran, DDRotation());
225  copyoffset++;
226  tran = DDTranslation(
227  rrroffset * cos(phi) - cool2Offset * sin(phi), rrroffset * sin(phi) + cool2Offset * cos(phi), 0);
228  cpv.position(coolTube, layer, copyoffset, tran, DDRotation());
229  copyoffset++;
230  }
231  LogDebug("PixelGeom") << "DDPixBarLayerUpgradeAlgo test: " << coolTube.name() << " number " << i + 1
232  << " positioned in " << layer.name() << " at " << tran << " with " << rot;
233  }
234 }
235 
236 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDPixBarLayerUpgradeAlgo, "track:DDPixBarLayerUpgradeAlgo");
DDPixBarLayerUpgradeAlgo::ladder
string ladder
Definition: DDPixBarLayerUpgradeAlgo.cc:55
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
DDPixBarLayerUpgradeAlgo::tubeMatHalf
string tubeMatHalf
Definition: DDPixBarLayerUpgradeAlgo.cc:54
MessageLogger.h
DDPixBarLayerUpgradeAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDPixBarLayerUpgradeAlgo.cc:113
DDrot
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
DDPixBarLayerUpgradeAlgo::layerDz
double layerDz
Definition: DDPixBarLayerUpgradeAlgo.cc:44
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
DDPixBarLayerUpgradeAlgo
Definition: DDPixBarLayerUpgradeAlgo.cc:26
DDPixBarLayerUpgradeAlgo::coolMat
string coolMat
Definition: DDPixBarLayerUpgradeAlgo.cc:51
DDSplit.h
DDPixBarLayerUpgradeAlgo::outerFirst
int outerFirst
Definition: DDPixBarLayerUpgradeAlgo.cc:59
DDPixBarLayerUpgradeAlgo::cool1Offset
double cool1Offset
Definition: DDPixBarLayerUpgradeAlgo.cc:49
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
versionedElectronIDProducer_cfi.idName
idName
Definition: versionedElectronIDProducer_cfi.py:11
DDPixBarLayerUpgradeAlgo::idNameSpace
string idNameSpace
Definition: DDPixBarLayerUpgradeAlgo.cc:41
DDPixBarLayerUpgradeAlgo::coolThick
double coolThick
Definition: DDPixBarLayerUpgradeAlgo.cc:46
DDPixBarLayerUpgradeAlgo::DDPixBarLayerUpgradeAlgo
DDPixBarLayerUpgradeAlgo()
Definition: DDPixBarLayerUpgradeAlgo.cc:65
DDPixBarLayerUpgradeAlgo::phiFineTune
double phiFineTune
Definition: DDPixBarLayerUpgradeAlgo.cc:60
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDPixBarLayerUpgradeAlgo::ladderThick
double ladderThick
Definition: DDPixBarLayerUpgradeAlgo.cc:57
DDPixBarLayerUpgradeAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDPixBarLayerUpgradeAlgo.cc:71
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDPixBarLayerUpgradeAlgo::~DDPixBarLayerUpgradeAlgo
~DDPixBarLayerUpgradeAlgo() override
Definition: DDPixBarLayerUpgradeAlgo.cc:69
DDPixBarLayerUpgradeAlgo::tubeMat
string tubeMat
Definition: DDPixBarLayerUpgradeAlgo.cc:52
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDPixBarLayerUpgradeAlgo::coolRadius
double coolRadius
Definition: DDPixBarLayerUpgradeAlgo.cc:47
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDBase::name
const N & name() const
Definition: DDBase.h:59
DDSolidFactory::tubs
static DDSolid tubs(const DDName &name, double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)
Definition: DDSolid.cc:667
DDSolid.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
DDPixBarLayerUpgradeAlgo::rOuterFineTune
double rOuterFineTune
Definition: DDPixBarLayerUpgradeAlgo.cc:61
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDPixBarLayerUpgradeAlgo::rInnerFineTune
double rInnerFineTune
Definition: DDPixBarLayerUpgradeAlgo.cc:62
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDPixBarLayerUpgradeAlgo::coolDist
double coolDist
Definition: DDPixBarLayerUpgradeAlgo.cc:48
DDTypes.h
DDMaterial.h
DDPixBarLayerUpgradeAlgo::coolMatHalf
string coolMatHalf
Definition: DDPixBarLayerUpgradeAlgo.cc:53
createfilelist.int
int
Definition: createfilelist.py:10
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDLogicalPart.h
DDPixBarLayerUpgradeAlgo::ladderWidth
double ladderWidth
Definition: DDPixBarLayerUpgradeAlgo.cc:56
DDPixBarLayerUpgradeAlgo::ladderOffset
double ladderOffset
Definition: DDPixBarLayerUpgradeAlgo.cc:58
DDPixBarLayerUpgradeAlgo::genMat
string genMat
Definition: DDPixBarLayerUpgradeAlgo.cc:42
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
PVValHelper::ladder
Definition: PVValidationHelpers.h:73
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDPixBarLayerUpgradeAlgo::cool2Offset
double cool2Offset
Definition: DDPixBarLayerUpgradeAlgo.cc:50
pi
const Double_t pi
Definition: trackSplitPlot.h:36
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDPixBarLayerUpgradeAlgo::coolDz
double coolDz
Definition: DDPixBarLayerUpgradeAlgo.cc:45
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:98
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
DDPixBarLayerUpgradeAlgo::number
int number
Definition: DDPixBarLayerUpgradeAlgo.cc:43