Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-14 07:53:14

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 Py8DecayerPhysics.cc
0027 /// \brief Implementation of the Py8DecayerPhysics class
0028 ///
0029 /// \author J. Yarba; FNAL
0030 
0031 #include "Py8DecayerPhysics.hh"
0032 
0033 #include "Py8Decayer.hh"
0034 
0035 #include "G4Decay.hh"
0036 #include "G4DecayTable.hh"
0037 #include "G4ParticleDefinition.hh"
0038 #include "G4ProcessManager.hh"
0039 
0040 // factory
0041 //
0042 #include "G4PhysicsConstructorFactory.hh"
0043 //
0044 // register it with contructor factory
0045 //
0046 G4_DECLARE_PHYSCONSTR_FACTORY(Py8DecayerPhysics);
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 Py8DecayerPhysics::Py8DecayerPhysics(G4int) : G4VPhysicsConstructor("Py8DecayerPhysics") {}
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 Py8DecayerPhysics::~Py8DecayerPhysics() {}
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 void Py8DecayerPhysics::ConstructParticle()
0059 {
0060   // Nothing needs to be done here
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 void Py8DecayerPhysics::ConstructProcess()
0066 {
0067   // Adding external decayer to G4Decay process (per each thread).
0068   // G4Decay will use the external decayer if G4Decay process is
0069   // assigned to an unstable particle and that particle does not
0070   // have its decay table.
0071 
0072   // Loop over all particles instantiated and remove already-assigned
0073   // decay table for tau's and B+/- so that they will decay through
0074   // the external decayer (Pythia8).
0075 
0076   // NOTE: The extDecayer will be deleted in G4Decay destructor
0077 
0078   Py8Decayer* extDecayer = new Py8Decayer();
0079   G4bool setOnce = true;
0080 
0081   auto particleIterator = GetParticleIterator();
0082   particleIterator->reset();
0083   while ((*particleIterator)()) {
0084     G4ParticleDefinition* particle = particleIterator->value();
0085 
0086     // remove native/existing decay table for
0087     // a)tau's
0088     // b) B+/-
0089     // so that G4Decay will use the external decayer
0090     if (std::abs(particle->GetPDGEncoding()) == 15 || std::abs(particle->GetPDGEncoding()) == 521) {
0091       if (particle->GetDecayTable()) {
0092         delete particle->GetDecayTable();
0093         particle->SetDecayTable(nullptr);
0094         /*
0095                   if ( verboseLevel > 1 ) {
0096                      G4cout << "Use ext decayer for: "
0097                         <<  particleIterator->value()->GetParticleName()
0098                         << G4endl;
0099                   }
0100         */
0101       }
0102     }
0103 
0104     if (setOnce)
0105     // One G4Decay object is shared by all unstable particles (per thread).
0106     // Thus, we set the external decayer only once.
0107     {
0108       G4ProcessManager* pmanager = particle->GetProcessManager();
0109       G4ProcessVector* processVector = pmanager->GetProcessList();
0110       for (size_t i = 0; i < processVector->length(); ++i) {
0111         G4Decay* decay = dynamic_cast<G4Decay*>((*processVector)[i]);
0112         if (decay) {
0113           decay->SetExtDecayer(extDecayer);
0114           setOnce = false;
0115         }
0116       }
0117     }
0118   }
0119 
0120   return;
0121 }
0122 
0123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......