Dear friends,
I want to get the position of species using chem4. I know in chem4, the SD of ScoreSpecies.cc has provided the paint massages about the generated time, G value and name of species as follows:
std::ofstream out(“Species.txt”);
if(!out) return;
out << “# Time [ps] G-value (/100 eV) RMS Molecule” << G4endl;
std::map<G4String, std::map<G4double, std::pair<G4double,G4double>>> mol;
for(auto it_map1: fSpeciesInfoPerTime)
{
InnerSpeciesMap& map2 = it_map1.second;
G4double time = it_map1.first/ps;
for(auto it_map2: map2)
{
G4double G = it_map2.second.fG;
G4double G2 = it_map2.second.fG2;
G4double N = fNEvent;
G /= N;
G2 = std::sqrt( N/(N-1) * ( G2/N - G*G) );
mol[it_map2.first->GetName()][time]=std::make_pair(G,G2);
}
}
for ( auto it1 : mol )
for ( auto it2 : it1.second )
out << std::setw(12) << it2.first << std::setw(12) << it2.second.first
<< std::setw(12) << it2.second.second << std::setw(12)
<< std::setw(12) << it1.first << G4endl;
out.close();
But I want to get the position of Products. I know in chem2 or chem3 that provides the method in TimeStepAction.cc to get the position, as follows:
if (products)
{
G4cout << G4endl;
G4int nbProducts = products->size();
for (int i = 0 ; i < nbProducts ; i ++)
{
G4cout << “-> A = "
<< GetMolecule(&a)->GetName() << " (TrackID=” << a.GetTrackID() << “)”
<< " reacts with B = "
<< GetMolecule(&b)->GetName() << " (TrackID=" << b.GetTrackID() << “)”
<< " creating product " << i+1 << " ="
<< GetMolecule((*products)[i])->GetName()
<< G4endl ;
G4cout
<<" A position: x(nm)="<<a.GetPosition().getX()/nm
<<" y(nm)="<<a.GetPosition().getY()/nm
<<" z(nm)="<<a.GetPosition().getZ()/nm
<<G4endl;
G4cout
<<" B position: x(nm)="<<b.GetPosition().getX()/nm
<<" y(nm)="<<b.GetPosition().getY()/nm
<<" z(nm)="<<b.GetPosition().getZ()/nm
<<G4endl;
G4cout
<<" Product " << i+1 << "position: x(nm)="<<(*products)[i]->GetPosition().getX()/nm
<<" y(nm)="<<a.GetPosition().getY()/nm
<<" z(nm)="<<a.GetPosition().getZ()/nm
<<G4endl;
}
}
else
{
G4cout << G4endl;
G4cout << “-> A = "
<< GetMolecule(&a)->GetName() << " (TrackID=” << a.GetTrackID() << “)”
<< " reacts with B = "
<< GetMolecule(&b)->GetName() << " (TrackID=" << b.GetTrackID() << “)”
<< G4endl ;
G4cout
<<" A position: x(nm)="<<a.GetPosition().getX()/nm
<<" y(nm)="<<a.GetPosition().getY()/nm
<<" z(nm)="<<a.GetPosition().getZ()/nm
<<G4endl;
G4cout
<<" B position: x(nm)="<<b.GetPosition().getX()/nm
<<" y(nm)="<<b.GetPosition().getY()/nm
<<" z(nm)="<<b.GetPosition().getZ()/nm
<<G4endl;
}
But how can I use it in chem4 to get the position of products?
Thank you.