Changeset 14751


Ignore:
Timestamp:
12/17/12 15:31:48 (12 years ago)
Author:
Jens Buss
Message:
add shift in X functions, improved shifting
Location:
fact/tools/rootmacros/PulseTemplates
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/rootmacros/PulseTemplates/templateextractors.C

    r14742 r14751  
    184184void CalculateErrorsWithBootstrapping(TH1* inputHisto, int numIt, double* par, double* parErr)
    185185{
    186     cout << "...calculating errors of " << inputHisto->GetName() << endl;
     186//    cout << "...calculating errors of " << inputHisto->GetName() << endl;
    187187    Sample  sample;
    188188    double  Mean[numIt];
     
    192192    double  parameterErr[3];
    193193
     194//    TCanvas test_canvas;
     195//    test_canvas.Divide(2,1);
     196//    test_canvas.cd(1);
     197//    inputHisto->Draw();
    194198    for (int i = 0; i < numIt; i++)
    195199    {
    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() );
    210215
    211216        //improved determination of maximum
    212217//        TF1 gaus("fgaus", "gaus", Max[i]-10, Max[i]+10);
    213 //        tempHisto.Fit("fgaus", "WWQRN0");
     218//        tempHisto->Fit("fgaus", "WWQRN0");
    214219//        Max[i]      = gaus.GetParameter(1);
    215220
    216221
    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;
    219243    }
    220244
     
    585609
    586610        //calculate Errors with bootstrapping
    587         CalculateErrorsWithBootstrapping(hTempHisto, 100, slMean, slError);
     611        CalculateErrorsWithBootstrapping(hTempHisto, 10, slMean, slError);
    588612
    589613        if (verbosityLevel > 3)
     
    594618        //Get maximum of slice's distribution
    595619        max_prop    = hTempHisto->GetBinCenter( hTempHisto->GetMaximumBin() );
     620//                max_prop    = slMean[0];
    596621
    597622        //improve result by< fitting gaussian to slices distribution
     
    610635        }
    611636        median      = MedianOfH1(hTempHisto);
    612         median_err    = slError[1]; //error from bootstraping
     637//        median      = slMean[1];
     638        median_err  = slError[1]; //error from bootstraping
    613639
    614640        if (verbosityLevel > 3) cout << "\t\t...calculating Mean of slice " << slice << endl;
     
    616642
    617643        mean        = hTempHisto->GetMean();
     644//        mean        = slMean[2];
    618645        mean_err    = hTempHisto->GetRMS(); //RMS of slice
    619646//        mean_err    = slError[2];         //error from bootstraping
     
    640667//            verbosityLevel
    641668//            );
     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
    642699}
    643700// end of PlotMaxPropabilityPulse
     
    864921//    return returnval;
    865922//}
     923
     924
     925void
     926ShiftHistoInX(
     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
     937void
     938ShiftStartOfHistoInXTo(
     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  
    184184//        );
    185185
     186void ShiftHistoInX(
     187        TH1*                histo,
     188        float               shift
     189        );
     190void ShiftStartOfHistoInXTo(
     191        TH1*                histo,
     192        float               value
     193        );
     194
    186195#endif // TEMPLATEEXTRACTORS_H
    187196
Note: See TracChangeset for help on using the changeset viewer.