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 10.5.p1)


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