Changeset 1968


Ignore:
Timestamp:
04/21/03 14:25:52 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHHadronness.cc

    r1952 r1968  
    9292    fGraph->SetTitle("Acceptance Gammas vs. Hadrons");
    9393    fGraph->SetMaximum(1);
    94 
    95     fGhness = new TH1D("Ghness", "Hadronness", nbins, 0, 1);
    96     fPhness = new TH1D("Phness", "Hadronness", nbins, 0, 1);
     94    fGraph->SetMarkerStyle(kFullDotSmall);
     95
     96    fGhness = new TH1D("Ghness", "H. Gammas",  nbins, 0, 1);
     97    fPhness = new TH1D("Phness", "H. Hadrons", nbins, 0, 1);
    9798    fGhness->SetXTitle("Hadronness");
    9899    fPhness->SetXTitle("Hadronness");
    99100    fGhness->SetYTitle("Counts");
    100101    fPhness->SetYTitle("Counts");
     102    fPhness->SetLineColor(kRed);
     103    fGhness->SetDirectory(NULL);
     104    fPhness->SetDirectory(NULL);
    101105   
    102106    fIntGhness = new TH1D("AccGammas",  "Acceptance", nbins, 0, 1);
     
    108112    fIntGhness->SetMaximum(1.1);
    109113    fIntPhness->SetMaximum(1.1);
     114    fIntGhness->SetDirectory(NULL);
     115    fIntPhness->SetDirectory(NULL);
     116    fIntPhness->SetLineColor(kRed);
     117    fIntGhness->SetBit(TH1::kNoStats);
     118    fIntPhness->SetBit(TH1::kNoStats);
    110119
    111120    fQfac = new TGraph;
    112121    fQfac->SetTitle(" Naive Quality factor ");
    113 
    114     fGhness->SetDirectory(NULL);
    115     fPhness->SetDirectory(NULL);
    116     fIntGhness->SetDirectory(NULL);
    117     fIntPhness->SetDirectory(NULL);
     122    fQfac->SetMarkerStyle(kFullDotSmall);
    118123}
    119124
     
    241246//  - fill the Quality histogram (formular see class description)
    242247//
    243 Bool_t MHHadronness::Finalize()
     248void MHHadronness::CalcGraph(Double_t sumg, Double_t sump)
    244249{
    245250    Int_t n = fGhness->GetNbinsX();
     
    248253    fQfac->Set(n);
    249254
     255    // Calculate acceptances
     256    Float_t max=0;
     257
     258    for (Int_t i=1; i<=n; i++)
     259    {
     260        const Stat_t ip = fPhness->Integral(1, i)/sump;
     261        const Stat_t ig = fGhness->Integral(1, i)/sumg;
     262
     263        fIntPhness->SetBinContent(i, ip);
     264        fIntGhness->SetBinContent(i, ig);
     265
     266        fGraph->SetPoint(i, ip, ig);
     267
     268        if (ip<=0)
     269            continue;
     270
     271        const Double_t val = ig/sqrt(ip);
     272        fQfac->SetPoint(i, ig, val);
     273
     274        if (val>max)
     275            max = val;
     276    }
     277
     278    fQfac->SetMaximum(max*1.05);
     279}
     280
     281Bool_t MHHadronness::Finalize()
     282{
    250283    const Stat_t sumg = fGhness->Integral();
    251284    const Stat_t sump = fPhness->Integral();
    252285
    253286    *fLog << inf << "Sum Hadronness: gammas=" << sumg << " hadrons=" << sump << endl;
    254 
    255     if (sumg==0 )
    256         *fLog << warn << "Cannot calculate hadronness for 'gammas'." << endl;
    257     if (sump==0)
    258         *fLog << warn << "Cannot calculate hadronness for 'hadrons'." << endl;
    259287
    260288    // Normalize photon distribution
    261289    if (sumg>0)
    262290        fGhness->Scale(1./sumg);
     291    else
     292        *fLog << warn << "Cannot calculate hadronness for 'gammas'." << endl;
    263293
    264294    // Normalize hadron distribution
    265295    if (sump>0)
    266296        fPhness->Scale(1./sump);
    267 
    268     // Calculate acceptances
    269     Float_t max=0;
    270 
    271     for (Int_t i=1; i<=n; i++)
    272     {
    273         const Stat_t ip = fPhness->Integral(1, i);
    274         const Stat_t ig = fGhness->Integral(1, i);
    275 
    276         fIntPhness->SetBinContent(i, ip);
    277         fIntGhness->SetBinContent(i, ig);
    278 
    279         fGraph->SetPoint(i, ip, ig);
    280 
    281         if (ip<=0)
    282             continue;
    283 
    284         const Double_t val = ig/sqrt(ip);
    285         fQfac->SetPoint(i, ig, val);
    286 
    287         if (val>max)
    288             max = val;
    289     }
    290 
    291     fQfac->SetMaximum(max*1.05);
     297    else
     298        *fLog << warn << "Cannot calculate hadronness for 'hadrons'." << endl;
     299
     300    CalcGraph(1, 1);
    292301
    293302    return kTRUE;
     303}
     304
     305void MHHadronness::Paint(Option_t *opt="")
     306{
     307    Stat_t sumg = fGhness->Integral();
     308    Stat_t sump = fPhness->Integral();
     309
     310    // Normalize photon distribution
     311    if (sumg<=0)
     312        sumg=1;
     313
     314    // Normalize hadron distribution
     315    if (sump<=0)
     316        sump=1;
     317
     318    CalcGraph(sumg, sump);
    294319}
    295320
     
    399424// --------------------------------------------------------------------------
    400425//
    401 // Draw clone of all histograms. (For the Meaning see class description)
    402 //
    403 TObject *MHHadronness::DrawClone(Option_t *opt) const
    404 {
    405     if (fGraph->GetN()==0)
    406         return NULL;
    407 
    408     TCanvas &c = *MakeDefCanvas("Hadronness", fTitle);
    409     c.Divide(2, 2);
    410 
    411     gROOT->SetSelectedPad(NULL);
    412 
    413     c.cd(1);
     426// Draw all histograms. (For the Meaning see class description)
     427//
     428void MHHadronness::Draw(Option_t *)
     429{
     430    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas("Hadronness", fTitle);
     431    pad->SetBorderMode(0);
     432
     433    AppendPad("");
     434
     435    pad->Divide(2, 2);
     436
     437    TH1 *h;
     438
     439    pad->cd(1);
     440    gPad->SetBorderMode(0);
    414441    //gStyle->SetOptStat(10);
    415     Getghness()->DrawCopy();
    416     Getphness()->SetLineColor(kRed);
    417     Getphness()->DrawCopy("same");
    418 
    419     c.cd(2);
    420     //gStyle->SetOptStat(0);
    421     Getighness()->DrawCopy();
    422     Getiphness()->SetLineColor(kRed);
    423     Getiphness()->DrawCopy("same");
    424 
    425     c.cd(3);
    426     TGraph &g2 = (TGraph&)*fQfac->DrawClone("A*");
    427     g2.SetBit(kCanDelete);
    428     gPad->Modified();
    429     gPad->Update();
    430     if (g2.GetHistogram())
    431     {
    432         g2.GetXaxis()->SetRangeUser(0, 1);
    433         g2.GetXaxis()->SetTitle("Acceptance Gammas");
    434         g2.GetYaxis()->SetTitle("Quality");
    435         g2.SetMarkerStyle(kFullDotSmall);
    436         g2.Draw("P");
    437 
    438         gPad->Modified();
    439         gPad->Update();
    440     }
    441 
    442     c.cd(4);
    443     gPad->Modified();
    444     gPad->Update();
    445     TGraph &g = (TGraph&)*fGraph->DrawClone("AC");
    446     g.SetBit(kCanDelete);
    447     gPad->Modified();
    448     gPad->Update();
    449     if (g.GetHistogram())
    450     {
    451         g.GetXaxis()->SetRangeUser(0, 1);
    452         g.GetXaxis()->SetTitle("Acceptance Hadrons");
    453         g.GetYaxis()->SetTitle("Acceptance Gammas");
    454         g.SetMarkerStyle(kFullDotSmall);
    455         g.Draw("P");
    456 
    457         gPad->Modified();
    458         gPad->Update();
    459     }
    460     /*
    461     const Int_t h = fMinDist->GetMaximumBin();
    462     TMarker *m = new TMarker(fIntPhness->GetBinContent(h),
    463                              fIntGhness->GetBinContent(h), kStar);
    464     m->SetMarkerColor(kBlue);
    465     m->SetBit(kCanDelete);
    466     m->Draw();
    467     */
    468 
    469     gStyle->SetOptStat(1111);
    470 
    471     return &c;
    472 }
    473 
    474 // --------------------------------------------------------------------------
    475 //
    476 // Draw all histograms. (For the Meaning see class description)
    477 //
    478 void MHHadronness::Draw(Option_t *)
    479 {
    480    if (fGraph->GetN()==0)
    481         return;
    482 
    483    if (!gPad)
    484         MakeDefCanvas("Hadronness", fTitle);
    485 
    486     gPad->Divide(2, 2);
    487 
    488     gPad->cd(1);
    489     //gStyle->SetOptStat(10);
    490     Getghness()->Draw();
    491     Getphness()->SetLineColor(kRed);
    492     Getphness()->Draw("same");
    493 
    494     gPad->cd(2);
    495     //gStyle->SetOptStat(0);
    496     Getighness()->Draw();
    497     Getiphness()->SetLineColor(kRed);
    498     Getiphness()->Draw("same");
    499 
    500     gPad->cd(3);
     442    MH::Draw(*fGhness, *fPhness, "Hadronness"); // Displ both stat boxes
     443
     444    pad->cd(2);
     445    gPad->SetBorderMode(0);
     446    fIntGhness->Draw();
     447    fIntPhness->Draw("same");
     448
     449    pad->cd(3);
     450    gPad->SetBorderMode(0);
    501451    fQfac->Draw("A*");
    502452    gPad->Modified();
    503453    gPad->Update();
    504     if (fQfac->GetHistogram())
    505     {
    506         fQfac->GetXaxis()->SetRangeUser(0, 1);
    507         fQfac->GetXaxis()->SetTitle("Acceptance Gammas");
    508         fQfac->GetYaxis()->SetTitle("Quality");
    509         fQfac->SetMarkerStyle(kFullDotSmall);
     454    if ((h=fQfac->GetHistogram()))
     455    {
     456        h->GetXaxis()->SetRangeUser(0, 1);
     457        h->SetXTitle("Acceptance Gammas");
     458        h->SetYTitle("Quality");
    510459        fQfac->Draw("P");
    511 
    512460        gPad->Modified();
    513461        gPad->Update();
    514462    }
    515     gPad->cd(4);
    516     gPad->Modified();
    517     gPad->Update();
     463
     464    pad->cd(4);
     465    gPad->SetBorderMode(0);
    518466    fGraph->Draw("AC");
    519467    gPad->Modified();
    520468    gPad->Update();
    521     if (fGraph->GetHistogram())
    522     {
    523         fGraph->GetXaxis()->SetRangeUser(0, 1);
    524         fGraph->GetXaxis()->SetTitle("Acceptance Hadrons");
    525         fGraph->GetYaxis()->SetTitle("Acceptance Gammas");
    526         fGraph->SetMarkerStyle(kFullDotSmall);
     469    if ((h=fGraph->GetHistogram()))
     470    {
     471        h->GetXaxis()->SetRangeUser(0, 1);
     472        h->SetXTitle("Acceptance Hadrons");
     473        h->SetYTitle("Acceptance Gammas");
    527474        fGraph->Draw("P");
    528475        gPad->Modified();
  • trunk/MagicSoft/Mars/mhist/MHHadronness.h

    r1910 r1968  
    2626    TGraph *fGraph;   //-> gamma acceptance vs. hadron acceptance
    2727
     28    void Paint(Option_t *opt="");
     29    void CalcGraph(Double_t sumg, Double_t sump);
     30
    2831public:
    2932    MHHadronness(Int_t nbins=100, const char *name=NULL, const char *title=NULL);
     
    4851
    4952    void Draw(Option_t *opt="");
    50     TObject *DrawClone(Option_t *opt="") const;
    5153
    5254    ClassDef(MHHadronness, 1) // Gamma/Hadron Separation Quality Histograms
Note: See TracChangeset for help on using the changeset viewer.