Dear rooters,
Assume the following function
TH2F *Stack(std::vector<TH1F*> hists) {
//TH2F *hStack = new TH2F("hStack","Stack",8000,0,8000,510,-255,255);// for FIMG
TH2F *hStack = new TH2F("hStack","Stack",9e6,0,0.01,5000,-2000,3000); // for HPGE
for (size_t i=0;i < hists.size(); i++) {
cout << "Hist size is " << hists.size() << endl;
cout << i << " ";
for (int bin = 0; bin < hists[i]->GetNbinsX(); bin++) {
cout << endl << bin << " " ;
int resultBin = hStack->FindBin(bin, hists[i]->GetBinContent(bin));
int binContent = hStack->GetBinContent(resultBin) + 1;
hStack->SetBinContent(resultBin,binContent);
}
}
return hStack;
}//End of TH2F* Stack(vector<TH1F> hists)
I am calling this function inside my code
[code]//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 <= 1001; seg++) {
cout << "Run : " << run << endl;
cout << "Segment : " << seg << endl;
cout << "-----------------" << endl;
TH1F *hSignal = (TH1F*)f->FindObjectAny(TString::Format("h_HPGe_%d_%d_%d;1", detn, run, seg));
if(!hSignal){cout << "***Segment not found. Moving on." << endl; continue;}
hists.push_back(hSignal); //[seg-first_segment]=hSignal;
hSignal->Delete();
}//End of loop over segments
}//End of Loop over runs
//Compute average
cout << "Stacking raw histograms" << endl;
TH2F *hStack = Stack(hists);//Raw Signals Stack<-------------This is line 35[/code]
When running my code I get the following weird error
[quote]===========================================================
#5 0x00007f7750d89b08 in TObjectRefSpy::ShowMembers(TMemberInspector&) () from /usr/lib64/root/libCore.so.5.34
#6 0x00007f77460a53f9 in Stack (hists=Traceback (most recent call last):
itype0 = self.val.type.template_argument(0)
#7 0x00007f77460a64d1 in mean_Gamma_Flash_HPGE (runfirst=102642, runlast=102642, first_segment=1000, last_segment=2000, detn=1) at /afs/cern.ch/exp/ntof/.ROOT2015_09/THANOS_RAW2ROOT/HPGe/Signals/./mean_Gamma_Flash_HPGE.C:35
===========================================================
[/quote]
Note that line 35 is the call to Stack function.
I used some printing commands to trace the error and I was able to find the the crash occurs after the fisrt execution of the first for loop i.e. (output from execution)
[quote][code]Run : 102642
Segment : 1000
***Segment not found. Moving on.
Run : 102642
Segment : 1001
Stacking raw histograms
Hist size is 1
0
*** Break *** segmentation violation
0
===========================================================
There was a crash.
This is the entire stack trace of all threads:
[/code][/quote]
Any idea on why is this happening?
Thank a lot in advance!