ECCE @ 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
10 #include <memory>
11 #include <vector>
15 
16 namespace Acts {
17 
26  public:
28  ISurfaceMaterial() = default;
29 
33  ISurfaceMaterial(double splitFactor) : m_splitFactor(splitFactor) {}
34 
36  virtual ~ISurfaceMaterial() = default;
37 
41  virtual ISurfaceMaterial& operator*=(double scale) = 0;
42 
50  const Vector2D& lp) const = 0;
51 
59  const Vector3D& gp) const = 0;
60 
65  virtual const MaterialProperties& materialProperties(size_t ib0,
66  size_t ib1) const = 0;
67 
72  double factor(NavigationDirection pDir, MaterialUpdateStage mStage) const;
73 
84  MaterialUpdateStage mStage) const;
85 
96  MaterialUpdateStage mStage) const;
97 
104  friend std::ostream& operator<<(std::ostream& out,
105  const ISurfaceMaterial& sm) {
106  sm.toStream(out);
107  return out;
108  }
109 
111  virtual std::ostream& toStream(std::ostream& sl) const = 0;
112 
113  protected:
114  double m_splitFactor{1.};
115 };
116 
118  MaterialUpdateStage mStage) const {
119  if (mStage == Acts::fullUpdate) {
120  return 1.;
121  }
122  return (pDir * mStage > 0 ? m_splitFactor : 1. - m_splitFactor);
123 }
124 
126  const Vector2D& lp, NavigationDirection pDir,
127  MaterialUpdateStage mStage) const {
128  // The plain material properties associated to this bin
129  MaterialProperties plainMatProp = materialProperties(lp);
130  // Scale if you have material to scale
131  if (plainMatProp) {
132  double scaleFactor = factor(pDir, mStage);
133  if (scaleFactor == 0.) {
134  return MaterialProperties();
135  }
136  plainMatProp.scaleThickness(scaleFactor);
137  }
138  return plainMatProp;
139 }
140 
142  const Vector3D& gp, NavigationDirection pDir,
143  MaterialUpdateStage mStage) const {
144  // The plain material properties associated to this bin
145  MaterialProperties plainMatProp = materialProperties(gp);
146  // Scale if you have material to scale
147  if (plainMatProp) {
148  double scaleFactor = factor(pDir, mStage);
149  if (scaleFactor == 0.) {
150  return MaterialProperties();
151  }
152  plainMatProp.scaleThickness(scaleFactor);
153  }
154  return plainMatProp;
155 }
156 
157 } // namespace Acts