CMS 3D CMS Logo

DDMTDLinear.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
5 #include <Math/Cartesian3D.h>
6 #include <Math/DisplacementVector3D.h>
8 
9 using namespace std;
10 using namespace dd4hep;
11 using namespace cms;
12 using namespace cms_units::operators;
13 
14 using DD3Vector = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double> >;
15 
16 static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
17  cms::DDNamespace ns(ctxt, e, true);
18  DDAlgoArguments args(ctxt, e);
19 
20  int n = args.value<int>("N");
21  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
22  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
23  double theta = args.find("Theta") ? args.value<double>("Theta") : 0.;
24  double phi = args.find("Phi") ? args.value<double>("Phi") : 0.;
25  double theta_obj = args.find("Theta_obj") ? args.value<double>("Theta_obj") : 0.;
26  double phi_obj = args.find("Phi_obj") ? args.value<double>("Phi_obj") : 0.;
27  double delta = args.find("Delta") ? args.value<double>("Delta") : 0.;
28  vector<double> base = args.value<vector<double> >("Base");
29  Volume mother = ns.volume(args.parentName());
30  Volume child = ns.volume(args.value<string>("ChildName"));
31  int copy = startCopyNo;
32 
33  LogDebug("DDAlgorithm") << "DDMTDLinear: Parameters for positioning:: n " << n << " Direction Theta, Phi, Delta "
34  << convertRadToDeg(theta) << " " << convertRadToDeg(phi) << " " << convertRadToDeg(delta)
35  << " Base " << base[0] << ", " << base[1] << ", " << base[2] << convertRadToDeg(theta_obj)
36  << " " << convertRadToDeg(phi_obj);
37 
38  LogDebug("DDAlgorithm") << "DDMTDLinear: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
39  << ns.name();
40 
41  Position direction(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
42 
43  Position basetr(base[0], base[1], base[2]);
44 
45  //rotation is in xy plane
46  double thetaZ = theta_obj - 0.5_pi;
47  double phiZ = phi_obj;
48  double thetaX = theta_obj;
49  double thetaY = theta_obj;
50  double phiX = phi_obj;
51  double phiY = phi_obj + 0.5_pi;
52 
53  Rotation3D rotation = makeRotation3D(thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
54 
55  for (int i = 0; i < n; ++i) {
56  Position tran = basetr + (double(i) * delta) * direction;
57  mother.placeVolume(child, copy, Transform3D(rotation, tran));
58  LogDebug("DDAlgorithm") << "DDMTDLinear: " << child.name() << " number " << copy << " positioned in "
59  << mother.name() << " at " << tran << " with " << rotation;
60 
61  copy += incrCopyNo;
62  }
63 
64  return 1;
65 }
66 
67 // first argument is the type from the xml file
68 DECLARE_DDCMS_DETELEMENT(DDCMS_mtd_DDMTDLinear, 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
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
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: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: DDMTDLinear.cc:16
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
DD3Vector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
Definition: PGeometricDetBuilder.cc:20
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
GeantUnits.h
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
DDPlugins.h
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
DOFs::thetaY
Definition: AlignPCLThresholdsWriter.cc:37
DOFs::thetaX
Definition: AlignPCLThresholdsWriter.cc:37
align::Detector
Definition: StructureType.h:92
std
Definition: JetResolutionObject.h:76
DOFs::thetaZ
Definition: AlignPCLThresholdsWriter.cc:37
dd4hep
Definition: DDPlugins.h:8
CMSUnits.h
child
Definition: simpleInheritance.h:11
newFWLiteAna.base
base
Definition: newFWLiteAna.py:92
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