Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -23,9 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4MCTSimParticle.cc
// G4MCTSimParticle implementation
//
// ====================================================================
// Author: Youhei Morita, 12.09.2001
// --------------------------------------------------------------------
#include <sstream>
#include <iomanip>
@@ -37,173 +38,162 @@
#include "G4ios.hh"
#include "G4MCTSimVertex.hh"
// ====================================================================
//
// class description
//
// ====================================================================
/////////////////////////////////
// --------------------------------------------------------------------
G4MCTSimParticle::G4MCTSimParticle()
: parentParticle(0), pdgID(0),
trackID(0), parentTrackID(0),
primaryFlag(false),
vertex(0), storeFlag(false)
/////////////////////////////////
{
}
/////////////////////////////////////////////////////////////
G4MCTSimParticle::G4MCTSimParticle(std::string aname, int apcode,
int atid, int ptid,
const G4LorentzVector& p)
: parentParticle(0),
name(aname), pdgID(apcode),
trackID(atid), parentTrackID(ptid),
primaryFlag(false),momentumAtVertex(p),
vertex(0), storeFlag(false)
///////////////////////////////////////////////////////////////
// --------------------------------------------------------------------
G4MCTSimParticle::G4MCTSimParticle(const G4String& aname,
G4int apcode, G4int atid, G4int ptid,
const G4LorentzVector& p)
: name(aname)
, momentumAtVertex(p)
, pdgID(apcode)
, trackID(atid)
, parentTrackID(ptid)
{
}
/////////////////////////////////////////////////////////////
G4MCTSimParticle::G4MCTSimParticle(std::string aname, int apcode,
int atid, int ptid,
const G4LorentzVector& p,
const G4MCTSimVertex* v )
: parentParticle(0),
name(aname), pdgID(apcode),
trackID(atid), parentTrackID(ptid),
primaryFlag(false),momentumAtVertex(p),
vertex(const_cast<G4MCTSimVertex*>(v)), storeFlag(false)
///////////////////////////////////////////////////////////////
// --------------------------------------------------------------------
G4MCTSimParticle::G4MCTSimParticle(const G4String& aname,
G4int apcode, G4int atid, G4int ptid,
const G4LorentzVector& p,
const G4MCTSimVertex* v)
: name(aname)
, momentumAtVertex(p)
, vertex(const_cast<G4MCTSimVertex*>(v))
, pdgID(apcode)
, trackID(atid)
, parentTrackID(ptid)
{
}
/////////////////////////////////
// --------------------------------------------------------------------
G4MCTSimParticle::~G4MCTSimParticle()
/////////////////////////////////
{
associatedParticleList.clear();
}
////////////////////////////////////////////////////////
int G4MCTSimParticle::AssociateParticle(G4MCTSimParticle* p)
////////////////////////////////////////////////////////
// --------------------------------------------------------------------
G4int G4MCTSimParticle::AssociateParticle(G4MCTSimParticle* p)
{
associatedParticleList.push_back(p);
p-> SetParentParticle(this);
p->SetParentParticle(this);
return associatedParticleList.size();
}
/////////////////////////////////////////////////////
int G4MCTSimParticle::GetNofAssociatedParticles() const
/////////////////////////////////////////////////////
// --------------------------------------------------------------------
G4int G4MCTSimParticle::GetNofAssociatedParticles() const
{
return associatedParticleList.size();
}
//////////////////////////////////////////////////////////////////
G4MCTSimParticle* G4MCTSimParticle::GetAssociatedParticle(int i) const
//////////////////////////////////////////////////////////////////
// --------------------------------------------------------------------
G4MCTSimParticle* G4MCTSimParticle::GetAssociatedParticle(G4int i) const
{
int size= associatedParticleList.size();
if(i>=0 && i< size) return associatedParticleList[i];
else return 0;
G4int size = associatedParticleList.size();
if(i >= 0 && i < size)
return associatedParticleList[i];
else
return nullptr;
}
////////////////////////////////////////
int G4MCTSimParticle::GetTreeLevel() const
////////////////////////////////////////
// --------------------------------------------------------------------
G4int G4MCTSimParticle::GetTreeLevel() const
{
const G4MCTSimParticle* p= this;
int nlevel;
for(nlevel=1;;nlevel++) {
p= p-> GetParentParticle();
if(p==0) return nlevel;
const G4MCTSimParticle* p = this;
G4int nlevel;
for(nlevel = 1;; ++nlevel)
{
p = p->GetParentParticle();
if(p == nullptr)
return nlevel;
}
}
/////////////////////////////////////////////////////
// --------------------------------------------------------------------
void G4MCTSimParticle::SetStoreFlagToParentTree(G4bool q)
/////////////////////////////////////////////////////
{
storeFlag=q;
if(vertex) vertex-> SetStoreFlag(q);
if(primaryFlag) return;
if(parentParticle) parentParticle-> SetStoreFlagToParentTree(q);
storeFlag = q;
if(vertex)
vertex->SetStoreFlag(q);
if(primaryFlag)
return;
if(parentParticle)
parentParticle->SetStoreFlagToParentTree(q);
}
//////////////////////////////////////////////////////////
// --------------------------------------------------------------------
void G4MCTSimParticle::PrintSingle(std::ostream& ostr) const
//////////////////////////////////////////////////////////
{
std::ostringstream os;
char cqp=' ';
if(storeFlag) cqp='+';
char cqp = ' ';
if(storeFlag)
cqp = '+';
os << cqp << trackID << '\0';
std::string stid(os.str());
ostr << std::setw(6) << stid;
//ostr << std::setw(4) << trackID;
// ostr << std::setw(4) << trackID;
if(primaryFlag) ostr << "*";
else ostr << " ";
if(primaryFlag)
ostr << "*";
else
ostr << " ";
ostr << "<" << std::setw(5) << parentTrackID;
ostr.setf(std::ios::fixed);
ostr << ": P("
<< std::setw(7) << std::setprecision(3) << momentumAtVertex.x()/GeV
<< "," << std::setw(7) << std::setprecision(3)
<< momentumAtVertex.y()/GeV
<< "," << std::setw(7) << std::setprecision(3)
<< momentumAtVertex.z()/GeV
<< "," << std::setw(7) << std::setprecision(3)
<< momentumAtVertex.e()/GeV << ") @";
ostr << ": P(" << std::setw(7) << std::setprecision(3)
<< momentumAtVertex.x() / GeV << "," << std::setw(7)
<< std::setprecision(3) << momentumAtVertex.y() / GeV << ","
<< std::setw(7) << std::setprecision(3) << momentumAtVertex.z() / GeV
<< "," << std::setw(7) << std::setprecision(3)
<< momentumAtVertex.e() / GeV << ") @";
ostr << name << "(" << pdgID << ")";
if(vertex) {
ostr << " %" << vertex-> GetCreatorProcessName() << G4endl;
if(vertex != nullptr)
{
ostr << " %" << vertex->GetCreatorProcessName() << G4endl;
std::ostringstream osv;
char cqv=' ';
if(vertex->GetStoreFlag()) cqv='+';
osv << cqv << vertex-> GetID() << '\0';
char cqv = ' ';
if(vertex->GetStoreFlag())
cqv = '+';
osv << cqv << vertex->GetID() << '\0';
std::string svid(osv.str());
ostr << " " << std::setw(6) << svid;
//ostr << " " << std::setw(4) << vertex-> GetID();
// ostr << " " << std::setw(4) << vertex-> GetID();
ostr.unsetf(std::ios::fixed);
ostr.setf(std::ios::scientific|std::ios::right|std::ios::showpoint);
ostr << "- X(" << std::setw(9) << std::setprecision(2)
<< vertex-> GetPosition().x()/mm
<< "," << std::setw(9) << std::setprecision(2)
<< vertex-> GetPosition().y()/mm
<< "," << std::setw(9) << std::setprecision(2)
<< vertex-> GetPosition().z()/mm
<< "," << std::setw(9) << std::setprecision(2)
<< vertex-> GetTime()/ns << ")";
ostr.setf(std::ios::scientific | std::ios::right | std::ios::showpoint);
ostr << "- X(" << std::setw(9) << std::setprecision(2)
<< vertex->GetPosition().x() / mm << "," << std::setw(9)
<< std::setprecision(2) << vertex->GetPosition().y() / mm << ","
<< std::setw(9) << std::setprecision(2)
<< vertex->GetPosition().z() / mm << "," << std::setw(9)
<< std::setprecision(2) << vertex->GetTime() / ns << ")";
ostr.unsetf(std::ios::scientific);
ostr << " @" << vertex-> GetVolumeName()
<< "-" << vertex-> GetVolumeNumber();
}
ostr << " @" << vertex->GetVolumeName() << "-" << vertex->GetVolumeNumber();
}
ostr << G4endl;
}
////////////////////////////////////////////////////////////////////
// --------------------------------------------------------------------
void G4MCTSimParticle::Print(std::ostream& ostr, G4bool qrevorder) const
////////////////////////////////////////////////////////////////////
{
PrintSingle(ostr);
// recursively print associated particles
if (!qrevorder) { // parent -> child
SimParticleList::const_iterator itr;
for(itr= associatedParticleList.begin();
itr!= associatedParticleList.end(); ++itr) {
(*itr)-> Print(ostr);
if(!qrevorder)
{ // parent -> child
for(auto itr = associatedParticleList.cbegin();
itr != associatedParticleList.cend(); ++itr)
{
(*itr)->Print(ostr);
}
} else { // child -> parent
if(parentParticle) parentParticle-> Print(ostr, true);
}
else
{ // child -> parent
if(parentParticle)
parentParticle->Print(ostr, true);
}
}