CMS 3D CMS Logo

DDHCalFibreBundle.cc
Go to the documentation of this file.
4 #include "DD4hep/DetFactoryHelper.h"
5 
6 //#define EDM_ML_DEBUG
7 
8 using namespace geant_units::operators;
9 
10 static long algorithm(dd4hep::Detector& /* description */,
12  xml_h e,
13  dd4hep::SensitiveDetector& /* sens */) {
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 }
101 
102 // first argument is the type from the xml file
103 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalFibreBundle, algorithm);
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:355
geant_units::operators::convertCm2ToMm2
constexpr NumType convertCm2ToMm2(NumType centimeters)
Definition: GeantUnits.h:74
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:547
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:30
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:121
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:14
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
geant_units::operators
Definition: GeantUnits.h:18
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
Definition: DDHCalFibreBundle.cc:10
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
HLT_2018_cff.dPhi
dPhi
Definition: HLT_2018_cff.py:12290
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
geant_units::operators::convertCmToMm
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
GeantUnits.h
DDPlugins.h
edm::LogVerbatim
Definition: MessageLogger.h:297
cuy.ib
ib
Definition: cuy.py:662
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
align::Detector
Definition: StructureType.h:86
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:68
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:190
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37