CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DDHCalForwardAlgo.cc
Go to the documentation of this file.
5 #include "DD4hep/DetFactoryHelper.h"
6 
7 //#define EDM_ML_DEBUG
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  std::string parentName = DDSplit(args.parentName()).first;
18  std::string cellMat = args.value<std::string>("CellMaterial"); //Cell material
19  double cellDx = args.value<double>("CellDx"); //Cell size (x)
20  double cellDy = args.value<double>("CellDy"); //Cell size (y)
21  double cellDz = args.value<double>("CellDz"); //Cell size (z)
22  double startY = args.value<double>("StartY"); //Starting Y for Cell
23  std::vector<std::string> childName = args.value<std::vector<std::string> >("Child"); //Children name
24  std::vector<int> number = args.value<std::vector<int> >("Number"); //Number of cells
25  std::vector<int> size = args.value<std::vector<int> >("Size"); //Number of children
26  std::vector<int> type = args.value<std::vector<int> >("Type"); //First child
27 #ifdef EDM_ML_DEBUG
28  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: Cell material " << cellMat << "\tCell Size "
29  << convertCmToMm(cellDx) << ", " << convertCmToMm(cellDy) << ", "
30  << convertCmToMm(cellDz) << "\tStarting Y " << convertCmToMm(startY) << "\tChildren "
31  << childName[0] << ", " << childName[1] << "\n "
32  << " Cell positioning done for " << number.size() << " times";
33  for (unsigned int i = 0; i < number.size(); ++i)
34  edm::LogVerbatim("HCalGeom") << "\t" << i << " Number of children " << size[i] << " occurence " << number[i]
35  << " first child index " << type[i];
36  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo debug: Parent " << args.parentName() << " NameSpace " << ns.name();
37 #endif
38 
39  dd4hep::Volume parent = ns.volume(args.parentName());
40  dd4hep::Material matter = ns.material(cellMat);
41 
42  double ypos = startY;
43  int box = 0;
44  for (unsigned int i = 0; i < number.size(); i++) {
45  double dx = cellDx * size[i];
46  int indx = type[i];
47  for (int j = 0; j < number[i]; j++) {
48  box++;
49  std::string name = parentName + std::to_string(box);
50  dd4hep::Solid solid = dd4hep::Box(ns.prepend(name), dx, cellDy, cellDz);
51 #ifdef EDM_ML_DEBUG
52  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: " << solid.name() << " Box made of " << cellMat << " of Size "
53  << convertCmToMm(dx) << ", " << convertCmToMm(cellDy) << ", "
54  << convertCmToMm(cellDz);
55 #endif
56  dd4hep::Volume glog(solid.name(), solid, matter);
57 
58  parent.placeVolume(glog, box, dd4hep::Position(0.0, ypos, 0.0));
59 #ifdef EDM_ML_DEBUG
60  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: " << solid.name() << " number " << box << " positioned in "
61  << parent.name() << " at (0.0, " << convertCmToMm(ypos) << ", 0.0) with no rotation";
62 #endif
63 
64  double xpos = -dx + cellDx;
65  ypos += 2 * cellDy;
66  indx = 1 - indx;
67  for (int k = 0; k < size[i]; ++k) {
68  glog.placeVolume(ns.volume(childName[indx]), k + 1, dd4hep::Position(xpos, 0.0, 0.0));
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: " << childName[indx] << " number " << k + 1
71  << " positioned in " << glog.name() << " at (" << convertCmToMm(xpos)
72  << ", 0,0, 0.0) with no rotation";
73 #endif
74  xpos += 2 * cellDx;
75  }
76  }
77  }
78 #ifdef EDM_ML_DEBUG
79  edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalForwardAlgo construction";
80 #endif
81  return 1;
82 }
83 
84 // first argument is the type from the xml file
85 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalForwardAlgo, algorithm);
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:355
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
cms::DDParsingContext
Definition: DDParsingContext.h:14
cms::DDNamespace
Definition: DDNamespace.h:16
DDSplit.h
geant_units::operators
Definition: GeantUnits.h:18
dqmdumpme.first
first
Definition: dqmdumpme.py:55
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
Definition: DDHCalForwardAlgo.cc:10
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:66
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
type
type
Definition: HCALResponse.h:21
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:68
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
PVValHelper::dx
Definition: PVValidationHelpers.h:48
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37