Automation to fill several histograms in a for loop

Hey All,

I fill multiple histograms manually, e.g.:


I am wondering if it is possible to automate and loop this instead of manually occupying multiple (100 lines)? I am not an expert in ROOT/C++ and will appreciate any assistance please?

Resolved using this post. Here is full working code:

  int numOfDetectors=5; // number of desired histograms
  // create histograms
  TH1F** EDep=new TH1F*[numOfDetectors];
  for (int i=0; i<numOfDetectors;i++) {
    EDep[i] = new TH1F(TString::Format("%i_EDep_gm", i+1), TString::Format("Energy deposited by gamma events in det-%i", i+1), 1000, 0., 1000.);

  // fill-in histograms
  for (int i=0; i<numOfDetectors;i++){

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