CMS 3D CMS Logo

DDHCalXtalAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalXtalAlgo.cc
3 // Description: Positioning the crystal (layers) in the mother volume
5 
6 #include <cmath>
7 #include <algorithm>
8 #include <map>
9 #include <string>
10 #include <vector>
11 
20 
21 //#define EDM_ML_DEBUG
22 using namespace angle_units::operators;
23 
24 class DDHCalXtalAlgo : public DDAlgorithm {
25 public:
26  //Constructor and Destructor
28  ~DDHCalXtalAlgo() 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  double radius; //Pointing distance from front surface
40  double offset; //Offset along Z
41  double dx; //Half size along x
42  double dz; //Half size along z
43  double angwidth; //Angular width
44  int iaxis; //Axis of rotation
45  std::vector<std::string> names; //Names for rotation matrices
46 
47  std::string idNameSpace; //Namespace of this and ALL sub-parts
48  std::string idName; //Children name
49 };
50 
52 #ifdef EDM_ML_DEBUG
53  edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo info: Creating an instance";
54 #endif
55 }
56 
58 
60  const DDVectorArguments&,
61  const DDMapArguments&,
62  const DDStringArguments& sArgs,
63  const DDStringVectorArguments& vsArgs) {
64  radius = nArgs["Radius"];
65  offset = nArgs["Offset"];
66  dx = nArgs["Dx"];
67  dz = nArgs["Dz"];
68  angwidth = nArgs["AngWidth"];
69  iaxis = int(nArgs["Axis"]);
70  names = vsArgs["Names"];
71 
72 #ifdef EDM_ML_DEBUG
73  edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo::Parameters for positioning:"
74  << " Axis " << iaxis << "\tRadius " << radius << "\tOffset " << offset << "\tDx " << dx
75  << "\tDz " << dz << "\tAngWidth " << convertRadToDeg(angwidth) << "\tNumbers "
76  << names.size();
77  for (unsigned int i = 0; i < names.size(); i++)
78  edm::LogVerbatim("HCalGeom") << "\tnames[" << i << "] = " << names[i];
79 #endif
80  idNameSpace = DDCurrentNamespace::ns();
81  idName = sArgs["ChildName"];
82 #ifdef EDM_ML_DEBUG
83  edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: Parent " << parent().name() << "\tChild " << idName << " NameSpace "
84  << idNameSpace;
85 #endif
86 }
87 
89  double theta[3], phi[3], pos[3];
90  phi[0] = 0;
91  phi[1] = 90._deg;
92  theta[1 - iaxis] = 90._deg;
93  pos[1 - iaxis] = 0;
94  int number = (int)(names.size());
95  for (int i = 0; i < number; i++) {
96  double angle = 0.5 * angwidth * (2 * i + 1 - number);
97  theta[iaxis] = 90._deg + angle;
98  if (angle > 0) {
99  theta[2] = angle;
100  phi[2] = iaxis * 90._deg;
101  } else {
102  theta[2] = -angle;
103  phi[2] = (2 - 3 * iaxis) * 90._deg;
104  }
105  pos[iaxis] = angle * (dz + radius);
106  pos[2] = dx * std::abs(sin(angle)) + offset;
107 
109  std::string rotstr = names[i];
110  DDTranslation tran(pos[0], pos[1], pos[2]);
111  DDName parentName = parent().name();
112 
113  static const double tol = 0.01_deg; // 0.01 degree
114  if (std::abs(angle) > tol) {
115 #ifdef EDM_ML_DEBUG
116  edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: Creating a rotation " << rotstr << "\t"
117  << convertRadToDeg(theta[0]) << "," << convertRadToDeg(phi[0]) << ","
118  << convertRadToDeg(theta[1]) << "," << convertRadToDeg(phi[1]) << ","
119  << convertRadToDeg(theta[2]) << "," << convertRadToDeg(phi[2]);
120 #endif
121  rotation = DDrot(DDName(rotstr, idNameSpace), theta[0], phi[0], theta[1], phi[1], theta[2], phi[2]);
122  }
123  cpv.position(DDName(idName, idNameSpace), parentName, i + 1, tran, rotation);
124 #ifdef EDM_ML_DEBUG
125  edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: " << DDName(idName, idNameSpace) << " number " << i + 1
126  << " positioned in " << parentName << " at " << tran << " with " << rotation;
127 #endif
128  }
129 }
130 
131 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalXtalAlgo, "hcal:DDHCalXtalAlgo");
PluginFactory.h
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
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
pos
Definition: PixelAliasList.h:18
DDHCalXtalAlgo::iaxis
int iaxis
Definition: DDHCalXtalAlgo.cc:44
versionedElectronIDProducer_cfi.idName
idName
Definition: versionedElectronIDProducer_cfi.py:11
DDHCalXtalAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDHCalXtalAlgo.cc:88
DDHCalXtalAlgo::radius
double radius
Definition: DDHCalXtalAlgo.cc:39
DDHCalXtalAlgo::~DDHCalXtalAlgo
~DDHCalXtalAlgo() override
Definition: DDHCalXtalAlgo.cc:57
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDHCalXtalAlgo::offset
double offset
Definition: DDHCalXtalAlgo.cc:40
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
DDHCalXtalAlgo::names
std::vector< std::string > names
Definition: DDHCalXtalAlgo.cc:45
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
DDHCalXtalAlgo::idNameSpace
std::string idNameSpace
Definition: DDHCalXtalAlgo.cc:47
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
edmplugin::PluginFactory
Definition: PluginFactory.h:34
angle_units::operators
Definition: angle_units.h:11
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
DDHCalXtalAlgo::angwidth
double angwidth
Definition: DDHCalXtalAlgo.cc:43
DDLogicalPart.h
DDHCalXtalAlgo::dx
double dx
Definition: DDHCalXtalAlgo.cc:41
DDHCalXtalAlgo::DDHCalXtalAlgo
DDHCalXtalAlgo()
Definition: DDHCalXtalAlgo.cc:51
ReadMapType< double >
DDAlgorithm.h
DDHCalXtalAlgo::dz
double dz
Definition: DDHCalXtalAlgo.cc:42
DDHCalXtalAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHCalXtalAlgo.cc:59
PVValHelper::dz
Definition: PVValidationHelpers.h:51
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
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
DDHCalXtalAlgo
Definition: DDHCalXtalAlgo.cc:24
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DDHCalXtalAlgo::idName
std::string idName
Definition: DDHCalXtalAlgo.cc:48
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
angle_units.h
DDAlgorithmFactory.h
edm::Log
Definition: MessageLogger.h:70
class-composition.parent
parent
Definition: class-composition.py:88
PVValHelper::dx
Definition: PVValidationHelpers.h:49
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