EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DigitizationModule.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DigitizationModule.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 // DigitizationModule.cpp, Acts project
12 
14 
15 #include <utility>
16 
18  std::shared_ptr<const Segmentation> moduleSegmentation,
19  double halfThickness, int readoutDirection, double lorentzAngle,
20  double energyThreshold, bool analogue)
21  :
22 
23  m_halfThickness(halfThickness),
24  m_readoutDirection(readoutDirection),
25  m_lorentzAngle(lorentzAngle),
26  m_tanLorentzAngle(tan(lorentzAngle)),
27  m_energyThreshold(energyThreshold),
28  m_analogue(analogue),
29  m_segmentation(std::move(moduleSegmentation)),
30  m_boundarySurfaces(),
31  m_segmentationSurfacesX(),
32  m_segmentationSurfacesY() {
33  m_segmentation->createSegmentationSurfaces(
35  halfThickness, readoutDirection, lorentzAngle);
36 }
37 
39  const Acts::DigitizationCell& entryCids,
40  const Acts::DigitizationCell& exitCids) const {
41  SurfacePtrVector sSurfaces;
42 
43  auto startbinX = entryCids.channel0;
44  auto endbinX = exitCids.channel0;
45  // swap if needed
46  if (startbinX > endbinX) {
47  std::swap(startbinX, endbinX);
48  }
49  // now cash in the rest
50  for (; startbinX <= endbinX; ++startbinX) {
51  sSurfaces.push_back(m_segmentationSurfacesX[startbinX]);
52  }
53 
54  // start bin, end bin
55  auto startbinY = entryCids.channel1;
56  auto endbinY = exitCids.channel1;
57  // swap if needed
58  if (startbinY > endbinY) {
59  std::swap(startbinY, endbinY);
60  }
61  // now cash in the rest
62  for (; startbinY <= endbinY; ++startbinY) {
63  sSurfaces.push_back(m_segmentationSurfacesY[startbinY]);
64  }
65 
66  // return what you have
67  return sSurfaces;
68 }
69 
71  const Vector3D& start, const Vector3D& end) const {
72  // prepare the return vector
73  SurfacePtrVector stepSurfaces;
74 
75  const DigitizationCell startCell = m_segmentation->cell(start);
76  const DigitizationCell endCell = m_segmentation->cell(end);
77 
78  // go along x - first with the naive binning (i.e. w.o lorentz angle)
79  size_t sCellX = startCell.channel0;
80  size_t eCellX = endCell.channel0;
81  if (sCellX > eCellX) {
82  std::swap(sCellX, eCellX);
83  }
84  // now take the boundaries as well
85  if (sCellX > 0) {
86  --sCellX;
87  }
88  ++eCellX; // @TODO check : safe because we can assume to have eCell+1
89  // the surfaces along Y are easy, just the bin surfaces
90  size_t sCellY = startCell.channel1;
91  size_t eCellY = endCell.channel1;
92  if (sCellY > eCellY) {
93  std::swap(sCellY, eCellY);
94  }
95  // reserve - be safe
96  stepSurfaces.reserve((eCellY - sCellY) + (eCellX - sCellX) + 2);
97  // now fill the x surfaces
98  for (; sCellX <= eCellX && sCellX < m_segmentationSurfacesX.size();
99  ++sCellX) {
100  stepSurfaces.push_back(m_segmentationSurfacesX[sCellX]);
101  }
102  // end fill the y surfaces
103  for (; sCellY <= eCellY && sCellY < m_segmentationSurfacesY.size();
104  ++sCellY) {
105  stepSurfaces.push_back(m_segmentationSurfacesY[sCellY]);
106  }
107  // return the lot
108  return stepSurfaces;
109 }