CMS 3D CMS Logo

DDHGCalWaferAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
7 
8 //#define EDM_ML_DEBUG
9 using namespace angle_units::operators;
10 
11 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
12  cms::DDNamespace ns(ctxt, e, true);
14 
15  // Header section of original DDHGCalWafer.h
16  const auto& cellSize = args.value<double>("CellSize"); // Cell Size
17  const auto& cellType = args.value<int>("CellType"); // Type (1 fine; 2 coarse)
18  const auto& childNames = args.value<std::vector<std::string> >("ChildNames"); // Names of children
19  const auto& positionX = args.value<std::vector<int> >("PositionX"); // Position in X
20  const auto& positionY = args.value<std::vector<int> >("PositionY"); // Position in Y
21  const auto& angles = args.value<std::vector<double> >("Angles"); // Rotation angle
22  const auto& detectorType = args.value<std::vector<int> >("DetectorType"); // Detector type
23 #ifdef EDM_ML_DEBUG
24  edm::LogVerbatim("HGCalGeom") << childNames.size() << " children: " << childNames[0] << "; " << childNames[1]
25  << " positioned " << positionX.size() << " times with cell size " << cellSize;
26  for (unsigned int k = 0; k < positionX.size(); ++k)
27  edm::LogVerbatim("HGCalGeom") << "[" << k << "] x " << cms::convert2mm(positionX[k]) << " y "
28  << cms::convert2mm(positionY[k]) << " angle " << angles[k] << " detector "
29  << detectorType[k];
30 
31  std::string idName = args.parentName(); // Name of the "parent" volume.
32  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo debug: Parent " << idName << " NameSpace " << ns.name();
33 #endif
34 
35  dd4hep::Volume mother = ns.volume(args.parentName());
36  double dx = 0.5 * cellSize;
37  double dy = 0.5 * dx * tan(30._deg);
38 
39  for (unsigned int k = 0; k < positionX.size(); ++k) {
40  std::string name(childNames[detectorType[k]]);
41  name = ns.prepend(name);
42  dd4hep::Rotation3D rotation;
43  if (angles[k] != 0) {
44  double phi = convertDegToRad(angles[k]);
45 #ifdef EDM_ML_DEBUG
46  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating new rotation \t90, " << angles[k] << ", 90, "
47  << (angles[k] + 90) << ", 0, 0";
48 #endif
49  rotation = cms::makeRotation3D(90._deg, phi, 90._deg, (90._deg + phi), 0, 0);
50  }
51  double xpos = dx * positionX[k];
52  double ypos = dy * positionY[k];
53  dd4hep::Position tran(xpos, ypos, 0);
54  int copy = HGCalTypes::packCellType6(cellType, k);
55  mother.placeVolume(ns.volume(name), copy, dd4hep::Transform3D(rotation, tran));
56 #ifdef EDM_ML_DEBUG
57  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: " << name << " number " << copy << " positioned in " << idName
58  << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos) << ",0) with "
59  << rotation;
60 #endif
61  }
62 
63  return cms::s_executed;
64 }
65 
66 // first argument is the type from the xml file
67 DECLARE_DDCMS_DETELEMENT(DDCMS_hgcal_DDHGCalWaferAlgo, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:13
cms::DDNamespace
Definition: DDNamespace.h:16
angle_units::operators::convertDegToRad
constexpr long double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
versionedElectronIDProducer_cfi.idName
idName
Definition: versionedElectronIDProducer_cfi.py:11
HGCalTypes::packCellType6
static int32_t packCellType6(int type, int cell)
Definition: HGCalTypes.cc:36
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:60
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:75
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
angle_units::operators
Definition: angle_units.h:11
DDPlugins.h
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
cms::convert2mm
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDHGCalWaferAlgo.cc:11
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
PVValHelper::dy
Definition: PVValidationHelpers.h:50
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:92
particleFlowDisplacedVertex_cfi.angles
angles
Definition: particleFlowDisplacedVertex_cfi.py:84
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
angle_units.h
HGCalTypes.h
edm::Log
Definition: MessageLogger.h:70
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:205
PVValHelper::dx
Definition: PVValidationHelpers.h:49
DDutils.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37