Hi all, I am working in the interpreter in Linux with version 2.00/00 (9 March 1998). I do the following .L ../tools/fifty80.C .L correlation.C correlation("rootfile.root"); // this makes a histogram and calls // th function fifty80 below. Float_t fifty80(TH1 *hi, Float_t fraction = 0.8) { Double_t total = 0.0; Int_t nBins = hi->GetNbinsX(); Int_t i = 0; Stat_t htotal = hi->GetIntegral(); printf("%f\n",htotal); // if (htotal <= 0.0) return -1.0E32; Double_t cutoff; cutoff = (1.0-fraction)*htotal; Double_t answer; printf("%f\n",cutoff); printf("Warning: Using a grainy 50/80. Only as good as bin width.\n"); for( i=1 ; i<=nBins ; i++) { total += hi->GetBinContent(i); printf("%d\t%f\t%f\n",i,total,cutoff); if (total>cutoff) break; } answer = hi->GetBinCenter(i); printf("Value of %f point on histogram is %f.\n",fraction,answer); return answer; } The first problem is the line (now commented out) with the condition followed by a return statement gives the interpreter amnesia. That is to say the interpreter can not find the value of cutoff so the routine fails. The second problem concerns bin numbering. This routine only works when I count from 1 to nBins. I would have excpected 0 to nBins-1. Is there documention about where unit-offset counting is performed as opposed to zero-offset counting? Thanks, Chris ================================================================= = = = Chris Jillings = = Department of Physics phone/voice mail: (613) 545-6000x4805 = = Queen's University fax: (613) 545-6813 = = Kingston, Ontario email: chris@sno.phy.queensu.ca = = Canada, K7L 3N6 web: http://snodaq.phy.queensu.ca = = = =================================================================
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET