CMS 3D CMS Logo

DDTrackerPhiAltAlgo.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  Volume child = ns.volume(args.childName());
16  double tilt = args.value<double>("Tilt"); //Tilt of the module
17  double startAngle = args.value<double>("StartAngle"); //offset in phi
18  double rangeAngle = args.value<double>("RangeAngle"); //Maximum range in phi
19  double radiusIn = args.value<double>("RadiusIn"); //Inner radius
20  double radiusOut = args.value<double>("RadiusOut"); //Outer radius
21  double zpos = args.value<double>("ZPosition"); //z position
22  int number = args.value<int>("Number"); //Number of copies
23  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; //Start copy number
24  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1; //Increment in copy number
25 
26  LogDebug("TrackerGeom") << "Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name();
27  LogDebug("TrackerGeom") << "Parameters for positioning-- Tilt " << tilt << "\tStartAngle "
28  << convertRadToDeg(startAngle) << "\tRangeAngle " << convertRadToDeg(rangeAngle) << "\tRin "
29  << radiusIn << "\tRout " << radiusOut << "\t ZPos " << zpos << "\tCopy Numbers " << number
30  << " Start/Increment " << startCopyNo << ", " << incrCopyNo;
31 
32  if (number > 0) {
33  double theta = 90._deg;
34  double dphi;
35  if (number == 1 || fabs(rangeAngle - 360.0_deg) < 0.001_deg)
36  dphi = rangeAngle / number;
37  else
38  dphi = rangeAngle / (number - 1);
39  int copyNo = startCopyNo;
40 
41  for (int i = 0; i < number; i++) {
42  double phi = startAngle + i * dphi;
43  double phix = phi - tilt + 90._deg;
44  double phiy = phix + 90._deg;
45  double phideg = convertRadToDeg(phix);
46 
47  Rotation3D rotation;
48  if (phideg != 0) {
49  rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
50  }
51 
52  double xpos, ypos;
53  if (i % 2 == 0) {
54  xpos = radiusIn * cos(phi);
55  ypos = radiusIn * sin(phi);
56  } else {
57  xpos = radiusOut * cos(phi);
58  ypos = radiusOut * sin(phi);
59  }
60  Position tran(xpos, ypos, zpos);
61  /* PlacedVolume pv = */ mother.placeVolume(child, copyNo, Transform3D(rotation, tran));
62  LogDebug("TrackerGeom") << "" << child.name() << " number " << copyNo << " positioned in " << mother.name()
63  << " at " << tran << " with " << rotation;
64  copyNo += incrCopyNo;
65  }
66  }
67  return 1;
68 }
69 
70 // first argument is the type from the xml file
71 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerPhiAltAlgo, 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
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
Definition: DDTrackerPhiAltAlgo.cc:11
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
align::Detector
Definition: StructureType.h:86
std
Definition: JetResolutionObject.h:76
dd4hep
Definition: DDPlugins.h:8
CMSUnits.h
child
Definition: simpleInheritance.h:11
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