Ignore:
Timestamp:
05/30/05 11:23:55 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/tpoint/plot.C

    r7104 r7105  
     1#include <iomanip>
     2
    13Double_t GetResidual(Double_t fRawEl,  Double_t fRawAz,
    24                     Double_t fStarEl, Double_t fStarAz)
     
    7577    ifstream fin(fname);
    7678
     79    cout << "Reading from " << fname << "..." << flush;
     80
    7781    while (1)
    7882    {
     
    105109    }
    106110
     111    cout << "done (" << g[0].GetN() << ")" << endl;
     112
    107113    return g[0].GetN();
    108114}
    109115
     116struct Description_t
     117{
     118    const char *fName;
     119    const char *fTitle;
     120    const char *fFile;
     121};
     122
     123const Int_t counts = 12-4;
     124Description_t desc[counts] =
     125{
     126    // No good pointing model has been applied yet
     127  //  {"0404",  "TPoints Residuals 4/2004" ,   "tpoint/tpoint0404.txt"},
     128  //  {"0405",  "TPoints Residuals 5/2004" ,   "tpoint/tpoint0405.txt"},
     129  //  {"04081", "TPoints Residuals 8/2004-1" , "tpoint/tpoint0408-1.txt"},
     130    {"04082", "TPoints Residuals 8/2004-2" , "tpoint/tpoint0408-2.txt"},
     131    {"0409",  "TPoints Residuals 9/2004" ,   "tpoint/tpoint0409.txt"},
     132    // Culmination tests
     133  //  {"0410",  "TPoints Residuals 10/2004" ,  "tpoint/tpoint0410.txt"},
     134    {"0411",  "TPoints Residuals 11/2004" ,  "tpoint/tpoint0411.txt"},
     135    {"0412",  "TPoints Residuals 12/2004" ,  "tpoint/tpoint0412.txt"},
     136    // Worse pointing due to realignment of the mirror
     137    {"0503",  "TPoints Residuals 3/2005" ,   "tpoint/tpoint0503.txt"},
     138    {"0504",  "TPoints Residuals 4/2005" ,   "tpoint/tpoint0504.txt"},
     139    {"05051", "TPoints Residuals 5/2004-1" , "tpoint/tpoint0505-1.txt"},
     140    // Mirror alignment has been fixed
     141    {"05052", "TPoints Residuals 5/2004-2" , "tpoint/tpoint0505-2.txt"}
     142};
     143
    110144void plot()
    111145{
    112146    TGraph g[3];
    113147
    114     TH1F h0("0404", "TPoints Residuals 4/2004",  35, 0, 0.2);
    115     TH1F h1("0405", "TPoints Residuals 5/2004",  35, 0, 0.2);
    116     TH1F h2("0408", "TPoints Residuals 8/2004",  35, 0, 0.2);
    117     TH1F h3("0409", "TPoints Residuals 9/2004",  35, 0, 0.2);
    118     TH1F h4("0410", "TPoints Residuals 10/2004", 35, 0, 0.2);
    119     TH1F h5("0411", "TPoints Residuals 11/2004", 35, 0, 0.2);
    120     TH1F h6("0412", "TPoints Residuals 12/2004", 35, 0, 0.2);
    121     TH1F h7("0503", "TPoints Residuals 3/2005",  35, 0, 0.2);
    122     TH1F h8("0504", "TPoints Residuals 4/2005",  35, 0, 0.2);
    123 
    124     TH1 *h[9] = { &h0, &h1, &h2, &h3, &h4, &h5, &h6, &h7, &h8 };
    125 
    126     TArrayI n(9);
    127     n[0] = fill("tpoint0404.txt", g, &h0);
    128     n[1] = fill("tpoint0405.txt", g, &h1);
    129     n[2] = fill("tpoint0408.txt", g, &h2);
    130     n[3] = fill("tpoint0409.txt", g, &h3);
    131     n[4] = fill("tpoint0410.txt", g, &h4);
    132     n[5] = fill("tpoint0411.txt", g, &h5);
    133     n[6] = fill("tpoint0412.txt", g, &h6);
    134     n[7] = fill("tpoint0503.txt", g, &h7);
    135     n[8] = fill("tpoint0504.txt", g, &h8);
    136 
    137 //    for (int i=0; i<n.GetSize(); i++)
    138 //        cout << "Overflows: " << Form("%4.0f", h[i]->GetBinContent(h[i]->GetNbinsX()+1)*h[i]->GetEntries()/h[i]->GetEntries()) << "/" << Form("%4.0f", h[i]->GetEntries()) << endl;
     148    MBinning bins(10, 0, 0.2);
     149
     150    TArrayI n(counts);
     151
     152    TH1F hx[counts];
     153    for (int i=0; i<counts; i++)
     154    {
     155        hx[i].SetNameTitle(desc[i].fName, desc[i].fTitle);
     156        hx[i].SetDirectory(0);
     157        bins.Apply(hx[i]);
     158
     159        cout << setw(2) << i << ": " << flush;
     160        n[i] = fill(desc[i].fFile, g, &hx[i]);
     161    }
    139162
    140163    g[0].SetMarkerColor(kGreen);
     
    170193    l.SetLineColor(kBlue);
    171194    for (int i=0; i<n.GetSize(); i++)
    172         l.DrawLine(n[i], gPad->GetUymin(), n[i], gPad->GetUymax());
     195        l.DrawLine(n[i], 0, n[i], 0.2);
    173196
    174197    // --------- Second Canvas ----------
     
    176199    new TCanvas("Distrib", "");
    177200
    178     Double_t max = 0;
    179     for (int i=0; i<n.GetSize(); i++)
    180     {
    181         h[i]->Scale(1./h[i]->GetEntries());
    182         max = TMath::Max(max, h[i]->GetMaximum());
    183     }
    184     for (int i=0; i<n.GetSize(); i++)
    185         h[i]->SetMaximum(max*1.05);
    186 
    187     h0.SetLineColor(kYellow);
    188     h1.SetLineColor(kGreen);
    189     h2.SetLineColor(kBlue);
    190     //h3.SetLineColor(kYellow);
    191 
    192     h7.DrawCopy();
    193     h0.DrawCopy("same");
    194     h1.DrawCopy("same");
    195     h2.DrawCopy("same");
    196     h3.DrawCopy("same");
    197     h4.DrawCopy("same");
    198     h5.DrawCopy("same");
    199     h6.DrawCopy("same");
    200     h7.DrawCopy("same");
     201    Double_t max=0;
     202    for (int i=0; i<n.GetSize(); i++)
     203    {
     204        if (hx[i].GetEntries()==0)
     205        {
     206            cout << "Skip #" << i << endl;
     207            continue;
     208        }
     209
     210        hx[i].Scale(1./hx[i].GetEntries());
     211        max = TMath::Max(max, hx[i].GetMaximum());
     212    }
     213    for (int i=0; i<n.GetSize(); i++)
     214    {
     215        hx[i].SetMaximum(max*1.05);
     216        if (i<6)
     217            hx[i].SetLineColor(kRed+i);
     218        else
     219            hx[i].SetMarkerStyle(kPlus+i-6);
     220
     221
     222    }
     223
     224    for (int i=0; i<counts; i++)
     225        hx[i].DrawCopy(i==0?"LP":"LPsame");
    201226
    202227    return;
     
    204229    for (int i=0; i<n.GetSize(); i++)
    205230    {
    206         cout << "Mean:  " << Form("%.3f +- %.3f", h[i]->GetMean(), h[i]->GetRMS());
    207         cout << "   (Overflows=" << h[i]->GetBinContent(h[i]->GetNbinsX()+1)*h[i]->GetEntries() << ")" << endl;
     231        cout << "Mean:  " << Form("%.3f +- %.3f", hx[i].GetMean(), hx[i].GetRMS());
     232        cout << "   (Overflows=" << hx[i].GetBinContent(hx[i].GetNbinsX()+1)*hx[i].GetEntries() << ")" << endl;
    208233    }
    209234}
Note: See TracChangeset for help on using the changeset viewer.