LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 
4 
5 
7 
8 #include "cetlib_except/exception.h"
9 
10 #include "Geant4/G4Material.hh"
11 #include <cmath>
12 
13 
14 
15 
16 namespace larg4
17 {
18 
19  //-----------------------------------------------
20  // OpParamAction base class methods
21  //-----------------------------------------------
22 
23 
24 
26  {
27  }
28 
30  {
31  }
32 
33  double OpParamAction::GetAttenuationFraction(G4ThreeVector /*PhotonDirection*/, G4ThreeVector /*PhotonPosition*/)
34  {
35  return 0;
36  }
37 
38 
39 
40  //-----------------------------------------------
41  // SimpleWireplaneAction Methods
42  //-----------------------------------------------
43 
44 
45  SimpleWireplaneAction::SimpleWireplaneAction(TVector3 WireDirection, TVector3 PlaneNormal, double WirePitch, double WireDiameter)
46  {
47  fWireDirection = G4ThreeVector(WireDirection.X(),
48  WireDirection.Y(),
49  WireDirection.Z()).unit();
50  fPlaneNormal = G4ThreeVector(PlaneNormal.X(),
51  PlaneNormal.Y(),
52  PlaneNormal.Z()).unit();
53  fDPRatio = WireDiameter/WirePitch;
54  }
55 
56  //-----------------------------------------------
57 
59  {
60  }
61 
62  //-----------------------------------------------
63  // An ideal simple wireplane attenuates the light by a fraction
64  // Wire_Diameter / (Pitch * cos theta) where theta is the angle
65  // of incident light projected into the plane perpendicular to the
66  // wires. The photon position is not used.
67  //
68  double SimpleWireplaneAction::GetAttenuationFraction(G4ThreeVector PhotonDirection, G4ThreeVector /*PhotonPosition*/)
69  {
70  G4ThreeVector ProjDirection = PhotonDirection - fWireDirection*(fWireDirection.dot(PhotonDirection));
71  double CosTheta = std::abs(fPlaneNormal.dot(ProjDirection));
72  if(CosTheta < fDPRatio)
73  return 0;
74  else
75  return (1.0 - fDPRatio / CosTheta);
76  }
77 
78 
79 
80  //-----------------------------------------------
81  // OverlaidWireplanesAction Methods
82  //-----------------------------------------------
83 
84 
85  OverlaidWireplanesAction::OverlaidWireplanesAction(std::vector<std::vector<double> > InputVectors, int Orientation)
86  {
87 
88  G4ThreeVector WireBasis1, WireBasis2;
89 
90  if(Orientation==0)
91  {
92  fPlaneNormal=G4ThreeVector(1,0,0);
93  WireBasis1 =G4ThreeVector(0,1,0);
94  WireBasis2 =G4ThreeVector(0,0,1);
95  }
96  else if(Orientation==1)
97  {
98  fPlaneNormal=G4ThreeVector(0,1,0);
99  WireBasis1 =G4ThreeVector(1,0,0);
100  WireBasis2 =G4ThreeVector(0,0,1);
101  }
102  else if(Orientation==2)
103  {
104  fPlaneNormal=G4ThreeVector(0,0,1);
105  WireBasis1 =G4ThreeVector(0,1,0);
106  WireBasis2 =G4ThreeVector(0,0,1);
107  }
108  else
109  {
110  throw cet::exception("OpParamAction") << "Unrecognized wireplane orientation. Options are 1=Xdrift, 2=Ydrift, 3=Zdrift\n";
111  }
112  for(size_t i=0; i!=InputVectors.size(); ++i)
113  {
114  if(InputVectors.at(i).size()!=3)
115  {
116  throw cet::exception("OpParamAction") << "Unrecognized wireplane parameter format. Expected vector(3)'s with v[0] = wire angle, v[1] = wire pitch, v[2] = wire diameter\n";
117  }
118  else
119  {
120  double theta = InputVectors[i][0]*3.142/180.;
121  fWireDirections.push_back(cos(theta)*WireBasis1 + sin(theta)*WireBasis2);
122  fDPRatios.push_back(InputVectors[i][2]/InputVectors[i][1]);
123  }
124  }
125  }
126 
127 
128  //-----------------------------------------------
129 
131  {
132  }
133 
134 
135  //-----------------------------------------------
136 
137  double OverlaidWireplanesAction::GetAttenuationFraction(G4ThreeVector PhotonDirection, G4ThreeVector /*PhotonPosition*/)
138  {
139 
140  double AttenFraction=1.;
141 
142  for(size_t i=0; i!=fWireDirections.size(); ++i)
143  {
144  G4ThreeVector ProjDirection = PhotonDirection - fWireDirections.at(i) * (fWireDirections.at(i).dot(PhotonDirection.unit()));
145 
146  // fWireDirections.at(i).cross(PhotonDirection.cross(fWireDirections.at(i)).unit());
147  double CosTheta = (ProjDirection.mag() > 0 ? std::abs(fPlaneNormal.dot(ProjDirection))/ProjDirection.mag() : 1.0);
148  if(CosTheta < fDPRatios.at(i))
149  return 0;
150  else
151  AttenFraction *= (1.0 - fDPRatios.at(i) / CosTheta);
152  }
153  return AttenFraction;
154  }
155 
156 
157 
158 
159 
160 }
SimpleWireplaneAction(TVector3 WireDirection, TVector3 PlaneNormal, double WirePitch, double WireDiameter)
double GetAttenuationFraction(G4ThreeVector PhotonDirection, G4ThreeVector PhotonPosition)
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:265
OverlaidWireplanesAction(std::vector< std::vector< double > >, int)
virtual double GetAttenuationFraction(G4ThreeVector PhotonDirection, G4ThreeVector PhotonPosition)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33