Segmentation fault from GetMaterial() during run

EDIT: (I have updated the code for the physics list, but am still getting a segfault)

I am trying to enable alpha particles in the physics list in the example RMC01, but I am receiving a segmentation fault during the run. The primary error seems to be in “G4MaterialCutsCouple::GetMaterial()”. Any advice is greatly appreciated.

Here is the current report from gdb:

Thread 1 "ATOM" received signal SIGSEGV, Segmentation fault.
0x00007ffff58d21f8 in G4MaterialCutsCouple::GetMaterial() const ()
   from /home/jordan/Documents/Geant4/geant4.10.6-build/BuildProducts/lib/libG4tracking.so
(gdb) where
#0  0x00007ffff58d21f8 in G4MaterialCutsCouple::GetMaterial() const ()
    at /home/jordan/Documents/Geant4/geant4.10.6-build/BuildProducts/lib/libG4tracking.so
#1  0x00007ffff0e708cb in G4VEmAdjointModel::DefineCurrentMaterial(G4MaterialCutsCouple const*) ()
    at /home/jordan/Documents/Geant4/geant4.10.6-build/BuildProducts/lib/libG4processes.so
#2  0x00007ffff0e6dea7 in G4VEmAdjointModel::AdjointCrossSection(G4MaterialCutsCouple const*, double, bool) ()
    at /home/jordan/Documents/Geant4/geant4.10.6-build/BuildProducts/lib/libG4processes.so
#3  0x00007ffff0e4f071 in G4AdjointCSManager::ComputeAdjointCS(G4Material*, G4VEmAdjointModel*, double, double, bool, std::vector<double, std::allocator<double> >&) ()
    at /home/jordan/Documents/Geant4/geant4.10.6-build/BuildProducts/lib/libG4processes.so
#4  0x00007ffff0e6df22 in G4VEmAdjointModel::AdjointCrossSection(G4MaterialCutsCouple const*, double, bool) ()
    at /home/jordan/Documents/Geant4/geant4.10.6-build/BuildProducts/lib/libG4processes.so
#5  0x00007ffff0e6dfbe in G4VEmAdjointModel::GetAdjointCrossSection(G4MaterialCutsCouple const*, double, bool) ()
    at /home/jordan/Documents/Geant4/geant4.10.6-build/BuildProducts/lib/libG4pr

Relevant bits of code:

  if (fUse_gionisation) {
          if (!fGIonisation) fGIonisation  = new G4ionIonisation();
        fGIonisation->SetLossFluctuations(fUse_egain_fluctuation);
        theCSManager->RegisterAdjointParticle(
                G4AdjointGenericIon::GenericIon());
        theCSManager->RegisterAdjointParticle(
                G4AdjointAlpha::Alpha());
  } 
  //Define  adjoint ionisation for ions
  //---------------------
   G4AdjointIonIonisationModel* thegInverseIonisationModel = 0;
   G4IonInverseIonisation* thegInverseIonisationProjToProjCase = 0 ;
   G4IonInverseIonisation* thegInverseIonisationProdToProjCase = 0;
   if (fUse_gionisation) {
     thegInverseIonisationModel = new G4AdjointIonIonisationModel();
     thegInverseIonisationModel->SetHighEnergyLimit(fEmax_adj_models);
     thegInverseIonisationModel->SetLowEnergyLimit(fEmin_adj_models);
     thegInverseIonisationModel->SetUseMatrix(false);
     thegInverseIonisationProjToProjCase = new G4IonInverseIonisation(true,
                                     "Inv_gIon",thegInverseIonisationModel);
     thegInverseIonisationProdToProjCase = new G4IonInverseIonisation(false,
                                    "Inv_gIon1",thegInverseIonisationModel);
     theAdjointSimManager->ConsiderParticleAsPrimary(G4String("ion"));
     theAdjointSimManager->SetPrimaryIon(G4AdjointAlpha::Alpha(),G4Alpha::Alpha());
     theCSManager->SetIon(G4AdjointAlpha::Alpha(),G4Alpha::Alpha());
     thegInverseIonisationModel->SetIon(G4AdjointAlpha::Alpha(),G4Alpha::Alpha());
     std::cout<<theAdjointSimManager->GetPrimaryIonName()<<std::endl;
   }
if (particleName == "alpha" && fUse_gionisation) {
      if (fUse_ms && fUse_gionisation) pmanager->AddProcess(thegMS);

      if (fUse_gionisation){
            pmanager->AddProcess(fGIonisation);
            G4AdjointCSManager::GetAdjointCSManager()->
                      RegisterEnergyLossProcess(fGIonisation,particle);
      }

      G4int n_order=0;
      if (fUse_ms && fUse_gionisation) {
        n_order++;
            pmanager->SetProcessOrdering(thegMS, idxAlongStep,n_order);
      }

      if (fUse_gionisation) {
          n_order++;
          pmanager->SetProcessOrdering(fGIonisation,idxAlongStep,n_order);
      }
            
      n_order=0;
      if (fUse_ms && fUse_gionisation) {
            n_order++;
          pmanager->SetProcessOrdering(thegMS, idxPostStep,n_order);
      }

      if (fUse_gionisation) {
          n_order++;
          pmanager->SetProcessOrdering(fGIonisation,idxPostStep,n_order);
      }
    
    }
    
    if (particleName == "adj_alpha" && fUse_gionisation) {
      G4ContinuousGainOfEnergy* theContinuousGainOfEnergy =0;
      if (fUse_gionisation ) {
       theContinuousGainOfEnergy= new G4ContinuousGainOfEnergy();
       theContinuousGainOfEnergy->SetLossFluctuations(
                               fUse_egain_fluctuation);
       theContinuousGainOfEnergy->SetDirectEnergyLossProcess(fGIonisation);
          theContinuousGainOfEnergy->SetDirectParticle(G4Alpha::Alpha());
          pmanager->AddProcess(theContinuousGainOfEnergy);
       }

       G4int n_order=0;
       if (fUse_ms) {
         n_order++;
         pmanager->AddProcess(thegMS);
         pmanager->SetProcessOrdering(thegMS, idxAlongStep,n_order);
       }

       n_order++;
       pmanager->SetProcessOrdering(theContinuousGainOfEnergy,idxAlongStep,
                                                                   n_order);
            
       n_order++;
       G4AdjointAlongStepWeightCorrection* theAlongStepWeightCorrection =
                                  new G4AdjointAlongStepWeightCorrection();
      pmanager->AddProcess(theAlongStepWeightCorrection);
      pmanager->SetProcessOrdering(theAlongStepWeightCorrection,
                                            idxAlongStep,
                                                    n_order);
      n_order=0;
      if (fUse_gionisation) {
        pmanager->AddProcess(thegInverseIonisationProjToProjCase);
        n_order++;
            pmanager->SetProcessOrdering(
                               thegInverseIonisationProjToProjCase,
                                                   idxPostStep,n_order);
      }

      if (fUse_ms && fUse_gionisation) {
        n_order++;
        pmanager->SetProcessOrdering(thegMS,idxPostStep,n_order);
      }
    }

And here is the full code:

//
// ********************************************************************
// * License and Disclaimer                                           *
// *                                                                  *
// * The  Geant4 software  is  copyright of the Copyright Holders  of *
// * the Geant4 Collaboration.  It is provided  under  the terms  and *
// * conditions of the Geant4 Software License,  included in the file *
// * LICENSE and available at  http://cern.ch/geant4/license .  These *
// * include a list of copyright holders.                             *
// *                                                                  *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work  make  any representation or  warranty, express or implied, *
// * regarding  this  software system or assume any liability for its *
// * use.  Please see the license in the file  LICENSE  and URL above *
// * for the full disclaimer and the limitation of liability.         *
// *                                                                  *
// * This  code  implementation is the result of  the  scientific and *
// * technical work of the GEANT4 collaboration.                      *
// * By using,  copying,  modifying or  distributing the software (or *
// * any work based  on the software)  you  agree  to acknowledge its *
// * use  in  resulting  scientific  publications,  and indicate your *
// * acceptance of all terms of the Geant4 Software license.          *
// ********************************************************************
//
/// \file biasing/ReverseMC01/src/G4AdjointPhysicsList.cc
/// \brief Implementation of the G4AdjointPhysicsList class
//
//
//////////////////////////////////////////////////////////////
//  Class Name:        G4AdjointPhysicsList
//        Author:               L. Desorgher
//         Organisation:         SpaceIT GmbH
//        Contract:        ESA contract 21435/08/NL/AT
//         Customer:             ESA/ESTEC
//////////////////////////////////////////////////////////////

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

#include "G4AdjointPhysicsList.hh"
#include "G4ProcessManager.hh"
#include "G4ParticleTypes.hh"
#include "G4AdjointPhysicsMessenger.hh"
#include "G4SystemOfUnits.hh"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

G4AdjointPhysicsList::G4AdjointPhysicsList()
 :G4VUserPhysicsList(),
  fEminusIonisation(0),fPIonisation(0),fGIonisation(0),
  fUse_forced_interaction(true),
  fUse_eionisation(true),fUse_pionisation(true),fUse_gionisation(true),
  fUse_brem(true),fUse_compton(true),fUse_ms(true),
  fUse_egain_fluctuation(true),fUse_peeffect(true),
  fEmin_adj_models(1.*keV), fEmax_adj_models(1.*MeV),
  fCS_biasing_factor_compton(1.),fCS_biasing_factor_brem(1.),
  fCS_biasing_factor_ionisation(1.),fCS_biasing_factor_PEeffect(1.)
{
  defaultCutValue = 1.0*mm;
  SetVerboseLevel(1);
  fPhysicsMessenger = new G4AdjointPhysicsMessenger(this);
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

G4AdjointPhysicsList::~G4AdjointPhysicsList()
{
}
void G4AdjointPhysicsList::ConstructParticle()
{
  // In this method, static member functions should be called
  // for all particles which you want to use.
  // This ensures that objects of these particle types will be
  // created in the program. 
  ConstructBosons();
  ConstructLeptons();
  ConstructMesons();
  ConstructBaryons();
  ConstructIons();
  ConstructAdjointParticles();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4AdjointPhysicsList::SetLossFluctuationFlag(bool aBool)
{
 if (fEminusIonisation) fEminusIonisation->SetLossFluctuations(aBool);
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4AdjointPhysicsList::ConstructBosons()
{
  // pseudo-particles
  G4Geantino::GeantinoDefinition();
  G4ChargedGeantino::ChargedGeantinoDefinition();

  // gamma
  G4Gamma::GammaDefinition();

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

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4AdjointPhysicsList::ConstructLeptons()
{
  // leptons
  G4Electron::ElectronDefinition();
  G4Positron::PositronDefinition();
  G4MuonPlus::MuonPlusDefinition();
  G4MuonMinus::MuonMinusDefinition();

  G4NeutrinoE::NeutrinoEDefinition();
  G4AntiNeutrinoE::AntiNeutrinoEDefinition();
  G4NeutrinoMu::NeutrinoMuDefinition();
  G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4AdjointPhysicsList::ConstructMesons()
{
//  mesons
  G4PionPlus::PionPlusDefinition();
  G4PionMinus::PionMinusDefinition();
  G4PionZero::PionZeroDefinition();
  G4Eta::EtaDefinition();
  G4EtaPrime::EtaPrimeDefinition();
  G4KaonPlus::KaonPlusDefinition();
  G4KaonMinus::KaonMinusDefinition();
  G4KaonZero::KaonZeroDefinition();
  G4AntiKaonZero::AntiKaonZeroDefinition();
  G4KaonZeroLong::KaonZeroLongDefinition();
  G4KaonZeroShort::KaonZeroShortDefinition();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4AdjointPhysicsList::ConstructBaryons()
{
//  barions
  G4Proton::ProtonDefinition();
  G4AntiProton::AntiProtonDefinition();
  G4Neutron::NeutronDefinition();
  G4AntiNeutron::AntiNeutronDefinition();
}

#include "G4Alpha.hh"
#include "G4AntiAlpha.hh"
#include "G4GenericIon.hh"
void G4AdjointPhysicsList::ConstructIons()
{
  //  nuclei
  G4Alpha::AlphaDefinition();
  //  anti_nuclei
  G4AntiAlpha::AntiAlphaDefinition();
  //  generic ion
  G4GenericIon::GenericIonDefinition();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

#include"G4AdjointGamma.hh"
#include"G4AdjointElectron.hh"
#include"G4AdjointProton.hh"
#include"G4AdjointAlpha.hh"
#include"G4AdjointGenericIon.hh"
void G4AdjointPhysicsList::ConstructAdjointParticles()
{
// adjoint_gammma
  G4AdjointGamma::AdjointGammaDefinition();

// adjoint_electron
  G4AdjointElectron::AdjointElectronDefinition();
  
// adjoint_proton
  G4AdjointProton::AdjointProtonDefinition();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4AdjointPhysicsList::ConstructProcess()
{
  AddTransportation();
  ConstructEM();
  ConstructGeneral();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

//#include "G4PEEffectFluoModel.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4eMultipleScattering.hh"
#include "G4eAdjointMultipleScattering.hh"
#include "G4hMultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4hIonisation.hh"
#include "G4ionIonisation.hh"
//#include "G4IonParametrisedLossModel.hh"

#include "G4eBremsstrahlung.hh"
#include "G4ContinuousGainOfEnergy.hh"
#include "G4eInverseIonisation.hh"
#include "G4AdjointeIonisationModel.hh"
#include "G4AdjointCSManager.hh"
#include "G4AdjointBremsstrahlungModel.hh"
#include "G4eInverseBremsstrahlung.hh"
#include "G4AdjointComptonModel.hh"
#include "G4eInverseCompton.hh"
#include "G4InversePEEffect.hh"
#include "G4AdjointPhotoElectricModel.hh"
#include "G4AdjointAlongStepWeightCorrection.hh"
#include "G4hInverseIonisation.hh"
#include "G4AdjointhIonisationModel.hh"
#include "G4AdjointhMultipleScattering.hh"
#include "G4IonInverseIonisation.hh"
#include "G4AdjointIonIonisationModel.hh"

#include "G4AdjointSimManager.hh"
#include "G4AdjointProcessEquivalentToDirectProcess.hh"

#include "G4SystemOfUnits.hh"
#include "G4PhysicalConstants.hh"
#include "G4UrbanMscModel.hh"
#include "G4UrbanAdjointMscModel.hh"
#include "G4UrbanAdjointMscModel.hh"
#include "G4AdjointForcedInteractionForGamma.hh"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4AdjointPhysicsList::ConstructEM()
{
  G4AdjointCSManager* theCSManager =
       G4AdjointCSManager::GetAdjointCSManager();
  G4AdjointSimManager* theAdjointSimManager =
              G4AdjointSimManager::GetInstance();
  
  theCSManager->RegisterAdjointParticle(
            G4AdjointElectron::AdjointElectron());
  
  if (fUse_brem || fUse_peeffect ||fUse_compton)
              theCSManager->RegisterAdjointParticle(
                  G4AdjointGamma::AdjointGamma());

  if (fUse_eionisation) {
          if (!fEminusIonisation) fEminusIonisation  =
                         new G4eIonisation();
        fEminusIonisation->SetLossFluctuations(fUse_egain_fluctuation);
  }
  if (fUse_pionisation) {
          if (!fPIonisation) fPIonisation  = new G4hIonisation();
        fPIonisation->SetLossFluctuations(fUse_egain_fluctuation);
        theCSManager->RegisterAdjointParticle(
                G4AdjointProton::AdjointProton());
  }
  if (fUse_gionisation) {
          if (!fGIonisation) fGIonisation  = new G4ionIonisation();
        fGIonisation->SetLossFluctuations(fUse_egain_fluctuation);
        theCSManager->RegisterAdjointParticle(
                G4AdjointGenericIon::GenericIon());
        theCSManager->RegisterAdjointParticle(
                G4AdjointAlpha::Alpha());
  }    
  
  G4eBremsstrahlung* theeminusBremsstrahlung = 0;
  if (fUse_brem && fUse_eionisation)
                  theeminusBremsstrahlung = new G4eBremsstrahlung();
  
  G4ComptonScattering* theComptonScattering =0;
  if (fUse_compton) theComptonScattering = new G4ComptonScattering();
  
  G4PhotoElectricEffect* thePEEffect =0;
  if (fUse_peeffect) thePEEffect = new G4PhotoElectricEffect();
  
  G4eMultipleScattering* theeminusMS = 0;
  G4hMultipleScattering* thepMS= 0;
  G4hMultipleScattering* thegMS= 0;
  G4eAdjointMultipleScattering* theeminusAdjointMS = 0;
  if (fUse_ms) {
         theeminusMS = new G4eMultipleScattering();
         G4UrbanMscModel* msc1 = new G4UrbanMscModel();
         theeminusMS->SetEmModel(msc1);
         theeminusAdjointMS = new G4eAdjointMultipleScattering();
         G4UrbanAdjointMscModel* msc2 = new G4UrbanAdjointMscModel();
         theeminusAdjointMS->SetEmModel(msc2);
         thepMS = new G4hMultipleScattering();
         thegMS = new G4hMultipleScattering();
  }        
  
  G4VProcess*  theGammaConversion =0;
  if (fUse_gamma_conversion) theGammaConversion = new G4GammaConversion();

  //Define  adjoint ionisation for ions
  //---------------------
   G4AdjointIonIonisationModel* thegInverseIonisationModel = 0;
   G4IonInverseIonisation* thegInverseIonisationProjToProjCase = 0 ;
   G4IonInverseIonisation* thegInverseIonisationProdToProjCase = 0;
   if (fUse_gionisation) {
     thegInverseIonisationModel = new G4AdjointIonIonisationModel();
     thegInverseIonisationModel->SetHighEnergyLimit(fEmax_adj_models);
     thegInverseIonisationModel->SetLowEnergyLimit(fEmin_adj_models);
     thegInverseIonisationModel->SetUseMatrix(false);
     thegInverseIonisationProjToProjCase = new G4IonInverseIonisation(true,
                                     "Inv_gIon",thegInverseIonisationModel);
     thegInverseIonisationProdToProjCase = new G4IonInverseIonisation(false,
                                    "Inv_gIon1",thegInverseIonisationModel);
     theAdjointSimManager->ConsiderParticleAsPrimary(G4String("ion"));
     theAdjointSimManager->SetPrimaryIon(G4AdjointAlpha::Alpha(),G4Alpha::Alpha());
     theCSManager->SetIon(G4AdjointAlpha::Alpha(),G4Alpha::Alpha());
     thegInverseIonisationModel->SetIon(G4AdjointAlpha::Alpha(),G4Alpha::Alpha());
     std::cout<<theAdjointSimManager->GetPrimaryIonName()<<std::endl;
   }

  //Declare the processes active for the different particles
  //--------------------------------------------------------
  auto particleIterator=GetParticleIterator();
  particleIterator->reset();
  while( (*particleIterator)() ){
    G4ParticleDefinition* particle = particleIterator->value();
    G4ProcessManager* pmanager = particle->GetProcessManager();
    if (!pmanager) {
     pmanager = new G4ProcessManager(particle);
     particle->SetProcessManager(pmanager);
    }
        
    G4String particleName = particle->GetParticleName();
    std::cout<<particleName<<std::endl;
    G4String particleType = particle->GetParticleType();

    if (particleName == "e-") {
      if (fUse_ms && fUse_eionisation) pmanager->AddProcess(theeminusMS);
      if (fUse_eionisation){
        pmanager->AddProcess(fEminusIonisation);
        G4AdjointCSManager::GetAdjointCSManager()->
                    RegisterEnergyLossProcess(fEminusIonisation,particle);
      }
      if (fUse_brem && fUse_eionisation) {
        pmanager->AddProcess(theeminusBremsstrahlung);
        G4AdjointCSManager::GetAdjointCSManager()->
                   RegisterEnergyLossProcess(theeminusBremsstrahlung,particle);
      }
      G4int n_order=0;
      if (fUse_ms && fUse_eionisation) {
        n_order++;
        pmanager->SetProcessOrdering(theeminusMS, idxAlongStep,n_order);
      }
      if (fUse_eionisation) {
        n_order++;
        pmanager->SetProcessOrdering(fEminusIonisation,idxAlongStep,n_order);
      }
      if (fUse_brem && fUse_eionisation) {
        n_order++;
        pmanager->SetProcessOrdering(theeminusBremsstrahlung,
                                           idxAlongStep,n_order);
      }
      n_order=0;
      if (fUse_ms && fUse_eionisation) {
        n_order++;
        pmanager->SetProcessOrdering(theeminusMS,idxPostStep,n_order);
      }
      if (fUse_eionisation) {
        n_order++;
        pmanager->SetProcessOrdering(fEminusIonisation,idxPostStep,n_order);
      }
      if (fUse_brem && fUse_eionisation) {
        n_order++;
        pmanager->SetProcessOrdering(theeminusBremsstrahlung,idxPostStep,
                                                                     n_order);
      }
    }
   
    if (particleName == "gamma") {
      if (fUse_compton) {
        pmanager->AddDiscreteProcess(theComptonScattering);
            G4AdjointCSManager::GetAdjointCSManager()->
                          RegisterEmProcess(theComptonScattering,particle);
      }
      if (fUse_peeffect) {
            pmanager->AddDiscreteProcess(thePEEffect);
            G4AdjointCSManager::GetAdjointCSManager()->
                                   RegisterEmProcess(thePEEffect,particle);
      }
      if (fUse_gamma_conversion) {
            pmanager->AddDiscreteProcess(theGammaConversion);
      }
    }
        
    if (particleName == "e+" && fUse_gamma_conversion) {//positron
      G4VProcess* theeplusMultipleScattering = new G4eMultipleScattering();
      G4VProcess* theeplusIonisation         = new G4eIonisation();
      G4VProcess* theeplusBremsstrahlung     = new G4eBremsstrahlung();
      G4VProcess* theeplusAnnihilation       = new G4eplusAnnihilation();

      // add processes
      pmanager->AddProcess(theeplusMultipleScattering);
      pmanager->AddProcess(theeplusIonisation);
      pmanager->AddProcess(theeplusBremsstrahlung);
      pmanager->AddProcess(theeplusAnnihilation);

      // set ordering for AtRestDoIt
      pmanager->SetProcessOrderingToFirst(theeplusAnnihilation, idxAtRest);

      // set ordering for AlongStepDoIt
      pmanager->SetProcessOrdering(theeplusMultipleScattering,
                                                             idxAlongStep,1);
      pmanager->SetProcessOrdering(theeplusIonisation, idxAlongStep,2);
      pmanager->SetProcessOrdering(theeplusBremsstrahlung,idxAlongStep,3);

      // set ordering for PostStepDoIt
      pmanager->SetProcessOrdering(theeplusMultipleScattering,
                                                             idxPostStep,1);
      pmanager->SetProcessOrdering(theeplusIonisation,idxPostStep,2);
      pmanager->SetProcessOrdering(theeplusBremsstrahlung,idxPostStep,3);
      pmanager->SetProcessOrdering(theeplusAnnihilation,idxPostStep,4);
    }

    if (particleName == "alpha" && fUse_gionisation) {
      if (fUse_ms && fUse_gionisation) pmanager->AddProcess(thegMS);

      if (fUse_gionisation){
            pmanager->AddProcess(fGIonisation);
            G4AdjointCSManager::GetAdjointCSManager()->
                      RegisterEnergyLossProcess(fGIonisation,particle);
      }

      G4int n_order=0;
      if (fUse_ms && fUse_gionisation) {
        n_order++;
            pmanager->SetProcessOrdering(thegMS, idxAlongStep,n_order);
      }

      if (fUse_gionisation) {
          n_order++;
          pmanager->SetProcessOrdering(fGIonisation,idxAlongStep,n_order);
      }
            
      n_order=0;
      if (fUse_ms && fUse_gionisation) {
            n_order++;
          pmanager->SetProcessOrdering(thegMS, idxPostStep,n_order);
      }

      if (fUse_gionisation) {
          n_order++;
          pmanager->SetProcessOrdering(fGIonisation,idxPostStep,n_order);
      }
    
    }
    
    if (particleName == "adj_alpha" && fUse_gionisation) {
      G4ContinuousGainOfEnergy* theContinuousGainOfEnergy =0;
      if (fUse_gionisation ) {
       theContinuousGainOfEnergy= new G4ContinuousGainOfEnergy();
       theContinuousGainOfEnergy->SetLossFluctuations(
                               fUse_egain_fluctuation);
       theContinuousGainOfEnergy->SetDirectEnergyLossProcess(fGIonisation);
          theContinuousGainOfEnergy->SetDirectParticle(G4Alpha::Alpha());
          pmanager->AddProcess(theContinuousGainOfEnergy);
       }

       G4int n_order=0;
       if (fUse_ms) {
         n_order++;
         pmanager->AddProcess(thegMS);
         pmanager->SetProcessOrdering(thegMS, idxAlongStep,n_order);
       }

       n_order++;
       pmanager->SetProcessOrdering(theContinuousGainOfEnergy,idxAlongStep,
                                                                   n_order);
            
       n_order++;
       G4AdjointAlongStepWeightCorrection* theAlongStepWeightCorrection =
                                  new G4AdjointAlongStepWeightCorrection();
      pmanager->AddProcess(theAlongStepWeightCorrection);
      pmanager->SetProcessOrdering(theAlongStepWeightCorrection,
                                            idxAlongStep,
                                                    n_order);
      n_order=0;
      if (fUse_gionisation) {
        pmanager->AddProcess(thegInverseIonisationProjToProjCase);
        n_order++;
            pmanager->SetProcessOrdering(
                               thegInverseIonisationProjToProjCase,
                                                   idxPostStep,n_order);
      }

      if (fUse_ms && fUse_gionisation) {
        n_order++;
        pmanager->SetProcessOrdering(thegMS,idxPostStep,n_order);
      }
    }
  }
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

#include "G4Decay.hh"
void G4AdjointPhysicsList::ConstructGeneral()
{
  // Add Decay Process
  G4Decay* theDecayProcess = new G4Decay();
  auto particleIterator=GetParticleIterator();
  particleIterator->reset();
  while( (*particleIterator)() ){
    G4ParticleDefinition* particle = particleIterator->value();
    G4ProcessManager* pmanager = particle->GetProcessManager();
    if (theDecayProcess->IsApplicable(*particle)) { 
      pmanager ->AddProcess(theDecayProcess);
      // set ordering for PostStepDoIt and AtRestDoIt
      pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
      pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
    }
  }
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4AdjointPhysicsList::SetCuts()
{
  if (verboseLevel >0){
    G4cout << "G4AdjointPhysicsList::SetCuts:";
    G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
  }

  // set cut values for gamma at first and for e- second and next for e+,
  // because some processes for e+/e- need cut values for gamma
  //
  SetCutValue(defaultCutValue, "gamma");
  SetCutValue(defaultCutValue, "e-");
  SetCutValue(defaultCutValue, "e+");

  if (verboseLevel>0) DumpCutValuesTable();
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

Hello,

most likely this material-cuts-coupe object does not exist. If you run the example without the modification , does it work for you? Does reverse MC assume running for alpha particles?

I would advice to change the title of this post, because it is missleading . For example “How to use adjoign simulation for alpha particles in RMC01 example?”

VI