CMS 3D CMS Logo

DDTotemAngular.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <algorithm>
3 #include <map>
4 #include <string>
5 #include <vector>
6 
16 
17 using namespace geant_units::operators;
18 
19 //#define EDM_ML_DEBUG
20 
21 class DDTotemAngular : public DDAlgorithm {
22 public:
23  //Constructor and Destructor
25 
26  void initialize(const DDNumericArguments& nArgs,
27  const DDVectorArguments& vArgs,
28  const DDMapArguments& mArgs,
29  const DDStringArguments& sArgs,
30  const DDStringVectorArguments& vsArgs) override;
31 
32  void execute(DDCompactView& cpv) override;
33 
34 private:
35  double startAngle_; //Start angle
36  double stepAngle_; //Step angle
37  double zoffset_; //Offset in z
38  double roffset_; //Offset in R
39  int n_; //Number 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 
49 #ifdef EDM_ML_DEBUG
50  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: Creating an instance";
51 #endif
52 }
53 
55  const DDVectorArguments&,
56  const DDMapArguments&,
57  const DDStringArguments& sArgs,
58  const DDStringVectorArguments&) {
59  startAngle_ = nArgs["startAngle"];
60  stepAngle_ = nArgs["stepAngle"];
61  zoffset_ = nArgs["zoffset"];
62  roffset_ = nArgs["roffset"];
63  n_ = int(nArgs["n"]);
64  startCopyNo_ = int(nArgs["startCopyNo"]);
65  incrCopyNo_ = int(nArgs["incrCopyNo"]);
66 #ifdef EDM_ML_DEBUG
67  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: Parameters for positioning-- " << n_ << " copies in steps of "
68  << convertRadToDeg(stepAngle_) << " from " << convertRadToDeg(startAngle_)
69  << " \tZoffset " << zoffset_ << " \tRoffset " << roffset_
70  << "\tStart and inremental copy nos " << startCopyNo_ << ", " << incrCopyNo_;
71 #endif
72  rotns_ = sArgs["RotNameSpace"];
73  idNameSpace_ = DDCurrentNamespace::ns();
74  childName_ = sArgs["ChildName"];
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular debug: Parent " << parent().name() << "\tChild " << childName_
77  << "\tNameSpace " << idNameSpace_ << "\tRotation Namespace " << rotns_;
78 #endif
79 }
80 
82  double phi = startAngle_;
83  int copyNo = startCopyNo_;
84 
85  for (int ii = 0; ii < n_; ii++) {
86  Geom::Phi0To2pi<double> phitmp = phi;
88  std::string rotstr("NULL");
89 
90  rotstr = "RT" + formatAsDegrees(phitmp);
91  rotation = DDRotation(DDName(rotstr, rotns_));
92  if (!rotation) {
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: Creating a new rotation " << DDName(rotstr, rotns_)
95  << "\t90, " << convertRadToDeg(phitmp + 90._deg) << ", 0, 0, 90, "
96  << convertRadToDeg(phitmp);
97 #endif
98  rotation = DDrot(DDName(rotstr, rotns_), 90._deg, 90._deg + phitmp, 0., 0., 90._deg, phitmp);
99  }
100 
101  DDTranslation tran(roffset_ * cos(phi), roffset_ * sin(phi), zoffset_);
102 
103  DDName parentName = parent().name();
104  cpv.position(DDName(childName_, idNameSpace_), parentName, copyNo, tran, rotation);
105 #ifdef EDM_ML_DEBUG
106  edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: " << DDName(childName_, idNameSpace_) << " number " << copyNo
107  << " positioned in " << parentName << " at " << tran << " with " << rotstr << " "
108  << rotation;
109 #endif
110  phi += stepAngle_;
111  copyNo += incrCopyNo_;
112  }
113 }
114 
115 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTotemAngular, "forward:DDTotemAngular");
Phi.h
DDTotemAngular::zoffset_
double zoffset_
Definition: DDTotemAngular.cc:37
PluginFactory.h
DDCurrentNamespace.h
MessageLogger.h
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
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
DDTotemAngular::idNameSpace_
std::string idNameSpace_
Definition: DDTotemAngular.cc:44
geant_units::operators
Definition: GeantUnits.h:18
DDTotemAngular::startCopyNo_
int startCopyNo_
Definition: DDTotemAngular.cc:40
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
DDTotemAngular::DDTotemAngular
DDTotemAngular()
Definition: DDTotemAngular.cc:48
DDTotemAngular
Definition: DDTotemAngular.cc:21
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
formatAsDegrees
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:68
DDTotemAngular::execute
void execute(DDCompactView &cpv) override
Definition: DDTotemAngular.cc:81
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDTotemAngular::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDTotemAngular.cc:54
DDTotemAngular::rotns_
std::string rotns_
Definition: DDTotemAngular.cc:43
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDTotemAngular::incrCopyNo_
int incrCopyNo_
Definition: DDTotemAngular.cc:41
DDTotemAngular::roffset_
double roffset_
Definition: DDTotemAngular.cc:38
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
GeantUnits.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTotemAngular::childName_
std::string childName_
Definition: DDTotemAngular.cc:45
DDTypes.h
DDTotemAngular::stepAngle_
double stepAngle_
Definition: DDTotemAngular.cc:36
createfilelist.int
int
Definition: createfilelist.py:10
Geom::Phi
Definition: Phi.h:52
DDLogicalPart.h
ReadMapType< double >
DDTotemAngular::startAngle_
double startAngle_
Definition: DDTotemAngular.cc:35
DDAlgorithm.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDTotemAngular::n_
int n_
Definition: DDTotemAngular.cc:39
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
cuy.ii
ii
Definition: cuy.py:590
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