Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/optical/src/G4OpWLS.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/optical/src/G4OpWLS.cc (Version 11.3.0) and /processes/optical/src/G4OpWLS.cc (Version 9.5.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4OpWLS.cc,v 1.13 2008-10-24 19:50:50 gum Exp $
                                                   >>  28 // GEANT4 tag $Name: not supported by cvs2svn $
 27 //                                                 29 //
 28 //////////////////////////////////////////////     30 ////////////////////////////////////////////////////////////////////////
 29 // Optical Photon WaveLength Shifting (WLS) Cl     31 // Optical Photon WaveLength Shifting (WLS) Class Implementation
 30 //////////////////////////////////////////////     32 ////////////////////////////////////////////////////////////////////////
 31 //                                                 33 //
 32 // File:        G4OpWLS.cc                         34 // File:        G4OpWLS.cc
 33 // Description: Discrete Process -- Wavelength     35 // Description: Discrete Process -- Wavelength Shifting of Optical Photons
 34 // Version:     1.0                                36 // Version:     1.0
 35 // Created:     2003-05-13                         37 // Created:     2003-05-13
 36 // Author:      John Paul Archambault              38 // Author:      John Paul Archambault
 37 //              (Adaptation of G4Scintillation     39 //              (Adaptation of G4Scintillation and G4OpAbsorption)
 38 // Updated:     2005-07-28 - add G4ProcessType     40 // Updated:     2005-07-28 - add G4ProcessType to constructor
 39 //              2006-05-07 - add G4VWLSTimeGen     41 //              2006-05-07 - add G4VWLSTimeGeneratorProfile
                                                   >>  42 // mail:        gum@triumf.ca
                                                   >>  43 //              jparcham@phys.ualberta.ca
 40 //                                                 44 //
 41 //////////////////////////////////////////////     45 ////////////////////////////////////////////////////////////////////////
 42                                                    46 
 43 #include "G4OpWLS.hh"                              47 #include "G4OpWLS.hh"
                                                   >>  48 
 44 #include "G4ios.hh"                                49 #include "G4ios.hh"
 45 #include "G4PhysicalConstants.hh"                  50 #include "G4PhysicalConstants.hh"
 46 #include "G4SystemOfUnits.hh"                      51 #include "G4SystemOfUnits.hh"
 47 #include "G4OpProcessSubType.hh"                   52 #include "G4OpProcessSubType.hh"
 48 #include "G4Poisson.hh"                        <<  53 
 49 #include "G4OpticalParameters.hh"              << 
 50 #include "G4WLSTimeGeneratorProfileDelta.hh"       54 #include "G4WLSTimeGeneratorProfileDelta.hh"
 51 #include "G4WLSTimeGeneratorProfileExponential     55 #include "G4WLSTimeGeneratorProfileExponential.hh"
 52                                                    56 
 53 //....oooOO0OOooo........oooOO0OOooo........oo <<  57 /////////////////////////
                                                   >>  58 // Class Implementation
                                                   >>  59 /////////////////////////
                                                   >>  60 
                                                   >>  61 /////////////////
                                                   >>  62 // Constructors
                                                   >>  63 /////////////////
                                                   >>  64 
 54 G4OpWLS::G4OpWLS(const G4String& processName,      65 G4OpWLS::G4OpWLS(const G4String& processName, G4ProcessType type)
 55   : G4VDiscreteProcess(processName, type)          66   : G4VDiscreteProcess(processName, type)
 56 {                                                  67 {
 57   WLSTimeGeneratorProfile = nullptr;           << 
 58   Initialise();                                << 
 59   SetProcessSubType(fOpWLS);                       68   SetProcessSubType(fOpWLS);
 60   theIntegralTable = nullptr;                  << 
 61                                                    69 
 62   if(verboseLevel > 0)                         <<  70   theIntegralTable = 0;
                                                   >>  71  
                                                   >>  72   if (verboseLevel>0) {
 63     G4cout << GetProcessName() << " is created     73     G4cout << GetProcessName() << " is created " << G4endl;
                                                   >>  74   }
                                                   >>  75 
                                                   >>  76   WLSTimeGeneratorProfile = 
                                                   >>  77        new G4WLSTimeGeneratorProfileDelta("WLSTimeGeneratorProfileDelta");
                                                   >>  78 
                                                   >>  79   BuildThePhysicsTable();
 64 }                                                  80 }
 65                                                    81 
 66 //....oooOO0OOooo........oooOO0OOooo........oo <<  82 ////////////////
                                                   >>  83 // Destructors
                                                   >>  84 ////////////////
                                                   >>  85 
 67 G4OpWLS::~G4OpWLS()                                86 G4OpWLS::~G4OpWLS()
 68 {                                                  87 {
 69   if(theIntegralTable)                         <<  88   if (theIntegralTable != 0) {
 70   {                                            << 
 71     theIntegralTable->clearAndDestroy();           89     theIntegralTable->clearAndDestroy();
 72     delete theIntegralTable;                       90     delete theIntegralTable;
 73   }                                                91   }
 74   delete WLSTimeGeneratorProfile;                  92   delete WLSTimeGeneratorProfile;
 75 }                                                  93 }
 76                                                    94 
 77 //....oooOO0OOooo........oooOO0OOooo........oo <<  95 ////////////
 78 void G4OpWLS::PreparePhysicsTable(const G4Part <<  96 // Methods
 79                                                <<  97 ////////////
 80 //....oooOO0OOooo........oooOO0OOooo........oo << 
 81 void G4OpWLS::Initialise()                     << 
 82 {                                              << 
 83   G4OpticalParameters* params = G4OpticalParam << 
 84   SetVerboseLevel(params->GetWLSVerboseLevel() << 
 85   UseTimeProfile(params->GetWLSTimeProfile()); << 
 86 }                                              << 
 87                                                    98 
 88 //....oooOO0OOooo........oooOO0OOooo........oo <<  99 // PostStepDoIt
 89 G4VParticleChange* G4OpWLS::PostStepDoIt(const << 100 // -------------
 90                                          const << 101 //
                                                   >> 102 G4VParticleChange*
                                                   >> 103 G4OpWLS::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
 91 {                                                 104 {
 92   std::vector<G4Track*> proposedSecondaries;   << 
 93   aParticleChange.Initialize(aTrack);             105   aParticleChange.Initialize(aTrack);
                                                   >> 106   
 94   aParticleChange.ProposeTrackStatus(fStopAndK    107   aParticleChange.ProposeTrackStatus(fStopAndKill);
 95                                                   108 
 96   if(verboseLevel > 1)                         << 109   if (verboseLevel>0) {
 97   {                                            << 110     G4cout << "\n** Photon absorbed! **" << G4endl;
 98     G4cout << "\n** G4OpWLS: Photon absorbed!  << 
 99   }                                               111   }
                                                   >> 112   
                                                   >> 113   const G4Material* aMaterial = aTrack.GetMaterial();
100                                                   114 
101   G4StepPoint* pPostStepPoint = aStep.GetPostS    115   G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
102   G4MaterialPropertiesTable* MPT =             << 116     
103     aTrack.GetMaterial()->GetMaterialPropertie << 117   G4MaterialPropertiesTable* aMaterialPropertiesTable =
104   if(!MPT)                                     << 118     aMaterial->GetMaterialPropertiesTable();
105   {                                            << 119   if (!aMaterialPropertiesTable)
106     return G4VDiscreteProcess::PostStepDoIt(aT    120     return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
107   }                                            << 121 
108   if(!MPT->GetProperty(kWLSCOMPONENT))         << 122   const G4MaterialPropertyVector* WLS_Intensity = 
109   {                                            << 123     aMaterialPropertiesTable->GetProperty("WLSCOMPONENT"); 
                                                   >> 124 
                                                   >> 125   if (!WLS_Intensity)
110     return G4VDiscreteProcess::PostStepDoIt(aT    126     return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
111   }                                            << 
112                                                   127 
113   G4int NumPhotons = 1;                           128   G4int NumPhotons = 1;
114   if(MPT->ConstPropertyExists(kWLSMEANNUMBERPH << 
115   {                                            << 
116     G4double MeanNumberOfPhotons = MPT->GetCon << 
117     NumPhotons                   = G4int(G4Poi << 
118     if(NumPhotons <= 0)                        << 
119     {                                          << 
120       // return unchanged particle and no seco << 
121       aParticleChange.SetNumberOfSecondaries(0 << 
122       return G4VDiscreteProcess::PostStepDoIt( << 
123     }                                          << 
124   }                                            << 
125                                                   129 
126   // Retrieve the WLS Integral for this materi << 130   if (aMaterialPropertiesTable->ConstPropertyExists("WLSMEANNUMBERPHOTONS")) {
127   // new G4PhysicsFreeVector allocated to hold << 
128   G4double primaryEnergy = aTrack.GetDynamicPa << 
129   G4double WLSTime       = 0.;                 << 
130   G4PhysicsFreeVector* WLSIntegral = nullptr;  << 
131                                                << 
132   WLSTime     = MPT->GetConstProperty(kWLSTIME << 
133   WLSIntegral = (G4PhysicsFreeVector*) ((*theI << 
134     aTrack.GetMaterial()->GetIndex()));        << 
135                                                   131 
136   // Max WLS Integral                          << 132      G4double MeanNumberOfPhotons = aMaterialPropertiesTable->
137   G4double CIImax       = WLSIntegral->GetMaxV << 133                                     GetConstProperty("WLSMEANNUMBERPHOTONS");
138   G4int NumberOfPhotons = NumPhotons;          << 134 
                                                   >> 135      NumPhotons = G4int(G4Poisson(MeanNumberOfPhotons));
                                                   >> 136 
                                                   >> 137      if (NumPhotons <= 0) {
139                                                   138 
140   for(G4int i = 0; i < NumPhotons; ++i)        << 
141   {                                            << 
142     G4double sampledEnergy;                    << 
143     // Make sure the energy of the secondary i << 
144     for(G4int j = 1; j <= 100; ++j)            << 
145     {                                          << 
146       // Determine photon energy               << 
147       G4double CIIvalue = G4UniformRand() * CI << 
148       sampledEnergy     = WLSIntegral->GetEner << 
149       if(sampledEnergy <= primaryEnergy)       << 
150         break;                                 << 
151     }                                          << 
152     // If no such energy can be sampled, retur << 
153     if(sampledEnergy > primaryEnergy)          << 
154     {                                          << 
155       if(verboseLevel > 1)                     << 
156       {                                        << 
157         G4cout << " *** G4OpWLS: One less WLS  << 
158                << G4endl;                      << 
159       }                                        << 
160       NumberOfPhotons--;                       << 
161       if(NumberOfPhotons == 0)                 << 
162       {                                        << 
163         if(verboseLevel > 1)                   << 
164         {                                      << 
165           G4cout                               << 
166             << " *** G4OpWLS: No WLS photon ca << 
167             << G4endl;                         << 
168         }                                      << 
169         // return unchanged particle and no se    139         // return unchanged particle and no secondaries
                                                   >> 140 
170         aParticleChange.SetNumberOfSecondaries    141         aParticleChange.SetNumberOfSecondaries(0);
                                                   >> 142 
171         return G4VDiscreteProcess::PostStepDoI    143         return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
172       }                                        << 
173       continue;                                << 
174     }                                          << 
175     else if(verboseLevel > 1)                  << 
176     {                                          << 
177       G4cout << "G4OpWLS: Created photon with  << 
178              << G4endl;                        << 
179     }                                          << 
180                                                   144 
181     // Generate random photon direction        << 145      }
182     G4double cost = 1. - 2. * G4UniformRand(); << 
183     G4double sint = std::sqrt((1. - cost) * (1 << 
184     G4double phi  = twopi * G4UniformRand();   << 
185     G4double sinp = std::sin(phi);             << 
186     G4double cosp = std::cos(phi);             << 
187     G4ParticleMomentum photonMomentum(sint * c << 
188                                                   146 
189     G4ThreeVector photonPolarization(cost * co << 147   }
190     G4ThreeVector perp = photonMomentum.cross( << 
191                                                   148 
192     phi                = twopi * G4UniformRand << 149   aParticleChange.SetNumberOfSecondaries(NumPhotons);
193     sinp               = std::sin(phi);        << 
194     cosp               = std::cos(phi);        << 
195     photonPolarization = (cosp * photonPolariz << 
196                                                   150 
197     // Generate a new photon:                  << 151   G4int materialIndex = aMaterial->GetIndex();
198     auto sec_dp =                              << 152 
199       new G4DynamicParticle(G4OpticalPhoton::O << 153   // Retrieve the WLS Integral for this material
200     sec_dp->SetPolarization(photonPolarization << 154   // new G4PhysicsOrderedFreeVector allocated to hold CII's
201     sec_dp->SetKineticEnergy(sampledEnergy);   << 
202                                                << 
203     G4double secTime = pPostStepPoint->GetGlob << 
204                        WLSTimeGeneratorProfile << 
205     G4ThreeVector secPos = pPostStepPoint->Get << 
206     G4Track* secTrack    = new G4Track(sec_dp, << 
207                                                   155 
208     secTrack->SetTouchableHandle(aTrack.GetTou << 156   G4double WLSTime = 0.*ns;
209     secTrack->SetParentID(aTrack.GetTrackID()) << 157   G4PhysicsOrderedFreeVector* WLSIntegral = 0;
210                                                   158 
211     proposedSecondaries.push_back(secTrack);   << 159   WLSTime   = aMaterialPropertiesTable->
212   }                                            << 160     GetConstProperty("WLSTIMECONSTANT");
                                                   >> 161   WLSIntegral =
                                                   >> 162     (G4PhysicsOrderedFreeVector*)((*theIntegralTable)(materialIndex));
                                                   >> 163    
                                                   >> 164   // Max WLS Integral
                                                   >> 165   
                                                   >> 166   G4double CIImax = WLSIntegral->GetMaxValue();
                                                   >> 167   
                                                   >> 168   for (G4int i = 0; i < NumPhotons; i++) {
                                                   >> 169     
                                                   >> 170     // Determine photon energy
                                                   >> 171     
                                                   >> 172     G4double CIIvalue = G4UniformRand()*CIImax;
                                                   >> 173     G4double sampledEnergy = 
                                                   >> 174       WLSIntegral->GetEnergy(CIIvalue);
                                                   >> 175     
                                                   >> 176     if (verboseLevel>1) {
                                                   >> 177       G4cout << "sampledEnergy = " << sampledEnergy << G4endl;
                                                   >> 178       G4cout << "CIIvalue =        " << CIIvalue << G4endl;
                                                   >> 179     }
                                                   >> 180     
                                                   >> 181     // Generate random photon direction
                                                   >> 182     
                                                   >> 183     G4double cost = 1. - 2.*G4UniformRand();
                                                   >> 184     G4double sint = std::sqrt((1.-cost)*(1.+cost));
213                                                   185 
214   aParticleChange.SetNumberOfSecondaries((G4in << 186     G4double phi = twopi*G4UniformRand();
215   for(auto sec : proposedSecondaries)          << 187     G4double sinp = std::sin(phi);
216   {                                            << 188     G4double cosp = std::cos(phi);
217     aParticleChange.AddSecondary(sec);         << 189     
218   }                                            << 190     G4double px = sint*cosp;
219   if(verboseLevel > 1)                         << 191     G4double py = sint*sinp;
220   {                                            << 192     G4double pz = cost;
221     G4cout << "\n Exiting from G4OpWLS::DoIt - << 193     
222            << aParticleChange.GetNumberOfSecon << 194     // Create photon momentum direction vector
                                                   >> 195     
                                                   >> 196     G4ParticleMomentum photonMomentum(px, py, pz);
                                                   >> 197     
                                                   >> 198     // Determine polarization of new photon
                                                   >> 199     
                                                   >> 200     G4double sx = cost*cosp;
                                                   >> 201     G4double sy = cost*sinp;
                                                   >> 202     G4double sz = -sint;
                                                   >> 203     
                                                   >> 204     G4ThreeVector photonPolarization(sx, sy, sz);
                                                   >> 205     
                                                   >> 206     G4ThreeVector perp = photonMomentum.cross(photonPolarization);
                                                   >> 207     
                                                   >> 208     phi = twopi*G4UniformRand();
                                                   >> 209     sinp = std::sin(phi);
                                                   >> 210     cosp = std::cos(phi);
                                                   >> 211     
                                                   >> 212     photonPolarization = cosp * photonPolarization + sinp * perp;
                                                   >> 213     
                                                   >> 214     photonPolarization = photonPolarization.unit();
                                                   >> 215     
                                                   >> 216     // Generate a new photon:
                                                   >> 217     
                                                   >> 218     G4DynamicParticle* aWLSPhoton =
                                                   >> 219       new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(),
                                                   >> 220           photonMomentum);
                                                   >> 221     aWLSPhoton->SetPolarization
                                                   >> 222       (photonPolarization.x(),
                                                   >> 223        photonPolarization.y(),
                                                   >> 224        photonPolarization.z());
                                                   >> 225     
                                                   >> 226     aWLSPhoton->SetKineticEnergy(sampledEnergy);
                                                   >> 227     
                                                   >> 228     // Generate new G4Track object:
                                                   >> 229     
                                                   >> 230     // Must give position of WLS optical photon
                                                   >> 231 
                                                   >> 232     G4double TimeDelay = WLSTimeGeneratorProfile->GenerateTime(WLSTime);
                                                   >> 233     G4double aSecondaryTime = (pPostStepPoint->GetGlobalTime()) + TimeDelay;
                                                   >> 234 
                                                   >> 235     G4ThreeVector aSecondaryPosition = pPostStepPoint->GetPosition();
                                                   >> 236 
                                                   >> 237     G4Track* aSecondaryTrack = 
                                                   >> 238       new G4Track(aWLSPhoton,aSecondaryTime,aSecondaryPosition);
                                                   >> 239    
                                                   >> 240     aSecondaryTrack->SetTouchableHandle(aTrack.GetTouchableHandle()); 
                                                   >> 241     // aSecondaryTrack->SetTouchableHandle((G4VTouchable*)0);
                                                   >> 242     
                                                   >> 243     aSecondaryTrack->SetParentID(aTrack.GetTrackID());
                                                   >> 244     
                                                   >> 245     aParticleChange.AddSecondary(aSecondaryTrack);
                                                   >> 246   }
                                                   >> 247 
                                                   >> 248   if (verboseLevel>0) {
                                                   >> 249     G4cout << "\n Exiting from G4OpWLS::DoIt -- NumberOfSecondaries = " 
                                                   >> 250      << aParticleChange.GetNumberOfSecondaries() << G4endl;  
223   }                                               251   }
224                                                << 252   
225   return G4VDiscreteProcess::PostStepDoIt(aTra    253   return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
226 }                                                 254 }
227                                                   255 
228 //....oooOO0OOooo........oooOO0OOooo........oo << 256 // BuildThePhysicsTable for the wavelength shifting process
229 void G4OpWLS::BuildPhysicsTable(const G4Partic << 257 // --------------------------------------------------
230 {                                              << 258 //
231   if(theIntegralTable)                         << 
232   {                                            << 
233     theIntegralTable->clearAndDestroy();       << 
234     delete theIntegralTable;                   << 
235     theIntegralTable = nullptr;                << 
236   }                                            << 
237                                                << 
238   const G4MaterialTable* materialTable = G4Mat << 
239   std::size_t numOfMaterials           = G4Mat << 
240   theIntegralTable                     = new G << 
241                                                   259 
                                                   >> 260 void G4OpWLS::BuildThePhysicsTable()
                                                   >> 261 {
                                                   >> 262   if (theIntegralTable) return;
                                                   >> 263   
                                                   >> 264   const G4MaterialTable* theMaterialTable = 
                                                   >> 265     G4Material::GetMaterialTable();
                                                   >> 266   G4int numOfMaterials = G4Material::GetNumberOfMaterials();
                                                   >> 267   
                                                   >> 268   // create new physics table
                                                   >> 269   
                                                   >> 270   if(!theIntegralTable)theIntegralTable = new G4PhysicsTable(numOfMaterials);
                                                   >> 271   
242   // loop for materials                           272   // loop for materials
243   for(std::size_t i = 0; i < numOfMaterials; + << 273   
244   {                                            << 274   for (G4int i=0 ; i < numOfMaterials; i++)
245     auto physVector = new G4PhysicsFreeVector( << 
246                                                << 
247     // Retrieve vector of WLS wavelength inten << 
248     // the material from the material's optica << 
249     G4MaterialPropertiesTable* MPT =           << 
250       (*materialTable)[i]->GetMaterialProperti << 
251     if(MPT)                                    << 
252     {                                             275     {
253       G4MaterialPropertyVector* wlsVector = MP << 276       G4PhysicsOrderedFreeVector* aPhysicsOrderedFreeVector =
254       if(wlsVector)                            << 277   new G4PhysicsOrderedFreeVector();
255       {                                        << 278       
256         // Retrieve the first intensity point  << 279       // Retrieve vector of WLS wavelength intensity for
257         // of (photon energy, intensity) pairs << 280       // the material from the material's optical properties table.
258         G4double currentIN = (*wlsVector)[0];  << 281       
259         if(currentIN >= 0.0)                   << 282       G4Material* aMaterial = (*theMaterialTable)[i];
260         {                                      << 283 
261           // Create first (photon energy)      << 284       G4MaterialPropertiesTable* aMaterialPropertiesTable =
262           G4double currentPM  = wlsVector->Ene << 285   aMaterial->GetMaterialPropertiesTable();
263           G4double currentCII = 0.0;           << 286 
264           physVector->InsertValues(currentPM,  << 287       if (aMaterialPropertiesTable) {
265                                                << 288 
266           // Set previous values to current on << 289   G4MaterialPropertyVector* theWLSVector = 
267           G4double prevPM  = currentPM;        << 290     aMaterialPropertiesTable->GetProperty("WLSCOMPONENT");
268           G4double prevCII = currentCII;       << 291 
269           G4double prevIN  = currentIN;        << 292   if (theWLSVector) {
270                                                << 293     
271           // loop over all (photon energy, int << 294     // Retrieve the first intensity point in vector
272           // pairs stored for this material    << 295     // of (photon energy, intensity) pairs
273           for(std::size_t j = 1; j < wlsVector << 296     
274           {                                    << 297     G4double currentIN = (*theWLSVector)[0];
275             currentPM = wlsVector->Energy(j);  << 298     
276             currentIN = (*wlsVector)[j];       << 299     if (currentIN >= 0.0) {
277             currentCII =                       << 300 
278               prevCII + 0.5 * (currentPM - pre << 301       // Create first (photon energy) 
279                                                << 302      
280             physVector->InsertValues(currentPM << 303       G4double currentPM = theWLSVector->Energy(0);
281                                                << 304       
282             prevPM  = currentPM;               << 305       G4double currentCII = 0.0;
283             prevCII = currentCII;              << 306       
284             prevIN  = currentIN;               << 307       aPhysicsOrderedFreeVector->
285           }                                    << 308         InsertValues(currentPM , currentCII);
286         }                                      << 309       
                                                   >> 310       // Set previous values to current ones prior to loop
                                                   >> 311       
                                                   >> 312       G4double prevPM  = currentPM;
                                                   >> 313       G4double prevCII = currentCII;
                                                   >> 314       G4double prevIN  = currentIN;
                                                   >> 315       
                                                   >> 316       // loop over all (photon energy, intensity)
                                                   >> 317       // pairs stored for this material
                                                   >> 318 
                                                   >> 319             for (size_t j = 1;
                                                   >> 320                  j < theWLSVector->GetVectorLength();
                                                   >> 321                  j++)     
                                                   >> 322         {
                                                   >> 323     currentPM = theWLSVector->Energy(j);
                                                   >> 324     currentIN = (*theWLSVector)[j];
                                                   >> 325     
                                                   >> 326     currentCII = 0.5 * (prevIN + currentIN);
                                                   >> 327     
                                                   >> 328     currentCII = prevCII +
                                                   >> 329       (currentPM - prevPM) * currentCII;
                                                   >> 330     
                                                   >> 331     aPhysicsOrderedFreeVector->
                                                   >> 332       InsertValues(currentPM, currentCII);
                                                   >> 333     
                                                   >> 334     prevPM  = currentPM;
                                                   >> 335     prevCII = currentCII;
                                                   >> 336     prevIN  = currentIN;
                                                   >> 337         }
                                                   >> 338     }
                                                   >> 339   }
287       }                                           340       }
                                                   >> 341   // The WLS integral for a given material
                                                   >> 342   // will be inserted in the table according to the
                                                   >> 343   // position of the material in the material table.
                                                   >> 344 
                                                   >> 345   theIntegralTable->insertAt(i,aPhysicsOrderedFreeVector);
288     }                                             346     }
289     theIntegralTable->insertAt(i, physVector); << 
290   }                                            << 
291 }                                                 347 }
292                                                   348 
293 //....oooOO0OOooo........oooOO0OOooo........oo << 349 // GetMeanFreePath
294 G4double G4OpWLS::GetMeanFreePath(const G4Trac << 350 // ---------------
295                                   G4ForceCondi << 351 //
                                                   >> 352 G4double G4OpWLS::GetMeanFreePath(const G4Track& aTrack,
                                                   >> 353                  G4double ,
                                                   >> 354                  G4ForceCondition* )
296 {                                                 355 {
297   G4double thePhotonEnergy = aTrack.GetDynamic << 356   const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
298   G4double attLength       = DBL_MAX;          << 357   const G4Material* aMaterial = aTrack.GetMaterial();
299   G4MaterialPropertiesTable* MPT =             << 358 
300     aTrack.GetMaterial()->GetMaterialPropertie << 359   G4double thePhotonEnergy = aParticle->GetTotalEnergy();
301                                                << 360 
302   if(MPT)                                      << 361   G4MaterialPropertiesTable* aMaterialPropertyTable;
303   {                                            << 362   G4MaterialPropertyVector* AttenuationLengthVector;
304     G4MaterialPropertyVector* attVector = MPT- << 363   
305     if(attVector)                              << 364   G4double AttenuationLength = DBL_MAX;
306     {                                          << 365 
307       attLength = attVector->Value(thePhotonEn << 366   aMaterialPropertyTable = aMaterial->GetMaterialPropertiesTable();
                                                   >> 367 
                                                   >> 368   if ( aMaterialPropertyTable ) {
                                                   >> 369     AttenuationLengthVector = aMaterialPropertyTable->
                                                   >> 370       GetProperty("WLSABSLENGTH");
                                                   >> 371     if ( AttenuationLengthVector ){
                                                   >> 372       AttenuationLength = AttenuationLengthVector->
                                                   >> 373   Value(thePhotonEnergy);
                                                   >> 374     }
                                                   >> 375     else {
                                                   >> 376       //             G4cout << "No WLS absorption length specified" << G4endl;
308     }                                             377     }
309   }                                               378   }
310   return attLength;                            << 379   else {
                                                   >> 380     //           G4cout << "No WLS absortion length specified" << G4endl;
                                                   >> 381   }
                                                   >> 382   
                                                   >> 383   return AttenuationLength;
311 }                                                 384 }
312                                                   385 
313 //....oooOO0OOooo........oooOO0OOooo........oo << 
314 void G4OpWLS::UseTimeProfile(const G4String na    386 void G4OpWLS::UseTimeProfile(const G4String name)
315 {                                                 387 {
316   if(WLSTimeGeneratorProfile)                  << 388   if (name == "delta")
317   {                                            << 389     {
318     delete WLSTimeGeneratorProfile;            << 390       delete WLSTimeGeneratorProfile;
319     WLSTimeGeneratorProfile = nullptr;         << 391       WLSTimeGeneratorProfile = 
320   }                                            << 392              new G4WLSTimeGeneratorProfileDelta("delta");
321   if(name == "delta")                          << 393     }
322   {                                            << 394   else if (name == "exponential")
323     WLSTimeGeneratorProfile = new G4WLSTimeGen << 395     {
324   }                                            << 396       delete WLSTimeGeneratorProfile;
325   else if(name == "exponential")               << 397       WLSTimeGeneratorProfile =
326   {                                            << 398              new G4WLSTimeGeneratorProfileExponential("exponential");
327     WLSTimeGeneratorProfile =                  << 399     }
328       new G4WLSTimeGeneratorProfileExponential << 
329   }                                            << 
330   else                                            400   else
331   {                                            << 401     {
332     G4Exception("G4OpWLS::UseTimeProfile", "em << 402       G4Exception("G4OpWLS::UseTimeProfile", "em0202",
333                 "generator does not exist");   << 403                   FatalException,
334   }                                            << 404                   "generator does not exist");
335   G4OpticalParameters::Instance()->SetWLSTimeP << 405     }
336 }                                              << 
337                                                << 
338 //....oooOO0OOooo........oooOO0OOooo........oo << 
339 void G4OpWLS::SetVerboseLevel(G4int verbose)   << 
340 {                                              << 
341   verboseLevel = verbose;                      << 
342   G4OpticalParameters::Instance()->SetWLSVerbo << 
343 }                                                 406 }
344                                                   407