LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
OpParamSD.h
Go to the documentation of this file.
1 //
6 //
7 // This class represents a partially opaque, parameterized optical volume.
8 //
9 // The photon transmission probability is determined as a function of
10 // photon position and momentum direction by a derived class of
11 // OpParamAction. The particlar derived class to use is specified in a string given to
12 // the constructor, along with any parameters required to define that object.
13 // This implementation allows for generic extensions to new types of wireplanes
14 // or opaque surfaces for future liquid argon TPC detectors.
15 //
16 // On each step of a photon within this volume, the GetAttenuationFraction
17 // method of the OpParamAction derivative is called to get a photon
18 // transmission probability. A fraction of all photons are killed
19 // accordingly.
20 //
21 // This sensitive detector object is attached to physical volumes by the
22 // OpDetReadoutGeometry class.
23 //
24 //
25 // Ben Jones, MIT,2013
26 //
27 
28 #ifndef OpParamSD_h
29 #define OpParamSD_h 1
30 
31 #include "Geant4/G4String.hh"
32 #include "Geant4/G4Types.hh"
33 #include "Geant4/G4VSensitiveDetector.hh"
34 #include "Geant4/Randomize.hh"
35 
36 #include <map>
37 #include <string>
38 #include <vector>
39 
40 class G4HCofThisEvent;
41 class G4Step;
42 class G4TouchableHistory;
43 
44 namespace larg4 {
45 
46  class OpParamAction;
47 
48  class OpParamSD : public G4VSensitiveDetector {
49 
50  public:
51  OpParamSD(G4String name,
52  std::string ModelName,
53  int Orientation,
54  std::vector<std::vector<double>> Parameters);
55  virtual ~OpParamSD() {}
56 
57  // Beginning and end of event
58  virtual void Initialize(G4HCofThisEvent*);
59  virtual void EndOfEvent(G4HCofThisEvent*) {}
60 
61  // Tidy up event in abort
62  virtual void clear() {}
63 
64  // Run per step in sensitive volume
65  virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*);
66 
67  // Required but empty
68  virtual void DrawAll() {}
69  virtual void PrintAll() {}
70 
71  private:
72  G4bool G4BooleanRand(const G4double prob) const;
73 
75  std::map<G4int, bool> fPhotonAlreadyCrossed;
76  };
77 
78  inline G4bool OpParamSD::G4BooleanRand(const G4double prob) const
79  {
80  /* Returns a random boolean variable with the specified probability */
81  return (G4UniformRand() < prob);
82  }
83 
84 }
85 
86 #endif
virtual void DrawAll()
Definition: OpParamSD.h:68
virtual void Initialize(G4HCofThisEvent *)
Definition: OpParamSD.cxx:78
virtual void PrintAll()
Definition: OpParamSD.h:69
Geant4 interface.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
Definition: OpParamSD.cxx:55
virtual ~OpParamSD()
Definition: OpParamSD.h:55
G4bool G4BooleanRand(const G4double prob) const
Definition: OpParamSD.h:78
std::map< G4int, bool > fPhotonAlreadyCrossed
Definition: OpParamSD.h:75
virtual void EndOfEvent(G4HCofThisEvent *)
Definition: OpParamSD.h:59
virtual void clear()
Definition: OpParamSD.h:62
OpParamSD(G4String name, std::string ModelName, int Orientation, std::vector< std::vector< double >> Parameters)
Definition: OpParamSD.cxx:27
OpParamAction * fOpa
Definition: OpParamSD.h:74