32 {
35
37
38 double dec;
39 double RA;
40 Range T_start_int;
41 Range E_min_max;
42 Range detector_coord;
43 double sterrad;
44 string options;
45 string file_name;
46
47 try {
48
49 JParser<> zap(
"Auxiliary program to integrate atmospheric neutrino flux over apparent trajectory of a source.");
50
51 zap[
'D'] =
make_field(dec,
"declination [deg]");
52 zap[
'R'] =
make_field(RA,
"right ascension [deg]");
53 zap[
't'] =
make_field(T_start_int,
"start time + interval [MJD]");
54 zap[
'E'] =
make_field(E_min_max,
"energy range [GeV]") = Range(1e3,1e7);
55 zap[
'C'] =
make_field(detector_coord,
"detector coordinates [rad]") = Range(ARCA.getLatitude(),ARCA.getLongitude());
56 zap[
's'] =
make_field(sterrad,
"correction factor") = 1;
57 zap[
'o'] =
make_field(file_name) =
"./formula.txt";
58
59 zap(argc, argv);
60 }
61 catch(const exception& error) {
62 FATAL(error.what() << endl);
63 }
64
65 Flux_Atmospheric
flux;
66
67 double epoch_mean = 2000.0;
68
69 dec *= M_PI/180.0;
70 RA *= M_PI/180.0;
71
74
75
76 const int NT = 10000;
77 const int NE = 1000;
78
79
80 const double xmax = log10(E_min_max.getUpperLimit());
81 const double xmin = log10(E_min_max.getLowerLimit());
82 double flx[NE];
83 double E[NE];
84 for (int i = 0; i < NE; ++i){
85 flx[i] = 0;
86 double x = (double(i))*(xmax-xmin)/(double(NE))+xmin;
88 }
89
90
91 for (int i = 0; i < NT; ++i) {
92 double RA_ap, dec_ap;
93 double amprms[21];
94
95
96 double time = T_start_int.getUpperLimit()*i;
97 time /= (double(NT));
98 time += T_start_int.getLowerLimit();
99
100
101 double LST = slaGmst(time) + detector_coord.getUpperLimit();
102 slaMappa(epoch_mean, time, amprms);
103 slaMapqkz(LST-RA, dec, amprms, &RA_ap, &dec_ap);
104
105
106 double phi, theta;
107 slaDe2h(RA_ap, dec_ap, detector_coord.getLowerLimit(), &phi, &theta);
108 thetavec.push_back(theta);
109 phivec.push_back(phi);
110
111
112 theta = cos(M_PI/2 - theta);
113
114
115 for (
int j = 0;
j < NE; ++
j){
116 flx[
j] +=
flux.dNdEdOmega(14, log10(E[j]), theta);
117 }
118 }
119
120
121 ostringstream oss_formula;
122
123
124 flx[0] *= (sterrad/NT) *
pow(E[0],3.7);
125 flx[1] *= (sterrad/NT) *
pow(E[1],3.7);
126
127 double rc = (flx[1]-flx[0])/(E[1]-E[0]);
128 oss_formula << "((x>=" << E[0] << "&&x<=" << E[1] << ")*(" << rc << "*(x-" << E[0] << ")+" << flx[0] << ")+";
129
130
131 for (int i = 2; i < NE; ++i){
132 flx[i] *= (sterrad/NT) *
pow(E[i],3.7);
133 rc = (flx[i]-flx[i-1])/(E[i]-E[i-1]);
134 oss_formula << "(x>" << E[i-1] << "&&x<=" << E[i] << ")*(" << rc << "*(x-" << E[i-1] << ")+" << flx[i-1] << ")+";
135 }
136
137 oss_formula << "(x>" << E[NE-1] << "&&x<=" << E_min_max.getUpperLimit() << ")*(" << rc << "*(x-" << E[NE-1] << ")+" << flx[NE-1] << "))*pow(x,-3.7)";
138
139
140
141
142 if (getFilenameExtension(file_name)=="txt"){
143 ofstream out(file_name);
144 out << oss_formula.str();
145 out.close();
146 }
147
148
149 if (getFilenameExtension(file_name)=="root"){
150 TFile out(file_name.c_str(), "recreate");
151
152
153 auto f1 = new TF1("f1",oss_formula.str().c_str(),E_min_max.getLowerLimit(),E_min_max.getUpperLimit());
154 f1->SetTitle("Linear interpolation");
155 f1->Write("formula");
156
157
158 TGraph* graph = new TGraph();
159 for (int i = 0; i < NE; ++i){
160 double flx_norm = flx[i] *
pow(E[i],-3.7);
161 graph->SetPoint(i,E[i],flx_norm);
162 }
163
164 graph->GetXaxis()->SetTitle("E");
165 graph->GetYaxis()->SetTitle("Flux");
166 graph->Write("flux");
167
168
169 TGraphErrors* graph_rec_coord = new TGraphErrors(thetavec.size(),&(phivec[0]),&(thetavec[0]));
170 graph_rec_coord->SetLineWidth(0);
171 graph_rec_coord->SetMarkerStyle(1);
172
173 graph_rec_coord->GetXaxis()->SetTitle("Azimuth");
174 graph_rec_coord->GetYaxis()->SetTitle("Altitude");
175 graph_rec_coord->SetTitle("");
176 graph_rec_coord->GetXaxis()->SetLimits(0,2*M_PI);
177 graph_rec_coord-> Write("path");
178
179 out.Write();
180 out.Close();
181 }
182
183 return 0;
184}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
T pow(const T &x, const double y)
Power .
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).