CMS 3D CMS Logo

DDHCalForwardAlgo.cc
Go to the documentation of this file.
6 #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  // Header section
15  std::string parentName = DDSplit(args.parentName()).first;
16  std::string cellMat = args.value<std::string>("CellMaterial"); //Cell material
17  double cellDx = args.value<double>("CellDx"); //Cell size (x)
18  double cellDy = args.value<double>("CellDy"); //Cell size (y)
19  double cellDz = args.value<double>("CellDz"); //Cell size (z)
20  double startY = args.value<double>("StartY"); //Starting Y for Cell
21  std::vector<std::string> childName = args.value<std::vector<std::string> >("Child"); //Children name
22  std::vector<int> number = args.value<std::vector<int> >("Number"); //Number of cells
23  std::vector<int> size = args.value<std::vector<int> >("Size"); //Number of children
24  std::vector<int> type = args.value<std::vector<int> >("Type"); //First child
25 #ifdef EDM_ML_DEBUG
26  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: Cell material " << cellMat << "\tCell Size "
27  << cms::convert2mm(cellDx) << ", " << cms::convert2mm(cellDy) << ", "
28  << cms::convert2mm(cellDz) << "\tStarting Y " << cms::convert2mm(startY) << "\tChildren "
29  << childName[0] << ", " << childName[1]
30  << "\n Cell positioning done for " << number.size() << " times";
31  for (unsigned int i = 0; i < number.size(); ++i)
32  edm::LogVerbatim("HCalGeom") << "\t" << i << " Number of children " << size[i] << " occurence " << number[i]
33  << " first child index " << type[i];
34  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo debug: Parent " << args.parentName() << " NameSpace " << ns.name();
35 #endif
36 
37  dd4hep::Volume parent = ns.volume(args.parentName());
38  dd4hep::Material matter = ns.material(cellMat);
39 
40  double ypos = startY;
41  int box = 0;
42  for (unsigned int i = 0; i < number.size(); i++) {
43  double dx = cellDx * size[i];
44  int indx = type[i];
45  for (int j = 0; j < number[i]; j++) {
46  box++;
47  std::string name = parentName + std::to_string(box);
48  dd4hep::Solid solid = dd4hep::Box(ns.prepend(name), dx, cellDy, cellDz);
49 #ifdef EDM_ML_DEBUG
50  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: " << solid.name() << " Box made of " << cellMat << " of Size "
51  << cms::convert2mm(dx) << ", " << cms::convert2mm(cellDy) << ", "
52  << cms::convert2mm(cellDz);
53 #endif
54  dd4hep::Volume glog(solid.name(), solid, matter);
55 
56  parent.placeVolume(glog, box, dd4hep::Position(0.0, ypos, 0.0));
57 #ifdef EDM_ML_DEBUG
58  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: " << solid.name() << " number " << box << " positioned in "
59  << parent.name() << " at (0.0, " << cms::convert2mm(ypos)
60  << ", 0.0) with no rotation";
61 #endif
62 
63  double xpos = -dx + cellDx;
64  ypos += 2 * cellDy;
65  indx = 1 - indx;
66  for (int k = 0; k < size[i]; ++k) {
67  glog.placeVolume(ns.volume(childName[indx]), k + 1, dd4hep::Position(xpos, 0.0, 0.0));
68 #ifdef EDM_ML_DEBUG
69  edm::LogVerbatim("HCalGeom") << "DDHCalForwardAlgo: " << childName[indx] << " number " << (k + 1)
70  << " positioned in " << glog.name() << " at (" << cms::convert2mm(xpos)
71  << ", 0,0, 0.0) with no rotation";
72 #endif
73  xpos += 2 * cellDx;
74  }
75  }
76  }
77 #ifdef EDM_ML_DEBUG
78  edm::LogVerbatim("HCalGeom") << "<<== End of DDHCalForwardAlgo construction";
79 #endif
80  return cms::s_executed;
81 }
82 
83 // first argument is the type from the xml file
84 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalForwardAlgo, algorithm);
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:582
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:116
cms::DDParsingContext
Definition: DDParsingContext.h:13
cms::DDNamespace
Definition: DDNamespace.h:16
DDSplit.h
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
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
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
angle_units::operators
Definition: angle_units.h:11
DDPlugins.h
cms::convert2mm
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDHCalForwardAlgo.cc:11
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:92
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
angle_units.h
edm::Log
Definition: MessageLogger.h:70
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
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:205
PVValHelper::dx
Definition: PVValidationHelpers.h:49
DDutils.h
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