Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:35

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 ///////////////////////////////////////////////////////////////////
0010 // DigitizationModule.cpp, Acts project
0011 ///////////////////////////////////////////////////////////////////
0012 
0013 #include "Acts/Digitization/DigitizationModule.hpp"
0014 
0015 #include <cmath>
0016 #include <cstddef>
0017 #include <utility>
0018 
0019 Acts::DigitizationModule::DigitizationModule(
0020     std::shared_ptr<const Segmentation> moduleSegmentation,
0021     double halfThickness, int readoutDirection, double lorentzAngle,
0022     double energyThreshold, bool analogue)
0023     :
0024 
0025       m_halfThickness(halfThickness),
0026       m_readoutDirection(readoutDirection),
0027       m_lorentzAngle(lorentzAngle),
0028       m_tanLorentzAngle(tan(lorentzAngle)),
0029       m_energyThreshold(energyThreshold),
0030       m_analogue(analogue),
0031       m_segmentation(std::move(moduleSegmentation)),
0032       m_boundarySurfaces(),
0033       m_segmentationSurfacesX(),
0034       m_segmentationSurfacesY() {
0035   m_segmentation->createSegmentationSurfaces(
0036       m_boundarySurfaces, m_segmentationSurfacesX, m_segmentationSurfacesY,
0037       halfThickness, readoutDirection, lorentzAngle);
0038 }
0039 
0040 const Acts::SurfacePtrVector Acts::DigitizationModule::segmentationSurfaces(
0041     const Acts::DigitizationCell& entryCids,
0042     const Acts::DigitizationCell& exitCids) const {
0043   SurfacePtrVector sSurfaces;
0044 
0045   auto startbinX = entryCids.channel0;
0046   auto endbinX = exitCids.channel0;
0047   // swap if needed
0048   if (startbinX > endbinX) {
0049     std::swap(startbinX, endbinX);
0050   }
0051   // now cash in the rest
0052   for (; startbinX <= endbinX; ++startbinX) {
0053     sSurfaces.push_back(m_segmentationSurfacesX[startbinX]);
0054   }
0055 
0056   // start bin, end bin
0057   auto startbinY = entryCids.channel1;
0058   auto endbinY = exitCids.channel1;
0059   // swap if needed
0060   if (startbinY > endbinY) {
0061     std::swap(startbinY, endbinY);
0062   }
0063   // now cash in the rest
0064   for (; startbinY <= endbinY; ++startbinY) {
0065     sSurfaces.push_back(m_segmentationSurfacesY[startbinY]);
0066   }
0067 
0068   // return what you have
0069   return sSurfaces;
0070 }
0071 
0072 Acts::SurfacePtrVector Acts::DigitizationModule::stepSurfaces(
0073     const Vector3& start, const Vector3& end) const {
0074   // prepare the return vector
0075   SurfacePtrVector stepSurfaces;
0076 
0077   const DigitizationCell startCell = m_segmentation->cell(start);
0078   const DigitizationCell endCell = m_segmentation->cell(end);
0079 
0080   // go along x - first with the naive binning (i.e. w.o lorentz angle)
0081   std::size_t sCellX = startCell.channel0;
0082   std::size_t eCellX = endCell.channel0;
0083   if (sCellX > eCellX) {
0084     std::swap(sCellX, eCellX);
0085   }
0086   // now take the boundaries as well
0087   if (sCellX > 0) {
0088     --sCellX;
0089   }
0090   ++eCellX;  // @TODO check : safe because we can assume to have eCell+1
0091   // the surfaces along Y are easy, just the bin surfaces
0092   std::size_t sCellY = startCell.channel1;
0093   std::size_t eCellY = endCell.channel1;
0094   if (sCellY > eCellY) {
0095     std::swap(sCellY, eCellY);
0096   }
0097   // reserve - be safe
0098   stepSurfaces.reserve((eCellY - sCellY) + (eCellX - sCellX) + 2);
0099   // now fill the x surfaces
0100   for (; sCellX <= eCellX && sCellX < m_segmentationSurfacesX.size();
0101        ++sCellX) {
0102     stepSurfaces.push_back(m_segmentationSurfacesX[sCellX]);
0103   }
0104   // end fill the y surfaces
0105   for (; sCellY <= eCellY && sCellY < m_segmentationSurfacesY.size();
0106        ++sCellY) {
0107     stepSurfaces.push_back(m_segmentationSurfacesY[sCellY]);
0108   }
0109   // return the lot
0110   return stepSurfaces;
0111 }