CMS 3D CMS Logo

DDMTDLinear.cc
Go to the documentation of this file.
15 
16 #include <cmath>
17 #include <memory>
18 
19 using namespace geant_units::operators;
20 using namespace angle_units::operators;
21 
22 class DDMTDLinear : public DDAlgorithm {
23 public:
25  : m_n(1), m_startCopyNo(1), m_incrCopyNo(1), m_theta(0.), m_phi(0.), m_delta(0.), m_phi_obj(0.), m_theta_obj(0.) {}
26 
27  void initialize(const DDNumericArguments& nArgs,
28  const DDVectorArguments& vArgs,
29  const DDMapArguments& mArgs,
30  const DDStringArguments& sArgs,
31  const DDStringVectorArguments& vsArgs) override;
32 
33  void execute(DDCompactView& cpv) override;
34 
35 private:
36  int m_n; //Number of copies
37  int m_startCopyNo; //Start Copy number
38  int m_incrCopyNo; //Increment in Copy number
39  double m_theta; //Theta
40  double m_phi; //Phi dir[Theta,Phi] ... unit-std::vector in direction Theta, Phi
41  double m_delta; //Delta - distance between two subsequent positions along dir[Theta,Phi]
42  double m_phi_obj; //Phi angle to rotate volumes (indipendent from m_phi traslation direction)
43  double m_theta_obj; //Theta angle to rotate volumes
44  std::vector<double> m_base; //Base values - a 3d-point where the offset is calculated from
45  //base is optional, if omitted base=(0,0,0)
46  std::pair<std::string, std::string> m_childNmNs; //Child name
47  //Namespace of the child
48 };
49 
51  const DDVectorArguments& vArgs,
52  const DDMapArguments&,
53  const DDStringArguments& sArgs,
54  const DDStringVectorArguments&) {
55  m_n = int(nArgs["N"]);
56  m_startCopyNo = int(nArgs["StartCopyNo"]);
57  m_incrCopyNo = int(nArgs["IncrCopyNo"]);
58  m_theta = nArgs["Theta"];
59  m_phi = nArgs["Phi"];
60  m_delta = nArgs["Delta"];
61  m_base = vArgs["Base"];
62  m_phi_obj = nArgs["Phi_obj"];
63  m_theta_obj = nArgs["Theta_obj"];
64 
65  LogDebug("DDAlgorithm") << "DDMTDLinear: Parameters for position"
66  << "ing:: n " << m_n << " Direction Theta, Phi, Offset, Delta " << convertRadToDeg(m_theta)
67  << " " << convertRadToDeg(m_phi) << " "
68  << " " << convertRadToDeg(m_delta) << " Base " << m_base[0] << ", " << m_base[1] << ", "
69  << m_base[2] << "Objects placement Phi_obj, Theta_obj " << convertRadToDeg(m_phi_obj) << " "
70  << convertRadToDeg(m_theta_obj);
71 
72  m_childNmNs = DDSplit(sArgs["ChildName"]);
73  if (m_childNmNs.second.empty())
74  m_childNmNs.second = DDCurrentNamespace::ns();
75 
76  DDName parentName = parent().name();
77  LogDebug("DDAlgorithm") << "DDMTDLinear: Parent " << parentName << "\tChild " << m_childNmNs.first << " NameSpace "
78  << m_childNmNs.second;
79 }
80 
82  DDName mother = parent().name();
83  DDName ddname(m_childNmNs.first, m_childNmNs.second);
84  int copy = m_startCopyNo;
85 
86  DDTranslation direction(sin(m_theta) * cos(m_phi), sin(m_theta) * sin(m_phi), cos(m_theta));
87 
88  DDTranslation basetr(m_base[0], m_base[1], m_base[2]);
89 
90  //rotation is in xy plane
91  double thetaZ = m_theta_obj - 0.5_pi;
92  double phiZ = m_phi_obj;
93  double thetaX = m_theta_obj;
94  double thetaY = m_theta_obj;
95  double phiX = m_phi_obj;
96  double phiY = m_phi_obj + 0.5_pi;
97 
98  DDRotation rotation = DDRotation("Rotation");
99 
100  if (!rotation) {
101  LogDebug("DDAlgorithm") << "DDMTDLinear: Creating a new "
102  << "rotation for " << ddname;
103 
104  rotation = DDrot("Rotation", DDcreateRotationMatrix(thetaX, phiX, thetaY, phiY, thetaZ, phiZ));
105  }
106 
107  for (int i = 0; i < m_n; ++i) {
108  DDTranslation tran = basetr + (double(i) * m_delta) * direction;
109  cpv.position(ddname, mother, copy, tran, rotation);
110  LogDebug("DDAlgorithm") << "DDMTDLinear: " << m_childNmNs.second << ":" << m_childNmNs.first << " number " << copy
111  << " positioned in " << mother << " at " << tran << " with " << rotation;
112  copy += m_incrCopyNo;
113  }
114 }
115 
PluginFactory.h
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:355
DDTransform.h
MessageLogger.h
DDMTDLinear::DDMTDLinear
DDMTDLinear()
Definition: DDMTDLinear.cc:24
DDrot
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
DDSplit.h
DDMTDLinear::m_phi_obj
double m_phi_obj
Definition: DDMTDLinear.cc:42
geant_units::operators
Definition: GeantUnits.h:18
DDCompactView.h
DDMTDLinear::execute
void execute(DDCompactView &cpv) override
Definition: DDMTDLinear.cc:81
DDMTDLinear::m_theta_obj
double m_theta_obj
Definition: DDMTDLinear.cc:43
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
DDMTDLinear::m_delta
double m_delta
Definition: DDMTDLinear.cc:41
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDMTDLinear::m_phi
double m_phi
Definition: DDMTDLinear.cc:40
DDMTDLinear::m_childNmNs
std::pair< std::string, std::string > m_childNmNs
Definition: DDMTDLinear.cc:46
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
GeantUnits.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
angle_units::operators
Definition: angle_units.h:11
DDTypes.h
DDMTDLinear::m_n
int m_n
Definition: DDMTDLinear.cc:36
createfilelist.int
int
Definition: createfilelist.py:10
DDTranslation.h
DOFs::thetaY
Definition: AlignPCLThresholdsWriter.cc:37
DDLogicalPart.h
DDMTDLinear::m_base
std::vector< double > m_base
Definition: DDMTDLinear.cc:44
DDMTDLinear::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDMTDLinear.cc:50
DDMTDLinear
Definition: DDMTDLinear.cc:22
DOFs::thetaX
Definition: AlignPCLThresholdsWriter.cc:37
ReadMapType< double >
DDAlgorithm.h
DDMTDLinear::m_startCopyNo
int m_startCopyNo
Definition: DDMTDLinear.cc:37
DOFs::thetaZ
Definition: AlignPCLThresholdsWriter.cc:37
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDName.h
DDMTDLinear::m_theta
double m_theta
Definition: DDMTDLinear.cc:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDcreateRotationMatrix
std::unique_ptr< DDRotationMatrix > DDcreateRotationMatrix(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
create a new DDRotationMatrix in the GEANT3 style.
Definition: DDRotation.cc:120
DDMTDLinear::m_incrCopyNo
int m_incrCopyNo
Definition: DDMTDLinear.cc:38
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:66
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18
DDRotationMatrix.h