GetBinContent() and GetNbinsX() aren't members of tools::histo::h1d

Hello, in EventAction and StackingAction I fille two histograms

analysisManager->FillH1(0, fEdep);

  analysisManager->FillH1(1, energy/keV);

I need to print the histograms in a text file, then in the RunAction I wrote the loop

void B1RunAction::EndOfRunAction(const G4Run* run)
{	
int i;
     // save histograms & ntuple
  //
   
  auto analysisManager = G4AnalysisManager::Instance();
  G4H1* h0 = analysisManager->GetH1(0);
  G4H1* h1 = analysisManager->GetH1(1);
     for (i=1;i<=h0->GetNbinsX();i++)
    {
       G4cout << i << " " << h0->GetBinContent(i) << " " << h1->GetBinContent(i) << G4endl;
    }
	analysisManager->Write();
    analysisManager->CloseFile();  
}

But I get errors because
GetNbinsX and GetBinContent aren’t members of tools::histo::h1d’

How can I solve to get these values?

1 Like

You should read the header files, and work your way up the inheritance chain. The headers may be found in $G4INCLUDE/tools/histo/, but they don’t have the usual “.h” or “.hh” suffix. Start with h1d, and you’ll see it’s parent is h1, whose parent is b1. If you look in each of those in turn, you will soon find functions which return the total number of entries, the sum of weights per bin, the sum of squared weights per bin, and so on.

Thank you @mkelsey I solved