CMS 3D CMS Logo

DDTECOptoHybAlgo.cc
Go to the documentation of this file.
1 // File: DDTECOptoHybAlgo.cc
3 // Description: Placing cooling pieces in the petal material of a TEC petal
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 DDTECOptoHybAlgo : public DDAlgorithm {
24 public:
25  //Constructor and Destructor
27  ~DDTECOptoHybAlgo() 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  string idNameSpace; //Namespace of this and ALL parts
39  string childName; //Child name
40  double rpos; //r Position
41  double zpos; //Z position of the OptoHybrid
42  double optoHeight; // Height of the OptoHybrid
43  double optoWidth; // Width of the OptoHybrid
44  int startCopyNo; //Start copy number
45  vector<double> angles; //Angular position of Hybrid
46 };
47 
49  LogDebug("TECGeom") << "DDTECOptoHybAlgo info: Creating an instance";
50 }
51 
53 
55  const DDVectorArguments& vArgs,
56  const DDMapArguments&,
57  const DDStringArguments& sArgs,
58  const DDStringVectorArguments&) {
60  childName = sArgs["ChildName"];
61 
62  DDName parentName = parent().name();
63 
64  LogDebug("TECGeom") << "DDTECOptoHybAlgo debug: Parent " << parentName << " Child " << childName << " NameSpace "
65  << idNameSpace;
66 
67  optoHeight = nArgs["OptoHeight"];
68  optoWidth = nArgs["OptoWidth"];
69  rpos = nArgs["Rpos"];
70  zpos = nArgs["Zpos"];
71  startCopyNo = int(nArgs["StartCopyNo"]);
72  angles = vArgs["Angles"];
73 
74  LogDebug("TECGeom") << "DDTECOptoHybAlgo debug: Height of the Hybrid " << optoHeight << " and Width " << optoWidth
75  << "Rpos " << rpos << " Zpos " << zpos << " StartCopyNo " << startCopyNo << " Number "
76  << angles.size();
77 
78  for (int i = 0; i < (int)(angles.size()); i++)
79  LogDebug("TECGeom") << "\tAngles[" << i << "] = " << angles[i];
80 }
81 
83  LogDebug("TECGeom") << "==>> Constructing DDTECOptoHybAlgo...";
84 
85  DDName mother = parent().name();
87 
88  // given r positions are for the lower left corner
89  rpos += optoHeight / 2;
90  int copyNo = startCopyNo;
91  for (double angle : angles) {
92  double phix = -angle;
93  // given phi positions are for the lower left corner
94  phix += asin(optoWidth / 2 / rpos);
95  double xpos = rpos * cos(phix);
96  double ypos = rpos * sin(phix);
97  DDTranslation tran(xpos, ypos, zpos);
98 
100  double phiy = phix + 90. * CLHEP::deg;
101  double phideg = phix / CLHEP::deg;
102  if (phideg != 0) {
103  string rotstr = DDSplit(childName).first + to_string(phideg * 1000.);
105  if (!rotation) {
106  double theta = 90. * CLHEP::deg;
107  LogDebug("TECGeom") << "DDTECOptoHybAlgo test: Creating a new "
108  << "rotation: " << rotstr << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
109  << ", 0, 0";
110  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
111  }
112  }
113 
114  cpv.position(child, mother, copyNo, tran, rotation);
115  LogDebug("TECGeom") << "DDTECOptoHybAlgo test " << child << " number " << copyNo << " positioned in " << mother
116  << " at " << tran << " with " << rotation;
117  copyNo++;
118  }
119 
120  LogDebug("TECGeom") << "<<== End of DDTECOptoHybAlgo construction ...";
121 }
122 
123 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTECOptoHybAlgo, "track:DDTECOptoHybAlgo");
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:428
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
DDTECOptoHybAlgo::startCopyNo
int startCopyNo
Definition: DDTECOptoHybAlgo.cc:44
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
DDTECOptoHybAlgo::angles
vector< double > angles
Definition: DDTECOptoHybAlgo.cc:45
DDTECOptoHybAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDTECOptoHybAlgo.cc:54
DDSplit.h
DDTECOptoHybAlgo
Definition: DDTECOptoHybAlgo.cc:23
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDTECOptoHybAlgo::childName
string childName
Definition: DDTECOptoHybAlgo.cc:39
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
DDTECOptoHybAlgo::rpos
double rpos
Definition: DDTECOptoHybAlgo.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
DDTECOptoHybAlgo::DDTECOptoHybAlgo
DDTECOptoHybAlgo()
Definition: DDTECOptoHybAlgo.cc:48
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
DDTECOptoHybAlgo::~DDTECOptoHybAlgo
~DDTECOptoHybAlgo() override
Definition: DDTECOptoHybAlgo.cc:52
DDTECOptoHybAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDTECOptoHybAlgo.cc:82
ReadMapType< double >
DDTECOptoHybAlgo::idNameSpace
string idNameSpace
Definition: DDTECOptoHybAlgo.cc:38
DDTECOptoHybAlgo::zpos
double zpos
Definition: DDTECOptoHybAlgo.cc:41
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
DDTECOptoHybAlgo::optoWidth
double optoWidth
Definition: DDTECOptoHybAlgo.cc:43
particleFlowDisplacedVertex_cfi.angles
angles
Definition: particleFlowDisplacedVertex_cfi.py:84
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:98
DDTECOptoHybAlgo::optoHeight
double optoHeight
Definition: DDTECOptoHybAlgo.cc:42
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:76