34 #define MAX_FILES 20 // num max of file in the input file list 40 #define TREE_NAME "waveburst" 42 #define MIN_SNR_NET 5 // SNRnet inf 43 #define MAX_SNR_NET 100 // SNRnet sup 44 #define NSNR 20 // number of snr bins 46 #define MIN_NSNR 20 // minimum number of entries in the SNR bin 47 #define MAX_MEDIAN50 50 // max median50 to be included in the fit 48 #define MAX_MEDIAN90 100 // max median90 to be included in the fit 50 #define LINX // set Logx to false 64 if((ofName!=
"")&&(!ofName.Contains(
".png"))) {
65 cout <<
"Error Output File : " << ilist_file.Data() << endl;
66 cout <<
"Must have .png extension" << endl;
69 ofName.ReplaceAll(
".png",
".gif");
72 TString ptitle=
"Sky Localization : median error area vs SNR";
74 if((pType!=
"MEDIAN50")&&(pType!=
"MEDIAN90")&&(pType!=
"")) {
77 if(pType==
"") pType=
"MEDIAN50";
78 if(pType==
"MEDIAN50") ptitle=ptitle+
"50% error region";
79 if(pType==
"MEDIAN90") ptitle=ptitle+
"90% error region";
90 in.open(ilist_file.Data(),
ios::in);
91 if (!in.good()) {cout <<
"Error Opening File : " << ilist_file.Data() << endl;
exit(1);}
98 if (!in.good())
break;
99 if(str[0] !=
'#') size++;
101 cout <<
"size " << size << endl;
102 in.clear(ios::goodbit);
103 in.seekg(0, ios::beg);
104 if (size==0) {cout <<
"Error : File " << ilist_file.Data() <<
" is empty" << endl;
exit(1);}
113 in >> sfile >> sname >> stype >> scolors >> sltyle;
114 if(!in.good())
break;
115 if(sfile[0]==
'#')
continue;
119 colors[NFILE]=scolors;
120 lstyle[NFILE]=sltyle;
121 cout << NFILE+1 <<
" " << ifile[NFILE] <<
" " << name[NFILE] <<
" " 122 << type[NFILE] <<
" " << colors[NFILE] <<
" " << lstyle[NFILE] << endl;
129 f1=
new TF1(
"medianfit",
medianfit,0.5,4,3);
130 f1->SetParNames(
"A",
"B",
"C");
141 for(
int n=0;
n<NFILE;
n++) {
142 cout <<
"Process File : " << ifile[
n].Data() << endl;
143 nevents[
n]=
GetMedian(ifile[
n], type[n], pType, snr[n], median[n], entries[n],
147 if(median[n][
i]>max_median) max_median=median[
n][
i];
154 gStyle->SetFrameBorderMode(0);
157 gStyle->SetTitleFont(72);
158 gStyle->SetMarkerColor(50);
159 gStyle->SetLineColor(kWhite);
160 gStyle->SetTitleW(0.98);
161 gStyle->SetTitleH(0.05);
162 gStyle->SetTitleY(0.98);
163 gStyle->SetFillColor(kWhite);
164 gStyle->SetLineColor(kWhite);
165 gStyle->SetTitleFont(12,
"D");
167 TCanvas *
canvas =
new TCanvas(
"median",
"median", 300,40, 600, 600);
169 canvas->ToggleEventStatus();
171 canvas->SetLogx(
false);
173 canvas->SetLogx(
true);
178 canvas->SetFillColor(kWhite);
187 for(
int n=0;
n<NFILE;
n++) {
191 gr[
n] =
new TGraphErrors(snr[
n].
size(),snr[
n].data,median[
n].data,esnr.
data,emedian.
data);
193 for(
int n=0;
n<NFILE;
n++) {
194 gr[
n]->SetLineWidth(0);
195 gr[
n]->SetLineColor(colors[
n]);
196 gr[
n]->SetLineStyle(1);
197 gr[
n]->SetMarkerColor(colors[n]);
198 gr[
n]->SetMarkerStyle(20);
199 gr[
n]->SetMarkerSize(1);
202 f1->SetLineColor(colors[n]);
203 f1->SetLineStyle(lstyle[n]);
206 gr[
n]->Fit(
"medianfit");
207 chi2[
n]=f1->GetChisquare();
208 A[
n]=f1->GetParameter(0);
209 B[
n]=f1->GetParameter(1);
210 C[
n]=f1->GetParameter(2);
214 TMultiGraph*
mg =
new TMultiGraph();
215 TString gTitle =
"Sky Localization "+pType+
" vs SNR";
216 if(pTitle!=
"") gTitle = gTitle+
" : "+pTitle;
217 mg->SetTitle(gTitle.Data());
218 for(
int n=0;
n<NFILE;
n++) mg->Add(gr[
n]);
224 mg->GetHistogram()->GetXaxis()->SetTitle(
"Injected SNRnet");
225 if(pType==
"MEDIAN50") mg->GetHistogram()->GetYaxis()->SetTitle(
"Median50 error angle (degrees)");
226 else mg->GetHistogram()->GetYaxis()->SetTitle(
"Median90 error angle (degrees)");
228 mg->GetHistogram()->GetXaxis()->SetLabelSize(0.04);
229 mg->GetHistogram()->GetYaxis()->SetLabelSize(0.04);
230 mg->GetHistogram()->GetXaxis()->SetTitleSize(0.04);
231 mg->GetHistogram()->GetYaxis()->SetTitleSize(0.04);
232 mg->GetHistogram()->GetXaxis()->SetTitleOffset(1.2);
233 mg->GetHistogram()->GetYaxis()->SetTitleOffset(1.2);
234 mg->GetHistogram()->GetXaxis()->CenterTitle(
true);
235 mg->GetHistogram()->GetYaxis()->CenterTitle(
true);
236 mg->GetHistogram()->GetXaxis()->SetLabelFont(42);
237 mg->GetHistogram()->GetXaxis()->SetTitleFont(42);
238 mg->GetHistogram()->GetYaxis()->SetLabelFont(42);
239 mg->GetHistogram()->GetYaxis()->SetTitleFont(42);
245 double hleg = 0.8-NFILE*0.05;
246 leg =
new TLegend(0.5793173,hleg,0.9915385,0.8721805,NULL,
"brNDC");
248 leg->SetBorderSize(1);
249 leg->SetTextAlign(22);
250 leg->SetTextFont(12);
251 leg->SetLineColor(1);
252 leg->SetLineStyle(1);
253 leg->SetLineWidth(1);
254 leg->SetFillColor(0);
255 leg->SetFillStyle(1001);
256 leg->SetTextSize(0.05);
257 leg->SetLineColor(kBlack);
258 leg->SetFillColor(kWhite);
260 for(
int n=0;n<NFILE;n++) {
261 double median_snr15 = A[
n]+pow(
fabs(B[n])/15.,1)+pow(C[n]/15.,2);
264 sprintf(legLabel,
"SNR(15) = %2.1f",median_snr15);
265 leg->AddEntry(gr[n],legLabel,
"lp");
273 canvas->Print(gfileName);
275 pfileName.ReplaceAll(
".gif",
".png");
277 sprintf(cmd,
"convert %s %s",gfileName.Data(),pfileName.Data());
280 sprintf(cmd,
"rm %s",gfileName.Data());
290 double y = par[0]+pow(
fabs(par[1])/x[0],1)+pow(par[2]/x[0],2);
300 TFile *file0 = TFile::Open(ifName);
301 cout << ifName.Data() << endl;
302 if (file0==NULL) {cout <<
"Error Opening file" << endl;
exit(1);}
304 if (itree==NULL) {cout <<
"Error Opening tree" << endl;
exit(1);}
307 TList*
list = itree->GetUserInfo();
308 int nIFO=list->GetSize();
309 if (nIFO==0) {cout <<
"Error : no ifo present in the tree" << endl;
exit(1);}
310 for (
int n=0;
n<list->GetSize();
n++) {
320 sprintf(cut,
"abs(time[0]-time[%d])<%f && netcc[%d]>%f && rho[%d]>%f",
321 nIFO,T_win,pp_inetcc,T_cor,pp_irho,T_cut);
322 if(T_vED>0) {
strcpy(tmp,cut);
sprintf(cut,
"%s && neted[0]/ecor<%f",tmp,T_vED);}
323 if(T_pen>0) {
strcpy(tmp,cut);
sprintf(cut,
"%s && penalty>%f",tmp,T_pen);}
324 if(type>0) {
strcpy(tmp,cut);
sprintf(cut,
"%s && type[1]==%d",tmp,type);}
325 if(T_ifar>0) {
strcpy(tmp,cut);
sprintf(cut,
"%s && ifar>(24.*3600.*365.)*%f",tmp,T_ifar);}
339 double supsnr=fsnr+infsnr;
341 double supsnr=fsnr*infsnr;
346 sprintf(SNRnet,
"sqrt(%s)",tmp);
351 sprintf(icut,
"%s && %s>%f && %s<=%f",cut,SNRnet,infsnr,SNRnet,supsnr);
354 itree->Draw(
"erA[0]",icut,
"goff");
356 int size = itree->GetSelectedRows();
358 double* erA = itree->GetV1();
362 TMath::Sort(size,erA,index,
false);
364 entries[nsnr] =
size;
365 median[nsnr] = (pType==
"MEDIAN50") ? erA[index[
int(size*0.5)]] : erA[index[
int(size*0.9)]];
366 snr[nsnr] = (supsnr+infsnr)/2.;
367 if(median[nsnr]<max_median) {
368 cout <<
"Selected entries : " << entries[nsnr] <<
"\t SNRnet : " 369 << snr[nsnr] <<
"\t median : " << median[nsnr] << endl;
detectorParams getDetectorParams()
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1) *itime+ifreq;double time=itime *dT;double freq=(ifreq >0) ? ifreq *dF :dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
double median(std::vector< double > &vec)
Complex Exp(double phase)
virtual size_t size() const
double fabs(const Complex &x)
strcpy(RunLabel, RUN_LABEL)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
virtual void resize(unsigned int)