Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
/** \file LaserOpticalPhysicsList.cc
 *
 *
 *  $Date: 2008/03/10 12:52:52 $
 *  $Revision: 1.5 $
 *  \author Maarten Thomas
 */

#include "Alignment/LaserAlignmentSimulation/interface/LaserOpticalPhysicsList.h"
#include "SimG4Core/PhysicsLists/interface/EmParticleList.h"

#include "G4ParticleTable.hh"
#include "G4ProcessManager.hh"

#include "G4Cerenkov.hh"
#include "G4OpAbsorption.hh"
#include "G4OpBoundaryProcess.hh"
#include "G4OpRayleigh.hh"
#include "G4Scintillation.hh"

LaserOpticalPhysicsList::LaserOpticalPhysicsList(const G4String &name)
    : G4VPhysicsConstructor(name),
      wasActivated(false),
      theScintProcess(),
      theCerenkovProcess(),
      theAbsorptionProcess(),
      theRayleighScattering(),
      theBoundaryProcess(),
      theWLSProcess() {
  if (verboseLevel > 0)
    std::cout << "<LaserOpticalPhysicsList::LaserOpticalPhysicsList(...)> "
                 "entering constructor ..."
              << std::endl;
}

LaserOpticalPhysicsList::~LaserOpticalPhysicsList() {
  if (verboseLevel > 0) {
    std::cout << "<LaserOpticalPhysicsList::~LaserOpticalPhysicsList()> "
                 "entering destructor ... "
              << std::endl;
    std::cout << "  deleting the processes ... ";
  }
  if (theWLSProcess != nullptr) {
    delete theWLSProcess;
  }
  if (theBoundaryProcess != nullptr) {
    delete theBoundaryProcess;
  }
  if (theRayleighScattering != nullptr) {
    delete theRayleighScattering;
  }
  if (theAbsorptionProcess != nullptr) {
    delete theAbsorptionProcess;
  }
  if (theScintProcess != nullptr) {
    delete theScintProcess;
  }
  if (verboseLevel > 0)
    G4cout << " done " << G4endl;
}

void LaserOpticalPhysicsList::ConstructParticle() {
  if (verboseLevel > 0)
    G4cout << "<LaserOpticalPhysicsList::ConstructParticle()>: constructing "
              "the optical photon ... "
           << G4endl;

  // optical photon
  G4OpticalPhoton::OpticalPhotonDefinition();
}

void LaserOpticalPhysicsList::ConstructProcess() {
  if (verboseLevel > 0)
    G4cout << "<LaserOpticalPhysicsList::ConstructProcess()>: constructing "
              "the physics ... "
           << G4endl;

  theScintProcess = new G4Scintillation();
  theAbsorptionProcess = new G4OpAbsorption();
  theRayleighScattering = new G4OpRayleigh();
  theBoundaryProcess = new G4OpBoundaryProcess("OpBoundary");
  theWLSProcess = new G4OpWLS();

  // set the verbosity level
  theAbsorptionProcess->SetVerboseLevel(verboseLevel);
  theBoundaryProcess->SetVerboseLevel(verboseLevel);

  G4ProcessManager *pManager = nullptr;

  pManager = G4OpticalPhoton::OpticalPhoton()->GetProcessManager();
  pManager->AddDiscreteProcess(theAbsorptionProcess);
  pManager->AddDiscreteProcess(theRayleighScattering);
  pManager->AddDiscreteProcess(theBoundaryProcess);
  pManager->AddDiscreteProcess(theWLSProcess);

  theScintProcess->SetTrackSecondariesFirst(true);

  G4ParticleTable *table = G4ParticleTable::GetParticleTable();
  EmParticleList emList;
  for (const auto &particleName : emList.PartNames()) {
    G4ParticleDefinition *particle = table->FindParticle(particleName);
    pManager = particle->GetProcessManager();
    if (theScintProcess->IsApplicable(*particle)) {
      pManager->AddProcess(theScintProcess);
      pManager->SetProcessOrderingToLast(theScintProcess, idxAtRest);
      pManager->SetProcessOrderingToLast(theScintProcess, idxPostStep);
    }
  }

  wasActivated = true;
}