I am getting this with verbosity 4
G4WT5 > ... going to create ntuple booking : Secondary Generation
G4WT5 > ... create ntuple booking : Secondary Generation ntupleId 0 - done
G4WT5 > ... going to create ntuple T column : ntupleId 0
G4WT5 > ... create ntuple T column : ParticleName ntupleId 0 - done
G4WT5 > ... going to create ntuple T column : ntupleId 0
G4WT5 > ... create ntuple T column : ProcessGen ntupleId 0 - done
G4WT5 > ... going to create ntuple T column : ntupleId 0
G4WT5 > ... create ntuple T column : PosX ntupleId 0 - done
G4WT5 > ... going to create ntuple T column : ntupleId 0
G4WT5 > ... create ntuple T column : PosY ntupleId 0 - done
G4WT5 > ... going to create ntuple T column : ntupleId 0
G4WT5 > ... create ntuple T column : PosZ ntupleId 0 - done
G4WT26 > Ntuple of id 0 was made
G4WT26 > Booking ntuple activation 1
G4WT26 > Booking number of ntuple 1
G4WT13 > Histograms are booked
It continues posting messages about the activated histograms being filled but then ends with this error with this level of verbosity.
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
This is my function to create the ntuple.
void HistoManager::SecondaryGenerationPositionNtuple()
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
// Create ntuples.
// Ntuples ids are generated automatically starting from 0.
// The start value can be changed by:
//analysisManager->SetFirstNtupleId(1);
// Create 1st ntuple (id = 0)
// create an ntuple of secondary Tritium
// if (volumeReps > 0){
//for (G4int k=1; k<=volumeReps; k++){
analysisManager->CreateNtuple("Secondary Generation", "Secondary Coordinates");
analysisManager->CreateNtupleSColumn("ParticleName");//column id 0
analysisManager->CreateNtupleSColumn("ProcessGen"); //column id 1
analysisManager->CreateNtupleDColumn("PosX"); //column id 2
analysisManager->CreateNtupleDColumn("PosY"); //column id 3
analysisManager->CreateNtupleDColumn("PosZ"); //column id 4
analysisManager->FinishNtuple();
//}
// }
//analysisManager->SetNtupleFileName(0,"TritiumLocation");
analysisManager->SetNtupleActivation(0,1);
G4cout << "Ntuple of id " << analysisManager->GetFirstNtupleId() << " was made " << G4endl;
G4cout << "Booking ntuple activation " << analysisManager->GetNtupleActivation(0) << G4endl;
G4cout << "Booking number of ntuple " << analysisManager->GetNofNtuples() << G4endl;
}
called here
HistoManager::HistoManager()
{
Book();
SecondaryGenerationPositionNtuple();
}
and filled here
void HistoManager::FillSecondaryNtuple(G4int fSampleRepetitions, G4String fParticleName, G4String fProcGen, G4double fPosX, G4double fPosY, G4double fPosZ)
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
// Fill 1st ntuple ( id = 0)
/*for (G4int volumeReps=1; volumeReps<=fSampleRepetitions; volumeReps++)
{*/
analysisManager->SetNtupleActivation(0,1);
G4cout << "filling ntuple " << G4endl;
G4cout << "Filling ntuple ID is " << analysisManager->GetFirstNtupleId() << G4endl;
G4cout << "ntuple directory name is " << analysisManager->GetNtupleDirectoryName() << G4endl;
G4cout << "ntuple activation " << analysisManager->GetNtupleActivation(0) << G4endl;
analysisManager->FillNtupleSColumn(0, fParticleName);
analysisManager->FillNtupleSColumn(1, fProcGen);
analysisManager->FillNtupleDColumn(2, fPosX);
analysisManager->FillNtupleDColumn(3, fPosY);
analysisManager->FillNtupleDColumn(4, fPosZ);
analysisManager->AddNtupleRow(0);
// Fill 2nd ntuple ( id = 1)
// Lets try and do this per sample Volume
//analysisManager->FillNtupleDColumn(1, 0, trackLAbs);
//analysisManager->FillNtupleDColumn(1, 1, trackLGap);
//analysisManager->AddNtupleRow(1);
//}
}
from stepping action as follows:
fSecondary = steppingManager -> GetfSecondary();
// Iterate across the size of this vector for all secondaries?
for(size_t lp1=0;lp1<(*fSecondary).size(); lp1++)
{
// Retrieve the info about the generation of secondary particles
G4int copyNumber = (*fSecondary)[lp1] -> GetVolume() -> GetCopyNo(); // copy of volume where secondary was generated
G4String volumeName = (*fSecondary)[lp1] -> GetVolume() -> GetName(); // volume where secondary was generated
G4String secondaryParticleName = (*fSecondary)[lp1]->GetDefinition() -> GetParticleName(); // name of the secondary
G4String process = (*fSecondary)[lp1]-> GetCreatorProcess()-> GetProcessName(); // process creating it
G4double charge = (*fSecondary)[lp1] -> GetDynamicParticle() -> GetDefinition() -> GetPDGCharge();
G4int AA = (*fSecondary)[lp1] -> GetDynamicParticle() -> GetDefinition() -> GetBaryonNumber();
//
// Secondary generation location
G4ThreeVector posXYZ = (*fSecondary)[lp1]->GetVertexPosition();
//Testing with larger volume!
//if (volumeName == "DiaVol_phys")
// G4cout << "Particle in = " << volumeName << G4endl;
if (/*(secondaryParticleName == "proton") ||
(secondaryParticleName == "neutron")||
(secondaryParticleName == "alpha") ||
(secondaryParticleName == "deuton") ||*/
(secondaryParticleName == "triton") /*||
(secondaryParticleName == "He3") ||
(secondaryParticleName =="GenericIon")*/)
{
G4cout << "the copy number is " <<copyNumber << G4endl;
fHistoManager->FillSecondaryNtuple(copyNumber, secondaryParticleName, process, posXYZ.getX() / mm, posXYZ.getY() / mm, posXYZ.getZ() / mm );
}
}
using this pointer
HistoManager* HistoManager::GetPointer()
{
if (nullptr == fManager) {
static HistoManager analysisManager;
fManager = &analysisManager;
}
return fManager;
}
I have some data from a previous example filled from stacking action
Using basically the same code so I don’t really know whats wrong.
Also can csv ntuples be merged?