G4AnalysisManager

Dear all,
When I use the following code to fill tuples in G4SteppingAction, why is there a lot of zero data, these data are not what I want to fill, how to solve this problem?

			G4int eventID =(G4EventManager::GetEventManager())->GetConstCurrentEvent()->GetEventID();       
			if(currentPhysicalName == "Cathode" && ProcessName == "OpAbsorption" &&particleName == "opticalphoton")
			{
				auto* analysisManager = G4AnalysisManager::Instance();
		  	G4double Globaltime = step->GetTrack()->GetGlobalTime();	
			G4int nabs= feventAction->nAbsPhotons++;
			G4int Columnid = eventID;
		   // analysisManager->FillNtupleDColumn(0,eventID, Globaltime);
			analysisManager->AddNtupleRow(0);
			}

this line is commented out, remove the leading // and see if that helps?

Thank you for your reply,
Adding this line to run gets the data I want, but at the same time the garbage data is still there

looking at the documentation for FillNtupleDColumn, I am not sure if the way you call it does what you want:

G4bool G4RootNtupleManager::FillNtupleDColumn 	( 	G4int  	ntupleId,
		G4int  	columnId,
		G4double  	value 
	) 	

ntupleId is 0, which is the first ntuple - should be fine
eventID presumably can be a very large number, and this goes into the columnId in your code. Could it be that all columns before these events are filled with zeros? So at the end you get a single ntuple but a large number of columns. Instead, you want a large number of ntuples, with 1 column each, right?

I would try to change the line into

analysisManager->FillNtupleDColumn(0, Globaltime);

and see if that helps.

It’s also often helpful to check the examples and how things are done there, e.g. geant4/EventAction.cc at geant4-11.0-release · Geant4/geant4 · GitHub

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.