Skip to content

Commit

Permalink
drop GeometryHelper, a copy of GeometryHelpers (#810)
Browse files Browse the repository at this point in the history
### Briefly, what does this PR introduce?

Drops GeometryHelper which contains an unused copy of a subset of
GeometryHelpers. The only used function deals with DD4hep placement for
B0. GeometryHelpers is not a utility for DD4hep, but for geometry
calculations, so the code is moved to B0 unit.

### What kind of change does this PR introduce?
- [ ] Bug fix (issue #__)
- [ ] New feature (issue #__)
- [ ] Documentation update
- [ ] Other: __

### Please check if this PR fulfills the following:
- [ ] Tests for the changes have been added
- [ ] Documentation has been added / updated
- [ ] Changes have been communicated to collaborators

### Does this PR introduce breaking changes? What changes might users
need to make to their code?
No

### Does this PR change default behavior?
No

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
veprbl and pre-commit-ci[bot] authored Nov 29, 2024
1 parent d2b9535 commit 63dda25
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 241 deletions.
36 changes: 32 additions & 4 deletions src/B0ECal_geo.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2022 Sakib Rahman, Whitney Armstrong

#include <vector>
#include <functional>

#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/OpticalSurfaces.h"
#include "DD4hep/Printout.h"
#include "DDRec/DetectorData.h"
#include "DDRec/Surface.h"
#include "GeometryHelper.h"
#include "Math/Point2D.h"
#include <XML/Helper.h>
#include <vector>

//////////////////////////////////////////////////
// Far Forward B0 Electromagnetic Calorimeter
Expand All @@ -24,6 +25,9 @@ using namespace dd4hep;

static tuple<Volume, Position> build_module(Detector& desc, xml_coll_t& plm,
SensitiveDetector& sens);
static tuple<int, int> add_individuals(
std::function<tuple<Volume, Position>(Detector&, xml_coll_t&, SensitiveDetector&)> build_module,
Detector& desc, Assembly& env, xml_coll_t& plm, SensitiveDetector& sens, int sid);

static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens) {
xml_det_t x_det = e;
Expand Down Expand Up @@ -53,8 +57,7 @@ static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens) {
int sector_id = 1;

for (xml_coll_t mod(plm, _Unicode(individuals)); mod; ++mod) {
auto [sector, nmod] =
ip6::geo::add_individuals(build_module, desc, detVol, mod, sens, sector_id++);
auto [sector, nmod] = add_individuals(build_module, desc, detVol, mod, sens, sector_id++);
addModuleNumbers(sector, nmod);
}

Expand Down Expand Up @@ -99,4 +102,29 @@ static tuple<Volume, Position> build_module(Detector& desc, xml::Collection_t& p
}
}

// place modules, id must be provided
static tuple<int, int> add_individuals(
std::function<tuple<Volume, Position>(Detector&, xml_coll_t&, SensitiveDetector&)> build_module,
Detector& desc, Assembly& env, xml_coll_t& plm, SensitiveDetector& sens, int sid) {
auto [modVol, modSize] = build_module(desc, plm, sens);
int sector_id = dd4hep::getAttrOrDefault<int>(plm, _Unicode(sector), sid);
int nmodules = 0;
for (xml_coll_t pl(plm, _Unicode(placement)); pl; ++pl) {
Position pos(dd4hep::getAttrOrDefault<double>(pl, _Unicode(x), 0.),
dd4hep::getAttrOrDefault<double>(pl, _Unicode(y), 0.),
dd4hep::getAttrOrDefault<double>(pl, _Unicode(z), 0.));
Position rot(dd4hep::getAttrOrDefault<double>(pl, _Unicode(rotx), 0.),
dd4hep::getAttrOrDefault<double>(pl, _Unicode(roty), 0.),
dd4hep::getAttrOrDefault<double>(pl, _Unicode(rotz), 0.));
auto mid = pl.attr<int>(_Unicode(id));
Transform3D tr =
Translation3D(pos.x(), pos.y(), pos.z()) * RotationZYX(rot.z(), rot.y(), rot.x());
auto modPV = env.placeVolume(modVol, tr);
modPV.addPhysVolID("sector", sector_id).addPhysVolID("module", mid);
nmodules++;
}

return {sector_id, nmodules};
}

DECLARE_DETELEMENT(B0_ECAL, createDetector)
173 changes: 0 additions & 173 deletions src/GeometryHelper.cpp

This file was deleted.

64 changes: 0 additions & 64 deletions src/GeometryHelper.h

This file was deleted.

0 comments on commit 63dda25

Please sign in to comment.