CMS 3D CMS Logo

DDTIDRingAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
5 
6 using namespace std;
7 using namespace dd4hep;
8 using namespace cms;
9 using namespace cms_units::operators;
10 
11 static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
12  cms::DDNamespace ns(ctxt, e, true);
13  DDAlgoArguments args(ctxt, e);
14  Volume mother = ns.volume(args.parentName());
15  vector<string> moduleName = args.value<vector<string> >("ModuleName"); //Name of the module
16  string iccName = args.value<string>("ICCName"); //Name of the ICC
17  int number = args.value<int>("Number"); //Number of copies
18  double startAngle = args.value<double>("StartAngle"); //Phi offset
19  double rModule = args.value<double>("ModuleR"); //Location of module in R
20  vector<double> zModule = args.value<vector<double> >("ModuleZ"); // in Z
21  double rICC = args.value<double>("ICCR"); //Location of ICC in R
22  double sICC = args.value<double>("ICCShift"); //Shift of ICC per to R
23  vector<double> zICC = args.value<vector<double> >("ICCZ"); // in Z
24 
25  edm::LogVerbatim("TIDGeom") << "Parent " << mother.name() << "\tModule " << moduleName[0] << ", " << moduleName[1]
26  << "\tICC " << iccName << "\tNameSpace " << ns.name();
27  edm::LogVerbatim("TIDGeom") << "Parameters for positioning--"
28  << " StartAngle " << convertRadToDeg(startAngle) << " Copy Numbers " << number
29  << " Modules at R " << rModule << " Z " << zModule[0] << ", " << zModule[1]
30  << " ICCs at R " << rICC << " Z " << zICC[0] << ", " << zICC[1];
31  double theta = 90._deg;
32  double phiy = 0._deg;
33  double dphi = 2_pi / number;
34 
35  //Loop over modules
36  Volume icc = ns.volume(iccName);
37  Volume mod0 = ns.volume(moduleName[0]);
38  Volume mod1 = ns.volume(moduleName[1]);
39  for (int i = 0; i < number; i++) {
40  //First the module
41  double phiz = startAngle + i * dphi;
42  double xpos = rModule * cos(phiz);
43  double ypos = rModule * sin(phiz);
44  double zpos, thetay, phix;
45  Volume module;
46  if (i % 2 == 0) {
47  phix = phiz + 90._deg;
48  thetay = 0._deg;
49  zpos = zModule[0];
50  module = mod0;
51  } else {
52  phix = phiz - 90._deg;
53  thetay = 180._deg;
54  zpos = zModule[1];
55  module = mod1;
56  }
57 
58  // stereo face inside toward structure, rphi face outside
59  phix = phix - 180._deg;
60  thetay = thetay + 180._deg;
61  //
62  Position trmod(xpos, ypos, zpos);
63  Rotation3D rotation = makeRotation3D(theta, phix, thetay, phiy, theta, phiz);
64  // int copyNr = i+1;
65  /* PlacedVolume pv = */ mother.placeVolume(module, i + 1, Transform3D(rotation, trmod));
66  edm::LogVerbatim("TIDGeom") << module.name() << " number " << i + 1 << " positioned in " << mother.name() << " at "
67  << trmod << " with " << rotation;
68  //Now the ICC
69  if (i % 2 == 0) {
70  zpos = zICC[0];
71  xpos = rICC * cos(phiz) + sICC * sin(phiz);
72  ypos = rICC * sin(phiz) - sICC * cos(phiz);
73  } else {
74  zpos = zICC[1];
75  xpos = rICC * cos(phiz) - sICC * sin(phiz);
76  ypos = rICC * sin(phiz) + sICC * cos(phiz);
77  }
78  // int copyNr = i+1;
79  Position tricc(xpos, ypos, zpos);
80  /* PlacedVolume pv = */ mother.placeVolume(icc, i + 1, Transform3D(rotation, tricc));
81  edm::LogVerbatim("TIDGeom") << icc.name() << " number " << i + 1 << " positioned in " << mother.name() << " at "
82  << tricc << " with " << rotation;
83  }
84  return 1;
85 }
86 
87 // first argument is the type from the xml file
88 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIDRingAlgo, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
cms_units::operators
Definition: CMSUnits.h:13
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
cms::DDParsingContext
Definition: DDParsingContext.h:14
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:22
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDTIDRingAlgo.cc:11
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDPlugins.h
EcalCalibMonitorClient_cfi.moduleName
moduleName
Definition: EcalCalibMonitorClient_cfi.py:17
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
callgraph.module
module
Definition: callgraph.py:61
align::Detector
Definition: StructureType.h:92
std
Definition: JetResolutionObject.h:76
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
dd4hep
Definition: DDPlugins.h:8
CMSUnits.h
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:79
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:264
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37