Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ISurfaceMaterial.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ISurfaceMaterial.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2020 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 
9 #pragma once
10 
16 
17 #include <memory>
18 #include <vector>
19 
20 namespace Acts {
21 
23 enum MappingType { PreMapping = -1, Default = 0, PostMapping = 1, Sensor = 2 };
24 
33  public:
35  ISurfaceMaterial() = default;
36 
40  ISurfaceMaterial(double splitFactor) : m_splitFactor(splitFactor) {}
41 
47  : m_splitFactor(splitFactor), m_mappingType(mappingType) {}
48 
50  virtual ~ISurfaceMaterial() = default;
51 
55  virtual ISurfaceMaterial& operator*=(double scale) = 0;
56 
63  virtual const MaterialSlab& materialSlab(const Vector2& lp) const = 0;
64 
71  virtual const MaterialSlab& materialSlab(const Vector3& gp) const = 0;
72 
77  virtual const MaterialSlab& materialSlab(size_t bin0, size_t bin1) const = 0;
78 
83  double factor(Direction pDir, MaterialUpdateStage mStage) const;
84 
88 
98  MaterialUpdateStage mStage) const;
99 
108  MaterialSlab materialSlab(const Vector3& gp, Direction pDir,
109  MaterialUpdateStage mStage) const;
110 
117  friend std::ostream& operator<<(std::ostream& out,
118  const ISurfaceMaterial& sm) {
119  sm.toStream(out);
120  return out;
121  }
122 
124  virtual std::ostream& toStream(std::ostream& sl) const = 0;
125 
126  protected:
127  double m_splitFactor{1.};
130 };
131 
133  MaterialUpdateStage mStage) const {
134  if (mStage == Acts::MaterialUpdateStage::FullUpdate) {
135  return 1.;
136  } else if (mStage == Acts::MaterialUpdateStage::PreUpdate) {
137  return pDir == Direction::Negative ? m_splitFactor : 1 - m_splitFactor;
138  } else /*if (mStage == Acts::MaterialUpdateStage::PostUpdate)*/ {
139  return pDir == Direction::Positive ? m_splitFactor : 1 - m_splitFactor;
140  }
141 }
142 
144  const Vector2& lp, Direction pDir, MaterialUpdateStage mStage) const {
145  // The plain material properties associated to this bin
146  MaterialSlab plainMatProp = materialSlab(lp);
147  // Scale if you have material to scale
148  if (plainMatProp) {
149  double scaleFactor = factor(pDir, mStage);
150  if (scaleFactor == 0.) {
151  return MaterialSlab();
152  }
153  plainMatProp.scaleThickness(scaleFactor);
154  }
155  return plainMatProp;
156 }
157 
159  const Vector3& gp, Direction pDir, MaterialUpdateStage mStage) const {
160  // The plain material properties associated to this bin
161  MaterialSlab plainMatProp = materialSlab(gp);
162  // Scale if you have material to scale
163  if (plainMatProp) {
164  double scaleFactor = factor(pDir, mStage);
165  if (scaleFactor == 0.) {
166  return MaterialSlab();
167  }
168  plainMatProp.scaleThickness(scaleFactor);
169  }
170  return plainMatProp;
171 }
172 
173 } // namespace Acts