CMS 3D CMS Logo

DDPixPhase1FwdDiskAlgo.cc
Go to the documentation of this file.
1 // File: DDPixPhase1FwdDiskAlgo.cc
3 // Description: Position n copies at given z-values
5 
13 #include "CLHEP/Units/PhysicalConstants.h"
14 #include "CLHEP/Units/SystemOfUnits.h"
15 
16 #include <cmath>
17 #include <algorithm>
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 using namespace std;
23 
24 class DDPixPhase1FwdDiskAlgo : public DDAlgorithm {
25 public:
26  //Constructor and Destructor
28  ~DDPixPhase1FwdDiskAlgo() override;
29 
30  void initialize(const DDNumericArguments& nArgs,
31  const DDVectorArguments& vArgs,
32  const DDMapArguments& mArgs,
33  const DDStringArguments& sArgs,
34  const DDStringVectorArguments& vsArgs) override;
35 
36  void execute(DDCompactView& cpv) override;
37 
38 private:
39  string idNameSpace; //Namespace of this and ALL sub-parts
40  string childName; //Child name
41  string rotName; //Name of the base rotation matrix
42  string flagString; //Flag if a blade is present
43  int nBlades; //Number of blades
44  int startCopyNo; //Start Copy number
45  double bladeAngle; //Angle of blade rotation aroung y-axis
46  double zPlane; //Common shift in z for all blades
47  vector<double> bladeZShift; //Shift in Z of individual blades
48  double anchorR; //Distance of beam line to anchor point
49  double bladeTilt; //Tilt of the blade around x-axis
50 };
51 
53  LogDebug("TrackerGeom") << "DDPixPhase1FwdDiskAlgo info: Creating an instance";
54 }
55 
57 
59  const DDVectorArguments& vArgs,
60  const DDMapArguments&,
61  const DDStringArguments& sArgs,
62  const DDStringVectorArguments& vsArgs) {
63  startCopyNo = int(nArgs["StartCopyNo"]);
64  nBlades = int(nArgs["NumberOfBlades"]);
65  bladeAngle = nArgs["BladeAngle"];
66  bladeTilt = -nArgs["BladeTilt"];
67  zPlane = nArgs["BladeCommonZ"];
68  bladeZShift = vArgs["BladeZShift"];
69  anchorR = nArgs["AnchorRadius"];
70 
71  idNameSpace = DDCurrentNamespace::ns();
72  childName = sArgs["ChildName"];
73  rotName = sArgs["RotationName"];
74  flagString = sArgs["FlagString"];
75  DDName parentName = parent().name();
76  LogDebug("TrackerGeom") << "DDPixPhase1FwdDiskAlgo debug: Parent " << parentName << "\tChild " << childName
77  << " NameSpace " << idNameSpace << "\tRot Name " << rotName << "\tCopyNo (Start/Total) "
78  << startCopyNo << ", " << nBlades << "\tAngles " << bladeAngle / CLHEP::deg << ", "
79  << bladeTilt / CLHEP::deg << "\tZshifts " << zPlane << "\tAmnchor Radius " << anchorR;
80 
81  for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
82  LogDebug("TrackerGeom") << "DDPixPhase1FwdDiskAlgo: Blade " << iBlade << " flag " << flagString[iBlade]
83  << " zshift " << bladeZShift[iBlade];
84  }
85 }
86 
88  int copy = startCopyNo;
89  DDName mother = parent().name();
90  DDName child(DDSplit(childName).first, DDSplit(childName).second);
91  string flagSelector = "Y";
92 
93  double deltaPhi = (360. / nBlades) * CLHEP::deg;
94  string rotns = DDSplit(rotName).second;
95  for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
96  if (flagString[iBlade] == flagSelector[0]) {
97  string rotstr = DDSplit(rotName).first + to_string(double(copy));
98 
99  double phi = (iBlade + 0.5) * deltaPhi;
100  double phiy = atan2(cos(phi), -sin(phi));
101  double thety = acos(sin(bladeTilt));
102  double phix = atan2(cos(bladeAngle) * sin(phi) + cos(phi) * sin(bladeTilt) * sin(bladeAngle),
103  cos(phi) * cos(bladeAngle) - sin(phi) * sin(bladeTilt) * sin(bladeAngle));
104  double thetx = acos(-cos(bladeTilt) * sin(bladeAngle));
105  double phiz = atan2(sin(phi) * sin(bladeAngle) - cos(phi) * cos(bladeAngle) * sin(bladeTilt),
106  cos(phi) * sin(bladeAngle) + cos(bladeAngle) * sin(phi) * sin(bladeTilt));
107  double thetz = acos(cos(bladeTilt) * cos(bladeAngle));
108  DDRotation rot = DDRotation(DDName(rotstr, rotns));
109  if (!rot) {
110  LogDebug("TrackerGeom") << "DDPixPhase1FwdDiskAlgo test: Creating a new "
111  << "rotation: " << rotstr << "\t" << thetx / CLHEP::deg << ", " << phix / CLHEP::deg
112  << ", " << thety / CLHEP::deg << ", " << phiy / CLHEP::deg << ", " << thetz / CLHEP::deg
113  << ", " << phiz / CLHEP::deg;
114  LogDebug("TrackerGeom") << "Rotation Matrix (" << phi / CLHEP::deg << ", " << bladeAngle / CLHEP::deg << ", "
115  << bladeTilt / CLHEP::deg << ") " << cos(phi) * cos(bladeAngle) << ", "
116  << (-sin(phi) * cos(bladeTilt) + cos(phi) * sin(bladeAngle) * sin(bladeTilt)) << ", "
117  << (sin(phi) * sin(bladeTilt) + cos(phi) * sin(bladeAngle) * cos(bladeTilt)) << ", "
118  << sin(phi) * cos(bladeAngle) << ", "
119  << (cos(phi) * cos(bladeTilt) + sin(phi) * sin(bladeAngle) * sin(bladeTilt)) << ", "
120  << (-cos(phi) * sin(bladeTilt) + sin(phi) * sin(bladeAngle) * cos(bladeTilt)) << ", "
121  << -sin(bladeAngle) << ", " << cos(bladeAngle) * sin(bladeTilt) << ", "
122  << cos(bladeAngle) * cos(bladeTilt);
123  rot = DDrot(DDName(rotstr, rotns), thetx, phix, thety, phiy, thetz, phiz);
124  }
125  double xpos = -anchorR * sin(phi);
126  double ypos = anchorR * cos(phi);
127  double zpos = zPlane + bladeZShift[iBlade % nBlades];
128  DDTranslation tran(xpos, ypos, zpos);
129  cpv.position(child, mother, copy, tran, rot);
130  LogDebug("TrackerGeom") << "DDPixPhase1FwdDiskAlgo test: " << child << " number " << copy << " positioned in "
131  << mother << " at " << tran << " with " << rot;
132  }
133  copy++;
134  }
135 }
136 
137 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDPixPhase1FwdDiskAlgo, "track:DDPixPhase1FwdDiskAlgo");
DDCurrentNamespace.h
DDPixPhase1FwdDiskAlgo::startCopyNo
int startCopyNo
Definition: DDPixPhase1FwdDiskAlgo.cc:44
DDPixPhase1FwdDiskAlgo::flagString
string flagString
Definition: DDPixPhase1FwdDiskAlgo.cc:42
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
DDPixPhase1FwdDiskAlgo::bladeAngle
double bladeAngle
Definition: DDPixPhase1FwdDiskAlgo.cc:45
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDSplit.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDPixPhase1FwdDiskAlgo::bladeZShift
vector< double > bladeZShift
Definition: DDPixPhase1FwdDiskAlgo.cc:47
DDPixPhase1FwdDiskAlgo::anchorR
double anchorR
Definition: DDPixPhase1FwdDiskAlgo.cc:48
dqmdumpme.first
first
Definition: dqmdumpme.py:55
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDPixPhase1FwdDiskAlgo::nBlades
int nBlades
Definition: DDPixPhase1FwdDiskAlgo.cc:43
DDPixPhase1FwdDiskAlgo::DDPixPhase1FwdDiskAlgo
DDPixPhase1FwdDiskAlgo()
Definition: DDPixPhase1FwdDiskAlgo.cc:52
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDPixPhase1FwdDiskAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDPixPhase1FwdDiskAlgo.cc:87
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
DDPixPhase1FwdDiskAlgo::bladeTilt
double bladeTilt
Definition: DDPixPhase1FwdDiskAlgo.cc:49
createfilelist.int
int
Definition: createfilelist.py:10
DDutils.h
DDPixPhase1FwdDiskAlgo::idNameSpace
string idNameSpace
Definition: DDPixPhase1FwdDiskAlgo.cc:39
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
submitPVValidationJobs.child
child
Definition: submitPVValidationJobs.py:119
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDPixPhase1FwdDiskAlgo::rotName
string rotName
Definition: DDPixPhase1FwdDiskAlgo.cc:41
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDPixPhase1FwdDiskAlgo::childName
string childName
Definition: DDPixPhase1FwdDiskAlgo.cc:40
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDPixPhase1FwdDiskAlgo
Definition: DDPixPhase1FwdDiskAlgo.cc:24
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
DDPixPhase1FwdDiskAlgo::~DDPixPhase1FwdDiskAlgo
~DDPixPhase1FwdDiskAlgo() override
Definition: DDPixPhase1FwdDiskAlgo.cc:56
class-composition.parent
parent
Definition: class-composition.py:88
DDPixPhase1FwdDiskAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDPixPhase1FwdDiskAlgo.cc:58
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
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18
DDPixPhase1FwdDiskAlgo::zPlane
double zPlane
Definition: DDPixPhase1FwdDiskAlgo.cc:46