1 #include "AntarcticaMapPlotter.h" 10 initializeInternals();
24 initializeInternals();
39 std::map<TString, TH2D*>::iterator histItr;
40 for(histItr=hists.begin(); histItr != hists.end(); ++histItr){
41 delete histItr->second;
43 std::map<TString, TGraph*>::iterator grItr;
44 for(grItr=grs.begin(); grItr != grs.end(); ++grItr){
58 void AntarcticaMapPlotter::initializeInternals(){
62 TString mapName =
"antarcticaMosaic.png";
67 if(mapName==
"antarcticaMosaic.png"){
69 RadiusOfEarth=6378.1e3;
73 scale=265/2.19496e+06;
79 RadiusOfEarth=6378.1e3;
84 scale=271.5/2.19496e+06;
90 const char* anitaUtilInstallDir = getenv(
"ANITA_UTIL_INSTALL_DIR");
92 TString mapFileName = TString::Format(
"%s/share/anitaMap/%s", anitaUtilInstallDir, mapName.Data());
93 img = TImage::Open(mapFileName);
95 img->SetConstRatio(kFALSE);
98 std::cerr <<
"Warning in " << __FILE__ <<
"! Unable to open " << mapFileName.Data()
99 <<
", check ANITA_UTIL_INSTALL_DIR environment variable is correctly set" << std::endl;
118 void AntarcticaMapPlotter::getRelXYFromLatLong(Double_t latitude, Double_t longitude,Double_t &x, Double_t &y){
123 Double_t absLat=TMath::Abs(latitude);
124 Double_t r=RadiusOfEarth*TMath::Cos((90.-TrueScaleLat)*TMath::DegToRad())*TMath::Tan((90-absLat)*TMath::DegToRad());
125 y=r*TMath::Cos(longitude*TMath::DegToRad());
126 x=r*TMath::Sin(longitude*TMath::DegToRad());
155 getRelXYFromLatLong(latitude, longitude, x, y);
156 return hCurrent->Fill(x, y, weight);
170 TString canName = TString::Format(
"can%s", hCurrent->GetName());
171 TString canTitle = TString::Format(
"Canvas of %s", hCurrent->GetTitle());
172 TCanvas* can =
new TCanvas(canName, canTitle, (Int_t) xSize, (Int_t) ySize);
174 can->SetTopMargin(0.03);
175 can->SetBottomMargin(0.03);
176 can->SetLeftMargin(0.03);
177 can->SetRightMargin(0.15);
181 hCurrent->Draw(opt +
"same");
196 TString canName = TString::Format(
"can%s", grCurrent->GetName());
197 TString canTitle = TString::Format(
"Canvas of %s", grCurrent->GetTitle());
198 TCanvas* can =
new TCanvas(canName, canTitle, (Int_t) xSize, (Int_t) ySize);
200 can->SetTopMargin(0.03);
201 can->SetBottomMargin(0.03);
202 can->SetLeftMargin(0.03);
203 can->SetRightMargin(0.15);
207 grCurrent->Draw(opt +
"same");
224 std::map<TString, TH2D*>::iterator histItr = hists.find(name);
225 Int_t successState = 0;
226 if(histItr == hists.end()){
230 hCurrent = histItr->second;
252 TH2D* theHist =
new TH2D(name, title, nBinsX, 0, 1, nBinsY, 0, 1);
253 hists[name] = theHist;
257 std::cerr <<
"Warning in " << __FILE__ <<
"! Histogram with name " << name.Data() <<
", already exists!" << std::endl;
277 Double_t* latitudes, Double_t* longitudes){
280 std::vector<Double_t> xs(n);
281 std::vector<Double_t> ys(n);
282 for(Int_t i=0; i<n; i++){
283 getRelXYFromLatLong(latitudes[i], longitudes[i], xs[i], ys[i]);
285 TGraph* theGraph =
new TGraph(n, &xs[0], &ys[0]);
287 theGraph->SetName(name);
288 theGraph->SetTitle(title);
289 grs[name] = theGraph;
290 grCurrent = theGraph;
293 std::cerr <<
"Warning in " << __FILE__ <<
"! TGraph with name " 294 << name.Data() <<
", already exists!" << std::endl;
296 std::cerr <<
"No points added to " << name.Data() <<
"!" << std::endl;
315 std::map<TString, TGraph*>::iterator grItr = grs.find(name);
316 Int_t successState = 0;
317 if(grItr == grs.end()){
321 grCurrent = grItr->second;
TH2D * getCurrentHistogram()
Return pointer to current histogram.
void DrawTGraph(TString opt)
Draws the canvas, image and histogram.
Int_t setCurrentTGraph(TString name)
Sets the current histrogram pointer* hCurrent.
TGraph * getCurrentTGraph()
Return pointer to current TGraph.
void DrawHist(TString opt)
Draws the canvas, image and histogram.
Class to plot reconstructed events onto a picture of Antarctica.
Int_t Fill(Double_t latitude, Double_t longitude, Double_t weight=1)
How to fill the histogram, converts latitude and longitude into x/y bins first.
Int_t setCurrentHistogram(TString name)
Sets the current histogram pointer* hCurrent.
void addHistogram(TString name, TString title, Int_t nBinsX, Int_t nBinsY)
Creates a new histogram to go in the internal map and sets it as the current histogram.
void addTGraph(TString name, TString title, Int_t n=0, Double_t *latitude=NULL, Double_t *longitude=NULL)
Creates a new graph to go in the internal map and sets it as the current histogram.
AntarcticaMapPlotter()
Constructor.
~AntarcticaMapPlotter()
Destructor.