Analysis Software
Documentation for sPHENIX simulation 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 <cmath>
16 #include <cstddef>
17 #include <utility>
18 
20  std::shared_ptr<const Segmentation> moduleSegmentation,
21  double halfThickness, int readoutDirection, double lorentzAngle,
22  double energyThreshold, bool analogue)
23  :
24 
25  m_halfThickness(halfThickness),
26  m_readoutDirection(readoutDirection),
27  m_lorentzAngle(lorentzAngle),
28  m_tanLorentzAngle(tan(lorentzAngle)),
29  m_energyThreshold(energyThreshold),
30  m_analogue(analogue),
31  m_segmentation(std::move(moduleSegmentation)),
32  m_boundarySurfaces(),
33  m_segmentationSurfacesX(),
34  m_segmentationSurfacesY() {
35  m_segmentation->createSegmentationSurfaces(
37  halfThickness, readoutDirection, lorentzAngle);
38 }
39 
41  const Acts::DigitizationCell& entryCids,
42  const Acts::DigitizationCell& exitCids) const {
43  SurfacePtrVector sSurfaces;
44 
45  auto startbinX = entryCids.channel0;
46  auto endbinX = exitCids.channel0;
47  // swap if needed
48  if (startbinX > endbinX) {
49  std::swap(startbinX, endbinX);
50  }
51  // now cash in the rest
52  for (; startbinX <= endbinX; ++startbinX) {
53  sSurfaces.push_back(m_segmentationSurfacesX[startbinX]);
54  }
55 
56  // start bin, end bin
57  auto startbinY = entryCids.channel1;
58  auto endbinY = exitCids.channel1;
59  // swap if needed
60  if (startbinY > endbinY) {
61  std::swap(startbinY, endbinY);
62  }
63  // now cash in the rest
64  for (; startbinY <= endbinY; ++startbinY) {
65  sSurfaces.push_back(m_segmentationSurfacesY[startbinY]);
66  }
67 
68  // return what you have
69  return sSurfaces;
70 }
71 
73  const Vector3& start, const Vector3& end) const {
74  // prepare the return vector
75  SurfacePtrVector stepSurfaces;
76 
77  const DigitizationCell startCell = m_segmentation->cell(start);
78  const DigitizationCell endCell = m_segmentation->cell(end);
79 
80  // go along x - first with the naive binning (i.e. w.o lorentz angle)
81  size_t sCellX = startCell.channel0;
82  size_t eCellX = endCell.channel0;
83  if (sCellX > eCellX) {
84  std::swap(sCellX, eCellX);
85  }
86  // now take the boundaries as well
87  if (sCellX > 0) {
88  --sCellX;
89  }
90  ++eCellX; // @TODO check : safe because we can assume to have eCell+1
91  // the surfaces along Y are easy, just the bin surfaces
92  size_t sCellY = startCell.channel1;
93  size_t eCellY = endCell.channel1;
94  if (sCellY > eCellY) {
95  std::swap(sCellY, eCellY);
96  }
97  // reserve - be safe
98  stepSurfaces.reserve((eCellY - sCellY) + (eCellX - sCellX) + 2);
99  // now fill the x surfaces
100  for (; sCellX <= eCellX && sCellX < m_segmentationSurfacesX.size();
101  ++sCellX) {
102  stepSurfaces.push_back(m_segmentationSurfacesX[sCellX]);
103  }
104  // end fill the y surfaces
105  for (; sCellY <= eCellY && sCellY < m_segmentationSurfacesY.size();
106  ++sCellY) {
107  stepSurfaces.push_back(m_segmentationSurfacesY[sCellY]);
108  }
109  // return the lot
110  return stepSurfaces;
111 }