EIC 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
13 
14 #include <memory>
15 #include <vector>
16 
17 namespace Acts {
18 
27  public:
29  ISurfaceMaterial() = default;
30 
34  ISurfaceMaterial(double splitFactor) : m_splitFactor(splitFactor) {}
35 
37  virtual ~ISurfaceMaterial() = default;
38 
42  virtual ISurfaceMaterial& operator*=(double scale) = 0;
43 
50  virtual const MaterialSlab& materialSlab(const Vector2D& lp) const = 0;
51 
58  virtual const MaterialSlab& materialSlab(const Vector3D& gp) const = 0;
59 
64  virtual const MaterialSlab& materialSlab(size_t ib0, size_t ib1) const = 0;
65 
70  double factor(NavigationDirection pDir, MaterialUpdateStage mStage) const;
71 
81  MaterialUpdateStage mStage) const;
82 
92  MaterialUpdateStage mStage) const;
93 
100  friend std::ostream& operator<<(std::ostream& out,
101  const ISurfaceMaterial& sm) {
102  sm.toStream(out);
103  return out;
104  }
105 
107  virtual std::ostream& toStream(std::ostream& sl) const = 0;
108 
109  protected:
110  double m_splitFactor{1.};
111 };
112 
114  MaterialUpdateStage mStage) const {
115  if (mStage == Acts::fullUpdate) {
116  return 1.;
117  }
118  return (pDir * mStage > 0 ? m_splitFactor : 1. - m_splitFactor);
119 }
120 
122  const Vector2D& lp, NavigationDirection pDir,
123  MaterialUpdateStage mStage) const {
124  // The plain material properties associated to this bin
125  MaterialSlab plainMatProp = materialSlab(lp);
126  // Scale if you have material to scale
127  if (plainMatProp) {
128  double scaleFactor = factor(pDir, mStage);
129  if (scaleFactor == 0.) {
130  return MaterialSlab();
131  }
132  plainMatProp.scaleThickness(scaleFactor);
133  }
134  return plainMatProp;
135 }
136 
138  const Vector3D& gp, NavigationDirection pDir,
139  MaterialUpdateStage mStage) const {
140  // The plain material properties associated to this bin
141  MaterialSlab plainMatProp = materialSlab(gp);
142  // Scale if you have material to scale
143  if (plainMatProp) {
144  double scaleFactor = factor(pDir, mStage);
145  if (scaleFactor == 0.) {
146  return MaterialSlab();
147  }
148  plainMatProp.scaleThickness(scaleFactor);
149  }
150  return plainMatProp;
151 }
152 
153 } // namespace Acts