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, SensitiveDetector& /* sens */) {
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  LogDebug("TIDGeom") << "Parent " << mother.name() << "\tModule " << moduleName[0] << ", " << moduleName[1] << "\tICC "
26  << iccName << "\tNameSpace " << ns.name();
27  LogDebug("TIDGeom") << "Parameters for positioning--"
28  << " StartAngle " << convertRadToDeg(startAngle) << " Copy Numbers " << number << " Modules at R "
29  << rModule << " Z " << zModule[0] << ", " << zModule[1] << " ICCs at R " << rICC << " Z "
30  << 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  LogDebug("TIDGeom") << module.name() << " number " << i + 1 << " positioned in " << mother.name() << " at " << trmod
67  << " 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  LogDebug("TIDGeom") << iccName << " number " << i + 1 << " positioned in " << mother.name() << " at " << tricc
82  << " 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:355
cms_units::operators
Definition: CMSUnits.h:13
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:30
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:16
cms::makeRotation3D
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
SensitiveDetector
Definition: SensitiveDetector.h:25
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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:62
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDPlugins.h
EcalCalibMonitorClient_cfi.moduleName
moduleName
Definition: EcalCalibMonitorClient_cfi.py:17
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
Definition: DDTIDRingAlgo.cc:11
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
module
Definition: vlib.h:198
align::Detector
Definition: StructureType.h:86
std
Definition: JetResolutionObject.h:76
dd4hep
Definition: DDPlugins.h:8
CMSUnits.h
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:68
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:190
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37