Changeset 14751 for fact/tools
- Timestamp:
- 12/17/12 15:31:48 (12 years ago)
- Location:
- fact/tools/rootmacros/PulseTemplates
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/templateextractors.C
r14742 r14751 184 184 void CalculateErrorsWithBootstrapping(TH1* inputHisto, int numIt, double* par, double* parErr) 185 185 { 186 cout << "...calculating errors of " << inputHisto->GetName() << endl;186 // cout << "...calculating errors of " << inputHisto->GetName() << endl; 187 187 Sample sample; 188 188 double Mean[numIt]; … … 192 192 double parameterErr[3]; 193 193 194 // TCanvas test_canvas; 195 // test_canvas.Divide(2,1); 196 // test_canvas.cd(1); 197 // inputHisto->Draw(); 194 198 for (int i = 0; i < numIt; i++) 195 199 { 196 TH1D tempHisto( 197 "tempHisto", 198 "tempHisto", 199 inputHisto->GetNbinsX(), 200 inputHisto->GetXaxis()->GetFirst(), 201 inputHisto->GetXaxis()->GetLast() 202 ); 203 204 sample.BootstrapTH1(inputHisto, &tempHisto); 205 206 Mean[i] = tempHisto.GetMean(); 207 Median[i] = MedianOfH1 ( &tempHisto ); 208 209 Max[i] = tempHisto.GetBinCenter( tempHisto.GetMaximumBin() ); 200 // test_canvas.cd(2); 201 TH1* tempHisto = (TH1*)inputHisto->Clone("tempHisto"); 202 // "", 203 // "", 204 // inputHisto->GetNbinsX(), 205 // inputHisto->GetXaxis()->GetBinLowEdge( inputHisto->GetXaxis()->GetFirst() ), 206 // inputHisto->GetXaxis()->GetBinUpEdge( inputHisto->GetXaxis()->GetLast() ) 207 // ); 208 tempHisto->Reset(); 209 sample.BootstrapTH1(inputHisto, tempHisto); 210 211 Mean[i] = tempHisto->GetMean(); 212 Median[i] = MedianOfH1 ( tempHisto ); 213 214 Max[i] = tempHisto->GetBinCenter( tempHisto->GetMaximumBin() ); 210 215 211 216 //improved determination of maximum 212 217 // TF1 gaus("fgaus", "gaus", Max[i]-10, Max[i]+10); 213 // tempHisto .Fit("fgaus", "WWQRN0");218 // tempHisto->Fit("fgaus", "WWQRN0"); 214 219 // Max[i] = gaus.GetParameter(1); 215 220 216 221 217 sample.SetSeed(sample.GetSeed() + 1); 218 222 // sample.SetSeed(sample.GetSeed() + 1); 223 224 /* 225 //Process gui events asynchronously during input 226 tempHisto->Draw(); 227 test_canvas.Modified(); 228 test_canvas.Update(); 229 cout << endl; 230 TTimer timer("gSystem->ProcessEvents();", 50, kFALSE); 231 timer.TurnOn(); 232 TString input = Getline("Type 'q' to exit, <return> to go on: "); 233 timer.TurnOff(); 234 if (input=="q\n") 235 { 236 return; 237 } 238 */ 239 240 241 242 delete tempHisto; 219 243 } 220 244 … … 585 609 586 610 //calculate Errors with bootstrapping 587 CalculateErrorsWithBootstrapping(hTempHisto, 10 0, slMean, slError);611 CalculateErrorsWithBootstrapping(hTempHisto, 10, slMean, slError); 588 612 589 613 if (verbosityLevel > 3) … … 594 618 //Get maximum of slice's distribution 595 619 max_prop = hTempHisto->GetBinCenter( hTempHisto->GetMaximumBin() ); 620 // max_prop = slMean[0]; 596 621 597 622 //improve result by< fitting gaussian to slices distribution … … 610 635 } 611 636 median = MedianOfH1(hTempHisto); 612 median_err = slError[1]; //error from bootstraping 637 // median = slMean[1]; 638 median_err = slError[1]; //error from bootstraping 613 639 614 640 if (verbosityLevel > 3) cout << "\t\t...calculating Mean of slice " << slice << endl; … … 616 642 617 643 mean = hTempHisto->GetMean(); 644 // mean = slMean[2]; 618 645 mean_err = hTempHisto->GetRMS(); //RMS of slice 619 646 // mean_err = slError[2]; //error from bootstraping … … 640 667 // verbosityLevel 641 668 // ); 669 // hOutputMaxHisto->GetXaxis()->SetLimits( 670 // 0, 671 // 300 672 // ); 673 674 // hOutputMeanHisto->GetXaxis()->SetLimits( 675 // 0, 676 // 300 677 // ); 678 679 // hOutputMedianHisto->GetXaxis()->SetLimits( 680 // 0, 681 // 300 682 // ); 683 684 ShiftStartOfHistoInXTo( 685 hOutputMaxHisto, 686 0 687 ); 688 689 ShiftStartOfHistoInXTo( 690 hOutputMeanHisto, 691 0 692 ); 693 694 ShiftStartOfHistoInXTo( 695 hOutputMedianHisto, 696 0 697 ); 698 642 699 } 643 700 // end of PlotMaxPropabilityPulse … … 864 921 // return returnval; 865 922 //} 923 924 925 void 926 ShiftHistoInX( 927 TH1* histo, 928 float shift 929 ) 930 { 931 histo->GetXaxis()->SetLimits( 932 histo->GetXaxis()->GetBinLowEdge( histo->GetXaxis()->GetFirst() ) + shift, 933 histo->GetXaxis()->GetBinUpEdge( histo->GetXaxis()->GetLast() ) + shift 934 ); 935 } 936 937 void 938 ShiftStartOfHistoInXTo( 939 TH1* histo, 940 float value 941 ) 942 { 943 float min = histo->GetXaxis()->GetBinLowEdge( histo->GetXaxis()->GetFirst() ); 944 float shift = value - min; 945 946 ShiftHistoInX( histo, shift); 947 } -
fact/tools/rootmacros/PulseTemplates/templateextractors.h
r14745 r14751 184 184 // ); 185 185 186 void ShiftHistoInX( 187 TH1* histo, 188 float shift 189 ); 190 void ShiftStartOfHistoInXTo( 191 TH1* histo, 192 float value 193 ); 194 186 195 #endif // TEMPLATEEXTRACTORS_H 187 196
Note:
See TracChangeset
for help on using the changeset viewer.