Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RootSkyMap2Fits.C
Go to the documentation of this file.
1 //
2 // This example show how to convert skymap probability from root to fits files in celestial coordinates
3 // Author : Gabriele Vedovato
4 
5 {
6  #define WAVE_FILE "merge/wave_bbh_low_lh_wp10_run2.M1.C_salvo.root"
7  #define NETRHO 0
8  #define NETCC 0.0
9  #define ODIR "fits"
10 
11  netevent event(WAVE_FILE); // open wave root file
12  int nevt = event.GetEntries(); // get number of detected events
13  if(nevt==0) {
14  cout << "no events are presents in the file : " << WAVE_FILE << endl;
15  gSystem->Exit(1);
16  } else cout << "nevt : " << nevt << endl;
17 
18  // print detectors infos
19  TList* ifoList = event.fChain->GetUserInfo();
20  int nIFO = ifoList->GetSize();
21  for (int n=0;n<nIFO;n++) {
22  detector* pDetector = (detector*)ifoList->At(n);
23  detectorParams dParams = pDetector->getDetectorParams();
24  cout << dParams.name << endl;
25  pDetector->print();
26  }
27 
28  for(int n=0;n<nevt;n++) { // loop over the detected events
29 
30  event.GetEntry(n); // load event #n
31 
32  skymap* Psm = event.Psm; // probability skymap
33 
34  cout << "-----------------------------------" << endl;
35  cout << "run : " << event.run << endl;
36  cout << "gps : " << int(event.time[0]) << endl;
37  cout << "rho : " << event.rho[1] << endl;
38  cout << "cc : " << event.netcc[0] << endl;
39  cout << "network snr : " << sqrt(event.likelihood) << endl;
40  cout << "-----------------------------------" << endl<<endl;
41 
42  if(Psm->size()!=0) {
43 
44  if(Psm->getType()==1) { // check if it is healpix
45  // dump skymap to fits (event.time[0] is the gps time of the first detector)
46  if((event.rho[1]>NETRHO) && (event.netcc[0]>NETCC)) { // filter output events
47 
48  // Dump2fits probability skymap in celestial coordinates (healpix)
49  skymap skyprobcc = *Psm;
50  skyprobcc=0.;
51 
52  double th,ph,ra;
53  int k;
54  for(j=0; j<int(Psm->size()); j++) {
55  th = Psm->getTheta(j);
56  ph = Psm->getPhi(j);
57 
58  k=Psm->getSkyIndex(th, ph);
59 
60  ra = Psm->getRA(j);
61  k=Psm->getSkyIndex(th, ra);
62  skyprobcc.set(k,Psm->get(j));
63  }
64 
65  char fits_name[256];sprintf(fits_name,"%s/probability_skymap_%d.fits.gz",ODIR,int(event.time[0]));
66  cout << "Dump fits file : " << fits_name << endl;
67  skyprobcc.Dump2fits(fits_name,event.time[0],"2G:MRA un-modeled",const_cast<char*>("PROB"),const_cast<char*>("pix-1"),'C');
68 
69  double prob=0;
70  for(int l=0;l<skyprobcc.size();l++) prob+=skyprobcc.get(l);
71  cout << "prob : " << prob << endl;
72  }
73  }
74  }
75  }
76 
77  exit(0);
78 }
detectorParams getDetectorParams()
Definition: detector.cc:201
#define NETCC
int nIFO
char name[32]
Definition: detector.hh:32
#define NETRHO
int n
Definition: cwb_net.C:10
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
TH2F * ph
double getTheta(size_t i)
Definition: skymap.hh:206
int nevt
int j
Definition: cwb_net.C:10
size_t getSkyIndex(double th, double ph)
param: theta param: phi
Definition: skymap.cc:702
double ra
Definition: ConvertGWGC.C:46
double getRA(size_t i)
Definition: skymap.hh:197
i() int(T_cor *100))
int k
#define WAVE_FILE
Definition: skymap.hh:45
double getPhi(size_t i)
Definition: skymap.hh:146
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)
void set(size_t i, double a)
param: sky index param: value to set
Definition: skymap.hh:104
double get(size_t i)
param: sky index
Definition: skymap.cc:681
#define ODIR
size_t size()
Definition: skymap.hh:118
exit(0)