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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 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 //
 27 /// \file field/field04/src/F04PhysicsList.cc
 28 /// \brief Implementation of the F04PhysicsList class
 29 //
 30 
 31 #include "F04PhysicsList.hh"
 32 
 33 #include "F04PhysicsListMessenger.hh"
 34 
 35 #include "G4LossTableManager.hh"
 36 #include "G4OpticalPhysics.hh"
 37 #include "G4ParticleTable.hh"
 38 #include "G4ParticleTypes.hh"
 39 #include "G4ProcessManager.hh"
 40 #include "G4StepLimiterPhysics.hh"
 41 
 42 #include "F04StepMax.hh"
 43 #include "FTFP_BERT.hh"
 44 #include "QGSP_BERT.hh"
 45 
 46 #include "G4DecayTable.hh"
 47 #include "G4DecayWithSpin.hh"
 48 #include "G4Electron.hh"
 49 #include "G4Gamma.hh"
 50 #include "G4MuMinusCapturePrecompound.hh"
 51 #include "G4MuonDecayChannelWithSpin.hh"
 52 #include "G4MuonMinusCapture.hh"
 53 #include "G4MuonRadiativeDecayChannelWithSpin.hh"
 54 #include "G4PionDecayMakeSpin.hh"
 55 #include "G4Positron.hh"
 56 #include "G4ProcessTable.hh"
 57 #include "G4SystemOfUnits.hh"
 58 
 59 G4ThreadLocal F04StepMax* F04PhysicsList::fStepMaxProcess = nullptr;
 60 
 61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 62 
 63 F04PhysicsList::F04PhysicsList(const G4String& physName) : G4VModularPhysicsList()
 64 {
 65   G4LossTableManager::Instance();
 66 
 67   defaultCutValue = 1. * mm;
 68 
 69   fMessenger = new F04PhysicsListMessenger(this);
 70 
 71   SetVerboseLevel(1);
 72 
 73   //    G4PhysListFactory factory;
 74   G4VModularPhysicsList* phys = nullptr;
 75   if (physName == "QGSP_BERT") {
 76     phys = new QGSP_BERT;
 77   }
 78   else {
 79     phys = new FTFP_BERT;
 80   }
 81 
 82   //    if (factory.IsReferencePhysList(physName))
 83   //       phys =factory.GetReferencePhysList(physName);
 84 
 85   // Physics List is defined via environment variable PHYSLIST
 86   //    if (!phys) phys = factory.ReferencePhysList();
 87 
 88   if (!phys)
 89     G4Exception("F04PhysicsList::F04PhysicsList", "InvalidSetup", FatalException,
 90                 "PhysicsList does not exist");
 91 
 92   for (G4int i = 0;; ++i) {
 93     auto elem = const_cast<G4VPhysicsConstructor*>(phys->GetPhysics(i));
 94     if (elem == nullptr) break;
 95     G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl;
 96     RegisterPhysics(elem);
 97   }
 98 
 99   RegisterPhysics(new G4StepLimiterPhysics());
100   RegisterPhysics(new G4OpticalPhysics());
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104 
105 F04PhysicsList::~F04PhysicsList()
106 {
107   delete fMessenger;
108 }
109 
110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
111 
112 void F04PhysicsList::ConstructParticle()
113 {
114   G4VModularPhysicsList::ConstructParticle();
115 
116   G4GenericIon::GenericIonDefinition();
117 
118   auto muonPlusDecayTable = new G4DecayTable();
119   muonPlusDecayTable->Insert(new G4MuonDecayChannelWithSpin("mu+", 0.986));
120   muonPlusDecayTable->Insert(new G4MuonRadiativeDecayChannelWithSpin("mu+", 0.014));
121   G4MuonPlus::MuonPlusDefinition()->SetDecayTable(muonPlusDecayTable);
122 
123   auto muonMinusDecayTable = new G4DecayTable();
124   muonMinusDecayTable->Insert(new G4MuonDecayChannelWithSpin("mu-", 0.986));
125   muonMinusDecayTable->Insert(new G4MuonRadiativeDecayChannelWithSpin("mu-", 0.014));
126   G4MuonMinus::MuonMinusDefinition()->SetDecayTable(muonMinusDecayTable);
127 }
128 
129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130 
131 void F04PhysicsList::ConstructProcess()
132 {
133   G4VModularPhysicsList::ConstructProcess();
134 
135   fStepMaxProcess = new F04StepMax();
136 
137   auto decayWithSpin = new G4DecayWithSpin();
138 
139   G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
140 
141   G4VProcess* decay;
142   decay = processTable->FindProcess("Decay", G4MuonPlus::MuonPlus());
143 
144   G4ProcessManager* pmanager;
145   pmanager = G4MuonPlus::MuonPlus()->GetProcessManager();
146 
147   if (pmanager) {
148     if (decay) pmanager->RemoveProcess(decay);
149     pmanager->AddProcess(decayWithSpin);
150     // set ordering for PostStepDoIt and AtRestDoIt
151     pmanager->SetProcessOrdering(decayWithSpin, idxPostStep);
152     pmanager->SetProcessOrdering(decayWithSpin, idxAtRest);
153   }
154 
155   decay = processTable->FindProcess("Decay", G4MuonMinus::MuonMinus());
156 
157   pmanager = G4MuonMinus::MuonMinus()->GetProcessManager();
158 
159   if (pmanager) {
160     if (decay) pmanager->RemoveProcess(decay);
161     pmanager->AddProcess(decayWithSpin);
162     // set ordering for PostStepDoIt and AtRestDoIt
163     pmanager->SetProcessOrdering(decayWithSpin, idxPostStep);
164     pmanager->SetProcessOrdering(decayWithSpin, idxAtRest);
165   }
166 
167   G4VProcess* process = processTable->FindProcess("muMinusCaptureAtRest", G4MuonMinus::MuonMinus());
168 
169   if (pmanager) {
170     if (process) pmanager->RemoveProcess(process);
171     process = new G4MuonMinusCapture(new G4MuMinusCapturePrecompound());
172     pmanager->AddRestProcess(process);
173   }
174 
175   auto poldecay = new G4PionDecayMakeSpin();
176 
177   decay = processTable->FindProcess("Decay", G4PionPlus::PionPlus());
178 
179   pmanager = G4PionPlus::PionPlus()->GetProcessManager();
180 
181   if (pmanager) {
182     if (decay) pmanager->RemoveProcess(decay);
183     pmanager->AddProcess(poldecay);
184     // set ordering for PostStepDoIt and AtRestDoIt
185     pmanager->SetProcessOrdering(poldecay, idxPostStep);
186     pmanager->SetProcessOrdering(poldecay, idxAtRest);
187   }
188 
189   decay = processTable->FindProcess("Decay", G4PionMinus::PionMinus());
190 
191   pmanager = G4PionMinus::PionMinus()->GetProcessManager();
192 
193   if (pmanager) {
194     if (decay) pmanager->RemoveProcess(decay);
195     pmanager->AddProcess(poldecay);
196     // set ordering for PostStepDoIt and AtRestDoIt
197     pmanager->SetProcessOrdering(poldecay, idxPostStep);
198     pmanager->SetProcessOrdering(poldecay, idxAtRest);
199   }
200 
201   AddStepMax();
202 }
203 
204 /*
205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
206 
207 void F04PhysicsList::RemoveFromPhysicsList(const G4String& name)
208 {
209     G4bool success = false;
210     for (G4PhysConstVector::iterator p  = physicsVector->begin();
211                                      p != physicsVector->end(); ++p) {
212         G4VPhysicsConstructor* e = (*p);
213         if (e->GetPhysicsName() == name) {
214            physicsVector->erase(p);
215            success = true;
216            break;
217         }
218     }
219     if (!success) {
220        std::ostringstream message;
221        message << "PhysicsList::RemoveFromPhysicsList "<< name << "not found";
222        G4Exception(message.str().c_str());
223     }
224 }
225 
226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
227 
228 void F04PhysicsList::ClearPhysics()
229 {
230     for (G4PhysConstVector::iterator p  = physicsVector->begin();
231                                      p != physicsVector->end(); ++p) {
232         delete (*p);
233     }
234     physicsVector->clear();
235 }
236 */
237 
238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
239 
240 void F04PhysicsList::SetStepMax(G4double step)
241 {
242   fMaxChargedStep = step;
243   fStepMaxProcess->SetStepMax(fMaxChargedStep);
244 }
245 
246 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
247 
248 F04StepMax* F04PhysicsList::GetStepMaxProcess() const
249 {
250   return fStepMaxProcess;
251 }
252 
253 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
254 
255 void F04PhysicsList::AddStepMax()
256 {
257   // Step limitation seen as a process
258 
259   auto particleIterator = GetParticleIterator();
260   particleIterator->reset();
261   while ((*particleIterator)()) {
262     G4ParticleDefinition* particle = particleIterator->value();
263     G4ProcessManager* pmanager = particle->GetProcessManager();
264 
265     if (fStepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived()) {
266       if (pmanager) pmanager->AddDiscreteProcess(fStepMaxProcess);
267     }
268   }
269 }
270