/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/physics/include/RAT/GLG4Scint.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/physics/include/RAT/GLG4Scint.hh Source File
Ratpac-two
GLG4Scint.hh
1 #ifndef GLG4Scint_h
3 #define GLG4Scint_h 1
4 /*
5  Declares GLG4Scint class and helpers.
6 
7  This file is part of the GenericLAND software library.
8 
9  Author: Glenn Horton-Smith (Tohoku) 28-Jan-1999
10 
11  Revision History:
12  13 Nov 2014: Matt Strait - Fixed shadowed variable warning
13  13 May 2015: W. Heintzelman - Modify ResetPhotonCount to allow setting to
14  non-zero values; correct error in GetScintillatedCount.
15  29 Feb 2016: W Heintzelman - Add functions: GetTotEdepall, SetTotEdep
16  23 Oct 2016: N Barros - Added UserTrackInformation objects to secondary
17  particles to track the process history of the photons.
18 */
19 
20 // [see detailed class documentation below]
21 
23 // Includes
25 
26 #include <RAT/BirksLaw.hh>
27 #include <RAT/Log.hh>
28 #include <RAT/Quadrature.hh>
29 #include <RAT/QuenchingCalculator.hh>
30 
31 #include "G4DynamicParticle.hh"
32 #include "G4Material.hh"
33 #include "G4MaterialPropertiesTable.hh"
34 #include "G4OpticalPhoton.hh"
35 #include "G4ParticleChange.hh"
36 #include "G4ParticleMomentum.hh"
37 #include "G4PhysicsOrderedFreeVector.hh"
38 #include "G4PhysicsTable.hh"
39 #include "G4Step.hh"
40 #include "G4ThreeVector.hh"
41 #include "G4UImessenger.hh"
42 #include "G4VProcess.hh"
43 #include "globals.hh"
44 #include "list"
45 #include "local_g4compat.hh"
46 #include "templates.hh"
47 #include "vector"
48 
49 // Dummy classes used as placeholders in new opticalphoton tracks so
50 // that G4Track users can figure out the name of the process which
51 // created the track.
52 class GLG4DummyProcess : public G4VProcess {
53  public:
54  GLG4DummyProcess(const G4String &aName = "NoName", G4ProcessType aType = fNotDefined) : G4VProcess(aName, aType){};
55 
56  // Bogus, not a real process
57  virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track & /*track*/, G4double /*previousStepSize*/,
58  G4double /*currentMinimumStep*/, G4double & /*proposedSafety*/,
59  G4GPILSelection * /*selection*/) {
60  return 0;
61  };
62 
63  virtual G4double AtRestGetPhysicalInteractionLength(const G4Track & /*track*/, G4ForceCondition * /*condition*/) {
64  return 0;
65  };
66 
67  virtual G4double PostStepGetPhysicalInteractionLength(const G4Track & /*track*/, G4double /*previousStepSize*/,
68  G4ForceCondition * /*condition*/) {
69  return 0;
70  };
71 
72  virtual G4VParticleChange *PostStepDoIt(const G4Track & /*track*/, const G4Step & /*stepData*/) { return 0; };
73 
74  virtual G4VParticleChange *AlongStepDoIt(const G4Track & /*track*/, const G4Step & /*stepData*/) { return 0; };
75  virtual G4VParticleChange *AtRestDoIt(const G4Track & /*track*/, const G4Step & /*stepData*/) { return 0; };
76 };
77 
78 class G4UIcommand;
79 class G4UIdirectory;
80 
82 // Class Definition
84 
85 /*
86  GLG4Scint is an extremely modified version of the G4Scintillation
87  process, so much so that it's not even a G4Process anymore!
88  Features include arbitrary scintillation light time profile and
89  spectra, Birks' law, particle-dependent specification of all
90  parameters, and reemission of optical photons killed by other processes.
91 
92  - Has a GenericPostPostStepDoIt() function (note two "Post"s)
93  instead of a PostStepDoIt() function. GenericPostPostStepDoIt()
94  should be called by user in UserSteppingAction. This guarantees
95  that GLG4Scint will absolutely be the last process considered, and
96  will definitely see the energy loss by charged particles accurately.
97 
98  - Modified to allow specification of absolute yield spectra,
99  resolution scale, Birk's-law coefficient, and digitized waveform,
100  customized for medium and (optionally) particle type.
101 
102  - No longer calls G4MaterialPropertiesTable::GetProperty() in
103  [Post]PostStepDoit() -- all needed data can be found quickly in
104  the internal physics table.
105 
106  - Uses poisson random distribution for number of photons if
107  mean number of photons <= 12.
108 
109  - The total scintillation yield is now found implicitly from
110  the integral of the scintillation spectrum, which must now be
111  in units of photons per photon energy.
112 
113  - The above feature has been modified by Dario Motta: a scintillation yield
114  CAN be defined and -if found- used instead of the implicit integral of the
115  scintillation spectrum. This allows having scintillators with the same
116  spectrum, but different light yields.
117 
118  - The materials property tables used are
119  SCINTILLATION == scintillation spectrum
120  SCINTWAVEFORM == scintillation waveform or time constant
121  SCINTMOD == resolution scale, Birk's constant, reference dE/dx
122 
123  - SCINTILLATION is required in each scintillating medium.
124  (Okay to omit if you don't want the medium to scintillate.)
125 
126  - If SCINTWAVEFORM is missing, uses exponential waveform with default
127  ScintillationTime. If SCINTWAVEFORM contains negative "Momentum"'s
128  then each "Momentum" is the decay time and its corresponding value
129  is the relative strength of that exponential decay.
130  Otherwise, the "PhotonEnergy" of each element is a time, and the
131  Value of each element is the relative strength.
132 
133  - Default values of resolution scale (=1.0), Birk's constant (=0.0)
134  and reference dE/dx (=0.0) are used if all or part of SCINTMOD is
135  is missing. SCINTMOD "PhotonEnergy" values should be set to the
136  index number (0.0, 1.0, 2.0, with no units).
137 
138  - Birk's law (see 1998 Particle Data Booklet eq. 25.1) is implemented
139  as
140  yield(dE/dx) = yield_ref * dE/dx * (1 + kb*(dE/dx)_ref) / (1 + kb*(dE/dx)).
141  I.e., the scintillation spectrum given in SCINTILLATION is
142  measured for particles with dE/dx = (dE/dx)_ref. The usual
143  formula is recovered if (dE/dx)_ref = 0.0 (the default).
144  This is useful if you have an empirically-measured spectrum for
145  some densely-ionizing particle (like an alpha).
146 
147  - The constructor now accepts an additional string argument, tablename,
148  which allows selection of alternate property tables. E.g,
149  tablename = "neutron" might be used to allow specification of a
150  different waveform for scintillation due to neutron energy deposition.
151  The code then searches for tables with names of the form
152  "SCINTILLATIONneutron"
153  If it finds such a table, that table is used in preference to
154  the default (un-suffixed) table when stepping particles of that type.
155 
156  - The process generates at most maxTracksPerStep secondaries per step.
157  If more "real" photons are needed, it increases the weight of the
158  tracked opticalphotons. Opticalphotons are thus macro-particles in
159  the high-scintillation case. The code preserves an integer number
160  of real photons per macro-particle.
161 */
162 
163 class GLG4Scint : public G4UImessenger // not creating a separate class is my laziness -GHS.
164 {
165  private:
167  // Operators
169 
170  // GLG4Scint& operator=(const GLG4Scint &right);
171 
172  public:
174  // Nested class
176 
178  public:
179  G4String *fName;
180  class Entry {
181  public:
182  G4PhysicsOrderedFreeVector *fSpectrumIntegral;
183  G4PhysicsOrderedFreeVector *fReemissionIntegral;
184  G4PhysicsOrderedFreeVector *fTimeIntegral;
185  G4PhysicsOrderedFreeVector *fReemissionTimeIntegral;
186  std::vector<G4PhysicsOrderedFreeVector *> fReemissionTimeVector;
187  std::vector<G4PhysicsOrderedFreeVector *> fReemissionSpectrumVector;
188  int fOwnSpectrumIntegral, fOwnTimeIntegral, fOwnReemissionTimeIntegral, fOwnReemissionTimeVector;
189  G4double fResolutionScale;
190  G4double fBirksConstant;
191  G4double fRefdEdx;
192  G4double fLightYield;
193  G4MaterialPropertyVector *fQuenchingArray;
194 
195  Entry();
196  ~Entry();
197 
198  void Build(const G4String &name, const G4String &matName, int material_index,
199  G4MaterialPropertiesTable *matprops);
200  };
201 
202  private:
203  static MyPhysicsTable *fHead;
204  MyPhysicsTable *fNext;
205  G4int fUsedByCount;
206 
207  Entry *fData;
208  G4int fLength;
209 
210  MyPhysicsTable();
211  ~MyPhysicsTable();
212 
213  void Build(const G4String &newname);
214 
215  friend class GLG4Scint;
216 
217  public:
218  static MyPhysicsTable *FindOrBuild(const G4String &name);
219  static const MyPhysicsTable *GetDefault(void) { return fHead; }
220  void IncUsedBy(void) { ++fUsedByCount; }
221  void DecUsedBy(void) {
222  if (--fUsedByCount <= 0) delete this;
223  }
224  const Entry *GetEntry(int i) const { return fData + i; }
225  void Dump(void) const;
226  };
227 
229  // Constructors and Destructor
231 
232  GLG4Scint(const G4String &tableName = "", G4double lowerMassLimit = 0.0);
233 
234  // GLG4Scint(const GLG4Scint &right);
235 
236  ~GLG4Scint();
237 
239  // Methods
241 
242  G4VParticleChange *PostPostStepDoIt(const G4Track &aTrack, const G4Step &aStep);
243 
244  G4double GetLowerMassLimit(void) const;
245 
246  void DumpInfo() const;
247 
248  MyPhysicsTable *GetMyPhysicsTable(void) const;
249 
250  G4int GetVerboseLevel(void) const;
251  void SetVerboseLevel(int level);
252 
253  // following two methods are for G4UImessenger
254  void SetNewValue(G4UIcommand *command, G4String newValues);
255  G4String GetCurrentValue(G4UIcommand *command);
256 
258  // static methods
260 
261  static G4VParticleChange *GenericPostPostStepDoIt(const G4Step *pStep);
262 
263  // following are for energy deposition diagnosis
264  static unsigned int fsScintillatedCount;
265  static unsigned int fsReemittedCount;
266  static void ResetPhotonCount(unsigned int sCt = 0, unsigned int rCt = 0) {
267  fsScintillatedCount = sCt;
268  fsReemittedCount = rCt;
269  }
270  static unsigned int GetScintillatedCount() { return fsScintillatedCount; }
271  static unsigned int GetReemittedCount() { return fsReemittedCount; }
272 
273  static void GetTotEdepAll(G4double &totEdep, G4double &totEdepQuenched, G4double &totEdepTime,
274  G4ThreeVector &scintCentroidSum) {
275  totEdep = fTotEdep;
276  totEdepQuenched = fTotEdepQuenched;
277  totEdepTime = fTotEdepTime;
278  scintCentroidSum = fScintCentroidSum;
279  }
280 
281  static void SetTotEdep(G4double &totEdep, G4double &totEdepQuenched, G4double &totEdepTime,
282  G4ThreeVector &scintCentroidSum) {
283  fTotEdep = totEdep;
284  fTotEdepQuenched = totEdepQuenched;
285  fTotEdepTime = totEdepTime;
286  fScintCentroidSum = scintCentroidSum;
287  }
288 
289  static void ResetTotEdep() {
290  fTotEdep = fTotEdepQuenched = fTotEdepTime = 0.0;
291  fScintCentroidSum *= 0.0;
292  }
293  static G4double GetTotEdep() { return fTotEdep; }
294  static G4double GetTotEdepQuenched() { return fTotEdepQuenched; }
295  static G4double GetTotEdepTime() { return fTotEdepTime; }
296  static G4bool GetDoScintillation() { return fDoScintillation; }
297  static G4ThreeVector GetScintCentroidSum() { return fScintCentroidSum * (1.0 / fTotEdepQuenched); }
298 
300  // Class Data Members
302 
303  protected:
304  int fVerboseLevel;
305 
306  // Below is the pointer to the physics table which this instance
307  // of GLG4Scint will use. You may create a separate instance
308  // of GLG4Scint for each particle, if you like.
309  MyPhysicsTable *fMyPhysicsTable;
310 
311  // below is the lower mass limit for this instance of GLG4Scint
312  G4double fLowerMassLimit;
313 
314  // return value of PostPostStepDoIt
315  G4ParticleChange fAParticleChange;
316 
318  // static variables
320 
321  // vector of all existing GLG4Scint objects.
322  // They register themselves when created,
323  // remove themselves when deleted.
324  // Used by GenericPostPostStepDoIt
325  static std::vector<GLG4Scint *> fMasterVectorOfGLG4Scint;
326 
327  // top level of scintillation command
328  static G4UIdirectory *fGLG4ScintDir;
329 
330  // universal maximum number of secondary tracks per step for GLG4Scint
331  static G4int fMaxTracksPerStep;
332 
333  // universal mean number of true photons per secondary track in GLG4Scint
334  static G4double fMeanPhotonsPerSecondary;
335 
336  // universal on/off flag
337  static G4bool fDoScintillation;
338 
339  // on/off flag for absorbed opticalphoton reemission
340  static G4bool fDoReemission;
341 
342  QuenchingCalculator *fQuenching;
343 
344  // total real energy deposited and total quenched energy deposited
345  static G4double fTotEdep;
346  static G4double fTotEdepQuenched;
347  static G4double fTotEdepTime;
348  static G4ThreeVector fScintCentroidSum;
349 
350  // Bogus processes used to tag photons created in GLG4Scint
351  static GLG4DummyProcess fScintProcess;
352  static GLG4DummyProcess fReemissionProcess;
353  static std::list<GLG4DummyProcess *> fReemissionProcessVector;
354 
355  // Quenching Factor
356  static G4double fQuenchingFactor;
357  // user-given (constant) quenching factor flag
358  static G4bool fUserQF;
359  static G4String fPrimaryName;
360  // primary particle energy
361  static G4double fPrimaryEnergy;
362 
363  public:
364  // methods to access the Quenching Factor
365  static G4double GetQuenchingFactor() { return fQuenchingFactor; }
366  static void SetQuenchingFactor(G4double qf);
367  // methods for getting/setting info for the QF calculation
368  static G4double GetPrimaryEnergy() { return fPrimaryEnergy; }
369  static void SetPrimaryEnergy(G4double pe) { fPrimaryEnergy = pe; }
370  static G4String GetPrimaryName() { return fPrimaryName; }
371  static void SetPrimaryName(G4String pn) { fPrimaryName = pn; }
372 };
373 
375 // Inline methods
377 
378 inline GLG4Scint::MyPhysicsTable *GLG4Scint::GetMyPhysicsTable() const { return fMyPhysicsTable; }
379 
380 inline void GLG4Scint::DumpInfo() const {
381  if (fMyPhysicsTable) {
382  RAT::info << "GLG4Scint[" << *(fMyPhysicsTable->fName) << "] {" << newline
383  << " fLowerMassLimit=" << fLowerMassLimit << newline;
384  if (fVerboseLevel >= 2) fMyPhysicsTable->Dump();
385  RAT::info << "}" << newline;
386  }
387 }
388 
389 inline G4double GLG4Scint::GetLowerMassLimit(void) const { return fLowerMassLimit; }
390 
391 inline void GLG4Scint::SetVerboseLevel(int level) { fVerboseLevel = level; }
392 inline G4int GLG4Scint::GetVerboseLevel(void) const { return fVerboseLevel; }
393 
394 #endif /* GLG4Scint_h */
Definition: GLG4Scint.hh:52
Definition: GLG4Scint.hh:180
Definition: GLG4Scint.hh:177
Definition: GLG4Scint.hh:164
static std::vector< GLG4Scint * > fMasterVectorOfGLG4Scint
Definition: GLG4Scint.hh:325
Interface for calculating quenched energy deposits.
Definition: QuenchingCalculator.hh:23