From 4868b6f3a993134bb378dd2f970aafd2962e22c9 Mon Sep 17 00:00:00 2001 From: mingf2 <fm140905@gmail.com> Date: Fri, 14 May 2021 20:37:38 -0500 Subject: [PATCH] update marker --- .gitignore | 3 ++- .vscode/c_cpp_properties.json | 4 ++-- Headers/draw.h | 8 +++++-- Headers/setup.h | 2 +- Sources/draw.cpp | 41 ++++++++++++++++++++++++++++++----- Sources/main.cpp | 3 ++- 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index c795b05..b68c223 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -build \ No newline at end of file +build +.vscode/* \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index fa67db6..4a3ed5d 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,8 +4,8 @@ "name": "Linux", "includePath": [ "${workspaceFolder}/**", - "/home/ming/root/include", - "/home/ming/root/lib" + "/home/mingf2/root/include", + "/home/mingf2/root/lib" ], "defines": [], "compilerPath": "/usr/bin/gcc", diff --git a/Headers/draw.h b/Headers/draw.h index f464978..829290c 100644 --- a/Headers/draw.h +++ b/Headers/draw.h @@ -3,14 +3,18 @@ #include <iostream> #include "TCanvas.h" +#include "TMath.h" #include "TH2F.h" #include "TGraph.h" #include "TStyle.h" -#include "TEllipse.h" +// #include "TEllipse.h" +#include "TMarker.h" #include "../Headers/setup.h" int Backprojection(const Setup& config, const std::vector<Cone>& cones, std::vector<std::vector<double>>& image); -int drawImage(const Setup& config, const std::vector<std::vector<double>>& image); \ No newline at end of file +int drawImage(const Setup& config, const std::vector<std::vector<double>>& image); + +int aitoff2xy(const double& l, const double& b, double &Al, double &Ab); \ No newline at end of file diff --git a/Headers/setup.h b/Headers/setup.h index b8081a1..62fa497 100644 --- a/Headers/setup.h +++ b/Headers/setup.h @@ -70,7 +70,7 @@ public: int pixelateSphere(); // simulation setup - const int nCones= 1000; + const int nCones= 100; double trueTheta; double truePhi; Vector3D trueSource; diff --git a/Sources/draw.cpp b/Sources/draw.cpp index 97fe265..4fd033b 100644 --- a/Sources/draw.cpp +++ b/Sources/draw.cpp @@ -124,13 +124,42 @@ int drawImage(const Setup& config, const std::vector<std::vector<double>>& image // // el1->Draw("SAME"); // draw source 2 - double sigma = 5; - TEllipse* el2 = new TEllipse(config.truePhi / conv, config.trueTheta / conv, sigma, sigma); - el2->SetFillColor(0); - el2->SetFillStyle(0); - el2->SetLineColor(4); - el2->Draw("SAME"); + // double sigma = 5; + // TEllipse* el2 = new TEllipse(config.truePhi / conv, config.trueTheta / conv, sigma, sigma); + // el2->SetFillColor(0); + // el2->SetFillStyle(0); + // el2->SetLineColor(4); + // el2->Draw("SAME"); + + // draw source in aitoff + double Ax, Ay; + aitoff2xy(config.truePhi / conv, config.trueTheta / conv, Ax, Ay); + TMarker *marker = new TMarker(Ax, Ay, 24); + // marker->SetMarkerColorAlpha(kBlue, 0.0); + marker->Draw("SAME"); + canvas->Draw(); return 0; +} + +int aitoff2xy(const double& l, const double& b, double &Al, double &Ab) +{ + Double_t x, y; + + Double_t alpha2 = (l/2)*TMath::DegToRad(); + Double_t delta = b*TMath::DegToRad(); + Double_t r2 = TMath::Sqrt(2.); + Double_t f = 2*r2/TMath::Pi(); + Double_t cdec = TMath::Cos(delta); + Double_t denom = TMath::Sqrt(1. + cdec*TMath::Cos(alpha2)); + x = cdec*TMath::Sin(alpha2)*2.*r2/denom; + y = TMath::Sin(delta)*r2/denom; + x *= TMath::RadToDeg()/f; + y *= TMath::RadToDeg()/f; + // x *= -1.; // for a skymap swap left<->right + Al = x; + Ab = y; + + return 0; } \ No newline at end of file diff --git a/Sources/main.cpp b/Sources/main.cpp index 34cde31..e0f3b80 100644 --- a/Sources/main.cpp +++ b/Sources/main.cpp @@ -14,7 +14,8 @@ int main(int argc, char** argv) { const Setup config(10); // simulate some cones std::vector<Cone> cones; - std::srand(std::time(nullptr)); + // std::srand(std::time(nullptr)); + std::srand(0); // for (int i = 0; i < 10; i++) for (int i = 0; i < config.nCones; i++) { -- GitLab