OpParamSD.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file OpParamSD.cxx
3 //
4 /// \author bjpjones@mit.edu
5 ////////////////////////////////////////////////////////////////////////
6 // Implementation of the OpParamSD
7 //
8 // See comments in OpParamSD.h
9 //
10 // Ben Jones, MIT, 2013
11 //
12 
13 #include "cetlib_except/exception.h"
16 
17 #include "Geant4/G4DynamicParticle.hh"
18 #include "Geant4/G4SDManager.hh"
19 #include "Geant4/G4Step.hh"
20 #include "Geant4/G4StepPoint.hh"
21 #include "Geant4/G4ThreeVector.hh"
22 #include "Geant4/G4Track.hh"
23 #include "Geant4/G4TrackStatus.hh"
24 
25 namespace larg4{
26 
27 
28  OpParamSD::OpParamSD(G4String DetectorUniqueName, std::string ModelName, int Orientation, std::vector<std::vector<double> > ModelParameters)
29  : G4VSensitiveDetector(DetectorUniqueName)
30  {
31  // Register self with sensitive detector manager
32  G4SDManager::GetSDMpointer()->AddNewDetector(this);
33 
34  if(ModelName == "OverlaidWireplanes")
35  fOpa = new OverlaidWireplanesAction(ModelParameters, Orientation);
36 
37  else if(ModelName == "TransparentPlaneAction")
39 
40 // else if(ModelName == "SimpleWireplane")
41 // fOpa = new SimpleWireplaneAction(ModelParameters, Orientation);
42 
43 
44  // else if( your model here )
45 
46  else
47  {
48  throw cet::exception("OpParamSD")<<"Error: Optical parameterization model " << ModelName <<" not found.\n";
49  }
50 
51  }
52 
53 
54  //--------------------------------------------------------
55 
56  G4bool OpParamSD::ProcessHits(G4Step * aStep, G4TouchableHistory *)
57  {
58 
59  const G4Track* aTrack = aStep->GetTrack();
60  const G4DynamicParticle* aParticle = aTrack->GetDynamicParticle();
61 
62 
63  G4ThreeVector mom = aParticle->GetMomentumDirection();
64  G4ThreeVector pos = aStep->GetPostStepPoint()->GetPosition();
65  if(!fPhotonAlreadyCrossed[aTrack->GetTrackID()])
66  {
68  {
69  // photon survives - let it carry on
70  fPhotonAlreadyCrossed[aTrack->GetTrackID()]=true;
71  }
72  else
73  {
74  // photon is absorbed
75  aStep->GetTrack()->SetTrackStatus(fStopAndKill);
76  }
77  }
78  return true;
79  }
80 
81  //--------------------------------------------------------
82 
83  void OpParamSD::Initialize(G4HCofThisEvent *)
84  {
85  fPhotonAlreadyCrossed.clear();
86  }
87 
88 }
std::string string
Definition: nybbler.cc:12
virtual void Initialize(G4HCofThisEvent *)
Definition: OpParamSD.cxx:83
struct vector vector
Geant4 interface.
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
Definition: OpParamSD.cxx:56
G4bool G4BooleanRand(const G4double prob) const
Definition: OpParamSD.h:84
std::map< G4int, bool > fPhotonAlreadyCrossed
Definition: OpParamSD.h:77
virtual double GetAttenuationFraction(G4ThreeVector PhotonDirection, G4ThreeVector PhotonPosition)
OpParamSD(G4String name, std::string ModelName, int Orientation, std::vector< std::vector< double > > Parameters)
Definition: OpParamSD.cxx:28
OpParamAction * fOpa
Definition: OpParamSD.h:76
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33