Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AnalyzeSkyProb.C
Go to the documentation of this file.
1 //
2 // This example show how to read/analyze skymap probability produced by CWB_Plugin_SkyProb.C plugin
3 // Author : Gabriele Vedovato
4 
5 {
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 EC_THR 0.5 // Euler Characteristic Threshold
16  //#define DISPLAY_SKYMAP // display skyprob skymap
17  //#define ANTENNA_PATTERN // tests with antenna pattern
18  //#define EC_HIST // display Euler Characteristic histogram
19  //#define FILL_HOLE // fill hole with the average of 8 neighbors pixels
20  //#define SKYPROB_HIS // display skyprob values @ injection dir histogram
21 
22  #include <vector>
23 
24  // read cwb parameters file
26  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
27  TString cwb_parameter_name = gSystem->Getenv("CWB_PARAMETERS_FILE");
28  gROOT->Macro(cwb_parameter_name);
29 
30  // define an alternative output_dir
31  strcpy(output_dir,"data");
32 
33  // read root file list from output directory
34  vector<TString> fileList = TB.getFileListFromDir(output_dir, ".root", "wave_");
35  if(fileList.size()==0) {
36  cout << "No root files in the directory : " << output_dir << endl;
37  gSystem->Exit(1);
38  }
39 
40 #ifdef EC_HIST
41  TH1F* hec = new TH1F("hec","hec",50,0,10);
42 #endif
43 #ifdef SKYPROB_HIST
44  TH1F* hskyprob = new TH1F("hskyprob","hskyprob",50,0,1);
45 #endif
46 
47  for(int n=0;n<fileList.size();n++) { // loop over the root output files
48 
49  cout << n << " " << fileList[n].Data() << endl;
50  netevent event(fileList[n].Data()); // open wave root file
51  int nevt = event.GetEntries(); // get number of detected events
52  if(nevt==0) continue;
53  else cout << "nevt : " << nevt << endl;
54 
55  // get number of ifos (nIFO) and ifo name list
56  TList* ifoList = event.fChain->GetUserInfo();
57  detectorParams dParams[NIFO_MAX];
58  int nIFO=ifoList->GetSize();
60  for (int k=0;k<nIFO;k++) {
61  detector* pDetector = (detector*)ifoList->At(k);
62  dParams[k] = pDetector->getDetectorParams();
63  IFO[k]=dParams[k].name;
64  cout << dParams[k].name << endl;
65  //pDetector->print(); // print detector infos
66  }
67  gnetwork* gNET = new gnetwork(nIFO,IFO);
68 
70 
71  for(int m=0;m<nevt;m++) { // loop over the detected events
72  event.GetEntry(m); // load event #n
73  skymap* Psm = event.Psm; // probability skymap
74  if(Psm->size()!=0) {
75  if(Psm->getType()==1) { // check if it is healpix
76  if(fabs(event.time[0]-event.time[nIFO])<0.1) { // filter output events
77 
78  gskymap* gSM = new gskymap(*(event.Psm));
79 
80 #ifdef FILL_HOLE
81  for(int l=0;l<Psm->size();l++) {
82  index = Psm->neighbors(l);
83  int M=0;double a=0;
84  for(int k=0;k<index.size();k++) if(Psm->get(index[k])) {M++;a+=Psm->get(index[k]);}
85  if(M) a/=M; // average
86  if(M==8) gSM->set(l,a); // fill hole with the average of 8 neighbors pixels
87  }
88 #endif
89 
90  int ec = gSM->getEulerCharacteristic(EC_THR); // compute the euler characteristic
91  cout << n << " " << m << " EC -> " << ec << " erA[0] -> " << event.erA[0] << endl;
92 #ifdef EC_HIST
93  hec->Fill(ec);
94 #endif
95 
96 #ifdef DISPLAY_SKYMAP
97  gStyle->SetPalette(1);
99  char title[256];
100  sprintf(title,"probability skymap gps = %d",int(event->time[0]));
101  gSM->SetTitle(title);
102  //gSM->GetHistogram()->GetZaxis()->SetRangeUser(TH, 1.);
103  //for(int l=0;l<gSM->size();l++) if(gSM->get(l)<=EC_THR) gSM->set(l,0); else gSM->set(l,1);
104  for(int l=0;l<gSM->size();l++) if(gSM->get(l)<=EC_THR) gSM->set(l,0); // set to 0 the pixels < EX_THR
105 
106 #ifdef ANTENNA_PATTERN
107 ` // check the sky antenna pattern
108  for(int l=0;l<gSM->size();l++) {
109  double theta = gSM->getTheta(l);
110  double phi = gSM->getPhi(l);
111  int polarization=2; // |Fx|/|F+| DPF
112  double ac = gNET->GetAntennaPattern(phi,theta,0,polarization);
113  //gSM->set(l,ac);
114  //if(ac<0.2) gSM->set(l,ac); else gSM->set(l,0);
115  if(ac<0.1) gSM->set(l,0);
116  }
117 #endif
118 
119  gSM->Draw(); // draw skymap
120  double RA = event->phi[1];
121  double DEC = event->theta[1];
122  gSM->DrawMarker(RA,DEC, 29, 1.5, kBlack); // draw injected direction
123  return;
124 #endif
125 
126 #ifdef SKYPROB_HIST
127  int l = gSM->getSkyIndex(event->theta[1],event->phi[1]);
128  double skyprob = gSM->get(l) ;
129  cout << "SkyProb @ injection pixel : " << l << " " << skyprob << endl;
130  hskyprob->Fill(skyprob);
131 #endif
132 
133  }
134  }
135  }
136  }
137  delete gNET;
138  }
139 
140 #ifdef EC_HIST
141  hec->Draw();
142 #endif
143 #ifdef SKYPROB_HIST
144  hskyprob->Draw();
145 #endif
146 }
gskymap * gSM
detectorParams getDetectorParams()
Definition: detector.cc:201
virtual size_t size() const
Definition: wavearray.hh:127
static vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="", TString containString="", bool fast=false)
Definition: Toolbox.cc:4333
gnetwork * gNET
char name[32]
Definition: detector.hh:32
wavearray< double > a(hp.size())
int n
Definition: cwb_net.C:10
TString("c")
void set(size_t i, double a)
Definition: gskymap.hh:110
float theta
void DrawMarker(double phi, double theta, int marker, Size_t msize=1, Color_t tcolor=1)
Definition: gskymap.cc:724
double getTheta(size_t i)
Definition: skymap.hh:206
int polarization
int nevt
#define M
Definition: UniqSLagsList.C:3
int m
Definition: cwb_net.C:10
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
void Draw(int dpaletteId=0, Option_t *option="colfz")
Definition: gskymap.cc:442
CWB::Toolbox TB
Definition: ComputeSNR.C:5
#define nIFO
size_t getSkyIndex(double th, double ph)
param: theta param: phi
Definition: skymap.cc:702
float phi
const int NIFO_MAX
Definition: wat.hh:4
int k
Definition: skymap.hh:45
vector< TString > fileList
void SetTitle(TString title)
Definition: gskymap.hh:134
TString cwb_parameter_name
#define EC_THR
double getPhi(size_t i)
Definition: skymap.hh:146
char title[256]
Definition: SSeriesExample.C:1
Float_t * phi
sqrt(h+*h+ + hx*hx)
Definition: netevent.hh:68
Float_t * theta
[0]-reconstructed, [1]-injected phi angle, [2]-RA
Definition: netevent.hh:69
Double_t * time
beam pattern coefficients for hx
Definition: netevent.hh:75
int getType()
Definition: skymap.hh:278
wavearray< int > index
double fabs(const Complex &x)
Definition: numpy.cc:37
int l
Definition: cbc_plots.C:434
#define PROJECTION
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
#define COORDINATES
double GetAntennaPattern(double phi, double theta, double psi=0., int polarization=1)
Definition: gnetwork.cc:545
void Draw(char *smName, network *net=NULL)
Definition: gnetwork.hh:59
double get(size_t i)
param: sky index
Definition: skymap.cc:681
strcpy(output_dir,"data")
size_t size()
Definition: skymap.hh:118
char output_dir[512]
Definition: test_config1.C:146
#define IFO
void SetOptions(TString projection="hammer", TString coordinate="Geographic", double resolution=1, bool goff=false)
Definition: gskymap.cc:66
skymap * Psm
error angle
Definition: netevent.hh:90