Import Geant4 11.0.0.beta source tree
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 eventgenerator/pythia/pythia8decayer/src/DetConstruction.cc
|
||||
/// \brief Implementation of the DetConstruction class
|
||||
///
|
||||
/// \author J. Yarba; FNAL
|
||||
|
||||
#include "DetConstruction.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* DetConstruction::Construct()
|
||||
{
|
||||
|
||||
// Define materials via NIST manager
|
||||
|
||||
auto worldMaterial =
|
||||
G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
|
||||
auto detMaterial =
|
||||
G4NistManager::Instance()->FindOrBuildMaterial("G4_C");
|
||||
|
||||
// World volume
|
||||
|
||||
G4ThreeVector worldSize( 200.*CLHEP::cm, 200.*CLHEP::cm, 200.*CLHEP::cm );
|
||||
|
||||
|
||||
fWorld = new G4PVPlacement(
|
||||
0, G4ThreeVector(),
|
||||
"world_phys",
|
||||
new G4LogicalVolume( new G4Box( "world_solid",
|
||||
0.5*worldSize.x(),
|
||||
0.5*worldSize.y(),
|
||||
0.5*worldSize.z() ),
|
||||
worldMaterial, "world_log", 0, 0, 0 ),
|
||||
0,
|
||||
false, 0 );
|
||||
|
||||
// "Detector"
|
||||
|
||||
double rmin = 10.*CLHEP::cm;
|
||||
double rmax = 80.*CLHEP::cm;
|
||||
double zlength = 98.*CLHEP::cm;
|
||||
|
||||
G4VSolid* sDet = new G4Tubs( "det_solid",
|
||||
rmin, rmax, 0.5*zlength,
|
||||
0., 2.*CLHEP::pi );
|
||||
|
||||
G4LogicalVolume* lDet = new G4LogicalVolume( sDet, detMaterial, "det_log",
|
||||
0, 0, 0 );
|
||||
|
||||
fDet = new G4PVPlacement( 0, G4ThreeVector(), "det_phys",
|
||||
lDet,
|
||||
fWorld, // it's mother (physical) volume
|
||||
false, 0 );
|
||||
|
||||
|
||||
//always return the root volume
|
||||
//
|
||||
return fWorld;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 eventgenerator/pythia/pythia8decayer/src/Py8Decayer.cc
|
||||
/// \brief Implementation of the Py8Decayer class
|
||||
///
|
||||
/// \author J. Yarba; FNAL
|
||||
|
||||
#include "Py8Decayer.hh"
|
||||
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
using namespace Pythia8;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Py8Decayer::Py8Decayer()
|
||||
: G4VExtDecayer("Py8Decayer"),
|
||||
fDecayer(nullptr)
|
||||
{
|
||||
|
||||
// use default path to the xml/configs but do NOT print banner
|
||||
//
|
||||
fDecayer = new Pythia( "../share/Pythia8/xmldoc", false );
|
||||
|
||||
// this is the trick to make Pythia8 work as "decayer"
|
||||
//
|
||||
fDecayer->readString("ProcessLevel:all = off");
|
||||
|
||||
fDecayer->readString("ProcessLevel:resonanceDecays=on");
|
||||
|
||||
// shut off Pythia8 (default) verbosty
|
||||
//
|
||||
fDecayer->readString("Init:showAllSettings=false");
|
||||
fDecayer->readString("Init:showChangedSettings=false");
|
||||
fDecayer->readString("Init:showAllParticleData=false");
|
||||
fDecayer->readString("Init:showChangedParticleData=false");
|
||||
//
|
||||
// specify how many Py8 events to print out, at either level
|
||||
// in this particular case print out a maximum of 10 events
|
||||
//
|
||||
fDecayer->readString("Next:numberShowProcess = 0" );
|
||||
fDecayer->readString("Next:numberShowEvent = 10");
|
||||
|
||||
fDecayer->init();
|
||||
|
||||
// shut off decays of pi0's as we want Geant4 to handle them
|
||||
// if other immediate decay products should be handled by Geant4,
|
||||
// their respective decay modes should be shut off as well
|
||||
//
|
||||
fDecayer->readString("111:onMode = off");
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Py8Decayer::~Py8Decayer()
|
||||
{
|
||||
|
||||
delete fDecayer;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4DecayProducts* Py8Decayer::ImportDecayProducts(const G4Track& track)
|
||||
{
|
||||
|
||||
fDecayer->event.reset();
|
||||
|
||||
G4DecayProducts* dproducts = nullptr;
|
||||
|
||||
G4ParticleDefinition* pd = track.GetDefinition();
|
||||
int pdgid = pd->GetPDGEncoding();
|
||||
|
||||
// check if pdgid is consistent with Pythia8 particle table
|
||||
//
|
||||
if ( !fDecayer->particleData.findParticle( pdgid ) )
|
||||
{
|
||||
G4cout << " can NOT find pdgid = " << pdgid
|
||||
<< " in Pythia8::ParticleData" << G4endl;
|
||||
return dproducts;
|
||||
}
|
||||
|
||||
if ( !fDecayer->particleData.canDecay(pdgid) )
|
||||
{
|
||||
G4cout << " Particle of pdgid = " << pdgid
|
||||
<< " can NOT be decayed by Pythia8" << G4endl;
|
||||
return dproducts;
|
||||
}
|
||||
|
||||
// NOTE: Energy should be in GeV
|
||||
|
||||
fDecayer->event.append( pdgid, 1, 0, 0,
|
||||
track.GetMomentum().x() / CLHEP::GeV,
|
||||
track.GetMomentum().y() / CLHEP::GeV,
|
||||
track.GetMomentum().z() / CLHEP::GeV,
|
||||
track.GetDynamicParticle()->GetTotalEnergy() / CLHEP::GeV,
|
||||
pd->GetPDGMass() / CLHEP::GeV );
|
||||
|
||||
// specify polarization, if any
|
||||
|
||||
// NOTE: while in Py8 polarization is a double variable ,
|
||||
// in reality it's expected to be -1, 0., or 1 in case of "external" tau's,
|
||||
// similar to LHA SPINUP; see Particle Decays, Hadron and Tau Decays in docs at
|
||||
// https://pythia.org/manuals/pythia8305/Welcome.html
|
||||
// so it's not able to handle anything like 0.99, thus we're rounding off
|
||||
fDecayer->event.back().pol(
|
||||
round( std::cos( track.GetPolarization().angle( track.GetMomentumDirection() ) )
|
||||
)
|
||||
);
|
||||
|
||||
int npart_before_decay = fDecayer->event.size();
|
||||
|
||||
fDecayer->next();
|
||||
|
||||
int npart_after_decay = fDecayer->event.size();
|
||||
|
||||
// create & fill up decay products
|
||||
//
|
||||
dproducts = new G4DecayProducts(*(track.GetDynamicParticle()));
|
||||
|
||||
// create G4DynamicParticle out of each fDecayer->event entry (except the 1st one)
|
||||
// and push into dproducts
|
||||
|
||||
for ( int ip=npart_before_decay; ip<npart_after_decay; ++ip )
|
||||
{
|
||||
|
||||
// only select final state decay products (direct or via subsequent decays);
|
||||
// skip all others
|
||||
//
|
||||
// NOTE: in general, final state decays products will have
|
||||
// positive status code between 91 and 99
|
||||
// (in case such information could be of interest in the future)
|
||||
//
|
||||
if ( fDecayer->event[ip].status() < 0 ) continue;
|
||||
|
||||
// should we also skip neutrinos ???
|
||||
// if so, skip products with abs(fDecayer->event[ip].id()) of 12, 14, or 16
|
||||
|
||||
G4ParticleDefinition* pddec =
|
||||
G4ParticleTable::GetParticleTable()->FindParticle( fDecayer->event[ip].id() );
|
||||
if ( !pddec ) continue; // maybe we should print out a warning !
|
||||
G4ThreeVector momentum = G4ThreeVector( fDecayer->event[ip].px() * CLHEP::GeV,
|
||||
fDecayer->event[ip].py() * CLHEP::GeV,
|
||||
fDecayer->event[ip].pz() * CLHEP::GeV );
|
||||
dproducts->PushProducts( new G4DynamicParticle( pddec, momentum) );
|
||||
}
|
||||
|
||||
return dproducts;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 eventgenerator/pythia/pythia8decayer/src/Py8DecayerPhysics.cc
|
||||
/// \brief Implementation of the Py8DecayerPhysics class
|
||||
///
|
||||
/// \author J. Yarba; FNAL
|
||||
|
||||
#include "Py8DecayerPhysics.hh"
|
||||
#include "Py8Decayer.hh"
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4Decay.hh"
|
||||
#include "G4DecayTable.hh"
|
||||
|
||||
// factory
|
||||
//
|
||||
#include "G4PhysicsConstructorFactory.hh"
|
||||
//
|
||||
// register it with contructor factory
|
||||
//
|
||||
G4_DECLARE_PHYSCONSTR_FACTORY(Py8DecayerPhysics);
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Py8DecayerPhysics::Py8DecayerPhysics(G4int)
|
||||
: G4VPhysicsConstructor("Py8DecayerPhysics")
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Py8DecayerPhysics::~Py8DecayerPhysics()
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Py8DecayerPhysics::ConstructParticle()
|
||||
{
|
||||
// Nothing needs to be done here
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void Py8DecayerPhysics::ConstructProcess()
|
||||
{
|
||||
|
||||
// Loop over all particles instantiated and add external decayer
|
||||
// to all decay processes where there's no decay table, plus tau's
|
||||
|
||||
// Create external decayer for G4Decay process
|
||||
// NOTE: The extDecayer will be deleted in G4Decay destructor
|
||||
Py8Decayer* extDecayer = new Py8Decayer();
|
||||
|
||||
auto particleIterator=GetParticleIterator();
|
||||
particleIterator->reset();
|
||||
while ((*particleIterator)())
|
||||
{
|
||||
G4ParticleDefinition* particle = particleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
/*
|
||||
if ( verboseLevel > 1 ) {
|
||||
G4cout << "Setting ext decayer for: "
|
||||
<< particleIterator->value()->GetParticleName()
|
||||
<< G4endl;
|
||||
}
|
||||
*/
|
||||
G4ProcessVector* processVector = pmanager->GetProcessList();
|
||||
for ( size_t i=0; i<processVector->length(); ++i )
|
||||
{
|
||||
G4Decay* decay = dynamic_cast<G4Decay*>((*processVector)[i]);
|
||||
if ( decay )
|
||||
{
|
||||
// remove native/existing decay table for
|
||||
// a)tau's
|
||||
// b) B+/-
|
||||
// and replace with external decayer
|
||||
if ( std::abs(particle->GetPDGEncoding()) == 15 ||
|
||||
std::abs(particle->GetPDGEncoding()) == 521 )
|
||||
{
|
||||
if ( particle->GetDecayTable() )
|
||||
{
|
||||
delete particle->GetDecayTable();
|
||||
particle->SetDecayTable(nullptr);
|
||||
}
|
||||
decay->SetExtDecayer(extDecayer);
|
||||
}
|
||||
// now set external decayer to all particles
|
||||
// that don't yet have a decay table
|
||||
if ( !particle->GetDecayTable() )
|
||||
{
|
||||
decay->SetExtDecayer(extDecayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 eventgenerator/pythia/pythia8decayer/src/SingleParticleGun.cc
|
||||
/// \brief Implementation of the SingleParticleGun class
|
||||
///
|
||||
/// \author J. Yarba; FNAL
|
||||
|
||||
#include "SingleParticleGun.hh"
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
// SPECIAL CASE - needed for treatment of polarization for tau's
|
||||
#include "G4TauMinus.hh"
|
||||
#include "G4TauPlus.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SingleParticleGun::SingleParticleGun( const G4String& pname, const double pmom )
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fGun(nullptr),
|
||||
fMomentum(pmom)
|
||||
{
|
||||
|
||||
int nparts = 1;
|
||||
fGun = new G4ParticleGun( nparts );
|
||||
|
||||
G4ParticleTable* pdt = G4ParticleTable::GetParticleTable();
|
||||
G4ParticleDefinition* pd = pdt->FindParticle( pname );
|
||||
fGun->SetParticleDefinition( pd );
|
||||
fGun->SetParticlePosition( G4ThreeVector(0.,0.,0.) );
|
||||
double mass = pd->GetPDGMass();
|
||||
double energy = std::sqrt( fMomentum*fMomentum + mass*mass );
|
||||
fGun->SetParticleEnergy( energy );
|
||||
|
||||
// NOTE: do not set momentum directions
|
||||
// as it'll be generated event-by-event
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
SingleParticleGun::~SingleParticleGun()
|
||||
{
|
||||
|
||||
delete fGun;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SingleParticleGun::GeneratePrimaries( G4Event* evt )
|
||||
{
|
||||
|
||||
if ( !fGun )
|
||||
{
|
||||
G4cout << " ParticleGun is NOT set up; BAIL OUT from this event " << G4endl;
|
||||
G4cout << " Check if you are using ctor "
|
||||
<< "SinglePartGun(const G4string& partname, const double pmom ) "
|
||||
<< G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
double phi = -1. * CLHEP::pi + CLHEP::twopi * G4UniformRand();
|
||||
double theta = CLHEP::pi/4. + CLHEP::halfpi * G4UniformRand();
|
||||
|
||||
double x = std::sin(theta) * std::cos(phi);
|
||||
double y = std::sin(theta) * std::sin(phi);
|
||||
double z = std::cos(theta);
|
||||
|
||||
fGun->SetParticleMomentumDirection( G4ThreeVector(x,y,z) );
|
||||
|
||||
// SPECIAL CASE: for particle such as tau polarization should be -1 * p3
|
||||
// while for tau_bar it should be +1
|
||||
//
|
||||
// NOTE: one could probably compare by name but that'd mean comparing strings...
|
||||
//
|
||||
if ( fGun->GetParticleDefinition() == G4TauMinus::TauMinus() )
|
||||
{
|
||||
fGun->SetParticlePolarization( G4ThreeVector(-1.0*x,-1.0*y,-1.0*z) );
|
||||
}
|
||||
else if ( fGun->GetParticleDefinition() == G4TauPlus::TauPlus() )
|
||||
{
|
||||
fGun->SetParticlePolarization( G4ThreeVector(x,y,z) );
|
||||
}
|
||||
|
||||
fGun->GeneratePrimaryVertex(evt);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Reference in New Issue
Block a user