Skip to content

Commit

Permalink
module-theta segmentation with merging per layer
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannimarchiori committed Aug 28, 2023
1 parent c635177 commit 15a1d84
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
37 changes: 32 additions & 5 deletions Detector/DetComponents/src/RedoSegmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ StatusCode RedoSegmentation::initialize() {
info() << "Old bitfield:\t" << m_oldDecoder->fieldDescription() << endmsg;
info() << "New bitfield:\t" << m_segmentation->decoder()->fieldDescription() << endmsg;
info() << "New segmentation is of type:\t" << m_segmentation->type() << endmsg;
if (m_segmentation->type() == "FCCSWGridModuleThetaMerged")
m_segmentationType=2;
else
m_segmentationType=0;
m_oldSegmentation = m_geoSvc->lcdd()->readout(m_oldReadoutName).segmentation().segmentation();
info() << "Old segmentation is of type:\t" << m_oldSegmentation->type() << endmsg;
if (m_oldSegmentation->type() == "FCCSWGridModuleThetaMerged")
m_oldSegmentationType=2;
else
m_oldSegmentationType=0;

m_outHitsCellIDEncoding.put(m_segmentation->decoder()->fieldDescription());

return StatusCode::SUCCESS;
Expand All @@ -79,16 +90,32 @@ StatusCode RedoSegmentation::execute() {
auto newHit = outHits->create();
newHit.setEnergy(hit.getEnergy());
// SimCalorimeterHit type (needed for createCaloCells which runs after RedoSegmentation) has no time member
//newHit.setTime(hit.getTime());
// newHit.setTime(hit.getTime());
dd4hep::DDSegmentation::CellID cellId = hit.getCellID();
if (debugIter < m_debugPrint) {
debug() << "OLD: " << m_oldDecoder->valueString(cellId) << endmsg;
}
// factor 10 to convert mm to cm // TODO: check
auto pos = hit.getPosition();
dd4hep::DDSegmentation::Vector3D position(pos.x / 10., pos.y / 10., pos.z / 10.);
dd4hep::DDSegmentation::Vector3D position;
if (m_oldSegmentationType == 2) {
position = m_oldSegmentation->position(cellId);
}
else {
auto pos = hit.getPosition();
// factor 10 to convert mm to cm
position = dd4hep::DDSegmentation::Vector3D (pos.x / 10., pos.y / 10., pos.z / 10.);
}

// first calculate proper segmentation fields
dd4hep::DDSegmentation::CellID newCellId = m_segmentation->cellID(position, position, 0);
// pass volumeID: we need layer / module information
// (which is easier/safer to get from cellID than infer from position)
dd4hep::DDSegmentation::VolumeID vID = volumeID(cellId);
// for module-theta merged segmentation in which we are replacing
// initial module number with merged module number, we still want
// to pass the initial module number to segmentation->cellID(..)
// as part of the volume ID
if (m_segmentationType == 2)
m_segmentation->decoder()->set(vID, "module", m_oldDecoder->get(cellId, "module"));
dd4hep::DDSegmentation::CellID newCellId = m_segmentation->cellID(position, position, vID);
// now rewrite all other fields (detector ID)
for (const auto& detectorField : m_detectorIdentifiers) {
oldid = m_oldDecoder->get(cellId, detectorField);
Expand Down
4 changes: 4 additions & 0 deletions Detector/DetComponents/src/RedoSegmentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ class RedoSegmentation : public GaudiAlgorithm {
m_outHits,"CellIDEncodingString", Gaudi::DataHandle::Writer};
/// New segmentation
dd4hep::DDSegmentation::Segmentation* m_segmentation;
int m_segmentationType; // use enum instead? defined in some namespace?
/// Name of the detector readout used in simulation
Gaudi::Property<std::string> m_oldReadoutName{this, "oldReadoutName", "",
"Name of the detector readout used in simulation"};
/// Old segmentation
dd4hep::DDSegmentation::Segmentation* m_oldSegmentation;
int m_oldSegmentationType; // use enum instead? defined in some namespace?
/// Name of the new detector readout
Gaudi::Property<std::string> m_newReadoutName{this, "newReadoutName", "", "Name of the new detector readout"};
/// Old bitfield decoder
Expand Down

0 comments on commit 15a1d84

Please sign in to comment.