- Timestamp:
- 02/27/13 12:25:30 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/templateextractors.C
r14946 r14962 121 121 //---------------------------------------------------------------------------- 122 122 123 Double_t MedianOfH1 ( 124 TH1 * inputHisto123 double MedianOfH1 ( //THE PROBLEM MUST BE HERE!!!!!!! 124 TH1D* inputHisto 125 125 ) 126 126 { 127 127 //compute the median for 1-d histogram h1 128 128 Int_t nbins = inputHisto->GetXaxis()->GetNbins(); 129 Double_t *x = new Double_t[nbins];130 Double_t *y = new Double_t[nbins];129 double *x = new double[nbins]; 130 double *y = new double[nbins]; 131 131 for (Int_t i=0;i<nbins;i++) { 132 x[i] = inputHisto->GetXaxis()->GetBinCenter(i +1);133 y[i] = inputHisto->GetBinContent(i +1);132 x[i] = inputHisto->GetXaxis()->GetBinCenter(i); 133 y[i] = inputHisto->GetBinContent(i); 134 134 } 135 Double_tmedian = TMath::Median(nbins,x,y);135 double median = TMath::Median(nbins,x,y); 136 136 delete [] x; 137 137 delete [] y; … … 189 189 double Median[numIt]; 190 190 double Max[numIt]; 191 double parameter[3]; 192 double parameterErr[3]; 191 double parameter[3] = {0,0,0}; 192 double parameterErr[3] = {0,0,0}; 193 for (int i = 0; i < numIt; i++) 194 { 195 Mean[i] = 0; 196 Median[i] = 0; 197 Max[i] = 0; 198 } 193 199 194 200 // TCanvas test_canvas; … … 196 202 // test_canvas.cd(1); 197 203 // inputHisto->Draw(); 204 198 205 for (int i = 0; i < numIt; i++) 199 206 { 200 207 // test_canvas.cd(2); 201 TH1 * tempHisto = (TH1*)inputHisto->Clone("tempHisto");208 TH1D* tempHisto = (TH1D*)inputHisto->Clone("tempHisto"); 202 209 // "", 203 210 // "", … … 207 214 // ); 208 215 tempHisto->Reset(); 216 sample.SetSeed(sample.GetSeed()+1); 209 217 sample.BootstrapTH1(inputHisto, tempHisto); 210 218 211 219 Mean[i] = tempHisto->GetMean(); 212 220 Median[i] = MedianOfH1 ( tempHisto ); 213 214 221 Max[i] = tempHisto->GetBinCenter( tempHisto->GetMaximumBin() ); 215 222 216 //improved determination of m aximum223 //improved determination of modus 217 224 // TF1 gaus("fgaus", "gaus", Max[i]-10, Max[i]+10); 218 225 // tempHisto->Fit("fgaus", "WWQRN0"); … … 540 547 TH1F* hOutputMeanHisto = NULL; 541 548 TH1F* hOutputMedianHisto = NULL; 542 TH1D* hTempHisto 549 TH1D* hTempHisto = NULL; 543 550 double max_prop = 0; 544 551 double median = 0; … … 600 607 int slice_max = hInputHisto->GetXaxis()->GetLast(); 601 608 609 if (verbosityLevel > 2) 610 { 611 cout << "\t...looping over slice range " << slice_min 612 << " to " << slice_max << endl; 613 } 614 602 615 for (Int_t slice=slice_min;slice<=slice_max;slice++) 603 616 { 604 617 605 hTempHisto = hInputHisto->ProjectionY("",slice,slice );618 hTempHisto = hInputHisto->ProjectionY("",slice,slice,"o"); 606 619 607 620 //containers for errors 608 double slMean[3] ;609 double slError[3] ;621 double slMean[3] ={0,0,0}; 622 double slError[3] ={0,0,0}; 610 623 611 624 //calculate Errors with bootstrapping
Note:
See TracChangeset
for help on using the changeset viewer.