CMS 3D CMS Logo

DDMuonAngular.cc
Go to the documentation of this file.
1 // File: DDMuonAngular.cc
3 // Description: Position inside the mother according to (eta,phi)
5 
6 #include <cmath>
7 #include <algorithm>
8 #include <map>
9 #include <string>
10 #include <vector>
11 
20 
21 class DDMuonAngular : public DDAlgorithm {
22 public:
23  //Constructor and Destructor
24  DDMuonAngular();
25  ~DDMuonAngular() override;
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  double startAngle; //Start angle
37  double stepAngle; //Step angle
38  double zoffset; //Offset in z
39  int n; //Mumber of copies
40  int startCopyNo; //Start copy Number
41  int incrCopyNo; //Increment copy Number
42 
43  std::string rotns; //Namespace for rotation matrix
44  std::string idNameSpace; //Namespace of this and ALL sub-parts
45  std::string childName; //Children name
46 };
47 
48 using namespace geant_units::operators;
49 
50 //#define EDM_ML_DEBUG
51 
53 #ifdef EDM_ML_DEBUG
54  edm::LogVerbatim("MuonGeom") << "DDMuonAngular: Creating an instance";
55 #endif
56 }
57 
59 
61  const DDVectorArguments&,
62  const DDMapArguments&,
63  const DDStringArguments& sArgs,
64  const DDStringVectorArguments&) {
65  startAngle = nArgs["startAngle"];
66  stepAngle = nArgs["stepAngle"];
67  zoffset = nArgs["zoffset"];
68  n = int(nArgs["n"]);
69  startCopyNo = int(nArgs["startCopyNo"]);
70  incrCopyNo = int(nArgs["incrCopyNo"]);
71 #ifdef EDM_ML_DEBUG
72  edm::LogVerbatim("MuonGeom") << "DDMuonAngular: Parameters for positioning-- " << n << " copies in steps of "
73  << convertRadToDeg(stepAngle) << " from " << convertRadToDeg(startAngle) << " \tZoffest "
74  << zoffset << "\tStart and inremental copy nos " << startCopyNo << ", " << incrCopyNo;
75 #endif
76  rotns = sArgs["RotNameSpace"];
77  idNameSpace = DDCurrentNamespace::ns();
78  childName = sArgs["ChildName"];
79 #ifdef EDM_ML_DEBUG
80  edm::LogVerbatim("MuonGeom") << "DDMuonAngular debug: Parent " << parent().name() << "\tChild " << childName
81  << "\tNameSpace " << idNameSpace << "\tRotation Namespace " << rotns;
82 #endif
83 }
84 
86  double phi = startAngle;
87  int copyNo = startCopyNo;
88 
89  for (int ii = 0; ii < n; ii++) {
90  double phitmp = phi;
91  if (phitmp >= 2._pi)
92  phitmp -= 2._pi;
94  std::string rotstr("NULL");
95 
96  if (std::abs(phitmp) >= 1.0_deg) {
97  rotstr = "R" + formatAsDegrees(phitmp);
98  rotation = DDRotation(DDName(rotstr, rotns));
99  if (!rotation) {
100 #ifdef EDM_ML_DEBUG
101  edm::LogVerbatim("MuonGeom") << "DDMuonAngular: Creating a new rotation " << DDName(rotstr, idNameSpace)
102  << "\t90, " << convertRadToDeg(phitmp) << ", 90, "
103  << convertRadToDeg(phitmp + 90._deg) << ", 0, 0";
104 #endif
105  rotation = DDrot(DDName(rotstr, rotns), 90._deg, phitmp, 90._deg, 90._deg + phitmp, 0., 0.);
106  }
107  }
108 
109  DDTranslation tran(0, 0, zoffset);
110 
111  DDName parentName = parent().name();
112  cpv.position(DDName(childName, idNameSpace), parentName, copyNo, tran, rotation);
113 #ifdef EDM_ML_DEBUG
114  edm::LogVerbatim("MuonGeom") << "DDMuonAngular: " << DDName(childName, idNameSpace) << " number " << copyNo
115  << " positioned in " << parentName << " at " << tran << " with " << rotstr << " "
116  << rotation;
117 #endif
118  phi += stepAngle;
119  copyNo += incrCopyNo;
120  }
121 }
122 
123 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDMuonAngular, "muon:DDMuonAngular");
PluginFactory.h
DDCurrentNamespace.h
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
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
DDMuonAngular::incrCopyNo
int incrCopyNo
Definition: DDMuonAngular.cc:41
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
DDMuonAngular::stepAngle
double stepAngle
Definition: DDMuonAngular.cc:37
DDMuonAngular::rotns
std::string rotns
Definition: DDMuonAngular.cc:43
geant_units::operators
Definition: GeantUnits.h:18
DDMuonAngular::startCopyNo
int startCopyNo
Definition: DDMuonAngular.cc:40
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDMuonAngular::~DDMuonAngular
~DDMuonAngular() override
Definition: DDMuonAngular.cc:58
formatAsDegrees
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:68
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDMuonAngular::idNameSpace
std::string idNameSpace
Definition: DDMuonAngular.cc:44
GeantUnits.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
DDLogicalPart.h
DDMuonAngular::n
int n
Definition: DDMuonAngular.cc:39
ReadMapType< double >
DDAlgorithm.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDMuonAngular::execute
void execute(DDCompactView &cpv) override
Definition: DDMuonAngular.cc:85
DDMuonAngular::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDMuonAngular.cc:60
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDMuonAngular::zoffset
double zoffset
Definition: DDMuonAngular.cc:38
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDMuonAngular::childName
std::string childName
Definition: DDMuonAngular.cc:45
DDMuonAngular
Definition: DDMuonAngular.cc:21
DDAlgorithmFactory.h
DDMuonAngular::DDMuonAngular
DDMuonAngular()
Definition: DDMuonAngular.cc:52
class-composition.parent
parent
Definition: class-composition.py:88
cuy.ii
ii
Definition: cuy.py:590
DDMuonAngular::startAngle
double startAngle
Definition: DDMuonAngular.cc:36
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:76
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18