Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResampleSkymapFunction.C
Go to the documentation of this file.
1 //
2 // This example show how the resampling helps in the reconstruction of the unbias maximum position
3 // Author : Gabriele Vedovato
4 
5 #define HEALPIX_ORDER 4 // initial skymap resolution
6 #define RESAMPLING 4 // resampling from initial resolution
7 
8 #define DISPLAY_FULL_SKYMAP
9 
11 
12  #include <complex>
13 
14  #define N 5 // set the frequency of the injected function
15  #define OFFSET 0.3 // offset in degrees of the injected function
16 
17  skymap sm(int(HEALPIX_ORDER)); // initial skymap resolution
18  int L = sm.size();
19  // fill skymap with sin^2 + cos^2 funcion
20  for(int l=0;l<L;l++) {
21  double th = sm.getTheta(l);
22  double ph = sm.getPhi(l);
23  double p = sin(TMath::TwoPi()*(th+45-OFFSET)/180.*N);
24  double q = cos(TMath::TwoPi()*(ph-OFFSET)/180.*N/2.);
25  //sm.set(l,p*p);
26  //sm.set(l,q*q);
27  sm.set(l,p*p+q*q);
28  }
29  // resample skymap to the new resolution
30  if(RESAMPLING!=0) {
31  int order = sm.getOrder();
32  cout << "resampling : " << order << " to " << order+RESAMPLING << endl;
33  sm.resample(int(order+RESAMPLING));
34  }
35 
36  int nlmax = 256;
37  wat::Alm alm = sm.getAlm(nlmax);
38 
39  // compute power in the sph har decomposition domain
40  double norm=0;
41  for(int l=0;l<=alm.Lmax();l++) {
42  int limit = TMath::Min(l,alm.Mmax());
43  for (int m=0; m<=limit; m++) {
44  double mod = pow(alm(l,m).real(),2)+pow(alm(l,m).imag(),2);
45  norm+= m==0 ? mod : 2*mod;
46  }
47  }
48  norm = norm/(4*TMath::Pi());
49  cout << "norm : " << norm << endl;
50 
51  // compute power using the skymap pixels
52  double en=0;
53  L = sm.size();
54  for(int i=0;i<L;i++) en+=pow(sm.get(i),2);
55  double dw = 1./L;
56  cout << "EN " << en*dw << endl;
57 
58  // pixel resolution
59  double ds = 4*TMath::Pi()*(180.*180./(TMath::Pi()*TMath::Pi()))/L;
60  cout << "L = " << L << endl;
61  cout << "sqrt(ds) = " << sqrt(ds) << endl;
62 
63  // rearch maximum around th=0, ph=0
64  #define RADIUS 10
65 
66  // find max
67  double max=-100;
68  int imax=0;
69  for(int l=0;l<L;l++) {
70  double th = sm.getTheta(l);
71  double ph = sm.getPhi(l);
72  if(ph>180) ph-=360;
73 #ifdef DISPLAY_FULL_SKYMAP
74  if(sqrt(pow(th-90,2)+pow(ph-0,2))>RADIUS) continue;
75 #else
76  if(sqrt(pow(th-90,2)+pow(ph-0,2))>RADIUS) {sm.set(l,0);continue;}
77 #endif
78  if(sm.get(l)>max) {max=sm.get(l);imax=l;}
79  }
80  double mth = sm.getTheta(imax);
81  double mph = sm.getPhi(imax);
82  // print unbias maximum position
83  cout << "imax " << imax << endl;
84  cout << "max " << max << endl;
85  cout << "mth " << mth << endl;
86  cout << "mph " << mph << endl;
87 
88  gskymap* gsm = new gskymap(sm);
89  gsm->Draw();
90 }
int Lmax() const
Returns the maximum l.
Definition: alm.hh:52
#define HEALPIX_ORDER
TH2F * ph
double getTheta(size_t i)
Definition: skymap.hh:206
int m
Definition: cwb_net.C:10
i drho i
void Draw(int dpaletteId=0, Option_t *option="colfz")
Definition: gskymap.cc:442
#define N
int Mmax() const
Returns the maximum m.
Definition: alm.hh:54
#define OFFSET
double Pi
int getOrder()
Definition: skymap.hh:296
#define RADIUS
Definition: skymap.hh:45
Definition: alm.hh:175
double getPhi(size_t i)
Definition: skymap.hh:146
int l
Definition: cbc_plots.C:434
void set(size_t i, double a)
param: sky index param: value to set
Definition: skymap.hh:104
#define RESAMPLING
double get(size_t i)
param: sky index
Definition: skymap.cc:681
size_t size()
Definition: skymap.hh:118
void ResampleSkymapFunction()