Hello,
I need to save the beam information in the tree
In the analysis messenger I fill a vector with beam information
void AnalysisManager::FillhPrimaries(G4ThreeVector fPos,G4double fkinE,G4ThreeVector fmom)
{
BeamX.push_back(fPos.x());
BeamY.push_back(fPos.y());
BeamZ.push_back(fPos.z());
BeamKinE.push_back(fkinE);
BeamTheta.push_back(fmom.theta()/deg);
}
moreover, to clean the vector at each primary particle, I’ve
void AnalysisManager::ClearPrimaries(){
BeamX.clear();
BeamY.clear();
BeamZ.clear();
BeamKinE.clear();
BeamTheta.clear();
}
the ClearPrimaries function is called in the event action, because I want that for each event, it saves the information in the tree
void EventAction::BeginOfEventAction(const G4Event* evt)
{
....
analysismanager->ClearPrimaries();
but when running the simulation, the number of entries isn’t correct. For example, I simulated 1000 primary particles, but I don’t get entries in the TTree
if I call the Clear Primaries in
void EventAction::EndOfEventAction(const G4Event* evt)
{
I get 57 entries (instead of 1000)
Then I don’t know how to save these information in the TTree
AnalysisManager.cc (10.5 KB)
EventAction.cc (3.7 KB)
PS. FillPrimaryParticles function is called in the primarygeneratoraction
PrimaryGeneratorAction.cc (1.9 KB)
I also tried to call the clearprimaries in the primarygeneratoraction, but I get 57 entries instead of 1000. Moreover, it would be better to not clean the variables in primarygeneratoraction (if possible) because it is a shared files with other experiments.