Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-30 08:07:56

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file G4AdjointPhysicsList.cc
0027 /// \brief Implementation of the G4AdjointPhysicsList class
0028 
0029 //  Class Name:        G4AdjointPhysicsList
0030 //        Author:               L. Desorgher
0031 //         Organisation:         SpaceIT GmbH
0032 //        Contract:        ESA contract 21435/08/NL/AT
0033 //         Customer:             ESA/ESTEC
0034 //////////////////////////////////////////////////////////////
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 #include "G4AdjointPhysicsList.hh"
0040 #include "G4ProcessManager.hh"
0041 #include "G4ParticleTypes.hh"
0042 #include "G4AdjointPhysicsMessenger.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4GenericIon.hh"
0045 #include "G4BosonConstructor.hh"
0046 #include "G4LeptonConstructor.hh"
0047 #include "G4MesonConstructor.hh"
0048 #include "G4BosonConstructor.hh"
0049 #include "G4BaryonConstructor.hh"
0050 #include "G4IonConstructor.hh"
0051 #include "G4ShortLivedConstructor.hh"
0052 #include "G4AdjointGenericIon.hh"
0053 #include "G4AnalysisUtilities.hh"
0054 
0055 #include "G4AdjointGamma.hh"
0056 #include "G4AdjointElectron.hh"
0057 #include "G4AdjointProton.hh"
0058 #include "G4AdjointTriton.hh"
0059 #include "G4AdjointDeuteron.hh"
0060 #include "G4AdjointAlpha.hh"
0061 #include "G4AdjointHe3.hh"
0062 
0063 #include "G4AdjointAlongStepWeightCorrection.hh"
0064 #include "G4AdjointBremsstrahlungModel.hh"
0065 #include "G4AdjointCSManager.hh"
0066 #include "G4AdjointComptonModel.hh"
0067 #include "G4AdjointForcedInteractionForGamma.hh"
0068 #include "G4AdjointIonIonisationModel.hh"
0069 #include "G4AdjointPhotoElectricModel.hh"
0070 #include "G4AdjointProcessEquivalentToDirectProcess.hh"
0071 #include "G4AdjointSimManager.hh"
0072 #include "G4AdjointeIonisationModel.hh"
0073 #include "G4AdjointhMultipleScattering.hh"
0074 #include "G4AdjointhIonisationModel.hh"
0075 #include "G4ComptonScattering.hh"
0076 #include "G4ContinuousGainOfEnergy.hh"
0077 #include "G4GammaConversion.hh"
0078 #include "G4InversePEEffect.hh"
0079 #include "G4IonInverseIonisation.hh"
0080 #include "G4PhotoElectricEffect.hh"
0081 #include "G4PhysicalConstants.hh"
0082 #include "G4SystemOfUnits.hh"
0083 #include "G4UrbanAdjointMscModel.hh"
0084 #include "G4UrbanMscModel.hh"
0085 #include "G4eAdjointMultipleScattering.hh"
0086 #include "G4eBremsstrahlung.hh"
0087 #include "G4eInverseBremsstrahlung.hh"
0088 #include "G4eInverseCompton.hh"
0089 #include "G4eInverseIonisation.hh"
0090 #include "G4eIonisation.hh"
0091 #include "G4eMultipleScattering.hh"
0092 #include "G4eplusAnnihilation.hh"
0093 #include "G4hInverseIonisation.hh"
0094 #include "G4hIonisation.hh"
0095 #include "G4hMultipleScattering.hh"
0096 #include "G4ionIonisation.hh"
0097 
0098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0099 
0100 G4AdjointPhysicsList::G4AdjointPhysicsList()
0101     : G4VUserPhysicsList(),
0102       fUse_forced_interaction(true),
0103       fUse_eionisation(true),
0104       fUse_pionisation(true),
0105       fUse_brem(true),
0106       fUse_compton(true),
0107       fUse_ms(true),
0108       fUse_egain_fluctuation(true),
0109       fUse_peeffect(true),
0110       fEmin_adj_models(1. * keV),
0111       fEmax_adj_models(1. * MeV),
0112       fCS_biasing_factor_compton(1.),
0113       fCS_biasing_factor_brem(1.),
0114       fCS_biasing_factor_ionisation(1.),
0115       fCS_biasing_factor_PEeffect(1.)
0116 {
0117   defaultCutValue = 1.0 * mm;
0118   SetVerboseLevel(1);
0119   fPhysicsMessenger = new G4AdjointPhysicsMessenger(this);
0120 }
0121 
0122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0123 
0124 G4AdjointPhysicsList::~G4AdjointPhysicsList()
0125 {;
0126 }
0127 
0128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0129 void G4AdjointPhysicsList::ConstructParticle()
0130 {
0131   // In this method, static member functions should be called
0132   // for all particles which you want to use.
0133   // This ensures that objects of these particle types will be
0134   // created in the program.
0135   ConstructBosons();
0136   ConstructLeptons();
0137   ConstructMesons();
0138   ConstructBaryons();
0139   G4GenericIon::GenericIonDefinition();
0140   G4IonConstructor pIonConstructor;
0141   pIonConstructor.ConstructParticle();
0142 
0143   G4ShortLivedConstructor pShortLivedConstructor;
0144   pShortLivedConstructor.ConstructParticle();
0145   ConstructAdjointParticles();
0146   // Required by MT even if ion physics not used
0147 }
0148 
0149 
0150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0151 
0152 void G4AdjointPhysicsList::ConstructBosons()
0153 {
0154   G4BosonConstructor pBosonConstructor;
0155   pBosonConstructor.ConstructParticle();
0156 }
0157 
0158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0159 
0160 void G4AdjointPhysicsList::ConstructLeptons()
0161 {
0162   G4LeptonConstructor pLeptonConstructor;
0163   pLeptonConstructor.ConstructParticle();
0164 }
0165 
0166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0167 
0168 void G4AdjointPhysicsList::ConstructMesons()
0169 {
0170   G4MesonConstructor pMesonConstructor;
0171   pMesonConstructor.ConstructParticle();
0172 }
0173 
0174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0175 
0176 void G4AdjointPhysicsList::ConstructBaryons()
0177 {
0178   G4BaryonConstructor pBaryonConstructor;
0179   pBaryonConstructor.ConstructParticle();
0180 }
0181 
0182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0183 
0184 void G4AdjointPhysicsList::ConstructAdjointParticles()
0185 {
0186   G4AdjointGamma::AdjointGamma();
0187   G4AdjointElectron::AdjointElectron();
0188   G4AdjointProton::AdjointProton();
0189   G4AdjointTriton::Definition();
0190   G4AdjointDeuteron::Definition();
0191   G4AdjointAlpha::Definition();
0192   G4AdjointHe3::Definition();
0193   G4AdjointGenericIon::Definition();
0194 }
0195 
0196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0197 
0198 void G4AdjointPhysicsList::ConstructProcess()
0199 {
0200   AddTransportation();
0201   ConstructEM();
0202   ConstructGeneral();
0203 }
0204 
0205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0206 
0207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0208 
0209 void G4AdjointPhysicsList::ConstructEM()
0210 {
0211   G4AdjointCSManager *theCSManager =  G4AdjointCSManager::GetAdjointCSManager();
0212   G4AdjointSimManager *theAdjointSimManager = G4AdjointSimManager::GetInstance();
0213 
0214   theCSManager->RegisterAdjointParticle(G4AdjointElectron::AdjointElectron());
0215 
0216   if (fUse_brem || fUse_peeffect || fUse_compton)
0217     theCSManager->RegisterAdjointParticle(G4AdjointGamma::AdjointGamma());
0218 
0219   G4eIonisation *fEminusIonisation = nullptr;
0220 
0221   if (fUse_eionisation)
0222   {
0223     fEminusIonisation = new G4eIonisation();
0224     fEminusIonisation->SetLossFluctuations(fUse_egain_fluctuation);
0225   }
0226   G4hIonisation *hPIonisation = nullptr;
0227 
0228   if (fUse_pionisation)
0229   {
0230 
0231     
0232     hPIonisation = new G4hIonisation();
0233     hPIonisation->SetLossFluctuations(fUse_egain_fluctuation);
0234     theCSManager->RegisterAdjointParticle(G4AdjointProton::AdjointProton());
0235   
0236   }
0237 
0238   G4eBremsstrahlung *theeminusBremsstrahlung = nullptr;
0239   if (fUse_brem && fUse_eionisation)
0240     theeminusBremsstrahlung = new G4eBremsstrahlung();
0241 
0242   G4ComptonScattering *theComptonScattering = nullptr;
0243   if (fUse_compton)
0244     theComptonScattering = new G4ComptonScattering();
0245 
0246   G4PhotoElectricEffect *thePEEffect = nullptr;
0247   if (fUse_peeffect)
0248     thePEEffect = new G4PhotoElectricEffect();
0249 
0250   G4eMultipleScattering *theeminusMS = nullptr;
0251   G4hMultipleScattering *thepMS = nullptr;
0252   G4eAdjointMultipleScattering *theeminusAdjointMS = nullptr;
0253   if (fUse_ms)
0254   {
0255     theeminusMS = new G4eMultipleScattering();
0256     G4UrbanMscModel *msc1 = new G4UrbanMscModel();
0257     theeminusMS->SetEmModel(msc1);
0258     theeminusAdjointMS = new G4eAdjointMultipleScattering();
0259     G4UrbanAdjointMscModel *msc2 = new G4UrbanAdjointMscModel();
0260     theeminusAdjointMS->SetEmModel(msc2);
0261     thepMS = new G4hMultipleScattering();
0262   }
0263 
0264   G4VProcess *theGammaConversion = 0;
0265   if (fUse_gamma_conversion)
0266     theGammaConversion = new G4GammaConversion();
0267   //Define adjoint e- ionisation
0268   //-------------------
0269   G4AdjointeIonisationModel *theeInverseIonisationModel = 0;
0270   G4eInverseIonisation *theeInverseIonisationProjToProjCase = 0;
0271   G4eInverseIonisation *theeInverseIonisationProdToProjCase = 0;
0272   if (fUse_eionisation)
0273   {
0274     theeInverseIonisationModel = new G4AdjointeIonisationModel();
0275     theeInverseIonisationModel->SetHighEnergyLimit(
0276         fEmax_adj_models);
0277     theeInverseIonisationModel->SetLowEnergyLimit(
0278         fEmin_adj_models);
0279     theeInverseIonisationModel->SetCSBiasingFactor(
0280         fCS_biasing_factor_ionisation);
0281     theeInverseIonisationProjToProjCase =
0282         new G4eInverseIonisation(true, "Inv_eIon",
0283                                  theeInverseIonisationModel);
0284     theeInverseIonisationProdToProjCase =
0285         new G4eInverseIonisation(false, "Inv_eIon1",
0286                                  theeInverseIonisationModel);
0287     theAdjointSimManager->ConsiderParticleAsPrimary(G4String("e-"));
0288   }
0289 
0290   //Define  adjoint Bremsstrahlung
0291   //-------------------------------
0292   G4AdjointBremsstrahlungModel *theeInverseBremsstrahlungModel = 0;
0293   G4eInverseBremsstrahlung *theeInverseBremsstrahlungProjToProjCase = 0;
0294   G4eInverseBremsstrahlung *theeInverseBremsstrahlungProdToProjCase = 0;
0295   G4AdjointForcedInteractionForGamma *theForcedInteractionForGamma = 0;
0296 
0297   if (fUse_brem && fUse_eionisation)
0298   {
0299     theeInverseBremsstrahlungModel = new G4AdjointBremsstrahlungModel();
0300     theeInverseBremsstrahlungModel->SetHighEnergyLimit(fEmax_adj_models * 1.01);
0301     theeInverseBremsstrahlungModel->SetLowEnergyLimit(fEmin_adj_models);
0302     theeInverseBremsstrahlungModel->SetCSBiasingFactor(
0303         fCS_biasing_factor_brem);
0304     theeInverseBremsstrahlungProjToProjCase = new G4eInverseBremsstrahlung(
0305         true, "Inv_eBrem", theeInverseBremsstrahlungModel);
0306     if (!fUse_forced_interaction)
0307       theeInverseBremsstrahlungProdToProjCase =
0308       new G4eInverseBremsstrahlung(false, G4String("Inv_eBrem1"),
0309                                    theeInverseBremsstrahlungModel);
0310     theAdjointSimManager->ConsiderParticleAsPrimary("e-");
0311     theAdjointSimManager->ConsiderParticleAsPrimary("gamma");
0312 
0313     if (fUse_forced_interaction)
0314     {
0315       theForcedInteractionForGamma =
0316         new G4AdjointForcedInteractionForGamma("ReverseGammaForcedInteraction");
0317       theForcedInteractionForGamma->RegisterAdjointBremModel(
0318         theeInverseBremsstrahlungModel);
0319     }
0320   }
0321 
0322   //Define  adjoint Compton
0323   //---------------------
0324   G4AdjointComptonModel *theeInverseComptonModel = nullptr;
0325   G4eInverseCompton *theeInverseComptonProjToProjCase = nullptr;
0326   G4eInverseCompton *theeInverseComptonProdToProjCase = nullptr;
0327 
0328   if (fUse_compton)
0329   {
0330     theeInverseComptonModel = new G4AdjointComptonModel();
0331     theeInverseComptonModel->SetHighEnergyLimit(fEmax_adj_models);
0332     theeInverseComptonModel->SetLowEnergyLimit(fEmin_adj_models);
0333     theeInverseComptonModel->SetDirectProcess(theComptonScattering);
0334     theeInverseComptonModel->SetUseMatrix(false);
0335 
0336     theeInverseComptonModel->SetCSBiasingFactor(fCS_biasing_factor_compton);
0337     if (!fUse_forced_interaction)
0338       theeInverseComptonProjToProjCase =
0339           new G4eInverseCompton(true, "Inv_Compt", theeInverseComptonModel);
0340     theeInverseComptonProdToProjCase = new G4eInverseCompton(false, "Inv_Compt1",
0341                                                              theeInverseComptonModel);
0342     if (fUse_forced_interaction)
0343     {
0344       if (!fUse_brem && !fUse_eionisation)
0345         theForcedInteractionForGamma =
0346             new G4AdjointForcedInteractionForGamma("ReverseGammaForcedInteraction");
0347       theForcedInteractionForGamma->RegisterAdjointComptonModel(theeInverseComptonModel);
0348     }
0349     theAdjointSimManager->ConsiderParticleAsPrimary(G4String("e-"));
0350     theAdjointSimManager->ConsiderParticleAsPrimary(G4String("gamma"));
0351   }
0352 
0353   //Define  adjoint PEEffect
0354   //---------------------
0355   G4AdjointPhotoElectricModel *theInversePhotoElectricModel = 0;
0356   G4InversePEEffect *theInversePhotoElectricProcess = 0;
0357 
0358   if (fUse_peeffect)
0359   {
0360     theInversePhotoElectricModel = new G4AdjointPhotoElectricModel();
0361     theInversePhotoElectricModel->SetHighEnergyLimit(fEmax_adj_models);
0362     theInversePhotoElectricModel->SetLowEnergyLimit(fEmin_adj_models);
0363     theInversePhotoElectricModel->SetCSBiasingFactor(
0364         fCS_biasing_factor_PEeffect);
0365     theInversePhotoElectricProcess
0366       = new G4InversePEEffect("Inv_PEEffect", theInversePhotoElectricModel);
0367     theAdjointSimManager->ConsiderParticleAsPrimary(G4String("e-"));
0368     theAdjointSimManager->ConsiderParticleAsPrimary(G4String("gamma"));
0369   }
0370 
0371   //Define  adjoint ionisation for protons
0372   //---------------------
0373   G4AdjointhIonisationModel *thepInverseIonisationModel = 0;
0374   G4hInverseIonisation *thepInverseIonisationProjToProjCase = 0;
0375   G4hInverseIonisation *thepInverseIonisationProdToProjCase = 0;
0376   if (fUse_pionisation)
0377   {
0378     thepInverseIonisationModel = new G4AdjointhIonisationModel(
0379         G4Proton::Proton());
0380     thepInverseIonisationModel->SetHighEnergyLimit(fEmax_adj_models);
0381     thepInverseIonisationModel->SetLowEnergyLimit(fEmin_adj_models);
0382     thepInverseIonisationModel->SetUseMatrix(false);
0383     thepInverseIonisationProjToProjCase
0384       = new G4hInverseIonisation(true, "Inv_pIon", thepInverseIonisationModel);
0385     thepInverseIonisationProdToProjCase
0386       = new G4hInverseIonisation(false, "Inv_pIon1", thepInverseIonisationModel);
0387     theAdjointSimManager->ConsiderParticleAsPrimary(G4String("e-"));
0388     theAdjointSimManager->ConsiderParticleAsPrimary(G4String("proton"));
0389   }
0390 
0391   //Declare the processes active for the different particles
0392   //--------------------------------------------------------
0393   auto particleIterator = GetParticleIterator();
0394 
0395   //size_t s1 = theParticleTable->size();
0396   particleIterator->reset();
0397   while ((*particleIterator)())
0398   {
0399     G4ParticleDefinition *particle = particleIterator->value();
0400     G4ProcessManager *pmanager = particle->GetProcessManager();
0401     if (!pmanager)
0402     {
0403       pmanager = new G4ProcessManager(particle);
0404       particle->SetProcessManager(pmanager);
0405     }
0406 
0407     G4String particleName = particle->GetParticleName();
0408     if (particleName == "e-")
0409     {
0410       if (fUse_ms && fUse_eionisation)
0411         pmanager->AddProcess(theeminusMS);
0412       if (fUse_eionisation)
0413       {
0414         pmanager->AddProcess(fEminusIonisation);
0415         G4AdjointCSManager::GetAdjointCSManager()
0416           ->RegisterEnergyLossProcess(fEminusIonisation, particle);
0417       }
0418       if (fUse_brem && fUse_eionisation)
0419       {
0420         pmanager->AddProcess(theeminusBremsstrahlung);
0421         G4AdjointCSManager::GetAdjointCSManager()
0422           ->RegisterEnergyLossProcess(theeminusBremsstrahlung, particle);
0423       }
0424       G4int n_order = 0;
0425       if (fUse_ms && fUse_eionisation)
0426       {
0427         n_order++;
0428         pmanager->SetProcessOrdering(theeminusMS, idxAlongStep, n_order);
0429       }
0430       if (fUse_eionisation)
0431       {
0432         n_order++;
0433         pmanager->SetProcessOrdering(fEminusIonisation, idxAlongStep, n_order);
0434       }
0435       if (fUse_brem && fUse_eionisation)
0436       {
0437         n_order++;
0438         pmanager->SetProcessOrdering(theeminusBremsstrahlung,
0439                                      idxAlongStep, n_order);
0440       }
0441       n_order = 0;
0442       if (fUse_ms && fUse_eionisation)
0443       {
0444         n_order++;
0445         pmanager->SetProcessOrdering(theeminusMS, idxPostStep, n_order);
0446       }
0447       if (fUse_eionisation)
0448       {
0449         n_order++;
0450         pmanager->SetProcessOrdering(fEminusIonisation, idxPostStep, n_order);
0451       }
0452       if (fUse_brem && fUse_eionisation)
0453       {
0454         n_order++;
0455         pmanager->SetProcessOrdering(theeminusBremsstrahlung, idxPostStep,
0456                                      n_order);
0457       }
0458     }
0459 
0460     if (particleName == "adj_e-")
0461     {
0462       G4ContinuousGainOfEnergy *theContinuousGainOfEnergy = 0;
0463       if (fUse_eionisation)
0464       {
0465         theContinuousGainOfEnergy = new G4ContinuousGainOfEnergy();
0466         theContinuousGainOfEnergy->SetLossFluctuations(
0467             fUse_egain_fluctuation);
0468         theContinuousGainOfEnergy->SetDirectEnergyLossProcess(
0469             fEminusIonisation);
0470         theContinuousGainOfEnergy->SetDirectParticle(G4Electron::Electron());
0471         pmanager->AddProcess(theContinuousGainOfEnergy);
0472       }
0473       G4int n_order = 0;
0474       if (fUse_ms)
0475       {
0476         n_order++;
0477         pmanager->AddProcess(theeminusAdjointMS);
0478         pmanager->SetProcessOrdering(theeminusAdjointMS,
0479                                      idxAlongStep, n_order);
0480       }
0481       n_order++;
0482       pmanager->SetProcessOrdering(theContinuousGainOfEnergy, idxAlongStep,
0483                                    n_order);
0484 
0485       n_order++;
0486       G4AdjointAlongStepWeightCorrection *theAlongStepWeightCorrection =
0487           new G4AdjointAlongStepWeightCorrection();
0488       pmanager->AddProcess(theAlongStepWeightCorrection);
0489       pmanager->SetProcessOrdering(theAlongStepWeightCorrection,
0490                                    idxAlongStep,
0491                                    n_order);
0492       n_order = 0;
0493       if (fUse_eionisation)
0494       {
0495         pmanager->AddProcess(theeInverseIonisationProjToProjCase);
0496         pmanager->AddProcess(theeInverseIonisationProdToProjCase);
0497         n_order++;
0498         pmanager->SetProcessOrdering(theeInverseIonisationProjToProjCase,
0499                                      idxPostStep, n_order);
0500         n_order++;
0501         pmanager->SetProcessOrdering(theeInverseIonisationProdToProjCase,
0502                                      idxPostStep, n_order);
0503       }
0504       if (fUse_brem && fUse_eionisation)
0505       {
0506         pmanager->AddProcess(theeInverseBremsstrahlungProjToProjCase);
0507         n_order++;
0508         pmanager->SetProcessOrdering(
0509             theeInverseBremsstrahlungProjToProjCase,
0510             idxPostStep, n_order);
0511       }
0512 
0513       if (fUse_compton)
0514       {
0515         pmanager->AddProcess(theeInverseComptonProdToProjCase);
0516         n_order++;
0517         pmanager->SetProcessOrdering(theeInverseComptonProdToProjCase,
0518                                      idxPostStep, n_order);
0519       }
0520       if (fUse_peeffect)
0521       {
0522         pmanager->AddDiscreteProcess(theInversePhotoElectricProcess);
0523         n_order++;
0524         pmanager->SetProcessOrdering(theInversePhotoElectricProcess,
0525                                      idxPostStep, n_order);
0526       }
0527       if (fUse_pionisation)
0528       {
0529         pmanager->AddProcess(thepInverseIonisationProdToProjCase);
0530         n_order++;
0531         pmanager->SetProcessOrdering(thepInverseIonisationProdToProjCase,
0532                                      idxPostStep, n_order);
0533       }
0534       if (fUse_ms && fUse_eionisation)
0535       {
0536         n_order++;
0537         pmanager->SetProcessOrdering(theeminusAdjointMS,
0538                                      idxPostStep, n_order);
0539       }
0540     }
0541 
0542     if (particleName == "adj_gamma")
0543     {
0544       G4int n_order = 0;
0545       if (!fUse_forced_interaction)
0546       {
0547         G4AdjointAlongStepWeightCorrection *theAlongStepWeightCorrection =
0548             new G4AdjointAlongStepWeightCorrection();
0549         pmanager->AddProcess(theAlongStepWeightCorrection);
0550         pmanager->SetProcessOrdering(theAlongStepWeightCorrection,
0551                                      idxAlongStep, 1);
0552 
0553         if (fUse_brem && fUse_eionisation)
0554         {
0555           pmanager->AddProcess(theeInverseBremsstrahlungProdToProjCase);
0556           n_order++;
0557           pmanager->SetProcessOrdering(
0558               theeInverseBremsstrahlungProdToProjCase,
0559               idxPostStep, n_order);
0560         }
0561         if (fUse_compton)
0562         {
0563           pmanager->AddDiscreteProcess(theeInverseComptonProjToProjCase);
0564           n_order++;
0565           pmanager->SetProcessOrdering(theeInverseComptonProjToProjCase,
0566                                        idxPostStep, n_order);
0567         }
0568       }
0569       else
0570       {
0571         //        if (theForcedInteractionForGamma)
0572         {
0573           pmanager->AddProcess(theForcedInteractionForGamma);
0574           n_order++;
0575           pmanager->SetProcessOrdering(theForcedInteractionForGamma,
0576                                        idxPostStep, n_order);
0577           pmanager->SetProcessOrdering(theForcedInteractionForGamma,
0578                                        idxAlongStep, n_order);
0579         }
0580       }
0581     }
0582 
0583     if (particleName == "gamma")
0584     {
0585       if (fUse_compton)
0586       {
0587         pmanager->AddDiscreteProcess(theComptonScattering);
0588         G4AdjointCSManager::GetAdjointCSManager()
0589           ->RegisterEmProcess(theComptonScattering, particle);
0590       }
0591       if (fUse_peeffect)
0592       {
0593         pmanager->AddDiscreteProcess(thePEEffect);
0594         G4AdjointCSManager::GetAdjointCSManager()
0595           ->RegisterEmProcess(thePEEffect, particle);
0596       }
0597       if (fUse_gamma_conversion)
0598       {
0599         pmanager->AddDiscreteProcess(theGammaConversion);
0600       }
0601     }
0602 
0603     if (particleName == "e+" && fUse_gamma_conversion)
0604     { //positron
0605       G4VProcess *theeplusMultipleScattering = new G4eMultipleScattering();
0606       G4VProcess *theeplusIonisation = new G4eIonisation();
0607       G4VProcess *theeplusBremsstrahlung = new G4eBremsstrahlung();
0608       G4VProcess *theeplusAnnihilation = new G4eplusAnnihilation();
0609 
0610       // add processes
0611       pmanager->AddProcess(theeplusMultipleScattering);
0612       pmanager->AddProcess(theeplusIonisation);
0613       pmanager->AddProcess(theeplusBremsstrahlung);
0614       pmanager->AddProcess(theeplusAnnihilation);
0615 
0616       // set ordering for AtRestDoIt
0617       pmanager->SetProcessOrderingToFirst(theeplusAnnihilation, idxAtRest);
0618 
0619       // set ordering for AlongStepDoIt
0620       pmanager->SetProcessOrdering(theeplusMultipleScattering,
0621                                    idxAlongStep, 1);
0622       pmanager->SetProcessOrdering(theeplusIonisation, idxAlongStep, 2);
0623       pmanager->SetProcessOrdering(theeplusBremsstrahlung, idxAlongStep, 3);
0624 
0625       // set ordering for PostStepDoIt
0626       pmanager->SetProcessOrdering(theeplusMultipleScattering,
0627                                    idxPostStep, 1);
0628       pmanager->SetProcessOrdering(theeplusIonisation, idxPostStep, 2);
0629       pmanager->SetProcessOrdering(theeplusBremsstrahlung, idxPostStep, 3);
0630       pmanager->SetProcessOrdering(theeplusAnnihilation, idxPostStep, 4);
0631     }
0632     if (particleName == "proton" && fUse_pionisation)
0633     {
0634       if (fUse_ms && fUse_pionisation)
0635         pmanager->AddProcess(thepMS);
0636 
0637       if (fUse_pionisation)
0638       {
0639         pmanager->AddProcess(hPIonisation);
0640         G4AdjointCSManager::GetAdjointCSManager()
0641           ->RegisterEnergyLossProcess(hPIonisation, particle);
0642       }
0643 
0644       G4int n_order = 0;
0645       if (fUse_ms && fUse_pionisation)
0646       {
0647         n_order++;
0648         pmanager->SetProcessOrdering(thepMS, idxAlongStep, n_order);
0649       }
0650 
0651       if (fUse_pionisation)
0652       {
0653         n_order++;
0654         pmanager->SetProcessOrdering(hPIonisation, idxAlongStep, n_order);
0655       }
0656 
0657       n_order = 0;
0658       if (fUse_ms && fUse_pionisation)
0659       {
0660         n_order++;
0661         pmanager->SetProcessOrdering(thepMS, idxPostStep, n_order);
0662       }
0663 
0664       if (fUse_pionisation)
0665       {
0666         n_order++;
0667         pmanager->SetProcessOrdering(hPIonisation, idxPostStep, n_order);
0668       }
0669     }
0670 
0671     if (particleName == "adj_proton" && fUse_pionisation)
0672     {
0673       G4ContinuousGainOfEnergy *theContinuousGainOfEnergy = 0;
0674       if (fUse_pionisation)
0675       {
0676         theContinuousGainOfEnergy = new G4ContinuousGainOfEnergy();
0677         theContinuousGainOfEnergy->SetLossFluctuations(
0678             fUse_egain_fluctuation);
0679         theContinuousGainOfEnergy->SetDirectEnergyLossProcess(hPIonisation);
0680         theContinuousGainOfEnergy->SetDirectParticle(G4Proton::Proton());
0681         pmanager->AddProcess(theContinuousGainOfEnergy);
0682       }
0683 
0684       G4int n_order = 0;
0685       if (fUse_ms)
0686       {
0687         n_order++;
0688         pmanager->AddProcess(thepMS);
0689         pmanager->SetProcessOrdering(thepMS, idxAlongStep, n_order);
0690       }
0691 
0692       n_order++;
0693       pmanager->SetProcessOrdering(theContinuousGainOfEnergy, idxAlongStep,
0694                                    n_order);
0695 
0696       n_order++;
0697       G4AdjointAlongStepWeightCorrection *theAlongStepWeightCorrection =
0698           new G4AdjointAlongStepWeightCorrection();
0699       pmanager->AddProcess(theAlongStepWeightCorrection);
0700       pmanager->SetProcessOrdering(theAlongStepWeightCorrection,
0701                                    idxAlongStep,
0702                                    n_order);
0703       n_order = 0;
0704       if (fUse_pionisation)
0705       {
0706         pmanager->AddProcess(thepInverseIonisationProjToProjCase);
0707         n_order++;
0708         pmanager->SetProcessOrdering(
0709             thepInverseIonisationProjToProjCase,
0710             idxPostStep, n_order);
0711       }
0712 
0713       if (fUse_ms && fUse_pionisation)
0714       {
0715         n_order++;
0716         pmanager->SetProcessOrdering(thepMS, idxPostStep, n_order);
0717       }
0718     }
0719   }
0720 }
0721 
0722 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0723 
0724 #include "G4Decay.hh"
0725 void G4AdjointPhysicsList::ConstructGeneral()
0726 {
0727 
0728   // Add Decay Process
0729   G4Decay *theDecayProcess = new G4Decay();
0730 
0731   auto particleIterator = GetParticleIterator();
0732   particleIterator->reset();
0733   while ((*particleIterator)())
0734   {
0735     G4ParticleDefinition *particle = particleIterator->value();
0736     G4ProcessManager *pmanager = particle->GetProcessManager();
0737     if (theDecayProcess->IsApplicable(*particle))
0738     {
0739       pmanager->AddProcess(theDecayProcess);
0740       // set ordering for PostStepDoIt and AtRestDoIt
0741       pmanager->SetProcessOrdering(theDecayProcess, idxPostStep);
0742       pmanager->SetProcessOrdering(theDecayProcess, idxAtRest);
0743     }
0744   }
0745 }
0746 
0747 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0748 
0749 void G4AdjointPhysicsList::SetCuts()
0750 {
0751   if (verboseLevel > 0)
0752   {
0753     G4cout << "G4AdjointPhysicsList::SetCuts:";
0754     G4cout << "CutLength : " << G4BestUnit(defaultCutValue, "Length") << G4endl;
0755   }
0756 
0757   // set cut values for gamma at first and for e- second and next for e+,
0758   // because some processes for e+/e- need cut values for gamma
0759   //
0760   SetCutValue(defaultCutValue, "gamma");
0761   SetCutValue(defaultCutValue, "e-");
0762   SetCutValue(defaultCutValue, "e+");
0763 
0764   if (verboseLevel > 0)
0765     DumpCutValuesTable();
0766 }
0767 
0768 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......