Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:17:40

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 // $Id: P6DExtDecayerPhysics.cc,v 1.3 2015/01/05 23:49:39 mccumber Exp $
0027 //
0028 /// \file eventgenerator/pythia/decayer6/src/P6DExtDecayerPhysics.cc
0029 /// \brief Implementation of the P6DExtDecayerPhysics class
0030 ///
0031 /// \author I. Hrivnacova; IPN, Orsay
0032 
0033 #include "P6DExtDecayerPhysics.hh"
0034 #include "G4Pythia6Decayer.hh"
0035 
0036 #include <Geant4/G4Decay.hh>
0037 #include <Geant4/G4ParticleDefinition.hh>
0038 #include <Geant4/G4ParticleTable.hh>  // for G4ParticleTable::G4PTblDi...
0039 #include <Geant4/G4ProcessManager.hh>
0040 #include <Geant4/G4ProcessVector.hh>  // for G4ProcessVector
0041 #include <Geant4/G4String.hh>         // for G4String
0042 #include <Geant4/G4VPhysicsConstructor.hh>
0043 #include <Geant4/G4VProcess.hh>  // for G4VProcess
0044 #include <Geant4/G4Version.hh>
0045 
0046 #include <cstddef>   // for size_t
0047 #include <iostream>  // for operator<<, endl, basic_o...
0048 #include <string>    // for operator<<
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 // hack for Geant 10.03.p03
0052 // Geant 10.02.p02 has this defined
0053 #ifndef aParticleIterator
0054 #define aParticleIterator ((subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator)
0055 #endif
0056 
0057 P6DExtDecayerPhysics::P6DExtDecayerPhysics(const G4String& name)
0058   : G4VPhysicsConstructor(name)
0059   , _active_force_decay(false)
0060   , _force_decay_type(kAll)
0061 {
0062   /// Standard constructor
0063 }
0064 
0065 //
0066 // protected methods
0067 //
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0070 
0071 void P6DExtDecayerPhysics::ConstructProcess()
0072 {
0073   /// Loop over all particles instantiated and add external decayer
0074   /// to all decay processes if External decayer is set
0075 
0076   // Create Geant4 external decayer
0077   G4Pythia6Decayer* extDecayer = new G4Pythia6Decayer();
0078   extDecayer->SetVerboseLevel(0);
0079 
0080   aParticleIterator->reset();
0081   int decayer_used = 0;
0082   while ((*aParticleIterator)())
0083   {
0084     G4ParticleDefinition* particle = aParticleIterator->value();
0085     G4ProcessManager* pmanager = particle->GetProcessManager();
0086 
0087     if (verboseLevel > 1)
0088     {
0089       std::cout << "Setting ext decayer for: "
0090                 << aParticleIterator->value()->GetParticleName()
0091                 << std::endl;
0092     }
0093 
0094     G4ProcessVector* processVector = pmanager->GetProcessList();
0095 #if G4VERSION_NUMBER >= 1060
0096     for (size_t i = 0; i < processVector->length(); i++)
0097 #else
0098     for (G4int i = 0; i < processVector->length(); i++)
0099 #endif
0100     {
0101       G4Decay* decay = dynamic_cast<G4Decay*>((*processVector)[i]);
0102       if (decay)
0103       {
0104         // The extDecayer will be deleted in G4Decay destructor
0105         // increment counter in case we want to print out stats
0106         // for whatever reason (non null means it is used and
0107         // must not be deleted)
0108         decay->SetExtDecayer(extDecayer);
0109         decayer_used++;
0110       }
0111     }
0112   }
0113 
0114   if (_active_force_decay)
0115   {
0116     extDecayer->ForceDecayType(_force_decay_type);
0117   }
0118 
0119   // If the extDecayer isn't used for this particle we need to delete it here
0120   // as far as I see this never happens but this makes coverity happy
0121   if (!decayer_used)
0122   {
0123     delete extDecayer;
0124   }
0125   if (verboseLevel > 0)
0126   {
0127     std::cout << "External decayer physics constructed." << std::endl;
0128   }
0129 }
0130 
0131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......