-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_simuSources.cc
More file actions
224 lines (190 loc) · 7.98 KB
/
example_simuSources.cc
File metadata and controls
224 lines (190 loc) · 7.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <sys/stat.h>
// Files
#include "healpixmap.h"
#include "events.h"
#include "coverage.h"
#include "angdist.h"
#include "maptools.h"
#include "projmap.h"
#include "simuevents.h"
#include "common.h"
#include "lima.h"
// ROOT
#include "TRint.h"
#include "TROOT.h"
#include "TStyle.h"
#ifdef gcc323
char* operator+( std::streampos&, char* );
#endif
using namespace std;
void Usage(string myname)
{
cout << endl;
cout << " Synopsis : " << endl;
cout << myname << " -h, --help to obtain this message" << endl;
cout << myname << " <lobe file>" << endl << endl;
cout << " Description :" << endl;
cout << "Two sources are simulated on a full and uniform sky. Their coordinates are those of the Galactic "
<< "Center and Centaurus A. Events are then simulated following this anisotropic pattern in addition to "
<< "a constant acceptance. The coverage map assuming a flat acceptance is then computed. Finally, the "
<< "Li & Ma map and the histogram of the significance of the pixels are computed. We also show a zoom "
<< "on both candidates. The <lobe file> must contain two colums: theta (in deg.) and the lobe value "
<< "normalized to one at maximum. You can easily produce one of this file using the compute_lobe "
<< "executable." << endl;
exit(0);
}
int main(int argc, char* argv[])
{
////////////////////////////////////////////////////////////////////////////
// //
// To start (initialization) //
// //
////////////////////////////////////////////////////////////////////////////
// Command line
if(argc != 2) Usage(argv[0]);
string lobeFile = argv[1];
if( !CheckFile(lobeFile) ) {cerr << "File: " << lobeFile << " not found" << endl; exit(0);}
int fargc = 1;
string extension;
TRint * rint = NULL;
rint = new TRint("SimuSources", &fargc, argv);
gROOT->SetStyle("Plain");
gStyle->SetTitleFont(30,"TITLE");
extension = ".png";
////////////////////////////////////////////////////////////////////////////
// //
// Simulation of the sources & the events //
// //
////////////////////////////////////////////////////////////////////////////
// Simulation of the sources
unsigned int nSide = 128;
int sizeX = 800, sizeY= 500;
double decLimit = 25.;
double longStep = 60., latStep = 30.;
THealpixMap sourceMap(nSide), sourceMapTmp(nSide);
// Pixels
vector<long> iPix(sourceMap.NPix());
vector<double> lPix, bPix; // Deg
for(unsigned int i = 0; i < sourceMap.NPix(); i++) iPix[i] = i;
sourceMap.GiveLB(iPix, lPix, bPix);
iPix.clear();
// Sources
double lSource[2] = {0.,309.5}, bSource[2] = {0,19.5}, ampSource[2] = {0.6,0.9}, sigmaSource[2] = {4.,2.};
for(unsigned int i = 0; i < 2; i++)
{
for(unsigned int j = 0; j < sourceMap.NPix(); j++)
{
vector<double> uvPix = ll2uv(lPix[j], bPix[j]);
vector<double> uvSource = ll2uv(lSource[i],bSource[i]);
double cosAngle = uvPix[0]*uvSource[0]+uvPix[1]*uvSource[1]+uvPix[2]*uvSource[2];
sourceMapTmp[j] = exp( (cosAngle-1)/(2.*(1-cos(sigmaSource[i]*DTOR))) );
}
sourceMapTmp *= ampSource[i]/sourceMapTmp.Max();
sourceMap = sourceMap + sourceMapTmp;
}
sourceMap = 1.+sourceMap;
TProjMap mapSourcesProj(sourceMap, sizeX, sizeY, 90.);
mapSourcesProj.SkyMap("Simulated Sources");
mapSourcesProj.SetPalette(PaletteOrange, 255);
mapSourcesProj.ShowGrid(longStep,latStep);
mapSourcesProj.Save("fullSkySources"+extension);
// Simulation of the events : no acceptance law
double thetaMax = 60.;
unsigned int nVal = 5000;
vector<double> thVal(nVal);
vector<double> pthVal(nVal);
for(unsigned int i=0; i<nVal; i++)
{
thVal[i] = i*180./(nVal-1);
pthVal[i] = sin(thVal[i]*M_PI/180)*cos(thVal[i]*M_PI/180);
if (thVal[i]>thetaMax) pthVal[i] = 0;
}
double latSite = kConstantsTK::AugerSouthLatitude;
double lonSite = kConstantsTK::AugerSouthLongitude;
unsigned int nb = 100000;
vector<TEvent> simData = SimulateEvents(sourceMap, nb, thVal, pthVal, latSite, lonSite);
cout << "Number of events simulated : " << simData.size() << endl;
ShowLocalCoord(simData, thVal, pthVal); ShowEqCoord(simData), ShowArrivalTimesCoord(simData);
////////////////////////////////////////////////////////////////////////////
// //
// Analysis //
// //
////////////////////////////////////////////////////////////////////////////
TCoverage coverage(nSide);
coverage.SetCoordSystem('G');
coverage.fMap = GetAnalyticalCoverage(nSide, thetaMax, kConstantsTK::AugerSouthLatitude);
// Li & Ma analysis
double threshold = 5;
TLiMa LiMa(coverage, simData, lobeFile, threshold);
LiMa.ComputeLiMaMap();
LiMa.ComputeMaxima();
int nbinslima = 31;
double minlima = -5;
double maxlima = 5;
TH1F* hlima = LiMa.GetLiMaHistogram(nbinslima,minlima,maxlima);
LiMa.DrawLiMaHistogram(hlima);
LiMa.PrintResults(false);
////////////////////////////////////////////////////////////////////////////
// //
// Maps //
// //
////////////////////////////////////////////////////////////////////////////
// Coverage map
THealpixMap covMap = coverage.fMap;
covMap *= 1./covMap.Max();
/* Coverage Map : Band of equal exposure
covMap *= 1./covMap.Total();
THealpixMap covMapIntExposure(nSide);
double raPix[covMap.NPix()], decPix[covMap.NPix()];
for(unsigned int i = 0; i < covMap.NPix(); i++)
{
gal2radec(lPix[i],bPix[i],&raPix[i],&decPix[i]);
raPix[i] = raPix[i]*15;
}
int * index = new int[covMap.NPix()];
TMath::Sort(covMap.NPix(),decPix,index,false);
double exposure = 0;
double band = 1.;
for(unsigned int i = 0; i < covMap.NPix(); i++)
{
exposure += covMap[index[i]];
if( exposure > band/6. && band < 6 ) band++;
covMapIntExposure[index[i]] = (7-band)/6;
}
cout << exposure << " " << band << endl;
for(unsigned int i = 0; i < covMap.NPix(); i++) if( decPix[i] > 25. ) covMapIntExposure[i] = 0.;
*/
TProjMap covMapProj(covMap, sizeX, sizeY, decLimit);
covMapProj.SkyMap("Coverage Map");
covMapProj.SetPalette(PaletteRGB, 255);
covMapProj.ShowGrid(longStep,latStep);
covMapProj.ShowFOV(kConstantsTK::AugerSouthLatitude+60., 1);
covMapProj.Save("covMap"+extension);
// Events map
THealpixMap eventsMap = LiMa.GetEventsMap();
TProjMap eventsMapProj(eventsMap, sizeX, sizeY, decLimit);
eventsMapProj.SkyMap("Events Map");
eventsMapProj.SetPalette(PaletteRGB, 255);
eventsMapProj.ShowGrid(longStep,latStep);
eventsMapProj.ShowFOV(kConstantsTK::AugerSouthLatitude+60., 1);
eventsMapProj.Save("eventsMap"+extension);
// LiMa map
THealpixMap LiMaMap = LiMa.GetLiMaMap();
vector<long> ipAboveThreshold;
vector<double> valueAbovethreshold;
LiMa.GetMaxima(ipAboveThreshold,valueAbovethreshold);
TProjMap LiMaMapProj(LiMaMap, sizeX, sizeY, decLimit);
LiMaMapProj.SkyMap("Blind Search Candidates",-10,10);
LiMaMapProj.SetPalette(PaletteBlueAndRed, 255);
LiMaMapProj.ShowGrid(longStep,latStep);
LiMaMapProj.ShowFOV(kConstantsTK::AugerSouthLatitude+60., 1);
LiMaMapProj.ShowSGP(1, kRed, 2);
LiMaMapProj.PlotMaxima(ipAboveThreshold);
LiMaMapProj.Save("LiMaMapMollweide"+extension);
cout << "Program Finished Normally" << endl;
rint->Run(kTRUE);
}