Hello, I am a newbie and here I have a problem with filling the histogram.
The problem is, I create histograms in one subroutine, and fill them in another one. But I always get the error message when the filling starts.
Here is a short version of the code:
#include <TH1F.h>
#include <TFile.h>
TH1F *hp;
void Analyzer::init(){
char infn[]="test.root";
TFile f(infn,"recreate");
hp = new TH1F("hp","postive",36,0.,6.28);
}
void Run::calc_fpasy(TH1F* hp) {
hp->Fill(data);
}
the Analyzer::init() is called in main program, and the Run::calc_fpasy is called after each event is read in.
I checked the pointer address of hp, it is the same when I pass it to calc_fpasy. I’m just started to use c++, can not figure out what was wrong, please help!
And also don’t know if this is the right place to post this question.
Thanks,
Wei