Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ReadSkyMapFromTree.C
Go to the documentation of this file.
1 //
2 // This example show how to read/save to fits/display skymap probability from output root file
3 // Author : Gabriele Vedovato
4 
5 //#define COORDINATES "cWB"
6 //#define COORDINATES "Geographic"
7 #define COORDINATES "Celestial"
8 
9 #define PROJECTION ""
10 //#define PROJECTION "hammer"
11 //#define PROJECTION "sinusoidal"
12 
13 #define WAVE_FILE "data.1/wave_966383954_600_uniform_in_snr_dbg1_1_job1.root"
14 
15 #define XANALYSIS "2G"
16 #define XSEARCH 'r'
17 
19 
21 
22  // load configuration parameters
23  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
24  TString cwb_parameter_name = gSystem->Getenv("CWB_PARAMETERS_FILE");
25  gROOT->Macro(cwb_parameter_name);
26  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
27  TString cwb_uparameter_name = gSystem->Getenv("CWB_UPARAMETERS_FILE");
28  gROOT->Macro(cwb_uparameter_name);
29 
30  netevent* event = new netevent(WAVE_FILE); // open wave root file
31  int nevt = event->GetEntries(); // get number of detected events
32  if(nevt==0) {
33  cout << "no events are presents in the file : " << WAVE_FILE << endl;
34  gSystem->Exit(1);
35  } else cout << "nevt : " << nevt << endl;
36 
37  // print detectors infos
38  TList* ifoList = event->fChain->GetUserInfo();
39  int nIFO = ifoList->GetSize();
40  for (int n=0;n<nIFO;n++) {
41  detector* pDetector = (detector*)ifoList->At(n);
42  detectorParams dParams = pDetector->getDetectorParams();
43  cout << dParams.name << endl;
44  pDetector->print();
45  }
46 
47  for(int n=0;n<nevt;n++) { // loop over the detected events
48 
49  event->GetEntry(n); // load event #n
50 
51  skymap* Psm = event->Psm; // probability skymap
52 
53  cout << "-----------------------------------" << endl;
54  cout << "gps : " << int(event->time[0]) << endl;
55  cout << "rho : " << event->rho[1] << endl;
56  cout << "cc : " << event->netcc[0] << endl;
57  cout << "network snr : " << sqrt(event->likelihood) << endl;
58  cout << "rec RA : " << event->phi[2] << endl;
59  cout << "rec DEC : " << event->theta[2] << endl;
60  cout << "-----------------------------------" << endl<<endl;
61 
62  if(Psm->size()!=0) {
63 
64  if(Psm->getType()==1) { // check if it is healpix
65  // dump skymap to fits (event->time[0] is the gps time of the first detector)
66  char fits_name[256];sprintf(fits_name,"probability_skymap_%d.fits.gz",int(event->time[0]));
67  // build configur info
68  char configur[64];
69  if (XSEARCH=='r') sprintf(configur,"%s un-modeled",XANALYSIS);
70  if((XSEARCH=='i')||(XSEARCH=='I')) sprintf(configur,"%s elliptical",XANALYSIS);
71  if((XSEARCH=='s')||(XSEARCH=='S')) sprintf(configur,"%s linear",XANALYSIS);
72  if((XSEARCH=='g')||(XSEARCH=='G')) sprintf(configur,"%s circular",XANALYSIS);
73  cout << "Dump fits file : " << fits_name << endl;
74  Psm->Dump2fits(fits_name,event->time[0],configur);
75  }
76 
77  // plot probability skymap
78  gskymap* gSM = new gskymap(*(event->Psm));
80  char title[256];sprintf(title,"probability skymap gps = %d",int(event->time[0]));
81  gSM->SetTitle(title);
82  gSM->Draw();
83  double RA = event->phi[2];
84  double DEC = event->theta[2];
85  RA=360-RA;
86  gSM->DrawMarker(RA,DEC, 29, 1.5, kWhite);
87 
88  double prob=0;
89  for(int l=0;l<Psm->size();l++) prob+=Psm->get(l);
90  cout << "prob : " << prob << endl;
91 
92  }
93 
94  break; // terminate after the first event
95  }
96 }
gskymap * gSM
detectorParams getDetectorParams()
Definition: detector.cc:201
char name[32]
Definition: detector.hh:32
void ReadSkyMapFromTree()
int n
Definition: cwb_net.C:10
TString("c")
void DrawMarker(double phi, double theta, int marker, Size_t msize=1, Color_t tcolor=1)
Definition: gskymap.cc:724
int nevt
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
#define XSEARCH
i() int(T_cor *100))
#define PROJECTION
Definition: skymap.hh:45
#define WAVE_FILE
#define COORDINATES
void SetTitle(TString title)
Definition: gskymap.hh:134
TString cwb_parameter_name
char title[256]
Definition: SSeriesExample.C:1
int getType()
Definition: skymap.hh:278
void print()
Definition: detector.cc:1768
int l
Definition: cbc_plots.C:434
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
#define XANALYSIS
double get(size_t i)
param: sky index
Definition: skymap.cc:681
size_t size()
Definition: skymap.hh:118
void SetOptions(TString projection="hammer", TString coordinate="Geographic", double resolution=1, bool goff=false)
Definition: gskymap.cc:66