CMS 3D CMS Logo

DDTECPhiAlgo.cc
Go to the documentation of this file.
1 // File: DDTECPhiAlgo.cc
3 // Description: Position n copies inside and outside Z at alternate phi values
5 
12 #include "CLHEP/Units/GlobalPhysicalConstants.h"
13 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 
15 #include <cmath>
16 #include <algorithm>
17 #include <map>
18 #include <string>
19 #include <vector>
20 
21 using namespace std;
22 
23 class DDTECPhiAlgo : public DDAlgorithm {
24 public:
25  //Constructor and Destructor
26  DDTECPhiAlgo();
27  ~DDTECPhiAlgo() override;
28 
29  void initialize(const DDNumericArguments& nArgs,
30  const DDVectorArguments& vArgs,
31  const DDMapArguments& mArgs,
32  const DDStringArguments& sArgs,
33  const DDStringVectorArguments& vsArgs) override;
34 
35  void execute(DDCompactView& cpv) override;
36 
37 private:
38  double startAngle; //Start angle
39  double incrAngle; //Increment in angle
40  double zIn; //z position for the even ones
41  double zOut; //z position for the odd ones
42  int number; //Number of copies
43  int startCopyNo; //Start copy number
44  int incrCopyNo; //Increment in copy number
45 
46  string idNameSpace; //Namespace of this and ALL sub-parts
47  string childName; //Child name
48 };
49 
50 DDTECPhiAlgo::DDTECPhiAlgo() { LogDebug("TECGeom") << "DDTECPhiAlgo info: Creating an instance"; }
51 
53 
55  const DDVectorArguments&,
56  const DDMapArguments&,
57  const DDStringArguments& sArgs,
58  const DDStringVectorArguments&) {
59  startAngle = nArgs["StartAngle"];
60  incrAngle = nArgs["IncrAngle"];
61  zIn = nArgs["ZIn"];
62  zOut = nArgs["ZOut"];
63  number = int(nArgs["Number"]);
64  startCopyNo = int(nArgs["StartCopyNo"]);
65  incrCopyNo = int(nArgs["IncrCopyNo"]);
66 
67  LogDebug("TECGeom") << "DDTECPhiAlgo debug: Parameters for "
68  << "positioning--"
69  << "\tStartAngle " << startAngle / CLHEP::deg << "\tIncrAngle " << incrAngle / CLHEP::deg
70  << "\tZ in/out " << zIn << ", " << zOut << "\tCopy Numbers " << number << " Start/Increment "
71  << startCopyNo << ", " << incrCopyNo;
72 
73  idNameSpace = DDCurrentNamespace::ns();
74  childName = sArgs["ChildName"];
75  DDName parentName = parent().name();
76  LogDebug("TECGeom") << "DDTECPhiAlgo debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
77  << idNameSpace;
78 }
79 
81  if (number > 0) {
82  double theta = 90. * CLHEP::deg;
83  int copyNo = startCopyNo;
84 
85  DDName mother = parent().name();
86  DDName child(DDSplit(childName).first, DDSplit(childName).second);
87  for (int i = 0; i < number; i++) {
88  double phix = startAngle + i * incrAngle;
89  double phiy = phix + 90. * CLHEP::deg;
90  double phideg = phix / CLHEP::deg;
91 
93  string rotstr = DDSplit(childName).first + to_string(phideg * 10.);
94  rotation = DDRotation(DDName(rotstr, idNameSpace));
95  if (!rotation) {
96  LogDebug("TECGeom") << "DDTECPhiAlgo test: Creating a new "
97  << "rotation " << rotstr << "\t" << theta / CLHEP::deg << ", " << phix / CLHEP::deg << ", "
98  << theta / CLHEP::deg << ", " << phiy / CLHEP::deg << ", 0, 0";
99  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
100  }
101 
102  double zpos = zOut;
103  if (i % 2 == 0)
104  zpos = zIn;
105  DDTranslation tran(0., 0., zpos);
106 
107  cpv.position(child, mother, copyNo, tran, rotation);
108  LogDebug("TECGeom") << "DDTECPhiAlgo test: " << child << " number " << copyNo << " positioned in " << mother
109  << " at " << tran << " with " << rotation;
110  copyNo += incrCopyNo;
111  }
112  }
113 }
114 
115 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTECPhiAlgo, "track:DDTECPhiAlgo");
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:355
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
DDTECPhiAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDTECPhiAlgo.cc:54
DDTECPhiAlgo::childName
string childName
Definition: DDTECPhiAlgo.cc:47
DDTECPhiAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDTECPhiAlgo.cc:80
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDTECPhiAlgo::DDTECPhiAlgo
DDTECPhiAlgo()
Definition: DDTECPhiAlgo.cc:50
DDSplit.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
dqmdumpme.first
first
Definition: dqmdumpme.py:55
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
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
DDTECPhiAlgo::incrAngle
double incrAngle
Definition: DDTECPhiAlgo.cc:39
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDTECPhiAlgo::zOut
double zOut
Definition: DDTECPhiAlgo.cc:41
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
DDTECPhiAlgo::startAngle
double startAngle
Definition: DDTECPhiAlgo.cc:38
DDTECPhiAlgo::incrCopyNo
int incrCopyNo
Definition: DDTECPhiAlgo.cc:44
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
DDTECPhiAlgo::idNameSpace
string idNameSpace
Definition: DDTECPhiAlgo.cc:46
DDTECPhiAlgo::~DDTECPhiAlgo
~DDTECPhiAlgo() override
Definition: DDTECPhiAlgo.cc:52
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDTECPhiAlgo::zIn
double zIn
Definition: DDTECPhiAlgo.cc:40
DDTECPhiAlgo::number
int number
Definition: DDTECPhiAlgo.cc:42
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
class-composition.child
child
Definition: class-composition.py:91
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDTECPhiAlgo
Definition: DDTECPhiAlgo.cc:23
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
DDTECPhiAlgo::startCopyNo
int startCopyNo
Definition: DDTECPhiAlgo.cc:43
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