CMS 3D CMS Logo

Functions
DDHCalFibreBundle.cc File Reference
#include "DataFormats/Math/interface/GeantUnits.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DD4hep/DetFactoryHelper.h"

Go to the source code of this file.

Functions

static long algorithm (dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_hcal_DDHCalFibreBundle)
 

Function Documentation

static long algorithm ( dd4hep::Detector &  ,
cms::DDParsingContext ctxt,
xml_h  e,
dd4hep::SensitiveDetector &   
)
static

Definition at line 10 of file DDHCalFibreBundle.cc.

References writedatasetfile::args, geant_units::operators::convertCm2ToMm2(), geant_units::operators::convertCmToMm(), angle_units::operators::convertRadToDeg(), filterCSVwithJSON::copy, funct::cos(), SiPixelRawToDigiRegional_cfi::deltaPhi, HLT_2018_cff::dPhi, mps_fire::i, cuy::ib, dqm-mbProfile::log, cms::DDNamespace::material(), g4SimHits_cfi::Material, Skims_PA_cff::name, cms::DDNamespace::name(), cms::DDAlgoArguments::parentName(), makeMuonMisalignmentScenario::rot, idealTransformation::rotation, AlCaHLTBitMon_QueryRunRegistry::string, cms::DDAlgoArguments::value(), and cms::DDNamespace::volume().

13  {
14  cms::DDNamespace ns(ctxt, e, true);
16  // Header section
17  double deltaPhi = args.value<double>("DeltaPhi");
18  double deltaZ = args.value<double>("DeltaZ");
19  int numberPhi = args.value<int>("NumberPhi");
20  std::string material = args.value<std::string>("Material");
21  std::vector<double> areaSection = args.value<std::vector<double> >("AreaSection");
22  std::vector<double> rStart = args.value<std::vector<double> >("RadiusStart");
23  std::vector<double> rEnd = args.value<std::vector<double> >("RadiusEnd");
24  std::vector<int> bundle = args.value<std::vector<int> >("Bundles");
25  double tilt = args.value<double>("TiltAngle");
26  std::string childPrefix = args.value<std::string>("Child");
27 #ifdef EDM_ML_DEBUG
28  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Parent " << args.parentName() << " with " << bundle.size()
29  << " children with prefix " << childPrefix << ", material " << material << " with "
30  << numberPhi << " bundles along phi; width of"
31  << " mother " << deltaZ << " along Z, " << convertRadToDeg(deltaPhi)
32  << " along phi and with " << rStart.size() << " different bundle types";
33  for (unsigned int i = 0; i < areaSection.size(); ++i)
34  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Child[" << i << "] Area " << convertCm2ToMm2(areaSection[i])
35  << " R at Start " << convertCmToMm(rStart[i]) << " R at End "
36  << convertCmToMm(rEnd[i]);
37  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: NameSpace " << ns.name() << " Tilt Angle "
38  << convertRadToDeg(tilt) << " Bundle type at different positions";
39  for (unsigned int i = 0; i < bundle.size(); ++i) {
40  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Position[" << i << "] "
41  << " with Type " << bundle[i];
42  }
43 #endif
44 
45  dd4hep::Volume mother = ns.volume(args.parentName());
46  dd4hep::Material matter = ns.material(material);
47 
48  // Create the rotation matrices
49  double dPhi = deltaPhi / numberPhi;
50  std::vector<dd4hep::Rotation3D> rotation;
51  dd4hep::Rotation3D rot;
52  for (int i = 0; i < numberPhi; ++i) {
53  double phi = -0.5 * deltaPhi + (i + 0.5) * dPhi;
54  rot = dd4hep::RotationZ(phi);
55 #ifdef EDM_ML_DEBUG
56  double phideg = convertRadToDeg(phi);
57  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Creating a new rotation " << 90 << "," << phideg << "," << 90
58  << "," << (phideg + 90) << ", 0, 0";
59 #endif
60  rotation.emplace_back(rot);
61  }
62 
63  // Create the solids and logical parts
64  std::vector<dd4hep::Volume> logs;
65  for (unsigned int i = 0; i < areaSection.size(); ++i) {
66  double r0 = rEnd[i] / std::cos(tilt);
67  double dStart = areaSection[i] / (2 * dPhi * rStart[i]);
68  double dEnd = areaSection[i] / (2 * dPhi * r0);
69  std::string name = childPrefix + std::to_string(i);
70  dd4hep::Solid solid = dd4hep::ConeSegment(
71  name, 0.5 * deltaZ, rStart[i] - dStart, rStart[i] + dStart, r0 - dEnd, r0 + dEnd, -0.5 * dPhi, 0.5 * dPhi);
72 #ifdef EDM_ML_DEBUG
73  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: Creating a new solid " << name << " a cons with dZ " << deltaZ
74  << " rStart " << rStart[i] - dStart << ":" << rStart[i] + dStart << " rEnd "
75  << r0 - dEnd << ":" << r0 + dEnd << " Phi " << convertRadToDeg(-0.5 * dPhi) << ":"
76  << convertRadToDeg(0.5 * dPhi);
77 #endif
78  dd4hep::Volume log(name, solid, matter);
79  logs.emplace_back(log);
80  }
81 
82  // Now posiiton them
83  int copy = 0;
84  int nY = static_cast<int>(bundle.size()) / numberPhi;
85  for (unsigned int i = 0; i < bundle.size(); i++) {
86  int ir = static_cast<int>(i) / nY;
87  if (ir >= numberPhi)
88  ir = numberPhi - 1;
89  int ib = bundle[i];
90  copy++;
91  if (ib >= 0 && ib < (int)(logs.size())) {
92  mother.placeVolume(logs[ib], copy, rotation[ir]);
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("HCalGeom") << "DDHCalFibreBundle: " << logs[ib].name() << " number " << copy
95  << " positioned in " << mother.name() << " at (0, 0, 0) with " << rotation[ir];
96 #endif
97  }
98  }
99  return 1;
100 }
constexpr NumType convertCm2ToMm2(NumType centimeters)
Definition: GeantUnits.h:74
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
dd4hep::Volume Volume
ib
Definition: cuy.py:662
DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hcal_DDHCalFibreBundle   
)

Definition at line 103 of file DDHCalFibreBundle.cc.