Dear rooters,
I am facing the following issue : I want to create a vector of histograms contained in a root file.
MY code is
[code]std::vector<TH1F*> hists;//Raw signals
//Load File
TFile *f = new TFile(TString::Format("HPGe_%d_%d_%d.root",runfirst, runlast, last_segment));
if (f->IsOpen()==kFALSE) {cout << "File " << f->GetName() << " not found" << endl;}
for (int run = runfirst; run <= runlast; run++){
for (int seg = first_segment; seg <= last_segment; seg++) {
cout << "Run : " << run << endl;
cout << "Segment : " << seg << endl;
cout << "-----------------" << endl;
TH1D *hSignal = (TH1D*)f->Get(TString::Format("h_HPGe_%d_%d_%d", detn, run, seg));
if(!hSignal){cout << "***Segment not found. Moving on." << endl; continue;}
hists.push_back(hSignal);
hSignal->Delete();
}//End of loop over segments
}//End of Loop over runs[/code]
I am loading and compiling this macro and I get the following error
[quote]error: no matching function for call to ‘std::vector<TH1F*, std::allocator<TH1F*> >::push_back(TH1D*&)’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_vector.h:733: note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = TH1F*, _Alloc = std::allocator<TH1F*>]
[/quote]
It seems like the histograms in the file are addresses? I am so confused…
Any ideas?