CMS 3D CMS Logo

DDTIDRingAlgo.cc
Go to the documentation of this file.
1 // File: DDTIDRingAlgo.cc
3 // Description: Position n copies of detectors in alternate positions and
4 // also associated ICC's
5 // Em 17Sep07: Cool inserts moved to DDTIDModulePosAlgo.h
7 
14 #include "CLHEP/Units/GlobalPhysicalConstants.h"
15 #include "CLHEP/Units/GlobalSystemOfUnits.h"
16 
17 #include <string>
18 #include <vector>
19 
20 using namespace std;
21 
22 class DDTIDRingAlgo : public DDAlgorithm {
23 public:
24  //Constructor and Destructor
25  DDTIDRingAlgo();
26  ~DDTIDRingAlgo() override;
27 
28  void initialize(const DDNumericArguments& nArgs,
29  const DDVectorArguments& vArgs,
30  const DDMapArguments& mArgs,
31  const DDStringArguments& sArgs,
32  const DDStringVectorArguments& vsArgs) override;
33 
34  void execute(DDCompactView& cpv) override;
35 
36 private:
37  string idNameSpace; //Namespace of this & ALL subparts
38  vector<string> moduleName; //Name of the module
39  string iccName; //Name of the ICC
40 
41  int number; //Number of copies
42  double startAngle; //Phi offset
43  double rModule; //Location of module in R
44  vector<double> zModule; // in Z
45  double rICC; //Location of ICC in R
46  double sICC; //Shift of ICC per to R
47  vector<double> zICC; // in Z
48 };
49 
50 DDTIDRingAlgo::DDTIDRingAlgo() { LogDebug("TIDGeom") << "DDTIDRingAlgo info: Creating an instance"; }
51 
53 
55  const DDVectorArguments& vArgs,
56  const DDMapArguments&,
57  const DDStringArguments& sArgs,
58  const DDStringVectorArguments& vsArgs) {
59  idNameSpace = DDCurrentNamespace::ns();
60  moduleName = vsArgs["ModuleName"];
61  iccName = sArgs["ICCName"];
62  DDName parentName = parent().name();
63  LogDebug("TIDGeom") << "DDTIDRingAlgo debug: Parent " << parentName << "\tModule " << moduleName[0] << ", "
64  << moduleName[1] << "\tICC " << iccName << "\tNameSpace " << idNameSpace;
65 
66  number = int(nArgs["Number"]);
67  startAngle = nArgs["StartAngle"];
68  rModule = nArgs["ModuleR"];
69  zModule = vArgs["ModuleZ"];
70  rICC = nArgs["ICCR"];
71  sICC = nArgs["ICCShift"];
72  zICC = vArgs["ICCZ"];
73 
74  LogDebug("TIDGeom") << "DDTIDRingAlgo debug: Parameters for positioning--"
75  << " StartAngle " << startAngle / CLHEP::deg << " Copy Numbers " << number << " Modules at R "
76  << rModule << " Z " << zModule[0] << ", " << zModule[1] << " ICCs at R " << rICC << " Z "
77  << zICC[0] << ", " << zICC[1];
78 }
79 
81  double theta = 90. * CLHEP::deg;
82  double phiy = 0. * CLHEP::deg;
83  double dphi = CLHEP::twopi / number;
84 
85  DDName mother = parent().name();
86  DDName module;
87  DDName icc(DDSplit(iccName).first, DDSplit(iccName).second);
88 
89  //Loop over modules
90  for (int i = 0; i < number; i++) {
91  //First the module
92  double phiz = startAngle + i * dphi;
93  double xpos = rModule * cos(phiz);
94  double ypos = rModule * sin(phiz);
95  double zpos, thetay, phix;
96  if (i % 2 == 0) {
97  phix = phiz + 90. * CLHEP::deg;
98  thetay = 0 * CLHEP::deg;
99  zpos = zModule[0];
101  } else {
102  phix = phiz - 90. * CLHEP::deg;
103  thetay = 180 * CLHEP::deg;
104  zpos = zModule[1];
106  }
107 
108  // stereo face inside toward structure, rphi face outside
109  phix = phix - 180. * CLHEP::deg;
110  thetay = thetay + 180. * CLHEP::deg;
111  //
112 
113  DDTranslation trmod(xpos, ypos, zpos);
114  double phideg = phiz / CLHEP::deg;
116  string rotstr = mother.name() + to_string(phideg * 10.);
117  rotation = DDRotation(DDName(rotstr, idNameSpace));
118  if (!rotation) {
119  LogDebug("TIDGeom") << "DDTIDRingAlgo test: Creating a new rotation " << rotstr << "\t" << theta / CLHEP::deg
120  << ", " << phix / CLHEP::deg << ", " << thetay / CLHEP::deg << ", " << phiy / CLHEP::deg
121  << ", " << theta / CLHEP::deg << ", " << phiz / CLHEP::deg;
122  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, thetay, phiy, theta, phiz);
123  }
124 
125  cpv.position(module, mother, i + 1, trmod, rotation);
126  LogDebug("TIDGeom") << "DDTIDRingAlgo test: " << module << " number " << i + 1 << " positioned in " << mother
127  << " at " << trmod << " with " << rotation;
128 
129  //Now the ICC
130  if (i % 2 == 0) {
131  zpos = zICC[0];
132  xpos = rICC * cos(phiz) + sICC * sin(phiz);
133  ypos = rICC * sin(phiz) - sICC * cos(phiz);
134  } else {
135  zpos = zICC[1];
136  xpos = rICC * cos(phiz) - sICC * sin(phiz);
137  ypos = rICC * sin(phiz) + sICC * cos(phiz);
138  }
139  DDTranslation tricc(xpos, ypos, zpos);
140  cpv.position(icc, mother, i + 1, tricc, rotation);
141  LogDebug("TIDGeom") << "DDTIDRingAlgo test: " << icc << " number " << i + 1 << " positioned in " << mother << " at "
142  << tricc << " with " << rotation;
143  }
144 }
145 
146 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTIDRingAlgo, "track:DDTIDRingAlgo");
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
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDTIDRingAlgo::rModule
double rModule
Definition: DDTIDRingAlgo.cc:43
DDSplit.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDTIDRingAlgo::iccName
string iccName
Definition: DDTIDRingAlgo.cc:39
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDTIDRingAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDTIDRingAlgo.cc:54
DDTIDRingAlgo::DDTIDRingAlgo
DDTIDRingAlgo()
Definition: DDTIDRingAlgo.cc:50
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
DDTIDRingAlgo::zModule
vector< double > zModule
Definition: DDTIDRingAlgo.cc:44
DDTIDRingAlgo::zICC
vector< double > zICC
Definition: DDTIDRingAlgo.cc:47
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
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:112
DDTIDRingAlgo::idNameSpace
string idNameSpace
Definition: DDTIDRingAlgo.cc:37
DDTIDRingAlgo
Definition: DDTIDRingAlgo.cc:22
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
DDTIDRingAlgo::~DDTIDRingAlgo
~DDTIDRingAlgo() override
Definition: DDTIDRingAlgo.cc:52
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
EcalCalibMonitorClient_cfi.moduleName
moduleName
Definition: EcalCalibMonitorClient_cfi.py:17
DDTIDRingAlgo::number
int number
Definition: DDTIDRingAlgo.cc:41
DDName::name
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
DDTIDRingAlgo::rICC
double rICC
Definition: DDTIDRingAlgo.cc:45
DDTIDRingAlgo::sICC
double sICC
Definition: DDTIDRingAlgo.cc:46
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
DDTIDRingAlgo::startAngle
double startAngle
Definition: DDTIDRingAlgo.cc:42
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDTIDRingAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDTIDRingAlgo.cc:80
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
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:16
DDTIDRingAlgo::moduleName
vector< string > moduleName
Definition: DDTIDRingAlgo.cc:38