LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
OpParamAction.cxx
Go to the documentation of this file.
1 // OpParamAction class implementation : Ben Jones, MIT 2013
2 // See header file for detailed description.
3 
5 
6 #include "cetlib_except/exception.h"
7 
8 #include <cmath>
9 
10 namespace larg4 {
11 
12  //-----------------------------------------------
13  // OpParamAction base class methods
14  //-----------------------------------------------
15 
17 
19 
20  double OpParamAction::GetAttenuationFraction(G4ThreeVector /*PhotonDirection*/,
21  G4ThreeVector /*PhotonPosition*/)
22  {
23  return 0;
24  }
25 
26  //-----------------------------------------------
27  // SimpleWireplaneAction Methods
28  //-----------------------------------------------
29 
31  TVector3 PlaneNormal,
32  double WirePitch,
33  double WireDiameter)
34  {
35  fWireDirection = G4ThreeVector(WireDirection.X(), WireDirection.Y(), WireDirection.Z()).unit();
36  fPlaneNormal = G4ThreeVector(PlaneNormal.X(), PlaneNormal.Y(), PlaneNormal.Z()).unit();
37  fDPRatio = WireDiameter / WirePitch;
38  }
39 
40  //-----------------------------------------------
41 
43 
44  //-----------------------------------------------
45  // An ideal simple wireplane attenuates the light by a fraction
46  // Wire_Diameter / (Pitch * cos theta) where theta is the angle
47  // of incident light projected into the plane perpendicular to the
48  // wires. The photon position is not used.
49  //
50  double SimpleWireplaneAction::GetAttenuationFraction(G4ThreeVector PhotonDirection,
51  G4ThreeVector /*PhotonPosition*/)
52  {
53  G4ThreeVector ProjDirection =
54  PhotonDirection - fWireDirection * (fWireDirection.dot(PhotonDirection));
55  double CosTheta = std::abs(fPlaneNormal.dot(ProjDirection));
56  if (CosTheta < fDPRatio)
57  return 0;
58  else
59  return (1.0 - fDPRatio / CosTheta);
60  }
61 
62  //-----------------------------------------------
63  // OverlaidWireplanesAction Methods
64  //-----------------------------------------------
65 
67  int Orientation)
68  {
69 
70  G4ThreeVector WireBasis1, WireBasis2;
71 
72  if (Orientation == 0) {
73  fPlaneNormal = G4ThreeVector(1, 0, 0);
74  WireBasis1 = G4ThreeVector(0, 1, 0);
75  WireBasis2 = G4ThreeVector(0, 0, 1);
76  }
77  else if (Orientation == 1) {
78  fPlaneNormal = G4ThreeVector(0, 1, 0);
79  WireBasis1 = G4ThreeVector(1, 0, 0);
80  WireBasis2 = G4ThreeVector(0, 0, 1);
81  }
82  else if (Orientation == 2) {
83  fPlaneNormal = G4ThreeVector(0, 0, 1);
84  WireBasis1 = G4ThreeVector(0, 1, 0);
85  WireBasis2 = G4ThreeVector(0, 0, 1);
86  }
87  else {
88  throw cet::exception("OpParamAction")
89  << "Unrecognized wireplane orientation. Options are 1=Xdrift, 2=Ydrift, 3=Zdrift\n";
90  }
91  for (size_t i = 0; i != InputVectors.size(); ++i) {
92  if (InputVectors.at(i).size() != 3) {
93  throw cet::exception("OpParamAction")
94  << "Unrecognized wireplane parameter format. Expected vector(3)'s with v[0] = wire "
95  "angle, v[1] = wire pitch, v[2] = wire diameter\n";
96  }
97  else {
98  double theta = InputVectors[i][0] * 3.142 / 180.;
99  fWireDirections.push_back(cos(theta) * WireBasis1 + sin(theta) * WireBasis2);
100  fDPRatios.push_back(InputVectors[i][2] / InputVectors[i][1]);
101  }
102  }
103  }
104 
105  //-----------------------------------------------
106 
108 
109  //-----------------------------------------------
110 
111  double OverlaidWireplanesAction::GetAttenuationFraction(G4ThreeVector PhotonDirection,
112  G4ThreeVector /*PhotonPosition*/)
113  {
114 
115  double AttenFraction = 1.;
116 
117  for (size_t i = 0; i != fWireDirections.size(); ++i) {
118  G4ThreeVector ProjDirection =
119  PhotonDirection -
120  fWireDirections.at(i) * (fWireDirections.at(i).dot(PhotonDirection.unit()));
121 
122  // fWireDirections.at(i).cross(PhotonDirection.cross(fWireDirections.at(i)).unit());
123  double CosTheta =
124  (ProjDirection.mag() > 0 ? std::abs(fPlaneNormal.dot(ProjDirection)) / ProjDirection.mag() :
125  1.0);
126  if (CosTheta < fDPRatios.at(i))
127  return 0;
128  else
129  AttenFraction *= (1.0 - fDPRatios.at(i) / CosTheta);
130  }
131  return AttenFraction;
132  }
133 
134 }
SimpleWireplaneAction(TVector3 WireDirection, TVector3 PlaneNormal, double WirePitch, double WireDiameter)
OverlaidWireplanesAction(std::vector< std::vector< double >>, int)
double GetAttenuationFraction(G4ThreeVector PhotonDirection, G4ThreeVector PhotonPosition)
constexpr auto abs(T v)
Returns the absolute value of the argument.
Geant4 interface.
double GetAttenuationFraction(G4ThreeVector PhotonDirection, G4ThreeVector PhotonPosition)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
virtual double GetAttenuationFraction(G4ThreeVector PhotonDirection, G4ThreeVector PhotonPosition)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33