Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_draw_antpat.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 // draw the network antenna pattern (read config from the user_parameters.C file) : used with the cwb_draw_antpat
20 {
21 
22  #define RESOLUTION 2
23  #define COORDINATES "Geographic"
24  #define WORLD_MAP_DIR "$CWB_GWAT/data/"
25 
26  // polarization=0 -> |Fx| DPF
27  // polarization=1 -> |F+| DPF
28  // polarization=2 -> |Fx|/|F+| DPF
29  // polarization=3 -> sqrt((|F+|^2+|Fx|^2)/nIFO) DPF
30  // polarization=4 -> |Fx|^2 DPF
31  // polarization=5 -> |F+|^2 DPF
32  // polarization=6 -> Fx only with 1 detector
33  // polarization=7 -> F+ only with 1 detector
34  // polarization=8 -> F1x/F2x only with 2 detectors
35  // polarization=9 -> F1+/F2+ only with 2 detectors
36  // polarization=10 -> sqrt(|F1+|^2+|F1x|^2)/sqrt(|F2+|^2+|F2x|^2) only with 2 detectors
37  // polarization=11 -> The same as (10) but averaged over psi only with 2 detectors
38 
39 
40  bool save_plot=false;
41  int polarization=3;
42  if(gSystem->Getenv("CWB_ANTPAT_POLARIZATION")!=NULL) {
43  TString cwb_antpat_polarization=TString(gSystem->Getenv("CWB_ANTPAT_POLARIZATION"));
44  if(cwb_antpat_polarization.CompareTo("")!=0) {
45  if(!cwb_antpat_polarization.IsFloat()) {cout<< "Error : CWB_ANTPAT_POLARIZATION is not a number" << endl;exit(1);}
46  polarization=cwb_antpat_polarization.Atoi();
47  }
48  }
49  if(gSystem->Getenv("CWB_ANTPAT_SAVE_PLOT")!=NULL) {
50  TString cwb_save_plot=TString(gSystem->Getenv("CWB_ANTPAT_SAVE_PLOT"));
51  if(cwb_save_plot.CompareTo("")!=0) {
52  if(!cwb_save_plot.IsFloat()) {cout<< "Error : CWB_ANTPAT_SAVE_PLOT is not a number" << endl;exit(1);}
53  if((cwb_save_plot.Atoi()==0)||(cwb_save_plot.Atoi()==1)) save_plot=cwb_save_plot.Atoi();
54  }
55  }
57  if(gSystem->Getenv("CWB_ANTPAT_PROJECTION")!=NULL) {
58  cwb_antpat_projection=TString(gSystem->Getenv("CWB_ANTPAT_PROJECTION"));
59  if(cwb_antpat_projection.Contains("rect")) cwb_antpat_projection="";
60  }
61 
62  double rad2deg = 180./TMath::Pi();
63  double deg2rad = TMath::Pi()/180.;
64 
66 
67  gskymap* gSM = gNET->GetGskymap();
68  gSM->SetOptions(cwb_antpat_projection,COORDINATES,RESOLUTION/2);
69 
71  for(int n=0; n<nIFO; n++) ifos[n]=ifo[n];
72  char ifostr[64]="";
73  for(int n=0; n<nIFO; n++) sprintf(ifostr,"%s %s",ifostr,ifo[n]);
74  cout << "Network : " << ifostr << endl;
75 
76  TString world_map = gSystem->ExpandPathName(WORLD_MAP_DIR);
77  gSM->SetWorldMapPath(world_map.Data());
78  gSM->SetWorldMap();
79 
80  TH2D* h2 = (TH2D*)gSM->GetHistogram();
81  h2->GetXaxis()->SetTitleSize(0.05);
82  h2->GetXaxis()->SetLabelSize(0.05);
83  h2->GetYaxis()->SetTitleSize(0.05);
84  h2->GetYaxis()->SetLabelSize(0.05);
85  h2->GetYaxis()->SetLabelFont(42);
86  h2->GetYaxis()->SetLabelFont(42);
87  h2->GetXaxis()->SetTitleFont(42);
88  h2->GetYaxis()->SetTitleFont(42);
89 
90  if(nIFO>1) h2->GetZaxis()->SetRangeUser(0,1.0);
91  else h2->GetZaxis()->SetRangeUser(0,1.0);
92 
93  if(polarization==2) h2->GetZaxis()->SetRangeUser(0,1.0);
94 
95  detector* pD[3];
96  for(int i=0; i<nIFO; i++) pD[i] = new detector(ifo[i]); // built in detector
97  for(int i=0; i<nIFO; i++) gNET->add(pD[i]);
98 
99  int palette = 0;
100  bool btitle = true;
101  gNET->DrawAntennaPattern(polarization,palette,btitle);
102  gNET->DrawSites(kBlack,2.0);
103  gNET->DrawSitesArms(1000000,kWhite,3.0);
104  gNET->DrawSitesShortLabel(kBlack);
105 
106  if(save_plot) {
107  char ofName[256];
108  sprintf(ofName,"%s/AntPat_%s",dump_dir,data_label);
109 
110  if(polarization==0) sprintf(ofName,"%s%s.png",ofName,"_Fc");
111  if(polarization==1) sprintf(ofName,"%s%s.png",ofName,"_Fp");
112  if(polarization==2) sprintf(ofName,"%s%s.png",ofName,"_Fc_over_Fp");
113  if(polarization==3) sprintf(ofName,"%s%s.png",ofName,"_Sqrt_Fp2_plus_Fc2");
114 
115  cout << "Write : " << ofName << endl;
116  gSM->Print(ofName);
117  exit(0);
118  }
119 }
120 
TH2D * GetHistogram()
Definition: gskymap.hh:138
gskymap * gSM
TString ofName
gnetwork * gNET
size_t add(detector *)
param: detector structure return number of detectors in the network
Definition: network.cc:2559
void DrawSitesArms(double mlength=600000., Color_t lcolor=kBlack, Size_t lwidth=1.0, Style_t lstyle=1)
Definition: gnetwork.cc:314
void DrawAntennaPattern(int polarization=-1, int dpaletteId=0, bool btitle=true, int order=6)
Definition: gnetwork.cc:674
int n
Definition: cwb_net.C:28
#define COORDINATES
TString("c")
int palette
Definition: DrawGnetwork2.C:17
char ifostr[64]
int polarization
i drho i
char ifo[NIFO_MAX][8]
#define nIFO
TString world_map
Definition: DrawGNET.C:16
char data_label[512]
Definition: test_config1.C:160
void DrawSitesShortLabel(Color_t tcolor=kBlack, Size_t tsize=0.052, Font_t tfont=32)
Definition: gnetwork.cc:426
#define RESOLUTION
double deg2rad
double Pi
void DrawSites(Color_t mcolor=kBlack, Size_t msize=2.0, Style_t mstyle=20)
Definition: gnetwork.cc:257
void SetWorldMapPath(TString worldMapPath)
Definition: gskymap.hh:156
TString cwb_antpat_projection
#define WORLD_MAP_DIR
double rad2deg
gskymap * GetGskymap()
Definition: gnetwork.hh:44
void SetWorldMap(bool drawWorldMap=true)
Definition: gskymap.hh:154
char dump_dir[512]
Definition: test_config1.C:156
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
bool btitle
Definition: DrawGnetwork2.C:16
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
detector ** pD
TString ifos[60]
exit(0)