Logo coherent WaveBurst  
Library Reference Guide
Logo
DrawFitsGraceDB.C
Go to the documentation of this file.
1 //
2 // This example show how to display skymap probability from fits file
3 // Author : Gabriele Vedovato
4 //
5 // Ex : root 'DrawFitsGraceDB.C("skyprobcc.fits","_skymap",true,false)'
6 
7 //#define COORDINATES "cWB"
8 //#define COORDINATES "Geographic"
9 #define COORDINATES "Celestial"
10 
11 //#define PROJECTION ""
12 #define PROJECTION "hammer"
13 //#define PROJECTION "sinusoidal"
14 
15 #define GRACEDB_LABEL "GXXXXXX"
16 #define EM_LABEL "EM_FOLLOWUP"
17 #define EM_PHI 360.-65.5
18 #define EM_THETA -82.06
19 
20 void DrawFitsGraceDB(TString fitsName, TString label="", bool cumulative=false, bool save=false) {
21 
22  gskymap* gSM = new gskymap((char*)fitsName.Data());
23 
24  int L = gSM->size(); // number of pixels in the sphere
25  double pi = TMath::Pi();
26  double S = 4*pi*pow(180/pi,2); // solid angle of a sphere
27  double dS = S/L; // solid angle of a pixel
28 
29  if(cumulative) {
30 
31  double cumul=0;
32  int L=gSM->size();
33  int* index = new int[L]; // sorted index
34  double* prob = new double[L]; // probability array
35  for(int l=0;l<L;l++) { // loop over the sky grid
36  prob[l] = gSM->get(l); // get skymap prob
37  }
38 
39  TMath::Sort(L,prob,index,false); // sort prob
40  cumul=0;
41  for(int l=0;l<L;l++) { // loop over the sky grid
42  int m=index[l]; // sorted index
43  double dec = gSM->getTheta(m); // get dec
44  double ra = gSM->getPhi(m); // get ra
45  cumul+=prob[m];
46  gSM->set(m,cumul); // set !=0 to force dark blue background
47 /*
48  if(prob[index[l]]>0) {
49  cout << m << "\tdec : " << dec << "\tra : " << ra << "\tprob : "
50  << prob[m] << "\tcumul prob : " << cumul << endl;
51  }
52 */
53  }
54  if(label!="") {
56  tag.ReplaceAll("_"," ");
57  gSM->SetTitle(TString::Format("%s : SkyMap Cumulative Probability Distribution (%s)",GRACEDB_LABEL,tag.Data()));
58  } else {
59  gSM->SetTitle(TString::Format("%s : SkyMap Cumulative Probability Distribution",GRACEDB_LABEL));
60  }
61  } else {
62  if(label!="") {
64  tag.ReplaceAll("_"," ");
65  gSM->SetTitle(TString::Format("%s : SkyMap Probability Distribution (%s)",GRACEDB_LABEL,tag.Data()));
66  } else {
67  gSM->SetTitle(TString::Format("%s : SkyMap Probability Distribution",GRACEDB_LABEL));
68  }
69  gSM->SetZaxisTitle("prob. per deg^{2}");
70  }
71 
72  for(int l=0;l<L;l++) { // loop over the sky grid
73  double P = gSM->get(l); // get probability per pixel
74  P/=dS; // normalize probability to prob per deg^2
75  if(P==0) gSM->set(l,1e-40); // set !=0 to force dark blue background
76  }
77 
78 
80  gSM->Draw(57);
81 
82  //gSM->DrawMarker(EM_PHI,EM_THETA,29,2.5,kWhite);
83  //gSM->DrawMarker(EM_PHI,EM_THETA,30,2.5,kBlack);
84 
85  //gSM->DrawMarker(EM_PHI,EM_THETA,30,2.0,kWhite);
86  //gSM->DrawText(EM_PHI-10,EM_THETA+10, EM_LABEL, 0.04, kWhite);
87 
88  //gSM->DrawMarker(EM_PHI,EM_THETA,30,2.0,kBlack);
89  //gSM->DrawText(EM_PHI-10,EM_THETA+10, EM_LABEL, 0.04, kWhite);
90 
91  if(save) {
92  if(cumulative) {
93  gSM->Print(TString::Format("%s_cumulative_probability_skymap%s.png",GRACEDB_LABEL,label.Data()));
94  } else {
95  gSM->Print(TString::Format("%s_probability_skymap%s.png",GRACEDB_LABEL,label.Data()));
96  }
97  exit(0);
98  }
99 }
gskymap * gSM
TString("c")
void set(size_t i, double a)
Definition: gskymap.hh:128
double getTheta(size_t i)
Definition: skymap.hh:224
void Draw(int dpaletteId=1, Option_t *option="colfz")
Definition: gskymap.cc:460
int m
Definition: cwb_net.C:28
double pi
Definition: TestChirp.C:18
double ra
Definition: ConvertGWGC.C:46
#define GRACEDB_LABEL
#define PROJECTION
TString label
Definition: MergeTrees.C:21
double Pi
int l
double e
char tag[256]
Definition: cwb_merge.C:92
void SetTitle(TString title)
Definition: gskymap.hh:152
double getPhi(size_t i)
Definition: skymap.hh:164
wavearray< int > index
Meyer< double > S(1024, 2)
double get(size_t i)
param: sky index
Definition: skymap.cc:699
#define COORDINATES
bool save
void DrawFitsGraceDB(TString fitsName, TString label="", bool cumulative=false, bool save=false)
size_t size()
Definition: skymap.hh:136
void Print(TString pname)
Definition: gskymap.cc:1122
void SetOptions(TString projection="hammer", TString coordinate="Geographic", double resolution=1, bool goff=false)
Definition: gskymap.cc:84
void SetZaxisTitle(TString zAxisTitle)
Definition: gskymap.hh:150
exit(0)