CMS 3D CMS Logo

DDHCalLinearXY.cc
Go to the documentation of this file.
4 #include "DD4hep/DetFactoryHelper.h"
5 
6 //#define EDM_ML_DEBUG
7 using namespace geant_units::operators;
8 
9 static long algorithm(dd4hep::Detector& /* description */,
11  xml_h e,
12  dd4hep::SensitiveDetector& /* sens */) {
13  cms::DDNamespace ns(ctxt, e, true);
15  // Header section of original DDHCalLinearXY.h
16  int numberX = args.value<int>("NumberX"); //Slices along X
17  int numberY = args.value<int>("NumberY"); //Slices along Y
18  double deltaX = args.value<double>("DeltaX"); //Step along X
19  double deltaY = args.value<double>("DeltaY"); //Step along Y
20  std::vector<double> centre = args.value<std::vector<double> >("Center");
21  dd4hep::Volume parent = ns.volume(args.parentName());
22  std::vector<std::string> childName = args.value<std::vector<std::string> >("Child");
23 
24 #ifdef EDM_ML_DEBUG
25  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: Parent " << parent.name() << " \twith " << childName.size()
26  << " children";
27  unsigned int k(0);
28  for (auto const& child : childName) {
29  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: Child[" << k << "] = " << child;
30  ++k;
31  }
32  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: Number along X/Y " << numberX << "/" << numberY
33  << "\tDelta along X/Y " << convertCmToMm(deltaX) << "/" << convertCmToMm(deltaY)
34  << "\tCentre (" << convertCmToMm(centre[0]) << ", " << convertCmToMm(centre[1]) << ","
35  << convertCmToMm(centre[2]);
36 #endif
37  double xoff = centre[0] - (numberX - 1) * 0.5 * deltaX;
38  double yoff = centre[1] - (numberY - 1) * 0.5 * deltaY;
39  unsigned int copy = 0;
40  for (int i = 0; i < numberX; ++i) {
41  for (int j = 0; j < numberY; ++j) {
42  unsigned int k = (childName.size() == 1) ? 0 : copy;
43  ++copy;
44  if (k < childName.size() && (childName[k] != " " && childName[k] != "Null")) {
45  std::string child = childName[k];
46  dd4hep::Position tran(xoff + i * deltaX, yoff + j * deltaY, centre[2]);
47  parent.placeVolume(ns.volume(child), copy, tran);
48 #ifdef EDM_ML_DEBUG
49  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: " << child << " number " << copy << " positioned in "
50  << parent.name() << " at (" << convertCmToMm(xoff + i * deltaX) << ", "
51  << convertCmToMm(yoff + j * deltaY) << ", " << convertCmToMm(centre[2])
52  << ") with no rotation";
53 #endif
54  } else {
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("HCalGeom") << "DDHCalLinearXY: no child placed for [" << copy << "]";
57 #endif
58  }
59  }
60  }
61  return 1;
62 }
63 
64 // first argument is the type from the xml file
65 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalLinearXY, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:30
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:14
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: DDHCalLinearXY.cc:9
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
geant_units::operators::convertCmToMm
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
GeantUnits.h
DDPlugins.h
edm::LogVerbatim
Definition: MessageLogger.h:297
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
align::Detector
Definition: StructureType.h:86
class-composition.child
child
Definition: class-composition.py:91
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
child
Definition: simpleInheritance.h:11
class-composition.parent
parent
Definition: class-composition.py:88
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