Ignore:
Timestamp:
01/23/02 19:37:56 (23 years ago)
Author:
rkb
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MBinning.h

    r1205 r1215  
    2020    void SetEdges(const TArrayD &arr)
    2121    {
     22        fEdges = arr;/*
    2223        const Int_t nbins = arr.GetSize();
    2324        fEdges.Set(nbins);
    24         for (int i=0; i<=nbins; i++)
    25             fEdges[i] = (*(TArrayD*)(&arr))[i];
     25        for (int i=0; i<nbins; i++)
     26            fEdges[i] = (*(TArrayD*)(&arr))[i];*/
    2627    }
    2728
  • trunk/MagicSoft/Mars/mhist/MH.cc

    r1211 r1215  
    197197void MH::SetBinning(TH1 *h, const TAxis *binsx)
    198198{
    199     MBinning bx;
    200     bx.SetEdges(*((TAxis*)binsx)->GetXbins()); // FIXME: Root!
     199    const Int_t nx = binsx->GetNbins();
     200
     201    TArrayD bx(nx+1);
     202    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
     203    bx[nx] = binsx->GetXmax();
     204
    201205    SetBinning(h, &bx);
    202206}
     
    204208void MH::SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy)
    205209{
    206     MBinning bx;
    207     MBinning by;
    208     bx.SetEdges(*((TAxis*)binsx)->GetXbins()); // FIXME: Root!
    209     by.SetEdges(*((TAxis*)binsy)->GetXbins()); // FIXME: Root!
     210    const Int_t nx = binsx->GetNbins();
     211    const Int_t ny = binsy->GetNbins();
     212
     213    TArrayD bx(nx+1);
     214    TArrayD by(ny+1);
     215    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
     216    for (int i=0; i<ny; i++) by[i] = binsy->GetBinLowEdge(i+1);
     217    bx[nx] = binsx->GetXmax();
     218    by[ny] = binsy->GetXmax();
     219
    210220    SetBinning(h, &bx, &by);
    211221}
     
    213223void MH::SetBinning(TH1 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz)
    214224{
    215     MBinning bx;
    216     MBinning by;
    217     MBinning bz;
    218     bx.SetEdges(*((TAxis*)binsx)->GetXbins()); // FIXME: Root!
    219     by.SetEdges(*((TAxis*)binsy)->GetXbins()); // FIXME: Root!
    220     bz.SetEdges(*((TAxis*)binsz)->GetXbins()); // FIXME: Root!
     225    const Int_t nx = binsx->GetNbins();
     226    const Int_t ny = binsy->GetNbins();
     227    const Int_t nz = binsz->GetNbins();
     228
     229    TArrayD bx(nx+1);
     230    TArrayD by(ny+1);
     231    TArrayD bz(nz+1);
     232    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
     233    for (int i=0; i<ny; i++) by[i] = binsy->GetBinLowEdge(i+1);
     234    for (int i=0; i<nz; i++) bz[i] = binsz->GetBinLowEdge(i+1);
     235    bx[nx] = binsx->GetXmax();
     236    by[ny] = binsy->GetXmax();
     237    bz[nz] = binsz->GetXmax();
     238
    221239    SetBinning(h, &bx, &by, &bz);
    222240}
  • trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.cc

    r1211 r1215  
    102102
    103103    fHist.Fill(hil.GetAlpha(), fEnergy->GetEnergy(), fMcEvt->GetTheta()*kRad2Deg);
     104
    104105    return kTRUE;
    105106}
     
    108109{
    109110    if (!gPad)
    110         MakeDefCanvas("AlphaEnergyTheta", "Distrib of \\alpha, E, \\Theta");
     111        MakeDefCanvas("AlphaEnergyTheta", "Distrib of alpha, E, Theta");
    111112
    112113    gPad->Divide(2,2);
    113114
     115    TH1 *h;
     116
    114117    gPad->cd(1);
    115     fHist.Project3D("x")->Draw(opt);
     118    h = fHist.Project3D("x");
     119    h->Draw(opt);
     120    h->SetBit(kCanDelete);
    116121
    117122    gPad->cd(2);
    118     fHist.Project3D("y")->Draw(opt);
     123    h = fHist.Project3D("y");
     124    h->Draw(opt);
     125    h->SetBit(kCanDelete);
    119126
    120127    gPad->cd(3);
    121     fHist.Project3D("z")->Draw(opt);
     128    h = fHist.Project3D("z");
     129    h->Draw(opt);
     130    h->SetBit(kCanDelete);
    122131
    123132    gPad->cd(4);
     
    130139TObject *MHAlphaEnergyTheta::DrawClone(Option_t *opt) const
    131140{
    132     TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib of \\Delta t, \\Theta");
     141    TCanvas *c = MakeDefCanvas("AlphaEnergyTheta", "Distrib of alpha, E, Theta");
    133142    c->Divide(2, 2);
    134143
     
    138147    // FIXME: ProjectionX,Y is not const within root
    139148    //
     149    TH1 *h;
     150
    140151    c->cd(1);
    141     ((TH3*)(&fHist))->Project3D("x")->DrawCopy(opt);
     152    h = ((TH3*)(&fHist))->Project3D("x");
     153    h->Draw(opt);
     154    h->SetBit(kCanDelete);
    142155
    143156    c->cd(2);
    144     ((TH3*)(&fHist))->Project3D("y")->DrawCopy(opt);
     157    h = ((TH3*)(&fHist))->Project3D("y");
     158    h->Draw(opt);
     159    h->SetBit(kCanDelete);
    145160
    146161    c->cd(3);
    147     ((TH3*)(&fHist))->Project3D("z")->DrawCopy(opt);
     162    h = ((TH3*)(&fHist))->Project3D("z");
     163    h->Draw(opt);
     164    h->SetBit(kCanDelete);
    148165
    149166    c->cd(4);
     
    158175void MHAlphaEnergyTheta::Substract(const TH3D *h1, const TH3D *h2)
    159176{
    160     MH::SetBinning(&fHist, h1);
     177    MH::SetBinning(&fHist, (TH1*)h1);
    161178
    162179    fHist.Sumw2();
  • trunk/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc

    r1211 r1215  
    113113{
    114114    if (!gPad)
    115         MakeDefCanvas("AlphaEnergyTime", "Distrib of \\alpha, E, t");
     115        MakeDefCanvas("AlphaEnergyTime", "Distrib of alpha, E, t");
    116116
    117117    gPad->Divide(2,2);
    118118
     119    TH1 *h;
     120
    119121    gPad->cd(1);
    120     fHist.Project3D("x")->Draw(opt);
     122    h = fHist.Project3D("x");
     123    h->Draw(opt);
     124    h->SetBit(kCanDelete);
    121125
    122126    gPad->cd(2);
    123     fHist.Project3D("y")->Draw(opt);
     127    h = fHist.Project3D("y");
     128    h->Draw(opt);
     129    h->SetBit(kCanDelete);
    124130
    125131    gPad->cd(3);
    126     fHist.Project3D("z")->Draw(opt);
     132    h = fHist.Project3D("z");
     133    h->Draw(opt);
     134    h->SetBit(kCanDelete);
    127135
    128136    gPad->cd(4);
     
    135143TObject *MHAlphaEnergyTime::DrawClone(Option_t *opt) const
    136144{
    137     TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib of \\Delta t, t");
     145    TCanvas *c = MakeDefCanvas("AlphaEnergyTime", "Distrib of alpha, E, t");
    138146    c->Divide(2, 2);
    139147
     
    143151    // FIXME: ProjectionX,Y is not const within root
    144152    //
     153    TH1 *h;
     154
    145155    c->cd(1);
    146     ((TH3D*)(&fHist))->Project3D("x")->DrawCopy(opt);
     156    h = ((TH3D*)(&fHist))->Project3D("x");
     157    h->Draw(opt);
     158    h->SetBit(kCanDelete);
    147159
    148160    c->cd(2);
    149     ((TH3D*)(&fHist))->Project3D("y")->DrawCopy(opt);
     161    h = ((TH3D*)(&fHist))->Project3D("y");
     162    h->Draw(opt);
     163    h->SetBit(kCanDelete);
    150164
    151165    c->cd(3);
    152     ((TH3D*)(&fHist))->Project3D("z")->DrawCopy(opt);
     166    h = ((TH3D*)(&fHist))->Project3D("z");
     167    h->Draw(opt);
     168    h->SetBit(kCanDelete);
    153169
    154170    c->cd(4);
     
    163179void MHAlphaEnergyTime::Substract(const TH3D *h1, const TH3D *h2)
    164180{
    165     MH::SetBinning(&fHist, h1);
     181    MH::SetBinning(&fHist, (TH1*)h1);
    166182
    167183    fHist.Sumw2();
  • trunk/MagicSoft/Mars/mhist/MHEffOnTimeTheta.cc

    r1213 r1215  
    8181        //new TCanvas(txt, "Title");
    8282
    83         TH1D *h = hist->ProjectionX("dTime-Distribution for fixed Time", i, i);
     83        TH1D &h = *hist->ProjectionX("dTime-Distribution for fixed Time", i, i);
    8484
    8585        //hist->Draw();
    8686        //gPad->SetLogy();
    8787
    88         Double_t Nmdel = h->Integral("width");
    89         Double_t mean  = h->GetMean();
     88        Double_t Nmdel = h.Integral("width");
     89        Double_t mean  = h.GetMean();
    9090
    9191        TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)",
     
    101101        func.SetParName(1, "Nmdel");
    102102
    103         h->Fit("Poisson", "RN");
     103        h.Fit("Poisson", "RN");
    104104
    105105        //func.SetRange(0, 0.1); // Range of Drawing
     
    113113        //cout << "t_eff = " << h->Integral()/lambda << "  T(last)=" << time.GetTimeLo()*0.0001 << endl;
    114114
    115         fHist.SetBinContent(i, h->Integral()/lambda);
     115        fHist.SetBinContent(i, h.Integral()/lambda);
     116
     117        delete &h;
    116118    }
    117119}
     
    133135TObject *MHEffOnTimeTheta::DrawClone(Option_t *opt) const
    134136{
    135     TCanvas *c = MakeDefCanvas("EffOnTimeTheta", "t_{eff} vs. \\Theta");
     137    TCanvas *c = MakeDefCanvas("EffOnTimeTheta", "t_eff vs. Theta");
    136138
    137139    gROOT->SetSelectedPad(NULL);
     
    148150{
    149151    if (!gPad)
    150         MakeDefCanvas("EffOnTimeTheta", "t_{eff} vs. \\Theta");
     152        MakeDefCanvas("EffOnTimeTheta", "t_eff vs. Theta");
    151153
    152154    fHist.Draw(opt);
  • trunk/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc

    r1213 r1215  
    2626//////////////////////////////////////////////////////////////////////////////
    2727//                                                                          //
    28 //  MHEffOnTimeTime                                                       //
     28//  MHEffOnTimeTime                                                         //
    2929//                                                                          //
    3030//                                                                          //
     
    6363
    6464    fHist.SetName("EffOn");
    65     fHist.SetTitle("Effective On Time Vs. Theta");
     65    fHist.SetTitle("Effective On Time Vs. Time");
    6666
    6767
     
    7474TObject *MHEffOnTimeTime::DrawClone(Option_t *opt) const
    7575{
    76     TCanvas *c = MakeDefCanvas("EffOnTimeTheta", "t_{eff} vs. t");
     76    TCanvas *c = MakeDefCanvas("EffOnTimeTheta", "t_eff vs. t");
    7777
    7878    gROOT->SetSelectedPad(NULL);
     
    8989{
    9090    if (!gPad)
    91         MakeDefCanvas("EffOnTimeTheta", "t_{eff} vs. t");
     91        MakeDefCanvas("EffOnTimeTheta", "t_eff vs. t");
    9292
    9393    fHist.Draw(opt);
     
    108108        //new TCanvas(txt, "Title");
    109109
    110         TH1D *h = hist->ProjectionX("dTime-Distribution for fixed Theta", i, i);
     110        TH1D &h = *hist->ProjectionX("dTime-Distribution for fixed Theta", i, i);
    111111
    112112        //hist->Draw();
    113113        //gPad->SetLogy();
    114114
    115         Double_t Nmdel = h->Integral("width");
    116         Double_t mean  = h->GetMean();
     115        Double_t Nmdel = h.Integral("width");
     116        Double_t mean  = h.GetMean();
    117117
    118118        TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)",
     
    128128        func.SetParName(1, "Nmdel");
    129129
    130         h->Fit("Poisson", "RN");
     130        h.Fit("Poisson", "RN");
    131131
    132132        //func.SetRange(0, 0.1); // Range of Drawing
     
    140140        //cout << "t_eff = " << h->Integral()/lambda << "  T(last)=" << time.GetTimeLo()*0.0001 << endl;
    141141
    142         fHist.SetBinContent(i, h->Integral()/lambda);
     142        fHist.SetBinContent(i, h.Integral()/lambda);
     143
     144        delete &h;
    143145    }
    144146}
  • trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc

    r1214 r1215  
    2626//////////////////////////////////////////////////////////////////////////////
    2727//                                                                          //
    28 //  MHTimeDiffTheta                                                       //
     28//  MHTimeDiffTheta                                                         //
    2929//                                                                          //
    3030//                                                                          //
     
    9898TObject *MHTimeDiffTheta::DrawClone(Option_t *opt) const
    9999{
    100     TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib \\Delta t, \\Theta");
     100    TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib of Delta t, Theta");
    101101    c->Divide(2, 2);
    102102
     
    106106    // FIXME: ProjectionX,Y is not const within root
    107107    //
     108    TH1 *h;
     109
    108110    c->cd(1);
    109     ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E")->DrawCopy(opt);
     111    h = ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E");
     112    h->DrawCopy(opt);
     113    delete h;
    110114    gPad->SetLogy();
    111115
    112116    c->cd(2);
    113     ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E")->DrawCopy(opt);
     117    h = ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E");
     118    h->DrawCopy(opt);
     119    delete h;
    114120
    115121    c->cd(3);
     
    125131{
    126132    if (!gPad)
    127         MakeDefCanvas("DiffTimeTheta", "Distrib \\Delta t, \\Theta");
     133        MakeDefCanvas("DiffTimeTheta", "Distrib of Delta t, Theta");
    128134
    129135    TH1 *h;
  • trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.cc

    r1214 r1215  
    2626//////////////////////////////////////////////////////////////////////////////
    2727//                                                                          //
    28 //  MHTimeDiffTime                                                       //
     28//  MHTimeDiffTime                                                          //
    2929//                                                                          //
    3030//                                                                          //
     
    9898    // FIXME: ProjectionX,Y is not const within root
    9999    //
     100    TH1 *h;
     101
    100102    c->cd(1);
    101     ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E")->DrawCopy(opt);
     103    h = ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E");
     104    h->Draw(opt);
     105    h->SetBit(kCanDelete);
    102106    gPad->SetLogy();
    103107
    104108    c->cd(2);
    105     ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E")->DrawCopy(opt);
     109    h = ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E");
     110    h->Draw(opt);
     111    h->SetBit(kCanDelete);
    106112
    107113    c->cd(3);
     
    121127    gPad->Divide(2,2);
    122128
     129    TH1 *h;
     130
    123131    gPad->cd(1);
    124     fHist.ProjectionX("ProX", -1, 9999, "E")->DrawCopy(opt);
     132    h = fHist.ProjectionX("ProX", -1, 9999, "E");
     133    h->Draw(opt);
     134    h->SetBit(kCanDelete);
    125135    gPad->SetLogy();
    126136
    127137    gPad->cd(2);
    128     fHist.ProjectionY("ProY", -1, 9999, "E")->DrawCopy(opt);
     138    h = fHist.ProjectionY("ProY", -1, 9999, "E");
     139    h->Draw(opt);
     140    h->SetBit(kCanDelete);
    129141
    130142    gPad->cd(3);
Note: See TracChangeset for help on using the changeset viewer.