Public Member Functions | Private Member Functions | Private Attributes | List of all members
larg4::OpBoundaryProcessSimple Class Reference

Discrete process for reflection and diffusion at optical interfaces. More...

#include <OpBoundaryProcessSimple.hh>

Inheritance diagram for larg4::OpBoundaryProcessSimple:

Public Member Functions

 OpBoundaryProcessSimple (const G4String &processName="OpBoundary", G4ProcessType type=fOptical)
 
G4bool IsApplicable (const G4ParticleDefinition &aParticleType)
 
G4double GetMeanFreePath (const G4Track &, G4double, G4ForceCondition *condition)
 
G4VParticleChange * PostStepDoIt (const G4Track &aTrack, const G4Step &aStep)
 
OpBoundaryProcessSimpleStatus GetStatus () const
 

Private Member Functions

G4bool G4BooleanRand (const G4double prob) const
 

Private Attributes

OpBoundaryProcessSimpleStatus fTheStatus
 
G4double fCarTolerance
 
int fVerbosity
 

Detailed Description

Discrete process for reflection and diffusion at optical interfaces.

See also
G4VDiscreteProcess

This class invokes a simplified model of optical reflections at boundaries between different materials. The relevant reflectivities are ultimately read from detinfo::LArProperties via larg4::MaterialPropertiesLoader.

The required parameters are total reflectance (detinfo::LArProperties::SurfaceReflectances()) and ratio of diffuse to specular reflectance (detinfo::LArProperties::SurfaceReflectanceDiffuseFractions()). Each photon crossing a boundary with a defined reflectance is randomly either reflected or absorbed and killed according to the supplied probability.

Every reflected photon with a defined diffuse reflection fraction is then randomly either diffusely or specularly reflected according to the supplied probability. All materials with no defined reflectance are assumed to be black and absorb all incident photons.

This physics process is loaded in larg4::OpticalPhysics physics constructor.

This class is based on the G4OpBoundaryProcess class in Geant4 and was adapted for LArSoft by Ben Jones, MIT, March 2010.

Definition at line 102 of file OpBoundaryProcessSimple.hh.

Constructor & Destructor Documentation

larg4::OpBoundaryProcessSimple::OpBoundaryProcessSimple ( const G4String &  processName = "OpBoundary",
G4ProcessType  type = fOptical 
)

Definition at line 65 of file OpBoundaryProcessSimple.cxx.

66  : G4VDiscreteProcess(processName, type)
67  {
68  G4cout << GetProcessName() << " is created " << G4endl;
69 
70  SetProcessSubType(fOpBoundary);
71 
73 
74  fCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
75  }
OpBoundaryProcessSimpleStatus fTheStatus

Member Function Documentation

G4bool larg4::OpBoundaryProcessSimple::G4BooleanRand ( const G4double  prob) const
inlineprivate

Definition at line 133 of file OpBoundaryProcessSimple.hh.

134  {
135  /* Returns a random boolean variable with the specified probability */
136  return (G4UniformRand() < prob);
137  }
G4double larg4::OpBoundaryProcessSimple::GetMeanFreePath ( const G4Track &  ,
G4double  ,
G4ForceCondition *  condition 
)

Definition at line 233 of file OpBoundaryProcessSimple.cxx.

234  {
235  *condition = Forced;
236 
237  return DBL_MAX;
238  }
OpBoundaryProcessSimpleStatus larg4::OpBoundaryProcessSimple::GetStatus ( void  ) const
inline

Definition at line 146 of file OpBoundaryProcessSimple.hh.

147  {
148  return fTheStatus;
149  }
OpBoundaryProcessSimpleStatus fTheStatus
G4bool larg4::OpBoundaryProcessSimple::IsApplicable ( const G4ParticleDefinition &  aParticleType)
inline

Definition at line 140 of file OpBoundaryProcessSimple.hh.

141  {
142  return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
143  }
G4VParticleChange * larg4::OpBoundaryProcessSimple::PostStepDoIt ( const G4Track &  aTrack,
const G4Step &  aStep 
)

Definition at line 81 of file OpBoundaryProcessSimple.cxx.

82  {
83 
84  // Note - these have to be loaded here, since this object
85  // is constructed before LArG4, and hence before the
86  // LArG4 parameters are read from config
87 
89  aParticleChange.Initialize(aTrack);
90 
91  G4StepPoint* pPreStepPoint = aStep.GetPreStepPoint();
92  G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
93 
94  if (pPostStepPoint->GetStepStatus() != fGeomBoundary) {
96  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
97  }
98  if (aTrack.GetStepLength() <= fCarTolerance / 2) {
100  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
101  }
102 
103  G4Material* Material1 = pPreStepPoint->GetMaterial();
104  G4Material* Material2 = pPostStepPoint->GetMaterial();
105 
106  if (Material1 != Material2) {
107 
109 
110  fVerbosity = lgp->OpVerbosity();
111 
112  G4ThreeVector NewMomentum;
113  G4ThreeVector NewPolarization;
114 
115  G4ThreeVector theGlobalNormal;
116  G4ThreeVector theFacetNormal;
117 
118  std::string Material1Name = Material1->GetName();
119  std::string Material2Name = Material2->GetName();
120 
121  const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
122  G4double thePhotonMomentum = aParticle->GetTotalMomentum();
123  G4ThreeVector OldMomentum = aParticle->GetMomentumDirection();
124  G4ThreeVector OldPolarization = aParticle->GetPolarization();
125 
126  if (fVerbosity > 9)
127  std::cout << "OpBoundaryProcessSimple Debug: Photon " << aTrack.GetTrackID() << " momentum "
128  << thePhotonMomentum << " Material1 " << Material1Name.c_str() << " Material 2 "
129  << Material2Name.c_str() << std::endl;
130 
131  G4ThreeVector theGlobalPoint = pPostStepPoint->GetPosition();
132 
133  G4Navigator* theNavigator =
134  G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
135 
136  G4ThreeVector theLocalPoint =
137  theNavigator->GetGlobalToLocalTransform().TransformPoint(theGlobalPoint);
138 
139  // Normal points back into volume
140  G4bool valid;
141  G4ThreeVector theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
142 
143  if (valid) { theLocalNormal = -theLocalNormal; }
144  else {
145  G4cerr << " OpBoundaryProcessSimple/PostStepDoIt(): "
146  << " The Navigator reports that it returned an invalid normal" << G4endl;
147  }
148 
149  theGlobalNormal = theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
150 
151  if (OldMomentum * theGlobalNormal > 0.0) {
152 #ifdef G4DEBUG_OPTICAL
153  G4cerr << " OpBoundaryProcessSimple/PostStepDoIt(): "
154  << " theGlobalNormal points the wrong direction " << G4endl;
155 #endif
156  theGlobalNormal = -theGlobalNormal;
157  }
158 
159  G4MaterialPropertiesTable* aMaterialPropertiesTable;
160  G4MaterialPropertyVector* Reflectance;
161  G4MaterialPropertyVector* DiffuseReflectanceFraction;
162 
163  aMaterialPropertiesTable = Material1->GetMaterialPropertiesTable();
164 
165  if (aMaterialPropertiesTable) {
166 
167  std::stringstream PropertyName;
168  PropertyName << "REFLECTANCE_" << Material2Name.c_str();
169  Reflectance = aMaterialPropertiesTable->GetProperty(PropertyName.str().c_str());
170 
171  PropertyName.str("");
172  PropertyName << "DIFFUSE_REFLECTANCE_FRACTION_" << Material2Name.c_str();
173  DiffuseReflectanceFraction =
174  aMaterialPropertiesTable->GetProperty(PropertyName.str().c_str());
175 
176  if (Reflectance) {
177  double theReflectance = Reflectance->Value(thePhotonMomentum);
178  if (G4BooleanRand(theReflectance)) {
179  if (DiffuseReflectanceFraction) {
180  double theDiffuseReflectanceFraction =
181  DiffuseReflectanceFraction->Value(thePhotonMomentum);
182  if (G4BooleanRand(theDiffuseReflectanceFraction)) { fTheStatus = SimpleDiffuse; }
183  else {
185  }
186  }
187  else {
189  }
190  }
191  else {
193  }
194  }
195  else {
197  }
198  }
199 
200  // Take action according to track status
201 
202  if (fTheStatus == SimpleDiffuse) {
203  NewMomentum = G4LambertianRand(theGlobalNormal);
204  theFacetNormal = (NewMomentum - OldMomentum).unit();
205  }
206 
207  else if (fTheStatus == SimpleSpecular) {
208  theFacetNormal = theGlobalNormal;
209  G4double PdotN = OldMomentum * theFacetNormal;
210  NewMomentum = OldMomentum - (2. * PdotN) * theFacetNormal;
211  }
212 
214  aParticleChange.ProposeTrackStatus(fStopAndKill);
215  }
216 
217  else if ((fTheStatus == NotAtBoundary) || (fTheStatus == StepTooSmall)) {
218  NewMomentum = OldMomentum;
219  }
220  else
221  aParticleChange.ProposeTrackStatus(fStopAndKill);
222 
223  NewMomentum = NewMomentum.unit();
224  aParticleChange.ProposeMomentumDirection(NewMomentum);
225  }
226  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
227  }
std::string string
Definition: nybbler.cc:12
OpBoundaryProcessSimpleStatus fTheStatus
int OpVerbosity() const
G4bool G4BooleanRand(const G4double prob) const
QTextStream & endl(QTextStream &s)

Member Data Documentation

G4double larg4::OpBoundaryProcessSimple::fCarTolerance
private

Definition at line 127 of file OpBoundaryProcessSimple.hh.

OpBoundaryProcessSimpleStatus larg4::OpBoundaryProcessSimple::fTheStatus
private

Definition at line 126 of file OpBoundaryProcessSimple.hh.

int larg4::OpBoundaryProcessSimple::fVerbosity
private

Definition at line 129 of file OpBoundaryProcessSimple.hh.


The documentation for this class was generated from the following files: