Ignore:
Timestamp:
11/01/06 08:29:46 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc

    r8106 r8185  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MHFalseSource.cc,v 1.20 2006-10-17 17:16:00 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MHFalseSource.cc,v 1.21 2006-11-01 08:29:45 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    121121#include <TF2.h>
    122122#include <TH2.h>
     123#include <TLatex.h>
    123124#include <TGraph.h>
    124125#include <TStyle.h>
    125126#include <TCanvas.h>
    126127#include <TRandom.h>
     128#include <TEllipse.h>
    127129#include <TPaveText.h>
    128130#include <TStopwatch.h>
     
    640642// source plot.
    641643//
    642 TObject *MHFalseSource::GetCatalog()
    643 {
    644     const Double_t maxr = 0.98*TMath::Abs(fHist.GetBinCenter(1));
     644TObject *MHFalseSource::GetCatalog() const
     645{
     646    const Double_t maxr = TMath::Abs(fHist.GetBinLowEdge(1))*TMath::Sqrt(2);
    645647
    646648    // Create catalog...
     
    12511253    }
    12521254}
     1255
     1256void MHFalseSource::DrawNicePlot() const
     1257{
     1258    Int_t newc = kTRUE;
     1259    Float_t zoom = 0.95;
     1260    Int_t col = kBlue+180;
     1261
     1262    if (!newc && !fDisplay)
     1263        return;
     1264
     1265    TH1 *h = dynamic_cast<TH1*>(FindObjectInPad("Alpha_yx_on"));
     1266    if (!h)
     1267        return;
     1268
     1269    // Open and setup canvas/pad
     1270    TCanvas &c = newc ? *new TCanvas("Excess", "Excess Plot", TMath::Nint(500.), TMath::Nint(500*0.77/0.89)) : fDisplay->AddTab("ThetsSq");
     1271
     1272    //c.SetPad(0.15, 0, 0.90, 1);
     1273
     1274    c.SetBorderMode(0);
     1275    c.SetFrameBorderMode(0);
     1276    c.SetFillColor(kWhite);
     1277
     1278    c.SetLeftMargin(0.11);
     1279    c.SetRightMargin(0.12);
     1280    c.SetBottomMargin(0.10);
     1281    c.SetTopMargin(0.01);
     1282
     1283    TH1 *h1 = (TH1*)h->Clone("");
     1284    h1->SetDirectory(0);
     1285    h1->SetTitle("");
     1286    h1->SetContour(99);
     1287    h1->SetBit(TH1::kNoStats);
     1288    h1->SetBit(TH1::kCanDelete);
     1289
     1290    if (h1->FindObject("stats"))
     1291        delete h1->FindObject("stats");
     1292
     1293    TAxis &x = *h1->GetXaxis();
     1294    TAxis &y = *h1->GetYaxis();
     1295    TAxis &z = *h1->GetZaxis();
     1296
     1297    x.SetRangeUser(-zoom, zoom);
     1298    y.SetRangeUser(-zoom, zoom);
     1299
     1300    x.SetTitleOffset(1.1);
     1301    y.SetTitleOffset(1.3);
     1302
     1303    x.SetTickLength(0.025);
     1304    y.SetTickLength(0.025);
     1305
     1306    x.SetAxisColor(kWhite);
     1307    y.SetAxisColor(kWhite);
     1308
     1309    x.CenterTitle();
     1310    y.CenterTitle();
     1311
     1312    x.SetTitle("Offset [#circ]");
     1313    y.SetTitle("Offset [#circ]");
     1314
     1315    x.SetDecimals();
     1316    y.SetDecimals();
     1317    z.SetDecimals();
     1318
     1319    MH::SetPalette("glowsym", 99);
     1320
     1321    const Float_t max = TMath::Max(h1->GetMinimum(), h1->GetMaximum());
     1322
     1323    h1->SetMinimum(-max);
     1324    h1->SetMaximum(max);
     1325
     1326    h1->Draw("colz");
     1327
     1328    // ------
     1329    // Convert pave coordinates from NDC to Pad coordinates.
     1330
     1331    gPad->Update();
     1332
     1333    Float_t x0 = 0.80;
     1334    Float_t y0 = 0.88;
     1335
     1336    Double_t dx  = gPad->GetX2() - gPad->GetX1();
     1337    Double_t dy  = gPad->GetY2() - gPad->GetY1();
     1338
     1339    // Check if pave initialisation has been done.
     1340    // This operation cannot take place in the Pave constructor because
     1341    // the Pad range may not be known at this time.
     1342    Float_t px = gPad->GetX1() + x0*dx;
     1343    Float_t py = gPad->GetY1() + y0*dy;
     1344    // -------
     1345
     1346    TEllipse *el = new TEllipse(px, py, 0.12, 0.12, 0, 360, 0);
     1347    el->SetFillStyle(4100);
     1348    el->SetFillColor(kBlack);
     1349    el->SetLineWidth(2);
     1350    el->SetLineColor(kWhite);
     1351    el->SetBit(kCanDelete);
     1352    el->Draw();
     1353
     1354    TString str1("el.SetX1(gPad->GetX1()+0.9*(gPad->GetX2()-gPad->GetX1()));");
     1355    TString str2("el.SetY1(gPad->GetY1()+0.9*(gPad->GetY2()-gPad->GetY1()));");
     1356
     1357    str1.ReplaceAll("el.", Form("((TEllipse*)%p)->", el));
     1358    str2.ReplaceAll("el.", Form("((TEllipse*)%p)->", el));
     1359
     1360    str1.ReplaceAll("0.9", Form("%f", x0));
     1361    str2.ReplaceAll("0.9", Form("%f", y0));
     1362
     1363    TLatex tex;
     1364    tex.SetBit(TText::kTextNDC);
     1365    tex.SetTextColor(kWhite);
     1366    tex.SetTextAlign(22);
     1367    tex.SetTextSize(0.04);
     1368    tex.SetTextAngle(0);
     1369    tex.DrawLatex(x0, y0, "psf");
     1370
     1371    TPad *pad = new TPad("pad", "Catalog Pad",
     1372                         c.GetLeftMargin(), c.GetBottomMargin(),
     1373                         1-c.GetRightMargin(), 1-c.GetTopMargin());
     1374
     1375    pad->SetFillStyle(4000);
     1376    pad->SetFillColor(kBlack);
     1377    pad->SetBorderMode(0);
     1378    pad->SetFrameBorderMode(0);
     1379    pad->SetBit(kCanDelete);
     1380    pad->Draw();
     1381
     1382    pad->Range(x.GetBinLowEdge(x.GetFirst()),
     1383               y.GetBinLowEdge(y.GetFirst()),
     1384               x.GetBinLowEdge(x.GetLast()+1),
     1385               y.GetBinLowEdge(y.GetLast()+1));
     1386
     1387    TString str3("pad->Range(x.GetBinLowEdge(x.GetFirst()),"
     1388                 "y.GetBinLowEdge(y.GetFirst()),"
     1389                 "x.GetBinLowEdge(x.GetLast()+1),"
     1390                 "y.GetBinLowEdge(y.GetLast()+1));");
     1391
     1392    str3.ReplaceAll("x.", Form("((TAxis*)%p)->", &x));
     1393    str3.ReplaceAll("y.", Form("((TAxis*)%p)->", &y));
     1394    // str3.ReplaceAll("pad", Form("((TPad*)(%p))", pad));
     1395
     1396    c.AddExec("SetPosX", str1);
     1397    c.AddExec("SetPosY", str2);
     1398    c.AddExec("Resize",  str3);
     1399
     1400    pad->cd();
     1401    gROOT->SetSelectedPad(0);
     1402
     1403    MAstroCatalog *cat = (MAstroCatalog*)GetCatalog();
     1404
     1405    cat->GetAttLineSky().SetLineColor(col);
     1406    cat->GetAttLineSky().SetLineWidth(2);
     1407    cat->GetAttLineSky().SetLineStyle(7);
     1408
     1409    cat->GetList()->Clear();
     1410    cat->SetBit(kCanDelete);
     1411    //    cat->AddObject(MAstro::Hms2Hor(12,17,52)*TMath::Pi()/12, TMath::DegToRad()*MAstro::Dms2Deg(30,7,0),   6, "1ES1215+303");
     1412    //    cat->AddObject(MAstro::Hms2Hor(12,18,27)*TMath::Pi()/12, TMath::DegToRad()*MAstro::Dms2Deg(29,48,46), 6, "Mrk766");
     1413
     1414    cat->Draw("mirror same");
     1415
     1416    /*
     1417     Int_t col = kBlue+180;
     1418
     1419     TLatex tex;
     1420     tex.SetTextColor(col);
     1421     tex.SetTextAlign(21);
     1422     tex.SetTextSize(0.04);
     1423     tex.DrawLatex(-0.79, -0.8, "43.0\\circ");
     1424     tex.DrawLatex(-0.78,  0.2, "42.0\\circ");
     1425
     1426     tex.SetTextAngle(-90);
     1427     tex.DrawLatex(-0.45, -0.55, "22.00h");
     1428     tex.DrawLatex( 0.30, -0.55, "22.07h");
     1429     */
     1430}
Note: See TracChangeset for help on using the changeset viewer.