CMS 3D CMS Logo

DDTrackerAngular.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  // Header section of original DDTrackerAngular.h
15  int n = args.value<int>("N");
16  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
17  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
18  double rangeAngle = args.value<double>("RangeAngle"); //Range in angle
19  double startAngle = args.value<double>("StartAngle"); //Start anle
20  double radius = args.value<double>("Radius"); //Radius
21  vector<double> center = args.value<vector<double> >("Center"); //Phi values
22  Volume mother = ns.volume(args.parentName());
23  Volume child = ns.volume(args.value<string>("ChildName"));
24 
25  double delta = 0e0; //Increment in phi
26  // Code section of original DDTrackerAngular.cc
27  if (fabs(rangeAngle - 360.0_deg) < 0.001_deg) {
28  delta = rangeAngle / double(n);
29  } else if (n > 1) {
30  delta = rangeAngle / double(n - 1);
31  }
32 
33  edm::LogVerbatim("TrackerGeom") << "DDTrackerAngular debug: Parameters for positioning:: n " << n
34  << " Start, Range, Delta " << convertRadToDeg(startAngle) << " "
35  << convertRadToDeg(rangeAngle) << " " << convertRadToDeg(delta) << " Radius "
36  << radius << " Centre " << center[0] << ", " << center[1] << ", " << center[2];
37  edm::LogVerbatim("TrackerGeom") << "DDTrackerAngular debug: Parent " << mother.name() << "\tChild " << child.name()
38  << " NameSpace " << ns.name();
39 
40  double theta = 90._deg;
41  int copy = startCopyNo;
42  double phi = startAngle;
43  for (int i = 0; i < n; i++) {
44  double phix = phi;
45  double phiy = phix + 90._deg;
46  double phideg = convertRadToDeg(phix);
47 
48  Rotation3D rotation;
49  if (phideg != 0) {
50  string rotstr = ns.nsName(child.name()) + std::to_string(phideg * 10.);
51  auto irot = ctxt.rotations.find(ns.prepend(rotstr));
52  if (irot != ctxt.rotations.end()) {
53  rotation = ns.rotation(ns.prepend(rotstr));
54  } else {
55  edm::LogVerbatim("TrackerGeom") << "DDTrackerAngular Creating a new "
56  << "rotation: " << rotstr << "\t90., " << convertRadToDeg(phix) << ", 90.,"
57  << convertRadToDeg(phiy) << ", 0, 0";
58  RotationZYX rot;
59  rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
60  }
61  }
62 
63  double xpos = radius * cos(phi) + center[0];
64  double ypos = radius * sin(phi) + center[1];
65  double zpos = center[2];
66  Position tran(xpos, ypos, zpos);
67  mother.placeVolume(child, copy, Transform3D(rotation, tran));
68  edm::LogVerbatim("TrackerGeom") << "DDTrackerAngular test " << child.name() << " number " << copy
69  << " positioned in " << mother.name() << " at " << tran << " with " << rotation;
70  copy += incrCopyNo;
71  phi += delta;
72  }
73  return 1;
74 }
75 
76 // first argument is the type from the xml file
77 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerAngular, 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
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:30
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
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
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:66
cms::DDParsingContext::rotations
tbb::concurrent_unordered_map< std::string, dd4hep::Rotation3D > rotations
Definition: DDParsingContext.h:37
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
cms::DDNamespace::rotation
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:130
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
DDPlugins.h
edm::LogVerbatim
Definition: MessageLogger.h:297
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
align::Detector
Definition: StructureType.h:86
cms::DDNamespace::nsName
static std::string nsName(const std::string &)
Definition: DDNamespace.cc:89
std
Definition: JetResolutionObject.h:76
dd4hep
Definition: DDPlugins.h:8
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
Definition: DDTrackerAngular.cc:11
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
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