Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-25 05:51:25

0001 /** \file LaserOpticalPhysicsList.cc
0002  *
0003  *
0004  *  $Date: 2008/03/10 12:52:52 $
0005  *  $Revision: 1.5 $
0006  *  \author Maarten Thomas
0007  */
0008 
0009 #include "Alignment/LaserAlignmentSimulation/interface/LaserOpticalPhysicsList.h"
0010 #include "SimG4Core/PhysicsLists/interface/EmParticleList.h"
0011 
0012 #include "G4ParticleTable.hh"
0013 #include "G4ProcessManager.hh"
0014 
0015 #include "G4Cerenkov.hh"
0016 #include "G4OpAbsorption.hh"
0017 #include "G4OpBoundaryProcess.hh"
0018 #include "G4OpRayleigh.hh"
0019 #include "G4Scintillation.hh"
0020 
0021 LaserOpticalPhysicsList::LaserOpticalPhysicsList(const G4String &name)
0022     : G4VPhysicsConstructor(name),
0023       wasActivated(false),
0024       theScintProcess(),
0025       theCerenkovProcess(),
0026       theAbsorptionProcess(),
0027       theRayleighScattering(),
0028       theBoundaryProcess(),
0029       theWLSProcess() {
0030   if (verboseLevel > 0)
0031     std::cout << "<LaserOpticalPhysicsList::LaserOpticalPhysicsList(...)> "
0032                  "entering constructor ..."
0033               << std::endl;
0034 }
0035 
0036 LaserOpticalPhysicsList::~LaserOpticalPhysicsList() {
0037   if (verboseLevel > 0) {
0038     std::cout << "<LaserOpticalPhysicsList::~LaserOpticalPhysicsList()> "
0039                  "entering destructor ... "
0040               << std::endl;
0041     std::cout << "  deleting the processes ... ";
0042   }
0043   if (theWLSProcess != nullptr) {
0044     delete theWLSProcess;
0045   }
0046   if (theBoundaryProcess != nullptr) {
0047     delete theBoundaryProcess;
0048   }
0049   if (theRayleighScattering != nullptr) {
0050     delete theRayleighScattering;
0051   }
0052   if (theAbsorptionProcess != nullptr) {
0053     delete theAbsorptionProcess;
0054   }
0055   if (theScintProcess != nullptr) {
0056     delete theScintProcess;
0057   }
0058   if (verboseLevel > 0)
0059     G4cout << " done " << G4endl;
0060 }
0061 
0062 void LaserOpticalPhysicsList::ConstructParticle() {
0063   if (verboseLevel > 0)
0064     G4cout << "<LaserOpticalPhysicsList::ConstructParticle()>: constructing "
0065               "the optical photon ... "
0066            << G4endl;
0067 
0068   // optical photon
0069   G4OpticalPhoton::OpticalPhotonDefinition();
0070 }
0071 
0072 void LaserOpticalPhysicsList::ConstructProcess() {
0073   if (verboseLevel > 0)
0074     G4cout << "<LaserOpticalPhysicsList::ConstructProcess()>: constructing "
0075               "the physics ... "
0076            << G4endl;
0077 
0078   theScintProcess = new G4Scintillation();
0079   theAbsorptionProcess = new G4OpAbsorption();
0080   theRayleighScattering = new G4OpRayleigh();
0081   theBoundaryProcess = new G4OpBoundaryProcess("OpBoundary");
0082   theWLSProcess = new G4OpWLS();
0083 
0084   // set the verbosity level
0085   theAbsorptionProcess->SetVerboseLevel(verboseLevel);
0086   theBoundaryProcess->SetVerboseLevel(verboseLevel);
0087 
0088   G4ProcessManager *pManager = nullptr;
0089 
0090   pManager = G4OpticalPhoton::OpticalPhoton()->GetProcessManager();
0091   pManager->AddDiscreteProcess(theAbsorptionProcess);
0092   pManager->AddDiscreteProcess(theRayleighScattering);
0093   pManager->AddDiscreteProcess(theBoundaryProcess);
0094   pManager->AddDiscreteProcess(theWLSProcess);
0095 
0096   theScintProcess->SetTrackSecondariesFirst(true);
0097 
0098   G4ParticleTable *table = G4ParticleTable::GetParticleTable();
0099   EmParticleList emList;
0100   for (const auto &particleName : emList.PartNames()) {
0101     G4ParticleDefinition *particle = table->FindParticle(particleName);
0102     pManager = particle->GetProcessManager();
0103     if (theScintProcess->IsApplicable(*particle)) {
0104       pManager->AddProcess(theScintProcess);
0105       pManager->SetProcessOrderingToLast(theScintProcess, idxAtRest);
0106       pManager->SetProcessOrderingToLast(theScintProcess, idxPostStep);
0107     }
0108   }
0109 
0110   wasActivated = true;
0111 }