Hi all,
I made a function given below [1]. But at line 62 it takes random value for variable binFill
. I am unable to understand why? This patch is very simple and I don’t see anything which can cause this. Please let me know if you find some issue.
I am pasting part of output here [2].
Thanks in advance for your help.
with regards,
Ram
[1]
33 TH1F* ResetTo4bins(TH1F* wjet, int nbins, double xmin, double xmax){
34
35 TH1F* hOut = new TH1F("hOut",";M_{WW} (Vjet Signal Region);",nbins, xmin, xmax);
36
37 double binWidth = (xmax - xmin)/nbins;
38
39 int binFill = 0;
40
41 double hOutBinContent[4] = {0.0, 0.0, 0.0, 0.0};
42
43 for (unsigned int ibin=1; ibin<wjet->GetNbinsX()+1; ++ibin){
44 double xlow = wjet->GetBinLowEdge(ibin);
45 double xhigh = wjet->GetBinLowEdge(ibin+1);
46
47 double xlow_New = hOut->GetBinLowEdge(binFill);
48 double xhigh_New = hOut->GetBinLowEdge(binFill+1);
49
50 cout<< "binFill = " << binFill << endl;
51 if (xlow < xlow_New){ cout<<" Don't fill lower bins..." << endl;cout<< "Debug 1: "<< binFill << endl; }
52 else{
53 if (xhigh <= xhigh_New)
54 {
55 hOutBinContent[binFill] += wjet->GetBinContent(ibin);
56 cout<< "Debug 2: "<< binFill << endl;
57 }
58 else
59 {
60 binFill += 1;
61 hOutBinContent[binFill] += wjet->GetBinContent(ibin);
62 cout<< "Debug 3: "<< binFill << endl;
63 }
64 }
65
66 cout<< "binFill = " << binFill << endl;
67 cout<<ibin << " xlow = " << xlow << " xhigh = " << xhigh << " xlow_New = " << xlow_New << " xhigh_New = " << xhigh_New << " hOutBinContent[" << binFill << "] = " << hOutBinContent[binFill] <<endl;
68
69
70 }
71
72 return hOut;
73
74 }
[2]
27 xlow = 1900 xhigh = 1950 xlow_New = 1550 xhigh_New = 2025 hOutBinContent[3] = 3.69794
binFill = 3
Debug 2: 3
binFill = 3
28 xlow = 1950 xhigh = 2000 xlow_New = 1550 xhigh_New = 2025 hOutBinContent[3] = 3.86957
binFill = 3
Debug 3: 1069678820
binFill = 1069678820
*** Break *** bus error
29 xlow = 2000 xhigh = 2050 xlow_New = 1550 xhigh_New = 2025 hOutBinContent[1069678820] =
_ROOT Version: 6.08/05
_Platform: fnal lpc cluster
Compiler: Not Provided