Changeset 8185 for trunk/MagicSoft/Mars/mhflux
- Timestamp:
- 11/01/06 08:29:46 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mhflux
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc
r8106 r8185 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MHFalseSource.cc,v 1.2 0 2006-10-17 17:16:00tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MHFalseSource.cc,v 1.21 2006-11-01 08:29:45 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 121 121 #include <TF2.h> 122 122 #include <TH2.h> 123 #include <TLatex.h> 123 124 #include <TGraph.h> 124 125 #include <TStyle.h> 125 126 #include <TCanvas.h> 126 127 #include <TRandom.h> 128 #include <TEllipse.h> 127 129 #include <TPaveText.h> 128 130 #include <TStopwatch.h> … … 640 642 // source plot. 641 643 // 642 TObject *MHFalseSource::GetCatalog() 643 { 644 const Double_t maxr = 0.98*TMath::Abs(fHist.GetBinCenter(1));644 TObject *MHFalseSource::GetCatalog() const 645 { 646 const Double_t maxr = TMath::Abs(fHist.GetBinLowEdge(1))*TMath::Sqrt(2); 645 647 646 648 // Create catalog... … … 1251 1253 } 1252 1254 } 1255 1256 void 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 } -
trunk/MagicSoft/Mars/mhflux/MHFalseSource.h
r7188 r8185 46 46 Double_t fDec; 47 47 48 TObject *GetCatalog() ;48 TObject *GetCatalog() const; 49 49 void MakeSymmetric(TH1 *h); 50 50 … … 87 87 } 88 88 89 void DrawNicePlot() const; //*MENU* 90 89 91 // MParContainer 90 92 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
Note:
See TracChangeset
for help on using the changeset viewer.