Logo coherent WaveBurst  
Library Reference Guide
Logo
CBCTool.cc
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Francesco Salemi
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 #include "CBCTool.hh"
19 #include "TStopwatch.h"
20 #include "TTreeFormula.h"
21 #include "watversion.hh"
22 //#include "GCBCTool.hh"
23 #include <Riostream.h>
24 #include "Math/BrentRootFinder.h"
25 #include "Math/WrappedTF1.h"
26 #include "TF1.h"
27 #include "TThread.h"
28 
29 #define CCAST(PAR) const_cast<char*>(PAR)
30 
31 // Without this macro the THtml doc for CWB::CBCTool can not be generated
32 ClassImp(CWB::CBCTool)
33 // int compareSegments(waveSegment a, waveSegment b) {return a.start < b.start;}
34 
35 // definitions used by CWB::CBCTool::mergeCWBTrees with threads
36 
37 #define MAX_THREADS 8
38 
39  ////______________________________________________________________________________
40 
41  Long64_t CWB::CBCTool::GetTreeIndex(TTree* tree, const char* selection) {
42 
43  tree->Draw("Entry$>>hist(Entries$,0,Entries$)", selection, "goff");
44  TH1I* hist = (TH1I*)gDirectory->Get("hist");
45  Long64_t iEntry = hist->GetBinLowEdge(hist->FindFirstBinAbove(0));
46  delete hist;
47  return iEntry;
48 }
49 
50 //______________________________________________________________________________
51 /*
52 TH1* CWB::CBCTool::GetCumulative(TH1* in, Bool_t forward)
53 {
54  // Return a pointer to an histogram containing the cumulative The
55  // cumulative can be computed both in the forward (default) or backward
56  // direction; the name of the new histogram is constructed from
57  // the name of this histogram with the suffix suffix appended.
58  //
59  // The cumulative distribution is formed by filling each bin of the
60  // resulting histogram with the sum of that bin and all previous
61  // (forward == kTRUE) or following (forward = kFALSE) bins.
62  //
63  // note: while cumulative distributions make sense in one dimension, you
64  // may not be getting what you expect in more than 1D because the concept
65  // of a cumulative distribution is much trickier to define; make sure you
66  // understand the order of summation before you use this method with
67  // histograms of dimension >= 2.
68 
69  const Int_t nbinsx = in->GetNbinsX();
70  const Int_t nbinsy = in->GetNbinsY();
71  const Int_t nbinsz = in->GetNbinsZ();
72  TH1* hintegrated = (TH1*) in->Clone();
73  hintegrated->Reset();
74  if (forward) { // Forward computation
75  Double_t sum = 0.;
76  for (Int_t binz = 1; binz <= nbinsz; ++binz) {
77  for (Int_t biny = 1; biny <= nbinsy; ++biny) {
78  for (Int_t binx = 1; binx <= nbinsx; ++binx) {
79  const Int_t bin = hintegrated->GetBin(binx, biny, binz);
80  sum += in->GetBinContent(bin);
81  hintegrated->SetBinContent(bin, sum);
82  }
83  }
84  }
85  } else { // Backward computation
86  Double_t sum = 0.;
87  for (Int_t binz = nbinsz; binz >= 1; --binz) {
88  for (Int_t biny = nbinsy; biny >= 1; --biny) {
89  for (Int_t binx = nbinsx; binx >= 1; --binx) {
90  const Int_t bin = hintegrated->GetBin(binx, biny, binz);
91  sum += in->GetBinContent(bin);
92  hintegrated->SetBinContent(bin, sum);
93  }
94  }
95  }
96  }
97  return hintegrated;
98 }
99 
100 */
101 
102 //______________________________________________________________________________
103 
104 void CWB::CBCTool::doROCPlot(int bkg_entries,
105  double* rho_bkg,
106  int* index,
107  float RHO_BIN,
108  double liveTot,
109  TF1* AverageRad,
110  TCanvas* c1,
111  TString odir,
112  bool write_ascii) {
113  //
114  // It produces ROC Plot from background and simulation ntuples
115  //
116  // Input
117  // bkg_entries : number of background events
118  // rho_bkg : array of doubles containing the events rho
119  // index : array of integers containing the sorted entries in
120  // ascending order // MY: too much useless stuff, need some
121  // clening and rearrangement! RHO_BIN : float containing the rho
122  // bin //MY: remove it? it should be defined in user-pp conf file
123  // liveTot : double containing the total background live time in
124  // seconds as calculated from the liveTime ntuple AverageRad :
125  // fitting function of the measured average radius as a function
126  // of rho (a power-law with some exponential, A*rho^B*exp(-C))
127  // calculated by the following doRangePlot method
128  // BEWARE, the fit does a decent job on all sofar tested
129  // waveforms, but no check is done! Look at the Range.png. The reasoning
130  // in favour of using the radius from fitting in place of the measured
131  // one (which produces some overestimate bias at low rho)
132  // is to have a better estimate at high rho, where the statistics
133  // is poor.
134  // c1 : the formatted canvas used for all plots by cbc_plots.C
135  // odir : output dir
136  // write_ascii : boolean to toggle on/off the writing of ascii
137  // output
138 
139  int nbins =
140  -TMath::Nint(rho_bkg[index[bkg_entries - 1]] - rho_bkg[index[0]]) /
141  RHO_BIN;
142  cout << "Rho max : " << rho_bkg[index[0]]
143  << " Rho min : " << rho_bkg[index[bkg_entries - 1]]
144  << " nbins : " << nbins << endl;
145 
146  // definition and filling of the events rho histogram
147  TH1D* h = new TH1D("h", "h", nbins, rho_bkg[index[bkg_entries - 1]],
148  rho_bkg[index[0]] * 1.05);
149  for (int i = 0; i < bkg_entries; i++) {
150  h->Fill(rho_bkg[i]);
151  }
152  // hc is the cumulative histogram of h
153  // TH1* hc = h->GetCumulative(kFALSE);
154  const Int_t nbinsx = h->GetNbinsX();
155  const Int_t nbinsy = h->GetNbinsY();
156  const Int_t nbinsz = h->GetNbinsZ();
157  TH1* hc = (TH1*)h->Clone();
158  hc->Reset();
159  Double_t sum = 0.;
160  for (Int_t binz = nbinsz; binz >= 1; --binz) {
161  for (Int_t biny = nbinsy; biny >= 1; --biny) {
162  for (Int_t binx = nbinsx; binx >= 1; --binx) {
163  const Int_t bin = hc->GetBin(binx, biny, binz);
164  sum += h->GetBinContent(bin);
165  hc->SetBinContent(bin, sum);
166  }
167  }
168  }
169 
170  double far[nbins], efar[nbins], rad[nbins], rhobin[nbins], erad[nbins];
171  for (int i = 0; i < nbins; i++) {
172  far[i] = (double)hc->GetBinContent(i) / liveTot;
173  efar[i] = (double)hc->GetBinError(i) / liveTot;
174  rhobin[i] = hc->GetBinCenter(
175  i); // MY : should I consider the left bound of the bin?
176  // this choice should be more conservative
177  rad[i] = AverageRad->Eval(
178  rhobin[i]); // BEWARE: no guarantee that the fitting
179  // function returns correct estimates
180  erad[i] = 0.0;
181  // cout << "(far, rho, radius) -
182  //"<<far[i]<<","<<hc->GetBinCenter(i)<<","<<rad[i]<<" ";
183  }
184  // cout<<endl;
185  // cout << "FAR max : "<< far[0] << " FAR min : "<<far[nbins-1] <<endl;
186  c1->Clear();
187  c1->SetLogy(1);
188  c1->SetLogx(1);
189 
190  hc->Scale(1. / liveTot);
191  hc->GetYaxis()->SetTitle("FAR [Hz]");
192  hc->GetXaxis()->SetTitle("#rho");
193  hc->Draw("LP");
194  char fname[1024];
195  sprintf(fname, "%s/FAR.png", odir.Data());
196  c1->Update();
197  c1->SaveAs(fname); // A dump of the FAR used for the ROC
198 
199  c1->Clear();
200  c1->SetLogx(1);
201  c1->SetLogy(0); // MY: log?
202  c1->SetTheta(89.999); // the setting of the theta and phi is for the
203  // viewing angle: there is no TGraphError with "pcol"
204  // option, so the trick is to use the 2D version and
205  // use a viewing angle the closest as possible to the
206  // vertical (Drawbacks: some artefacts due to that
207  // can be noticed; no gridlines)
208  c1->SetPhi(0.0001);
209 
210  TGraph2DErrors* gr2 =
211  new TGraph2DErrors(nbins, far, rad, rhobin, efar, erad, erad);
212  gr2->SetMarkerStyle(20);
213  gr2->SetLineColor(20);
214  gr2->SetMinimum(0.0);
215  double RHO_MAX = ceil(rho_bkg[index[0]] * 1.05);
216  gr2->SetMaximum(RHO_MAX);
217  // gr1->Draw("ALP");
218  // TMultiGraph *multi = new TMultiGraph();
219  // multi->Add(gr2);
220  // multi->Paint("AP");
221  gr2->SetTitle("ROC Curve: Average Range vs FAR @rho threshold");
222  gr2->GetHistogram()->GetXaxis()->SetTitle("FAR [Hz]");
223  gr2->GetHistogram()->GetZaxis()->SetTitle("#rho");
224  // multi->GetHistogram()->GetXaxis()->SetRangeUser(RHO_MIN,10.);
225  // multi->GetHistogram()->GetXaxis()->SetRangeUser(1e-12, 1e-7);
226  gr2->GetHistogram()->GetXaxis()->SetLimits(
227  1e-12, 1e-7); // MY: Add similar line for the y axis? declare the X
228  // and Y bounds in the definition
229  gr2->GetHistogram()->GetYaxis()->SetTitle("Average Range [Mpc]");
230  gr2->GetXaxis()->SetTitleOffset(1.3);
231  gr2->GetYaxis()->SetTitleOffset(1.25);
232  gr2->GetXaxis()->SetTickLength(0.02);
233  gr2->GetYaxis()->SetTickLength(0.01);
234  gr2->GetXaxis()->CenterTitle(kTRUE);
235  gr2->GetYaxis()->CenterTitle(kTRUE);
236  gr2->GetZaxis()->CenterTitle(kTRUE);
237  gr2->GetXaxis()->SetTitleFont(42);
238  gr2->GetXaxis()->SetLabelFont(42);
239  gr2->GetYaxis()->SetTitleFont(42);
240  gr2->GetYaxis()->SetLabelFont(42);
241  // gr2->GetYaxis()->SetMoreLogLabels(kTRUE);
242  gr2->GetYaxis()->SetNoExponent(kTRUE);
243 
244  gr2->Draw("err zcolpcol");
245  sprintf(fname, "%s/ROC.png", odir.Data());
246  c1->Update();
247  c1->SaveAs(fname);
248 
249  if (write_ascii) {
250  sprintf(fname, "%s/ROC.txt", odir.Data());
251  FILE* frange = fopen(fname, "w");
252  fprintf(frange, "#rho FAR[Hz] eFAR range[Mpc] erange\n");
253  for (int i = 0; i < nbins; i++) {
254  fprintf(frange, "%3.3g %4.3g %4.3g %4.4g %4.4g\n",
255  hc->GetBinCenter(i), far[i], efar[i], rad[i], erad[i]);
256  }
257  fclose(frange);
258  }
259 
260  delete h, hc, gr2;
261 
262  return;
263 }
264 
265 //______________________________________________________________________________
266 
267 void CWB::CBCTool::doROCPlot(int bkg_entries,
268  double* rho_bkg,
269  int* index,
270  float RHO_BIN,
271  float RHO_NBINS,
272  float RHO_MIN,
273  double liveTot,
274  double* Rrho,
275  double* eRrho,
276  double* Trho,
277  TCanvas* c1,
278  TString odir,
279  bool write_ascii) {
280  //
281  // It produces ROC Plot from background and simulation ntuples
282  //
283  // Input
284  // bkg_entries : number of background events
285  // rho_bkg : array of doubles containing the events rho
286  // index : array of integers containing the sorted entries in
287  // ascending order // MY: too much useless stuff, need some
288  // clening and rearrangement! RHO_BIN : float containing the rho
289  // bin //MY: remove it? it should be defined in user-pp conf file
290  // liveTot : double containing the total background live time in
291  // seconds as calculated from the liveTime ntuple Rrho and eRrho :
292  // arrays of doubles containing the Radius and error radius
293  // estimates at fixed rho thresholds Trho
294  //
295  // c1 : the formatted canvas used for all plots by cbc_plots.C
296  // odir : output dir
297  // write_ascii : boolean to toggle on/off the writing of ascii
298  // output
299 
300  // int nbins =
301  // -TMath::Nint(rho_bkg[index[bkg_entries-1]]-rho_bkg[index[0]])/RHO_BIN;
302  int nbins = (int)RHO_NBINS;
303  cout << "Rho max : " << rho_bkg[index[0]]
304  << " Rho min : " << rho_bkg[index[bkg_entries - 1]]
305  << " nbins : " << nbins << endl;
306 
307  // definition and filling of the events rho histogram
308  TH1D* h = new TH1D("h", "h", nbins, RHO_MIN, RHO_NBINS * RHO_BIN);
309  for (int i = 0; i < bkg_entries; i++) {
310  h->Fill(rho_bkg[i]);
311  }
312  // hc is the cumulative histogram of h
313  // TH1* hc = h->GetCumulative(kFALSE);
314 
315  const Int_t nbinsx = h->GetNbinsX();
316  const Int_t nbinsy = h->GetNbinsY();
317  const Int_t nbinsz = h->GetNbinsZ();
318  TH1* hc = (TH1*)h->Clone();
319  hc->Reset();
320  Double_t sum = 0.;
321  for (Int_t binz = nbinsz; binz >= 1; --binz) {
322  for (Int_t biny = nbinsy; biny >= 1; --biny) {
323  for (Int_t binx = nbinsx; binx >= 1; --binx) {
324  const Int_t bin = hc->GetBin(binx, biny, binz);
325  sum += h->GetBinContent(bin);
326  hc->SetBinContent(bin, sum);
327  }
328  }
329  }
330 
331  double far[nbins], efar[nbins], rad[nbins], rhobin[nbins], erad[nbins],
332  vol[nbins], evol[nbins], erhobin[nbins];
333  int j = 0;
334  for (int i = 0; i < nbins; i++) {
335  far[i] = (double)hc->GetBinContent(i + 1) / liveTot * 365. * 86400.;
336  efar[i] = (double)hc->GetBinError(i + 1) / liveTot * 365. * 86400.;
337  rhobin[i] = hc->GetBinCenter(
338  i + 1); // MY : should I consider the left bound of the
339  // bin? this choice should be more conservative
340  while (rhobin[i] > Trho[j]) {
341  j++;
342  }
343  erhobin[i] = RHO_BIN;
344  rad[i] = Rrho[j];
345  erad[i] = eRrho[j];
346  vol[i] = 4. / 3. * TMath::Pi() * pow(Rrho[j], 3.);
347  evol[i] = 4. * TMath::Pi() * pow(Rrho[j], 2.) * eRrho[j];
348  // cout << "(far, rho, radius) -
349  //"<<far[i]<<","<<hc->GetBinCenter(i)<<","<<rad[i]<<" ";
350  }
351  // cout<<endl;
352  // cout << "FAR max : "<< far[0] << " FAR min : "<<far[nbins-1] <<endl;
353  c1->Clear();
354  c1->SetLogy(1);
355  c1->SetLogx(1);
356 
357  hc->Scale(365. * 86400. / liveTot);
358  hc->GetYaxis()->SetTitle("FAR [year^{-1}]");
359  hc->GetXaxis()->SetTitle("#rho");
360  hc->Draw("LP");
361  char fname[1024];
362  sprintf(fname, "%s/FAR.png", odir.Data());
363  c1->Update();
364  c1->SaveAs(fname); // A dump of the FAR used for the ROC
365 
366  c1->Clear();
367  c1->SetLogx(1);
368  c1->SetLogy(0); // MY: log?
369  c1->SetTheta(89.999); // the setting of the theta and phi is for the
370  // viewing angle: there is no TGraphError with "pcol"
371  // option, so the trick is to use the 2D version and
372  // use a viewing angle the closest as possible to the
373  // vertical (Drawbacks: some artefacts due to that
374  // can be noticed; no gridlines)
375  c1->SetPhi(0.0001);
376 
377  TGraph2DErrors* gr2 =
378  new TGraph2DErrors(nbins, far, rad, rhobin, efar, erad, erhobin);
379  gr2->SetMarkerStyle(20);
380  gr2->SetLineColor(20);
381  gr2->SetMinimum(0.0);
382  double RHO_MAX = ceil(rho_bkg[index[0]] * 1.05);
383  gr2->SetMaximum(RHO_MAX);
384  // gr1->Draw("ALP");
385  // TMultiGraph *multi = new TMultiGraph();
386  // multi->Add(gr2);
387  // multi->Paint("AP");
388  gr2->SetTitle("ROC Curve: Average Range vs FAR @rho threshold");
389  gr2->GetHistogram()->GetXaxis()->SetTitle("FAR [year^{-1}]");
390  gr2->GetHistogram()->GetZaxis()->SetTitle("#rho");
391  // multi->GetHistogram()->GetXaxis()->SetRangeUser(RHO_MIN,10.);
392  // multi->GetHistogram()->GetXaxis()->SetRangeUser(1e-12, 1e-7);
393  gr2->GetHistogram()->GetXaxis()->SetLimits(
394  1e-5, 1e1); // MY: Add similar line for the y axis? declare the X
395  // and Y bounds in the definition
396  gr2->GetHistogram()->GetYaxis()->SetTitle("Average Range [Mpc]");
397  gr2->GetXaxis()->SetTitleOffset(1.3);
398  gr2->GetYaxis()->SetTitleOffset(1.25);
399  gr2->GetXaxis()->SetTickLength(0.02);
400  gr2->GetYaxis()->SetTickLength(0.01);
401  gr2->GetXaxis()->CenterTitle(kTRUE);
402  gr2->GetYaxis()->CenterTitle(kTRUE);
403  gr2->GetZaxis()->CenterTitle(kTRUE);
404  gr2->GetXaxis()->SetTitleFont(42);
405  gr2->GetXaxis()->SetLabelFont(42);
406  gr2->GetYaxis()->SetTitleFont(42);
407  gr2->GetYaxis()->SetLabelFont(42);
408  // gr2->GetYaxis()->SetMoreLogLabels(kTRUE);
409  gr2->GetYaxis()->SetNoExponent(kTRUE);
410 
411  gr2->Draw("err zcolpcol");
412  sprintf(fname, "%s/ROC.png", odir.Data());
413  c1->Update();
414  c1->SaveAs(fname);
415 
416  if (write_ascii) {
417  sprintf(fname, "%s/ROC.txt", odir.Data());
418  FILE* frange = fopen(fname, "w");
419  fprintf(frange,
420  "#rho FAR[year^{-1}] eFAR range[Mpc] "
421  "erange\n");
422  for (int i = 0; i < nbins; i++) {
423  fprintf(frange, "%3.3g %4.3g %4.3g %4.4g %4.4g\n",
424  hc->GetBinCenter(i), far[i], efar[i], rad[i], erad[i]);
425  }
426  fclose(frange);
427  }
428 
429  TGraph2DErrors* gr3 =
430  new TGraph2DErrors(nbins, far, vol, rhobin, efar, erad, erhobin);
431  gr3->SetTitle("ROC Curve: Average Volume vs FAR @rho threshold");
432  gr3->GetHistogram()->GetYaxis()->SetTitle("Average volume [Mpc^3]");
433  gr3->GetHistogram()->GetXaxis()->SetTitle("FAR [year^{-1}]");
434  gr3->GetHistogram()->GetZaxis()->SetTitle("#rho");
435  gr3->GetHistogram()->GetXaxis()->SetLimits(
436  1e-5, 1e2); // MY: Add similar line for the y axis? declare the X
437  // and Y bounds in the definition
438 
439  gr3->Draw("err zcolpcol");
440  sprintf(fname, "%s/ROCV.png", odir.Data());
441  c1->Update();
442  c1->SaveAs(fname);
443 
444  delete h, hc, gr2;
445 
446  return;
447 }
448 
449 //______________________________________________________________________________
450 
452  double* Trho,
453  double* Rrho,
454  double* eRrho,
455  float RHO_MIN,
456  float T_out,
457  TCanvas* c1,
458  TString networkname,
459  TString odir,
460  bool write_ascii) {
461  //
462  // It produces Range Plot from simulation ntuple
463  // AverageRad : fitting function of the measured average radius as
464  // a function of rho (a power-law with some exponential, A*rho^B*exp(-C))
465  // BEWARE, the fit does a decent job on all sofar tested
466  // waveforms, but no check is done! Look at the Range.png. The reasoning
467  // in favour of using the radius from fitting in place of the measured
468  // one (which produces some overestimate bias at low rho)
469  // is to have a better estimate at high rho, where the statistics
470  // is poor.
471  //
472  // Input
473  // RHO_NBINS : number of rho bins // MY: remove this in favour of
474  // the standard user_pp variables? Trho : array of doubles
475  // containg the rho thresholds at the left margin of the bins
476  // Rrho : array of doubles containing the average radius as
477  // calculated at the left margin of the bin eRrho : array of
478  // doubles containing the error on the average radius RHO_MIN : float
479  // with minimal rho // MY: do I really need this? T_out : float with
480  // output threashold c1 : the formatted canvas used for all plots by
481  // cbc_plots.C networkname : TString with the network name //MY: read it from
482  // the ntuple? odir : output dir write_ascii : boolean to toggle
483  // on/off the writing of ascii output
484 
485  char fname[1024];
486 
487  if (write_ascii) {
488  sprintf(fname, "%s/range_threshold.txt", odir.Data());
489  FILE* frange = fopen(fname, "w");
490  fprintf(frange, "#rho range[Mpc] \n");
491  for (int i = 0; i < RHO_NBINS; i++) {
492  fprintf(frange, "%3.2f %4.3e\n", Trho[i], Rrho[i]);
493  }
494  fclose(frange);
495  }
496 
497  // TF1 *f1 = new TF1("f1","[0]*pow(x,[1])",T_out,10.);
498  TF1* f2 = new TF1("f2", "[0]*pow(x,[1])*TMath::Exp(-x*[2])", T_out,
499  Trho[RHO_NBINS - 1]); // Empirical function to fit
500  // the radius vs rho
501  // TF1 *f3 = new TF1("f3","[0]+[1]/pow(x,1)",T_out,10.);
502  f2->SetParameters(500., -1., 0.0);
503 
504  TGraphErrors* grtmp = new TGraphErrors(RHO_NBINS, Trho, Rrho, NULL, eRrho);
505  grtmp->SetMarkerStyle(20);
506  grtmp->SetMarkerSize(1.0);
507  grtmp->GetHistogram()->GetXaxis()->SetTitle("#rho");
508  grtmp->GetHistogram()->GetXaxis()->SetRangeUser(RHO_MIN,
509  Trho[RHO_NBINS - 1]);
510  grtmp->GetHistogram()->GetYaxis()->SetRangeUser(
511  f2->Eval(Trho[RHO_NBINS - 1]), f2->Eval(T_out));
512  grtmp->GetHistogram()->GetYaxis()->SetTitle("Average Range [Mpc]");
513  grtmp->GetXaxis()->SetTitleOffset(1.3);
514  grtmp->GetYaxis()->SetTitleOffset(1.25);
515  grtmp->GetXaxis()->SetTickLength(0.01);
516  grtmp->GetYaxis()->SetTickLength(0.01);
517  grtmp->GetXaxis()->CenterTitle(kTRUE);
518  grtmp->GetYaxis()->CenterTitle(kTRUE);
519  grtmp->GetXaxis()->SetTitleFont(42);
520  grtmp->GetXaxis()->SetLabelFont(42);
521  grtmp->GetYaxis()->SetTitleFont(42);
522  grtmp->GetYaxis()->SetLabelFont(42);
523  grtmp->GetYaxis()->SetMoreLogLabels(kTRUE);
524  grtmp->GetYaxis()->SetNoExponent(kTRUE);
525 
526  grtmp->Fit("f2", "R");
527 
528  c1->Clear();
529  c1->SetLogy();
530  c1->SetLogx();
531  gStyle->SetOptFit(kTRUE);
532  sprintf(fname, "%s : Range (%s) ", networkname.Data(),
533  f2->GetExpFormula().Data());
534  grtmp->SetTitle(fname);
535  grtmp->Draw("ALP");
536 
537  sprintf(fname, "%s/Range.png", odir.Data());
538  c1->Update();
539  c1->SaveAs(fname);
540 
541  delete grtmp;
542 
543  return f2;
544 }
545 
546 //______________________________________________________________________________
547 
549  TChain& liv,
550  int lag_number,
551  int slag_number,
552  int dummy) {
553  //
554  // It calculates the total live time of all time shifts.
555  // If defining a lag_number/slag_number, it calculates live time for
556  // these only. This is a semplified version of the method (same name)
557  // that can be found in the standard toolbox: it's much faster as it
558  // does less things... Input: nIFO : detector number
559  // liv : tree containing live time information
560  // lag_number : specific lag number
561  // slag_number : specific slag number
562  // dummy : used to increase calculation speed
563  //
564  // Examples : (lag_number==-1) && (slag_number==-1) -> all non zero lags
565  // : excluded (lag==0&&slag==0)
566  // (lag_number>=0) && (slag_number>=0) -> select
567  // (lag==lag_number) && (slag==slag_number) (lag_number>=0)
568  // && (slag_number==-1) -> select lag=lag_number : excluded
569  // (lag==0&&slag==0) (lag_number==-1) && (slag_number>=0) ->
570  // select slag=slag_number : excluded (lag==0&&slag==0)
571  //
572  // Note: the variable dummy has been introduced to optimize
573  // speed of the method (the reason is unknown!!!)
574 
575  float xlag[NIFO_MAX + 1];
576  float xslag[NIFO_MAX + 1];
577  double xlive;
578  double liveTot = 0.;
579  double Live = 0.;
580 
581  // check if slag is presents in liv tree
582  TBranch* branch;
583  bool slagFound = false;
584  TIter next(liv.GetListOfBranches());
585  while ((branch = (TBranch*)next())) {
586  if (TString("slag").CompareTo(branch->GetName()) == 0)
587  slagFound = true;
588  }
589  next.Reset();
590  if (!slagFound) {
591  cout << "CWB::Toolbox::getLiveTime : Error - live tree do not "
592  "contains slag leaf"
593  << endl;
594  gSystem->Exit(1);
595  }
596 
597  // liv.SetCacheSize(10000000);
598  // liv.AddBranchToCache("slag");
599  // liv.AddBranchToCache("lag");
600  // liv.AddBranchToCache("live");
601  liv.SetBranchAddress("slag", xslag);
602  liv.SetBranchAddress("lag", xlag);
603 
604  liv.SetBranchAddress("live", &xlive);
605  liv.SetBranchStatus("gps", false);
606 
607  Long64_t ntrg = liv.GetEntries();
608  for (Long64_t i = 0; i < ntrg; i++) {
609  liv.GetEntry(i);
610 
611  if ((lag_number >= 0) && (slag_number >= 0)) {
612  Live = (xlag[nIFO] == lag_number && xslag[nIFO] == slag_number)
613  ? xlive
614  : 0.; // lag/slag live time
615  }
616  if ((lag_number >= 0) && (slag_number == -1)) {
617  Live = ((xlag[nIFO] == lag_number) &&
618  !((xlag[nIFO] == 0) && (xslag[nIFO] == 0)))
619  ? xlive
620  : 0.; // lag live time
621  }
622  if ((lag_number == -1) && (slag_number >= 0)) {
623  Live = ((xslag[nIFO] == slag_number) &&
624  !((xlag[nIFO] == 0) && (xslag[nIFO] == 0)))
625  ? xlive
626  : 0.; // slag live time
627  }
628  if ((lag_number == -1) && (slag_number == -1)) {
629  Live = !((xlag[nIFO] == 0) && (xslag[nIFO] == 0))
630  ? xlive
631  : 0.; // non-zero live time
632  }
633 
634  liveTot += Live;
635  }
636  return liveTot;
637 }
638 
639 //______________________________________________________________________________
640 
641 double CWB::CBCTool::getLiveTime2(TChain& liv) {
642  // It calculates the total live time of all time shifts (both zero lag
643  // and non-zero lags) : remember to subtract the zero-lag livetime if
644  // you need precise times! This is a semplified version of the previous
645  // method: it only reads&sums the live branch...faster than the speed of
646  // light...:) (very useful for large liveTime ntuples) Input:
647  // liv : tree containing live time information
648 
649  double xlive;
650  double liveTot = 0.;
651  TBranch* LIVE = liv.GetBranch("live");
652  LIVE->SetAddress(&xlive);
653  Long64_t nentries = LIVE->GetEntries();
654  for (Long64_t i = 0; i < nentries; i++) {
655  LIVE->GetEntry(i);
656  liveTot += xlive;
657  }
658  return liveTot;
659 }
660 //______________________________________________________________________________
661 
662 double CWB::CBCTool::getZeroLiveTime(int nIFO, TChain& liv) {
663  // It calculates the total live time of zero lag
664  // This is mostly needed to correct the background estimate from the
665  // previous method
666 
667  // Input: nIFO : detector number
668  // liv : tree containing live time information
669  double liveTot = 0.;
670  char cut[256];
671 
672  sprintf(cut, "(lag[%d]==0&&slag[%d]==0)", nIFO, nIFO);
673  liv.SetEstimate(-1);
674  Long64_t nentries = liv.Draw("live", cut, "goff");
675  double* xlive = liv.GetV1();
676  for (Long64_t i = 0; i < nentries; i++) {
677  liveTot += xlive[i];
678  }
679  return liveTot;
680 }
681 
682 //______________________________________________________________________________
683 
684 //______________________________________________________________________________
685 
686 double CWB::CBCTool::getZeroLiveTime2(int nIFO, TChain& liv) {
687  // It calculates the total live time of zero lag
688  // This is mostly needed to correct the background estimate from the
689  // previous method. Yet another emplementation to improve speed wrt the
690  // previous method (best so far) : it reads from branches just when it
691  // is really needed.
692  //
693 
694  // Input: nIFO : detector number
695  // liv : tree containing live time information
696 
697  float xlag[NIFO_MAX + 1];
698  float xslag[NIFO_MAX + 1];
699  double xlive;
700  double liveTot = 0.;
701 
702  Long64_t nentries = liv.GetEntries();
703  TBranch* lag = liv.GetBranch("lag");
704  lag->SetAddress(xlag);
705  TBranch* slag = liv.GetBranch("slag");
706  slag->SetAddress(xslag);
707  TBranch* live = liv.GetBranch("live");
708  live->SetAddress(&xlive);
709 
710  for (Long64_t i = 0; i < nentries; i++) {
711  // T->LoadTree(i);
712  slag->GetEntry(i);
713  if (xslag[nIFO] != 0)
714  continue;
715  lag->GetEntry(i);
716  if (xlag[nIFO] != 0)
717  continue;
718  live->GetEntry(i);
719  liveTot += xlive;
720  }
721  return liveTot;
722 }
723 
724 //______________________________________________________________________________
725 
726 //______________________________________________________________________________
727 
728 double CWB::CBCTool::getFAR(float rho, TH1* hc, double liveTot) {
729  int w = 0;
730  while ((rho > (float)hc->GetBinCenter(w)) && (w < hc->GetNbinsX() - 1)) {
731  w++;
732  }
733  double far = (double)hc->GetBinContent(w + 1) / liveTot;
734  double efar = (double)hc->GetBinError(w + 1) / liveTot;
735 
736  return far, efar;
737 }
738 
739 //______________________________________________________________________________
740 
742  TChain& live,
743  int NSlag,
744  double SlagMin,
745  double SlagMax) {
746  TH2F* lSlag = new TH2F("LSLAG", "Live time distribution over slags", NSlag,
747  SlagMin / 86400., SlagMax / 86400., NSlag,
748  SlagMin / 86400., SlagMax / 86400.);
749  cout << "Start filling lSlag histogram : " << endl;
750  // float xlag[NIFO_MAX+1];
751  float xslag[NIFO_MAX + 1];
752  double xlive;
753  live.SetBranchStatus("*", 0); // disable all branches
754  live.SetBranchStatus("slag", 1);
755  live.SetBranchStatus("live", 1);
756  live.SetBranchAddress("slag", xslag);
757  // live.SetBranchAddress("lag",xlag);
758  live.SetBranchAddress("live", &xlive);
759  // live.SetBranchStatus("gps",false);
760 
761  long int ntrg = live.GetEntries();
762  for (long int l = 0; l < ntrg; l++) {
763  live.GetEntry(l);
764  lSlag->Fill(xslag[0] / 86400., xslag[1] / 86400., xlive);
765  if (l % 10000000 == 0) {
766  cout << scientific << (double)l / ntrg << "% - ";
767  }
768  }
769 
770  return lSlag;
771 }
772 //______________________________________________________________________________
773 
774 void CWB::CBCTool::doChirpFARPlot(int sel_events,
775  double* recMchirp,
776  double* injMchirp,
777  double* far,
778  TCanvas* c1,
779  TString odir) {
780  c1->Clear();
781  c1->SetLogx(0);
782  c1->SetLogy(0);
783  c1->SetLogz(1);
784  c1->SetTheta(89.999); // the setting of the theta and phi is for the
785  // viewing angle: there is no TGraphError with "pcol"
786  // option, so the trick is to use the 2D version and
787  // use a viewing angle the closest as possible to the
788  // vertical (Drawbacks: some artefacts due to that
789  // can be noticed; no gridlines)
790  c1->SetPhi(0.0001);
791  double efar[sel_events];
792  for (int i = 0; i < sel_events; i++) {
793  efar[i] = 0.0;
794  }
795 
796  TGraph2DErrors* gr2 = new TGraph2DErrors(sel_events, recMchirp, injMchirp,
797  far, efar, efar, efar);
798  gr2->SetMarkerStyle(20);
799  gr2->SetLineColor(20);
800  // gr2->SetMinimum(1e-4);
801  // gr2->SetMaximum(1e1);
802  gr2->SetTitle("");
803  gr2->GetHistogram()->GetXaxis()->SetTitle("Injected mchirp");
804  gr2->GetHistogram()->GetYaxis()->SetTitle("Recovered mchirp");
805  gr2->GetHistogram()->GetXaxis()->SetLimits(
806  0., 70.); // MY: Add similar line for the y axis? declare the X and
807  // Y bounds in the definition
808  gr2->GetHistogram()->GetYaxis()->SetLimits(
809  0., 70.); // MY: Add similar line for the y axis? declare the X and
810  // Y bounds in the definition
811  gr2->GetHistogram()->GetZaxis()->SetTitle("False Alarm Rate [years^{-1}]");
812  gr2->GetXaxis()->SetTitleOffset(1.3);
813  gr2->GetYaxis()->SetTitleOffset(1.25);
814  gr2->GetXaxis()->SetTickLength(0.02);
815  gr2->GetYaxis()->SetTickLength(0.01);
816  gr2->GetXaxis()->CenterTitle(kTRUE);
817  gr2->GetYaxis()->CenterTitle(kTRUE);
818  gr2->GetZaxis()->CenterTitle(kTRUE);
819  gr2->GetXaxis()->SetTitleFont(42);
820  gr2->GetXaxis()->SetLabelFont(42);
821  gr2->GetYaxis()->SetTitleFont(42);
822  gr2->GetYaxis()->SetLabelFont(42);
823  // gr2->GetYaxis()->SetMoreLogLabels(kTRUE);
824  gr2->GetYaxis()->SetNoExponent(kTRUE);
825 
826  gr2->Draw("err zcolpcol");
827  char fname[1024];
828  sprintf(fname, "%s/ChirpFAR.png", odir.Data());
829  c1->Update();
830  c1->SaveAs(fname);
831 
832  return;
833 }
834 
835 //______________________________________________________________________________
837  // Calculate the ISCO radius of a Kerr BH as a function of the Kerr
838  // parameter a : Kerr parameter
839  // Ref. Eq. (2.5) of Ori, Thorne Phys Rev D 62 124022 (2000)
840 
841  double z1 = 1. + pow((1. - pow(a, 2.)), 1. / 3) *
842  (pow(1. + a, 1. / 3) + pow(1. - a, 1. / 3));
843  double z2 = pow(3. * pow(a, 2.) + pow(z1, 2.), 1. / 2);
844  double a_sign = TMath::Sign(1., a);
845  return 3 + z2 - pow((3. - z1) * (3. + z1 + 2. * z2), 1. / 2) * a_sign;
846 }
847 
848 //______________________________________________________________________________
849 
851  /*
852  Calculate the ISCO frequency of a Kerr BH as a function of the Kerr
853  parameter
854 
855  a : Kerr parameter (numpy array)
856  */
857 
858  double r_isco = CWB::CBCTool::calc_isco_radius(a);
859  double u_isco = pow(r_isco, -0.5);
860  double v_isco =
861  u_isco *
862  pow(1. - a * pow(u_isco, 3.) + pow(a, 2.) * pow(u_isco, 6.), 1. / 3.);
863  return pow(v_isco, 3.) / TMath::Pi();
864 }
865 //______________________________________________________________________________
866 
868  double eta,
869  double delta_m,
870  double S,
871  double Delta) {
872  // Internal function: the final spin is determined by minimizing this
873  // function
874 
875  // calculate ISCO radius
876  double r_isco = CWB::CBCTool::calc_isco_radius(a_f);
877 
878  // angular momentum at ISCO -- Eq.(2.8) of Ori, Thorne Phys Rev D 62
879  // 124022 (2000)
880  double J_isco =
881  (3 * pow(r_isco, 1. / 2) - 2 * a_f) * 2. / pow(3 * r_isco, 1. / 2);
882 
883  // fitting coefficients - Table X1 of Healy et al Phys Rev D 90, 104004
884  // (2014) [forth order fits]
885  double L0 = 0.686710;
886  double L1 = 0.613247;
887  double L2a = -0.145427;
888  double L2b = -0.115689;
889  double L2c = -0.005254;
890  double L2d = 0.801838;
891  double L3a = -0.073839;
892  double L3b = 0.004759;
893  double L3c = -0.078377;
894  double L3d = 1.585809;
895  double L4a = -0.003050;
896  double L4b = -0.002968;
897  double L4c = 0.004364;
898  double L4d = -0.047204;
899  double L4e = -0.053099;
900  double L4f = 0.953458;
901  double L4g = -0.067998;
902  double L4h = 0.001629;
903  double L4i = -0.066693;
904 
905  double a_f_new =
906  pow((4. * eta), 2.) *
907  (L0 + L1 * S + L2a * Delta * delta_m + L2b * pow(S, 2.) +
908  L2c * pow(Delta, 2.) + L2d * pow(delta_m, 2.) +
909  L3a * Delta * S * delta_m + L3b * S * pow(Delta, 2.) +
910  L3c * pow(S, 3.) + L3d * S * pow(delta_m, 2.) +
911  L4a * Delta * pow(S, 2) * delta_m +
912  L4b * pow(Delta, 3.) * delta_m + L4c * pow(Delta, 4.) +
913  L4d * pow(S, 4.) + L4e * pow(Delta, 2.) * pow(S, 2.) +
914  L4f * pow(delta_m, 4.) + L4g * Delta * pow(delta_m, 3.) +
915  L4h * pow(Delta, 2.) * pow(delta_m, 2.) +
916  L4i * pow(S, 2.) * pow(delta_m, 2.)) +
917  S * (1. + 8. * eta) * pow(delta_m, 4.) +
918  eta * J_isco * pow(delta_m, 6.);
919 
920  return TMath::Abs(a_f - a_f_new);
921 }
922 
923 //______________________________________________________________________________
924 
925 double CWB::CBCTool::_final_spin_diff(Double_t* x, Double_t* par) {
926  double a_f = x[0];
927  double eta = par[0];
928  double delta_m = par[1];
929  double S = par[2];
930  double Delta = par[3];
931  // Internal function: the final spin is determined by minimizing this
932  // function
933 
934  // calculate ISCO radius
935  double r_isco = CWB::CBCTool::calc_isco_radius(a_f);
936 
937  // angular momentum at ISCO -- Eq.(2.8) of Ori, Thorne Phys Rev D 62
938  // 124022 (2000)
939  double J_isco =
940  (3 * pow(r_isco, 1. / 2) - 2 * a_f) * 2. / pow(3 * r_isco, 1. / 2);
941 
942  // fitting coefficients - Table X1 of Healy et al Phys Rev D 90, 104004
943  // (2014) [forth order fits]
944  double L0 = 0.686710;
945  double L1 = 0.613247;
946  double L2a = -0.145427;
947  double L2b = -0.115689;
948  double L2c = -0.005254;
949  double L2d = 0.801838;
950  double L3a = -0.073839;
951  double L3b = 0.004759;
952  double L3c = -0.078377;
953  double L3d = 1.585809;
954  double L4a = -0.003050;
955  double L4b = -0.002968;
956  double L4c = 0.004364;
957  double L4d = -0.047204;
958  double L4e = -0.053099;
959  double L4f = 0.953458;
960  double L4g = -0.067998;
961  double L4h = 0.001629;
962  double L4i = -0.066693;
963 
964  double a_f_new =
965  pow((4. * eta), 2.) *
966  (L0 + L1 * S + L2a * Delta * delta_m + L2b * pow(S, 2.) +
967  L2c * pow(Delta, 2.) + L2d * pow(delta_m, 2.) +
968  L3a * Delta * S * delta_m + L3b * S * pow(Delta, 2.) +
969  L3c * pow(S, 3.) + L3d * S * pow(delta_m, 2.) +
970  L4a * Delta * pow(S, 2) * delta_m +
971  L4b * pow(Delta, 3.) * delta_m + L4c * pow(Delta, 4.) +
972  L4d * pow(S, 4.) + L4e * pow(Delta, 2.) * pow(S, 2.) +
973  L4f * pow(delta_m, 4.) + L4g * Delta * pow(delta_m, 3.) +
974  L4h * pow(Delta, 2.) * pow(delta_m, 2.) +
975  L4i * pow(S, 2.) * pow(delta_m, 2.)) +
976  S * (1. + 8. * eta) * pow(delta_m, 4.) +
977  eta * J_isco * pow(delta_m, 6.);
978 
979  return TMath::Abs(a_f - a_f_new);
980 }
981 
982 //______________________________________________________________________________
983 
985  double m2,
986  double chi1,
987  double chi2) {
988  /*
989  Calculate the mass and spin of the final BH resulting from the
990  merger of two black holes with non-precessing spins
991 
992  m1, m2: component masses
993  chi1, chi2: dimensionless spins of two BHs
994  */
995 
996  // binary parameters
997  double m = m1 + m2;
998  double q = m1 / m2;
999  double eta = q / pow((1. + q), 2.);
1000  double delta_m = (m1 - m2) / m;
1001 
1002  double S1 = chi1 * pow(m1, 2.); // spin angular momentum 1
1003  double S2 = chi2 * pow(m2, 2.); // spin angular momentum 2
1004  double S = (S1 + S2) / pow(m, 2.); // symmetric spin (dimensionless --
1005  // called \tilde{S} in the paper)
1006  double Delta =
1007  (S2 / m2 - S1 / m1) / m; // antisymmetric spin (dimensionless --
1008  // called tilde{Delta} in the paper
1009 
1010  //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1011  //# compute the final spin
1012  //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1013  //# res = so.minimize_scalar(_final_spin_diff, bounds=(-0.99999,
1014  // 0.99999), args=(eta, delta_m, S, Delta), method='Bounded', tol=1e-6,
1015  // options={'maxiter':100, 'disp':False})
1016  // a_f = res.x
1017 
1018  // x, cov_x = so.leastsq(_final_spin_diff, 0., args=(eta, delta_m, S,
1019  // Delta))
1020  TF1 f("spin_diff", CWB::CBCTool::_final_spin_diff, -1.0, 1.0, 4);
1021  f.SetParameters(eta, delta_m, S, Delta);
1022  ROOT::Math::WrappedTF1 wf1(f);
1023 
1024  // Create the Integrator
1025  ROOT::Math::BrentRootFinder brf;
1026 
1027  // Set parameters of the method
1028  brf.SetFunction(wf1, -1.0, 1.0);
1029  brf.Solve();
1030 
1031  // cout << brf.Root() << endl;
1032  double a_f = brf.Root();
1033 
1034  //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1035  //# now compute the final mass
1036  //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1037  double r_isco = CWB::CBCTool::calc_isco_radius(a_f);
1038 
1039  //# fitting coefficients - Table X1 of Healy et al Phys Rev D 90, 104004
1040  //(2014) # [forth order fits]
1041  double M0 = 0.951507;
1042  double K1 = -0.051379;
1043  double K2a = -0.004804;
1044  double K2b = -0.054522;
1045  double K2c = -0.000022;
1046  double K2d = 1.995246;
1047  double K3a = 0.007064;
1048  double K3b = -0.017599;
1049  double K3c = -0.119175;
1050  double K3d = 0.025000;
1051  double K4a = -0.068981;
1052  double K4b = -0.011383;
1053  double K4c = -0.002284;
1054  double K4d = -0.165658;
1055  double K4e = 0.019403;
1056  double K4f = 2.980990;
1057  double K4g = 0.020250;
1058  double K4h = -0.004091;
1059  double K4i = 0.078441;
1060 
1061  //# binding energy at ISCO -- Eq.(2.7) of Ori, Thorne Phys Rev D 62
1062  // 124022 (2000)
1063  double E_isco =
1064  (1. - 2. / r_isco + a_f / pow(r_isco, 1.5)) /
1065  pow(1. - 3. / r_isco + 2. * a_f / pow(r_isco, 1.5), 1. / 2.);
1066 
1067  //# final mass -- Eq. (14) of Healy et al Phys Rev D 90, 104004 (2014)
1068  double mf = pow(4. * eta, 2.) *
1069  (M0 + K1 * S + K2a * Delta * delta_m + K2b * pow(S, 2.) +
1070  K2c * pow(Delta, 2.) + K2d * pow(delta_m, 2.) +
1071  K3a * Delta * S * delta_m + K3b * S * pow(Delta, 2.) +
1072  K3c * pow(S, 3.) + K3d * S * pow(delta_m, 2.) +
1073  K4a * Delta * pow(S, 2.) * delta_m +
1074  K4b * pow(Delta, 3.) * delta_m + K4c * pow(Delta, 4.) +
1075  K4d * pow(S, 4.) + K4e * pow(Delta, 2.) * pow(S, 2.) +
1076  K4f * pow(delta_m, 4.) + K4g * Delta * pow(delta_m, 3.) +
1077  K4h * pow(Delta, 2.) * pow(delta_m, 2.) +
1078  K4i * pow(S, 2.) * pow(delta_m, 2.)) +
1079  (1 + eta * (E_isco + 11.)) * pow(delta_m, 6.);
1080 
1081  return mf * m;
1082 }
1083 
1084 double CWB::CBCTool::chip(double m1,
1085  double m2,
1086  double s1x,
1087  double s1y,
1088  double s1z,
1089  double s2x,
1090  double s2y,
1091  double s2z) {
1092  /*
1093  Calculate the dimensionless precession spin parameter chi_p in source
1094  frame
1095 
1096  m1, m2: component masses in solar masses
1097  s{1,2}_{x,y,z}: dimensionless spins of two BHs
1098  */
1099 
1100  double M = m1 + m2;
1101  double m1_2 = m1 * m1;
1102  double m2_2 = m2 * m2;
1103  double eta = m1 * m2 / (M * M); /* Symmetric mass-ratio */
1104 
1105  /* Aligned spins */
1106  double chi1_l = s1z; /* Dimensionless aligned spin on BH 1 */
1107  double chi2_l = s2z; /* Dimensionless aligned spin on BH 2 */
1108 
1109  /* Magnitude of the spin projections in the orbital plane */
1110  double S1_perp = m1_2 * sqrt(s1x * s1x + s1y * s1y);
1111  double S2_perp = m2_2 * sqrt(s2x * s2x + s2y * s2y);
1112 
1113  /* From this we can compute chip*/
1114  double A1 = 2 + (3 * m2) / (2 * m1);
1115  double A2 = 2 + (3 * m1) / (2 * m2);
1116  double ASp1 = A1 * S1_perp;
1117  double ASp2 = A2 * S2_perp;
1118  double num = (ASp2 > ASp1) ? ASp2 : ASp1;
1119  double den = (m2 > m1) ? A2 * m2_2 : A1 * m1_2;
1120 
1121  double chip =
1122  num / den; /* chip = max(A1 Sp1, A2 Sp2) / (A_i m_i^2) for i index
1123  of larger BH (See Eqn. 32 in technical document) */
1124 
1125  return chip;
1126 }
1127 //______________________________________________________________________________
1128 
1129 void CWB::CBCTool::AddChip(TString filein, TString treename) {
1130  // CWB::CBCTool cbcTool;
1131  TFile* f = new TFile(filein, "update");
1132  TTree* T = (TTree*)f->Get(treename);
1133  float mass[2];
1134  float spin[6];
1135  float chip;
1136  TBranch* bchip = T->Branch("chip", &chip, "chip/F");
1137  T->SetBranchAddress("mass", mass);
1138  T->SetBranchAddress("spin", spin);
1139  Long64_t nentries = T->GetEntries();
1140  for (Long64_t i = 0; i < nentries; i++) {
1141  T->GetEntry(i);
1142  chip = CWB::CBCTool::chip(mass[0], mass[1], spin[0], spin[1], spin[2],
1143  spin[3], spin[4], spin[5]);
1144  // cout << mass[0] << " " << mass[1] << " " << spin[0] << " "
1145  // << spin[1] << " " << spin[2] << " " << spin[3] << " " <<
1146  // spin[4] << " " <<spin[5] << endl;
1147  bchip->Fill();
1148  }
1149  T->Print();
1150  T->Write();
1151  delete f;
1152 }
1153 
1154 //______________________________________________________________________________
1155 
1156 // Creates various distance vs pars plots
1157 // Note : this method is used to generate the CBC report
1158 
1159 #define MAXY 50000.0
1160 #define MAXSNR 150.0
1161 
1163  char* mdc_file_name,
1164  char* netdir,
1165  TString opt = "",
1166  double MINX = 0.0,
1167  double MAXX = 1.0,
1168  double MAXDISTANCE = 5000.,
1169  int NBIN_DIST = 10,
1170  float T_ifar = 0.0,
1171  float T_win = 0.2,
1172  int nIFO = 2) {
1173  TCanvas* co_canvas3 = new TCanvas("sd3", "SD3", 3, 47, 1000, 802);
1174  co_canvas3->SetGridx();
1175  co_canvas3->SetGridy();
1176  co_canvas3->SetLogy();
1177 
1178  float myifar, netcc[3];
1179  float rho[2];
1180  double mytime[6];
1181  float factor, mydistance, mchirp;
1182  float mass[2];
1183  float spin[6];
1184  float chip;
1185  float iSNR[nIFO];
1186  float snr[nIFO];
1187  float chirp[6];
1188  float range[2];
1189  float iota[2];
1190 
1191  TFile* filein = new TFile(sim_file_name);
1192  TTree* sim = nullptr;
1193  filein->GetObject("waveburst", sim);
1194  if (!sim->GetListOfBranches()->FindObject("chip")) {
1195  cout << "Adding Chi_p branch to wave tree" << endl;
1196  CWB::CBCTool::AddChip(sim_file_name, "waveburst");
1197  }
1198  sim->SetBranchAddress("mass", mass);
1199  sim->SetBranchAddress("factor", &factor);
1200  sim->SetBranchAddress("range", range);
1201  sim->SetBranchAddress("chirp", chirp);
1202  sim->SetBranchAddress("rho", rho);
1203  sim->SetBranchAddress("netcc", netcc);
1204  sim->SetBranchAddress("ifar", &myifar);
1205  sim->SetBranchAddress("time", mytime);
1206  sim->SetBranchAddress("spin", spin);
1207  sim->SetBranchAddress("chip", &chip);
1208  sim->SetBranchAddress("iSNR", iSNR);
1209  sim->SetBranchAddress("iota", iota);
1210 
1211  TFile* filein2 = new TFile(mdc_file_name);
1212  TTree* mdc = nullptr;
1213  filein2->GetObject("mdc", mdc);
1214  gROOT->cd();
1215  if (!mdc->GetListOfBranches()->FindObject("chip")) {
1216  cout << "Adding Chi_p branch to mdc tree" << endl;
1217  CWB::CBCTool::AddChip(mdc_file_name, "mdc");
1218  }
1219 
1220  mdc->SetBranchAddress("time", mytime);
1221  mdc->SetBranchAddress("mass", mass);
1222  mdc->SetBranchAddress("factor", &factor);
1223  mdc->SetBranchAddress("distance", &mydistance);
1224  mdc->SetBranchAddress("mchirp", &mchirp);
1225  mdc->SetBranchAddress("spin", spin);
1226  mdc->SetBranchAddress("chip", &chip);
1227  mdc->SetBranchAddress("snr", snr);
1228  mdc->SetBranchAddress("iota", iota);
1229 
1230  int nevts = (int)mdc->GetEntries();
1231  float CYS = 86400. * 365.25;
1232 
1233  cout << nevts << " injected signals " << sim->GetEntries("ifar>0")
1234  << " recovered signals" << endl;
1235  int countv = 0;
1236  int countvifar = 0;
1237  int cnt = 0;
1238  std::vector<double> xi, xr, yi, yr;
1239 
1240  auto inj = new TH2F("Injected snr vs stat inj", "", NBIN_DIST, MINX, MAXX,
1241  100, 0.0, MAXSNR);
1242  // auto SNR= new TH2F("iSNR vs stat", "", 10, MINX, MAXX, 100,0.0,
1243  // 100.0);
1244  TMultiGraph* mg = new TMultiGraph();
1245 
1246  if (opt.Contains("chieff")) {
1247  inj->GetXaxis()->SetTitle("#chi_{eff}");
1248  mg->GetXaxis()->SetTitle("#chi_{eff}");
1249  } else if (opt.Contains("chip")) {
1250  inj->GetXaxis()->SetTitle("#chi_{p}");
1251  mg->GetXaxis()->SetTitle("#chi_{p}");
1252  } else if (opt.Contains("chirp")) {
1253  inj->GetXaxis()->SetTitle("Chirp Mass (M_{#odot})");
1254  mg->GetXaxis()->SetTitle("Chirp Mass (M_{#odot})");
1255  } else if (opt.Contains("mtot")) {
1256  inj->GetXaxis()->SetTitle("Total Mass (M_{#odot})");
1257  mg->GetXaxis()->SetTitle("Total Mass (M_{#odot})");
1258  } else if (opt.Contains("eta")) {
1259  inj->GetXaxis()->SetTitle("#eta, Symmetric Mass Ratio");
1260  mg->GetXaxis()->SetTitle("#eta, Symmetric Mass Ratio");
1261  } else if (opt.Contains("iota")) {
1262  inj->GetXaxis()->SetTitle("Cos(#iota), Inclination");
1263  mg->GetXaxis()->SetTitle("Cos(#iota), Inclination");
1264  } else if (opt.Contains("distance")) {
1265  inj->GetXaxis()->SetTitle("Sensitive Distance (Mpc)");
1266  mg->GetXaxis()->SetTitle("Injected snr");
1267  // cout <<"Distance plots" << endl;
1268  } else {
1269  cout << "Not a valid option! "
1270  "opt={\"chip\",\"chirp\",\"eta\",\"mtot\", \"chieff\", "
1271  " \"iota\"}"
1272  << endl;
1273  exit(1);
1274  }
1275 
1276  // inj->GetYaxis()->SetRangeUser(10., MAXDISTANCE);
1277  inj->GetYaxis()->SetTitle("Injected snr");
1278  inj->GetXaxis()->SetTitleOffset(1.3);
1279  inj->GetYaxis()->SetTitleOffset(1.3);
1280  inj->GetXaxis()->SetTickLength(0.01);
1281  inj->GetYaxis()->SetTickLength(0.01);
1282  inj->GetXaxis()->CenterTitle(kTRUE);
1283  inj->GetYaxis()->CenterTitle(kTRUE);
1284  inj->GetXaxis()->SetTitleFont(42);
1285  inj->GetXaxis()->SetLabelFont(42);
1286  inj->GetYaxis()->SetTitleFont(42);
1287  inj->GetYaxis()->SetLabelFont(42);
1288  inj->SetMarkerStyle(20);
1289  inj->SetMarkerSize(0.5);
1290  inj->SetMarkerColor(2);
1291  inj->SetTitle("");
1292  TH2F* rec = (TH2F*)inj->Clone("Injected snr vs stat rec");
1293  // rec->GetYaxis()->SetRangeUser(10., MAXDISTANCE/1000);
1294  // TH2F *SNRrec = (TH2F *)SNR->Clone("iSNR vs stat rec");
1295  rec->SetMarkerColor(4);
1296 
1297  mg->GetYaxis()->SetTitle("Sensitive Distance (Mpc)");
1298  // mg->GetXaxis()->SetTitle("Inverse False Alarm Rate [yr]");
1299  mg->GetXaxis()->SetTitleOffset(1.3);
1300  mg->GetYaxis()->SetTitleOffset(1.3);
1301  mg->GetXaxis()->SetTickLength(0.01);
1302  mg->GetYaxis()->SetTickLength(0.01);
1303  mg->GetXaxis()->CenterTitle(kTRUE);
1304  mg->GetYaxis()->CenterTitle(kTRUE);
1305  mg->GetXaxis()->SetTitleFont(42);
1306  mg->GetXaxis()->SetLabelFont(42);
1307  mg->GetYaxis()->SetTitleFont(42);
1308  mg->GetYaxis()->SetLabelFont(42);
1309  mg->SetTitle("");
1310 
1311  // Loop over mdc TTree
1312  float SNR2, mSNR;
1313  for (int g = 0; g < (int)mdc->GetEntries(); g++) {
1314  mdc->GetEntry(g);
1315  SNR2 = pow(snr[0], 2.0) + pow(snr[1], 2.0);
1316  for (int i = 2; i < nIFO; i++) {
1317  SNR2 += pow(snr[i], 2.0);
1318  }
1319  mSNR = TMath::Sqrt(SNR2);
1320  yi.push_back(mydistance);
1321  if (opt.Contains("chieff")) {
1322  xi.push_back((spin[2] * mass[0] + spin[5] * mass[1]) /
1323  (mass[1] + mass[0]));
1324  } else if (opt.Contains("chip")) {
1325  xi.push_back(chip);
1326  } else if (opt.Contains("chirp")) {
1327  xi.push_back(mchirp);
1328  } else if (opt.Contains("mtot")) {
1329  xi.push_back(mass[0] + mass[1]);
1330  } else if (opt.Contains("eta")) {
1331  xi.push_back(mass[0] * mass[1] / pow(mass[0] + mass[1], 2.0));
1332  } else if (opt.Contains("iota")) {
1333  xi.push_back(iota[1]);
1334  } else if (opt.Contains("distance")) {
1335  xi.push_back(mydistance);
1336  }
1337 
1338  inj->Fill(xi[xi.size() - 1], mSNR);
1339  // SNR->Fill(xi[xi.size()-1], mSNR);
1340  }
1341  // cout << MINX << " " << MAXX << " " << NBIN_DIST << " " << MAXDISTANCE
1342  // << endl;
1343  inj->Draw("p");
1344  // Loop over sim TTree
1345  for (int g = 0; g < (int)sim->GetEntries(); g++) {
1346  sim->GetEntry(g);
1347  // ifactor = (int)factor - 1;
1348  // cout << "g=" << g << " trueindex=" <<index1[g] <<" IFAR=" <<
1349  // myifar/CYS << " RHO1=" << rho[1] <<endl;
1350  if (myifar <= T_ifar * CYS) {
1351  countvifar++;
1352  // cout << g << " " <<index1[g] <<" " << myifar/CYS << "
1353  // ";
1354  continue;
1355  }
1356 
1357  if ((mytime[0] - mytime[nIFO]) < -T_win ||
1358  (mytime[0] - mytime[nIFO]) > 2 * T_win) {
1359  countv++;
1360  continue;
1361  } // NOT checking for detector 1 and 2: very small bias...
1362  SNR2 = 0.0;
1363  for (int i = 0; i < nIFO; i++) {
1364  SNR2 += iSNR[i];
1365  }
1366  mSNR = TMath::Sqrt(SNR2);
1367  yr.push_back(range[1]);
1368  if (opt.Contains("chieff")) {
1369  xr.push_back((spin[2] * mass[0] + spin[5] * mass[1]) /
1370  (mass[1] + mass[0]));
1371  cnt++;
1372  } else if (opt.Contains("chip")) {
1373  xr.push_back(chip);
1374  cnt++;
1375  } else if (opt.Contains("chirp")) {
1376  xr.push_back(chirp[0]);
1377  cnt++;
1378  } else if (opt.Contains("mtot")) {
1379  xr.push_back(mass[1] + mass[0]);
1380  cnt++;
1381  } else if (opt.Contains("eta")) {
1382  xr.push_back(mass[0] * mass[1] / pow(mass[0] + mass[1], 2.0));
1383  cnt++;
1384  } else if (opt.Contains("iota")) {
1385  xr.push_back(iota[1]);
1386  cnt++;
1387  } else if (opt.Contains("distance")) {
1388  xr.push_back(range[1]);
1389  cnt++;
1390  }
1391  rec->Fill(xr[xr.size() - 1], mSNR);
1392  }
1393 
1394  cout << endl;
1395  // cout << countvifar << " events vetoed by T_ifar : " << T_ifar <<
1396  // endl;
1397  // cout << countv << " events vetoed by T_win" << endl;
1398  // cout << rec->GetEntries() << " events selected" << endl;
1399 
1400  char lab[1024];
1401  char fname[1024];
1402  char fname2[1024];
1403  char fname3[1024];
1404 
1405  sprintf(fname, "%s/iSNR_vs_%s.eps", netdir, opt.Data());
1406  sprintf(fname3, "%s/Distance_vs_%s.eps", netdir, opt.Data());
1407  sprintf(fname2, "%s/%s_distribution.png", netdir, opt.Data());
1408 
1409  // D_Chi_rec->GetYaxis()->SetRangeUser(10.,3*MAXDISTANCE);
1410  // co_canvas3->SetLogx();
1411  inj->Draw("p");
1412  rec->Draw("p same");
1413  auto leg_D = new TLegend(0.6, 0.1, 0.9, 0.25, "", "brNDC");
1414  sprintf(lab, "Injections: %i", (int)mdc->GetEntries());
1415  leg_D->AddEntry("", lab, "a");
1416  sprintf(lab, "found: %i", cnt);
1417  leg_D->AddEntry(rec, lab, "p");
1418  sprintf(lab, "missed: %i", (int)mdc->GetEntries() - cnt);
1419  leg_D->AddEntry(inj, lab, "p");
1420  leg_D->SetFillColor(0);
1421  leg_D->SetFillColorAlpha(0, 0.9);
1422  leg_D->Draw();
1423  co_canvas3->SaveAs(fname);
1424  co_canvas3->SetLogx(0);
1425  // Test new scatter plot
1426  TGraph* rec_gr = new TGraph(xr.size(), &xr[0], &yr[0]);
1427  TGraph* inj_gr = new TGraph(xi.size(), &xi[0], &yi[0]);
1428  TH1D* injx;
1429  TH1D* recx;
1430  TH1D* snrx;
1431  if (!opt.Contains("distance")) {
1432  inj_gr->SetMarkerColor(2);
1433  inj_gr->SetMarkerStyle(20);
1434  inj_gr->SetMarkerSize(0.5);
1435 
1436  rec_gr->SetMarkerColor(4);
1437  rec_gr->SetMarkerStyle(20);
1438  rec_gr->SetMarkerSize(0.5);
1439 
1440  mg->Add(inj_gr);
1441  mg->Add(rec_gr);
1442  // mg->Draw("aple3");
1443  co_canvas3->Clear();
1444  mg->GetXaxis()->SetLimits(MINX, MAXX);
1445  mg->GetYaxis()->SetRangeUser(10., MAXDISTANCE);
1446  mg->Draw("ap");
1447  // rec_gr->Draw("ap");
1448  leg_D->Draw();
1449  co_canvas3->SaveAs(fname3);
1450  injx = (TH1D*)inj->ProjectionX();
1451  recx = (TH1D*)rec->ProjectionX();
1452  snrx = (TH1D*)inj->ProfileX();
1453  } else {
1454  injx = (TH1D*)inj->ProjectionX();
1455  recx = (TH1D*)rec->ProjectionX();
1456  snrx = (TH1D*)inj->ProfileX();
1457  }
1458 
1459  injx->Sumw2();
1460  // injx->SetFillColor(kRed);
1461  injx->SetFillColorAlpha(kRed, 0.3);
1462  injx->SetFillStyle(3004);
1463  recx->Sumw2();
1464  recx->SetFillColorAlpha(kBlue, 0.99);
1465  recx->SetFillStyle(3001);
1466 
1467  co_canvas3->Clear();
1468  co_canvas3->SetLogx(0);
1469 
1470  // Ratio plot
1471  auto rp1 = new TRatioPlot(recx, injx, "divsym");
1472  rp1->SetH1DrawOpt("PEBAR");
1473  rp1->SetH2DrawOpt("PEBAR");
1474  rp1->SetGraphDrawOpt("PB");
1475  rp1->SetSeparationMargin(0.01);
1476 
1477  // rp1->SetConfidenceIntervalColors();
1478  rp1->Draw("PEBAR");
1479  rp1->SetSplitFraction(0.5);
1480  // if (!opt.Contains("distance")){
1481  rp1->GetUpperRefYaxis()->SetRangeUser(1., MAXY);
1482  // rp1->GetLowerRefGraph()->SetMinimum(0.0);
1483  // rp1->GetLowerRefGraph()->SetMaximum(1.0);
1484  /* } else {
1485  //co_canvas3->SetLog();
1486  rp1->GetUpperRefYaxis()->SetRangeUser(1.,MAXY);
1487  //rp1->GetUpperRefXaxis()->SetRangeUser(1.,2000.);
1488  rp1->GetLowerRefGraph()->SetMinimum(0.0);
1489  rp1->GetLowerRefGraph()->SetMaximum(1.0);
1490  //rp1->GetLowYaxis()->SetNdivisions(510);
1491  }*/
1492 
1493  rp1->GetLowerRefYaxis()->SetTitle("ratio");
1494  rp1->GetLowerRefYaxis()->CenterTitle(kTRUE);
1495  rp1->GetUpperRefYaxis()->SetTitle("entries");
1496  rp1->GetUpperRefYaxis()->CenterTitle(kTRUE);
1497  // rp1->GetUpperRefYaxis()->SetLineColor(kBlue);
1498  rp1->GetLowerRefYaxis()->SetLabelColor(kBlue);
1499  rp1->GetLowerRefXaxis()->CenterTitle(kTRUE);
1500  rp1->GetLowerRefXaxis()->SetTitleOffset(1.3);
1501  rp1->GetLowerRefGraph()->SetFillColor(kBlue);
1502  rp1->GetLowerRefGraph()->SetFillStyle(3001);
1503  // leg_D2->Draw();
1504 
1505  auto leg_D3 = new TLegend(0.6, 0.8455, 0.8965, 0.94555, "", "brNDC");
1506  // sprintf(lab, "Injections: %i", (int)mdc->GetEntries());
1507  // leg_D3->AddEntry("", lab, "a");
1508  sprintf(lab, "Injected: %i", (int)mdc->GetEntries());
1509  leg_D3->AddEntry(inj, lab, "p");
1510  sprintf(lab, "Found: %i", cnt);
1511  leg_D3->AddEntry(rec, lab, "p");
1512  // leg_D3->SetFillColor(0);
1513  leg_D3->SetFillColorAlpha(0, 0.9);
1514  leg_D3->Draw();
1515  // TGraph *g = rp1->GetLowerRefGraph();
1516  // rp11 = TRatioPlot(h1,h0)
1517  // rp1->GetUpperPad()->cd()
1518  // h2->Draw("same")
1519  rp1->GetLowerPad()->cd();
1520  // TPad* mp = (TPad*)rp1->GetLowerPad();
1521 
1522  Float_t rightmax = 1.2 * snrx->GetMaximum();
1523  Float_t rightmin = 0.8 * snrx->GetMinimum();
1524  double ymax = rp1->GetLowerRefYaxis()->GetXmax();
1525  double ymin = rp1->GetLowerRefYaxis()->GetXmin();
1526  double xmax = rp1->GetLowerRefXaxis()->GetXmax();
1527  Float_t scale = (ymax) / (rightmax);
1528  // cout << "rightmax: " << rightmax << " Uymax: "<<gPad->GetUymax() << "
1529  // scale: " << scale << endl; g->Draw(); rp1->GetLowerPad()->cd();
1530  snrx->Scale(scale);
1531  snrx->SetLineColor(kGreen + 2);
1532  snrx->SetMarkerColor(kGreen + 2);
1533  // snrx->SetFillColor(kGreen+2);
1534  snrx->SetFillColorAlpha(kGreen + 2, 0.4);
1535  snrx->SetFillStyle(3001);
1536  snrx->SetMarkerStyle(20);
1537  snrx->SetMarkerSize(0.5);
1538 
1539  snrx->Draw("SAME PEBAR");
1540  // TGaxis*myaxis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
1541  // gPad->GetUxmax(),gPad->GetUymax(), 0,rightmax,510,"+L");
1542  TGaxis* myaxis =
1543  new TGaxis(xmax, ymin, xmax, ymax, rightmin, rightmax, 510, "+SL");
1544  myaxis->SetLineColor(kGreen + 2);
1545  myaxis->SetLabelColor(kGreen + 2);
1546  myaxis->SetTitle("Average Injected SNR");
1547  myaxis->SetTitleOffset(0.7);
1548  myaxis->SetTickLength(0.01);
1549  myaxis->CenterTitle(kTRUE);
1550  myaxis->SetTitleFont(42);
1551  myaxis->SetLabelFont(42);
1552  myaxis->SetLabelSize(0.06);
1553  myaxis->SetTitleSize(0.06);
1554 
1555  myaxis->Draw();
1556 
1557  auto leg_D4 = new TLegend(0.6, 0.75, 0.9, 0.975, "", "brNDC");
1558  // sprintf(lab, "Injections: %i", (int)mdc->GetEntries());
1559  // leg_D3->AddEntry("", lab, "a");
1560  sprintf(lab, "Ratio (i.e. Found / Injected)");
1561  leg_D4->AddEntry(recx, lab, "p");
1562  sprintf(lab, "Average Injected SNR");
1563  leg_D4->AddEntry(snrx, lab, "p");
1564  // leg_D3->SetFillColor(0);
1565  leg_D4->SetFillColorAlpha(0, 0.9);
1566  // leg_D4->Draw();
1567  // rp1->GetLowYaxis()->SetNdivisions(505);
1568  co_canvas3->Update();
1569 
1570  if (!opt.Contains("I")) {
1571  rp1->GetLowerPad()->SetEditable(kFALSE);
1572  co_canvas3->SaveAs(fname2);
1573  filein->Close();
1574  filein2->Close();
1575  delete filein, filein2;
1576  delete co_canvas3;
1577  delete inj, rec, injx, recx, snrx, leg_D, leg_D3, leg_D4, rp1, myaxis;
1578  xi.clear(), xr.clear(), yi.clear(), yr.clear();
1579  delete inj_gr, rec_gr, mg;
1580  }
1581 
1582  // exit(0);
1583 }
1584 
1585 //______________________________________________________________________________
1586 
1587 // Create Graphs of Radius vs IFAR
1588 // Note : this method is used to generate the CBC report
1589 
1590 #define MINMAXIFAR 4278.
1591 
1593  char* mdc_file_name,
1594  TString SEL,
1595  float shell_volume,
1596  Color_t color = kBlue,
1597  TString opt = "default",
1598  double liveTot = 1e6,
1599  float T_ifar = 0.0,
1600  float T_win = 0.2,
1601  int TRIALS = 1,
1602  int nIFO = 2,
1603  float VT = 1.0,
1604  float Tscale = 1.0) {
1605  float myifar, netcc[3];
1606  float rho[2];
1607  double mytime[6];
1608  float factor, distance, mchirp;
1609  float mass[2];
1610  float spin[6];
1611  // float chi[3];
1612 
1613  float chirp[6];
1614  float range[2];
1615 
1616  CWB::CBCTool cbcTool;
1617 
1618  TFile* filein = new TFile(sim_file_name);
1619  TTree* sim_org = nullptr;
1620  filein->GetObject("waveburst", sim_org);
1621  gROOT->cd();
1622  if (!sim_org->GetListOfBranches()->FindObject("chip")) {
1623  cout << "Adding Chi_p branch to wave tree" << endl;
1624  cbcTool.AddChip(sim_file_name, "waveburst");
1625  }
1626  TTree* sim = sim_org->CopyTree(SEL);
1627  sim->SetBranchAddress("mass", mass);
1628  sim->SetBranchAddress("factor", &factor);
1629  sim->SetBranchAddress("range", range);
1630  sim->SetBranchAddress("chirp", chirp);
1631  sim->SetBranchAddress("rho", rho);
1632  sim->SetBranchAddress("netcc", netcc);
1633  sim->SetBranchAddress("ifar", &myifar);
1634  sim->SetBranchAddress("time", mytime);
1635  sim->SetBranchAddress("spin", spin);
1636 
1637  TFile* filein2 = new TFile(mdc_file_name);
1638  TTree* mdc_org = nullptr;
1639  filein2->GetObject("mdc", mdc_org);
1640  gROOT->cd();
1641  SEL.ReplaceAll("chirp[0]", "mchirp");
1642  if (!mdc_org->GetListOfBranches()->FindObject("chip")) {
1643  cout << "Adding Chi_p branch to mdc tree" << endl;
1644  cbcTool.AddChip(mdc_file_name, "mdc");
1645  }
1646  TTree* mdc = mdc_org->CopyTree(SEL);
1647  mdc->SetBranchAddress("time", mytime);
1648  mdc->SetBranchAddress("mass", mass);
1649  mdc->SetBranchAddress("factor", &factor);
1650  mdc->SetBranchAddress("distance", &distance);
1651  mdc->SetBranchAddress("mchirp", &mchirp);
1652  mdc->SetBranchAddress("spin", spin);
1653 
1654  double dV = 0.0;
1655  std::vector<double> vdv;
1656  std::vector<double> vifar;
1657  std::vector<double> vrho;
1658  std::vector<double> vV;
1659  std::vector<double> veV;
1660  std::vector<double> vR;
1661  std::vector<double> veR;
1662  std::vector<double> vsifar;
1663  std::vector<double> vseifar;
1664  std::vector<double> vVr;
1665  std::vector<double> veVr;
1666  std::vector<double> vRr;
1667  std::vector<double> veRr;
1668  std::vector<double> vsrho;
1669  TGraphErrors* co_gr = nullptr;
1670 
1671  int nevts = (int)mdc->GetEntries();
1672  if (nevts == 0) {
1673  cout << "No events left after cut!" << endl;
1674  vR.push_back(0.0);
1675  vsifar.push_back(0.0);
1676  co_gr = new TGraphErrors(vR.size(), &vsifar[0], &vR[0], 0, 0);
1677  return co_gr;
1678  }
1679  float shell_volume_per_injection = shell_volume / nevts;
1680  int ifactor;
1681  float maxIFAR = 0.0;
1682  float CYS = 86400. * 365.25;
1683  if (sim->GetListOfBranches()->FindObject("ifar")) {
1684  maxIFAR = TMath::CeilNint(sim->GetMaximum("ifar") / CYS);
1685  // cout << "Maximum empirically estimated IFAR : " << maxIFAR <<
1686  // " [years]" << endl;
1687  } else {
1688  cout << "Missing ifar branch: either use cbc_plots or add it "
1689  "to wave tree."
1690  << endl;
1691  exit(1);
1692  }
1693  if (opt.Contains("rho")) {
1694  sim->BuildIndex("0", "rho[1]*10000"); // BEWARE rho[1] could be
1695  // search depandent!
1696  } else {
1697  sim->BuildIndex(
1698  "ifar",
1699  "rho[1]*1000"); // BEWARE rho[1] could be search depandent!
1700  }
1701  TTreeIndex* I1 = (TTreeIndex*)sim->GetTreeIndex(); // get the tree index
1702  Long64_t* index1 =
1703  I1->GetIndex(); // create an array of entries in sorted order
1704 
1705  // cout << nevts << " injected signals " << sim->GetEntries("ifar>0") <<
1706  // " recovered signals" <<endl;
1707  int countv = 0;
1708  int countvifar = 0;
1709  bool Error = false;
1710  double mpcTscale = 1.0;
1711  for (int g = 0; g < (int)sim->GetEntries(); g++) {
1712  sim->GetEntry(index1[g]);
1713  ifactor = (int)factor - 1;
1714  // cout << "g=" << g << " trueindex=" <<index1[g] <<" IFAR=" <<
1715  // myifar/CYS << " RHO1=" << rho[1] <<endl;
1716  if (myifar <= T_ifar * CYS) {
1717  countvifar++;
1718  // cout << g << " " <<index1[g] <<" " << myifar/CYS << "
1719  // ";
1720  continue;
1721  }
1722 
1723  if ((mytime[0] - mytime[nIFO]) < -T_win ||
1724  (mytime[0] - mytime[nIFO]) > 2 * T_win) {
1725  countv++;
1726  continue;
1727  } // NOT checking for detector 1 and 2: very small bias...
1728 
1729  if (opt.Contains("DDistrVolume")) {
1730  dV = shell_volume_per_injection;
1731  } else if (opt.Contains("DDistrUniform")) {
1732  dV = pow(range[1], 2) * shell_volume_per_injection;
1733  } else if (opt.Contains("DDistrChirpMass")) {
1734  dV = pow(range[1], 2) * shell_volume_per_injection *
1735  pow(chirp[0] / 1.22, 5. / 6.);
1736  } else if (opt.Contains("Redshift")) {
1737  dV = VT / (double)nevts;
1738  mpcTscale = Tscale * 1e-9; // Conversion from Gpc^3 to Mpc^3
1739  } else {
1740  if (!Error) {
1741  cout << "No defined distance distribution? "
1742  "WARNING: Assuming uniform in volume"
1743  << endl;
1744  Error = 1;
1745  }
1746  dV = shell_volume_per_injection;
1747  }
1748  // vdv.push_back(dV+internal_volume);
1749  vdv.push_back(dV);
1750  vifar.push_back(myifar);
1751  vrho.push_back(rho[1]);
1752  }
1753 
1754  // cout << endl;
1755  // cout << countvifar << " events vetoed by T_ifar : " << T_ifar <<
1756  // endl; cout << countv << " events vetoed by T_win" << endl; cout <<
1757  // vdv.size() << " events selected" << endl;
1758 
1759  // cout << "DEB2" << endl;
1760  vV.push_back(vdv[vdv.size() - 1]);
1761  veV.push_back(pow(vdv[vdv.size() - 1], 2));
1762  if (vifar[vdv.size() - 1] < MINMAXIFAR * CYS) {
1763  vsifar.push_back(vifar[vdv.size() - 1]);
1764  } else {
1765  vsifar.push_back(MINMAXIFAR * CYS);
1766  }
1767  vVr.push_back(vdv[vdv.size() - 1]);
1768  veVr.push_back(pow(vdv[vdv.size() - 1], 2));
1769  vsrho.push_back(vrho[vdv.size() - 1]);
1770  // cout << "vifar[vdv.size()-1] = " << vifar[vdv.size()-1] << endl;
1771  // cout << "vsifar[0] = " << vsifar[0] << endl;
1772  // break;
1773  int mcount_ifar = 0;
1774  int mcount_rho = 0;
1775  for (int i = vdv.size() - 1; i >= 0; i--) {
1776  if (vifar[i] == 0) {
1777  continue;
1778  }
1779  if (vifar[i] > vsifar[0]) {
1780  vV[0] += vdv[i];
1781  veV[0] += pow(vdv[i], 2);
1782  } else if (vifar[i] == vsifar[mcount_ifar]) {
1783  vV[mcount_ifar] += vdv[i];
1784  veV[mcount_ifar] += pow(vdv[i], 2);
1785  } else {
1786  vsifar.push_back(vifar[i]);
1787  vseifar.push_back(TMath::Sqrt(TMath::Nint(liveTot * vifar[i])));
1788  vV.push_back(vV[mcount_ifar] + vdv[i]);
1789  veV.push_back(veV[mcount_ifar] + pow(vdv[i], 2));
1790  mcount_ifar++;
1791  }
1792  // cout << i << " " << vsifar[mcount_ifar] << " " <<
1793  // vV[mcount_ifar] << endl;
1794  if (vrho[i] == vsrho[mcount_rho]) {
1795  vVr[mcount_rho] += vdv[i];
1796  veVr[mcount_rho] += pow(vdv[i], 2);
1797  } else {
1798  vsrho.push_back(vrho[i]);
1799  vVr.push_back(vVr[mcount_rho] + vdv[i]);
1800  veVr.push_back(veVr[mcount_rho] + pow(vdv[i], 2));
1801  mcount_rho++;
1802  }
1803  }
1804  // cout << "Length of ifar/volume vector: " << vV.size() << endl;
1805  // cout << "Length of rho/volume vector: " << vVr.size() << endl;
1806  // float
1807  for (int i = 0; i < (int)vV.size(); i++) {
1808  veV[i] = TMath::Sqrt(veV[i]);
1809  vsifar[i] /= (TRIALS * CYS);
1810  vR.push_back(pow(3. / (4. * TMath::Pi() * mpcTscale) * vV[i], 1. / 3.));
1811  veR.push_back(pow(3. / (4 * TMath::Pi() * mpcTscale), 1. / 3.) * 1. /
1812  3 * pow(vV[i], -2. / 3.) * veV[i]);
1813  // cout << i << " " << vsifar[i] << " " << vR[i] << " "
1814  //<<vV[i] <<endl;
1815  }
1816 
1817  for (int i = 0; i < (int)vVr.size(); i++) {
1818  veVr[i] = TMath::Sqrt(veVr[i]);
1819  vRr.push_back(
1820  pow(3. / (4. * TMath::Pi() * mpcTscale) * vVr[i], 1. / 3.));
1821  veRr.push_back(pow(3. / (4 * TMath::Pi() * mpcTscale), 1. / 3.) * 1. /
1822  3 * pow(vVr[i], -2. / 3.) * veVr[i]);
1823  // cout << vsrho[i] << " ";
1824  }
1825  // cout << endl;
1826 
1827  // std::vector<TGraphErrors> v_gr(2);
1828  // TGraphErrors *co_gr = new TGraphErrors[2];
1829  // TGraphErrors co_gr;
1830  // TGraphErrors* co_gr = new TGraphErrors(vR.size(), &vsifar[0], &vR[0],
1831  // 0, &veR[0]);
1832  if (opt.Contains("rho")) {
1833  co_gr = new TGraphErrors(vRr.size(), &vsrho[0], &vRr[0], 0, &veRr[0]);
1834  } else {
1835  co_gr = new TGraphErrors(vR.size(), &vsifar[0], &vR[0], 0, &veR[0]);
1836  }
1837  // co_gr[0] = TGraphErrors(vR.size(), &vsifar[0], &vR[0], 0, &veR[0]);
1838  // co_gr->GetYaxis()->SetTitle("Sensitive Distance [Mpc]");
1839  // co_gr->GetXaxis()->SetTitle("Inverse False Alarm Rate [yr]");
1840  // co_gr->GetXaxis()->SetLimits(MINIFAR,MAXIFAR);
1841  // co_gr->GetYaxis()->SetRangeUser(MINRADIUS,MAXRADIUS);
1842  co_gr->GetXaxis()->SetTitleOffset(1.3);
1843  co_gr->GetYaxis()->SetTitleOffset(1.25);
1844  co_gr->GetXaxis()->SetTickLength(0.01);
1845  co_gr->GetYaxis()->SetTickLength(0.01);
1846  co_gr->GetXaxis()->CenterTitle(kTRUE);
1847  co_gr->GetYaxis()->CenterTitle(kTRUE);
1848  co_gr->GetXaxis()->SetTitleFont(42);
1849  co_gr->GetXaxis()->SetLabelFont(42);
1850  co_gr->GetYaxis()->SetTitleFont(42);
1851  co_gr->GetYaxis()->SetLabelFont(42);
1852  co_gr->SetMarkerStyle(20);
1853  co_gr->SetMarkerSize(1.0);
1854  co_gr->SetMarkerColor(1);
1855  co_gr->SetLineColor(color);
1856  co_gr->SetLineWidth(3);
1857  co_gr->SetTitle("");
1858  co_gr->SetFillColor(color);
1859  co_gr->SetFillStyle(3001);
1860  // co_gr->Draw("aple3");
1861 
1862  filein->Close();
1863  filein2->Close();
1864  delete filein, filein2;
1865  delete mdc, mdc_org, sim, sim_org;
1866  vifar.clear();
1867  vdv.clear();
1868  vrho.clear();
1869  vsifar.clear();
1870  vseifar.clear();
1871  vsrho.clear();
1872  vR.clear();
1873  veR.clear();
1874  veRr.clear();
1875  vV.clear();
1876  veV.clear();
1877  vRr.clear();
1878  vVr.clear();
1879  veVr.clear();
1880  return co_gr;
1881 
1882  // exit(0);
1883 }
1884 
1885 //______________________________________________________________________________
1886 
1887 /*
1888 void CWB::CBCTool::doEffectiveRadiusChiPlot(){
1889 
1890 
1891  int spin_mtot_bins = 0;
1892  double V0_spin_mtot = 0.0;
1893  for(int j=0; j<NBINS_MTOT+1; j++){
1894  for(int k=0; k<NBINS_SPIN+1; k++){
1895 
1896  // volume_first_shell[j][k] =
1897 efficiency_first_shell->GetBinContent(j+1,k+1);
1898  // if(factor_events_rec->GetBinContent(j+1,k+1) != 0.) {
1899  // error_volume_first_shell[j][k]
1900 = 1./TMath::Sqrt(factor_events_rec->GetBinContent(j+1,k+1));
1901  // massbins++;
1902  //}
1903  if(spin_mtot_volume[j][k] != 0.) {
1904  spin_mtot_volume[j][k] =
1905 shell_volume*spin_mtot_volume[j][k]; /// Warning: neglecting the internal
1906 volume... + volume_internal_sphere*volume_first_shell[j][k]; V0_spin_mtot +=
1907 spin_mtot_volume[j][k]; error_spin_mtot_volume[j][k] =
1908 shell_volume*TMath::Sqrt(error_spin_mtot_volume[j][k]); ///Warning: neglecting
1909 the internal volume...+
1910 volume_internal_sphere*volume_first_shell[j][k]*error_volume_first_shell[j][k];
1911 
1912  spin_mtot_radius[j][k] =
1913 pow(3.*spin_mtot_volume[j][k]/(4*TMath::Pi()),1./3);
1914 
1915  error_spin_mtot_radius[j][k] =
1916 (1./3)*pow(3./(4*TMath::Pi()),1./3)*pow(1./pow(spin_mtot_volume[j][k],2),1./3)*error_spin_mtot_volume[j][k];
1917  spin_mtot_bins++;
1918  }
1919  cout<<j<< " "<<k<< " "<<spin_mtot_volume[j][k]<<"
1920 "<<spin_mtot_radius[j][k]<<endl;
1921  }
1922  }
1923  cout << "Average Spin-Mtot Volume at threshold V0 =
1924 "<<V0_spin_mtot/spin_mtot_bins <<endl; c1->Clear();
1925 
1926  TH2F* h_spin_mtot_radius = new
1927 TH2F("h_spin_mtot_radius","",NBINS_SPIN,MINCHI,MAXCHI,NBINS_MTOT,minMtot,maxMtot);
1928  //h_spin_mtot_radius->GetXaxis()->SetRangeUser(MIN_plot_mass1,MAX_plot_mass1);
1929  //h_spin_mtot_radius->GetYaxis()->SetRangeUser(MIN_plot_mass2,MAX_plot_mass2);
1930  h_spin_mtot_radius->GetXaxis()->SetTitle("#chi_{z}");
1931  h_spin_mtot_radius->GetYaxis()->SetTitle("Total Mass (M_{#odot})");
1932  h_spin_mtot_radius->GetXaxis()->SetTitleOffset(1.3);
1933  h_spin_mtot_radius->GetYaxis()->SetTitleOffset(1.25);
1934  h_spin_mtot_radius->GetXaxis()->CenterTitle(kTRUE);
1935  h_spin_mtot_radius->GetYaxis()->CenterTitle(kTRUE);
1936  h_spin_mtot_radius->GetXaxis()->SetNdivisions(410);
1937  h_spin_mtot_radius->GetYaxis()->SetNdivisions(410);
1938  h_spin_mtot_radius->GetXaxis()->SetTickLength(0.01);
1939  h_spin_mtot_radius->GetYaxis()->SetTickLength(0.01);
1940  h_spin_mtot_radius->GetZaxis()->SetTickLength(0.01);
1941  h_spin_mtot_radius->GetXaxis()->SetTitleFont(42);
1942  h_spin_mtot_radius->GetXaxis()->SetLabelFont(42);
1943  h_spin_mtot_radius->GetYaxis()->SetTitleFont(42);
1944  h_spin_mtot_radius->GetYaxis()->SetLabelFont(42);
1945  h_spin_mtot_radius->GetZaxis()->SetLabelFont(42);
1946  h_spin_mtot_radius->GetZaxis()->SetLabelSize(0.03);
1947  h_spin_mtot_radius->SetTitle("");
1948 
1949 
1950  for(int i=1; i<=NBINS_MTOT+1; i++){
1951  for(int j=1; j<=NBINS_SPIN+1; j++){
1952  h_spin_mtot_radius->SetBinContent(j,i,spin_mtot_radius[i-1][j-1]);
1953  h_spin_mtot_radius->SetBinError(j,i,error_spin_mtot_radius[i-1][j-1]);
1954  cout<<j<< " "<<i<< "
1955 "<<h_spin_mtot_radius->GetBinContent(j,i)<<endl;
1956  }
1957  }
1958 
1959 
1960  h_spin_mtot_radius->SetContour(NCont);
1961  h_spin_mtot_radius->SetEntries(1); // This option needs to be enabled
1962 when filling 2D histogram with SetBinContent h_spin_mtot_radius->Draw("colz text
1963 colsize=2"); // Option to write error associated to the bin content
1964  //h_spin_mtot_radius->Draw("colz text");
1965  h_spin_mtot_radius->GetZaxis()->SetRangeUser(0,MAX_EFFECTIVE_RADIUS/2.);
1966 
1967  TExec *ex2 = new TExec("ex2","gStyle->SetPaintTextFormat(\".0f\");");
1968  ex2->Draw();
1969 
1970 
1971  //char radius_title[256];
1972  sprintf(radius_title,"Effective radius Mtot vs #chi_{z} (Mpc, %.1f <
1973 #chi_{z} < %.1f)",MINCHI,MAXCHI);
1974 
1975 
1976 
1977  TPaveText *p_radius = new
1978 TPaveText(0.325301,0.926166,0.767068,0.997409,"blNDC");
1979  p_radius->SetBorderSize(0);
1980  p_radius->SetFillColor(0);
1981  p_radius->SetTextColor(1);
1982  p_radius->SetTextFont(32);
1983  p_radius->SetTextSize(0.045);
1984  TText *text = p_radius->AddText(radius_title);
1985  p_radius->Draw();
1986 
1987  sprintf(fname,"%s/Effective_radius_chi.png",netdir);
1988 
1989  c1->Update();
1990  c1->SaveAs(fname);
1991 
1992 
1993 }
1994 
1995 */
TTree * tree
Definition: TimeSortTree.C:20
double rho
float Tscale
double T_ifar
TChain sim("waveburst")
static double g(double e)
Definition: GNGen.cc:116
#define MAXY
Definition: CBCTool.cc:1159
double M
Definition: DrawEBHH.C:13
std::vector< double > vseifar
TString live
double Live
float factor
TString opt
static double bbh_final_mass_and_spin_non_precessing(double m1, double m2, double chi1, double chi2)
Definition: CBCTool.cc:984
double m1
Int_t nentries
Definition: TimeSortTree.C:24
wavearray< double > a(hp.size())
#define MINMAXIFAR
Definition: CBCTool.cc:1590
static double getZeroLiveTime2(int nIFO, TChain &liv)
Definition: CBCTool.cc:686
static TGraphErrors * CreateGraphRadiusIFAR(char *sim_file_name, char *mdc_file_name, TString SEL, float shell_volume, Color_t color, TString opt, double liveTot, float T_ifar, float T_win, int TRIALS, int nIFO, float VT, float Tscale)
Definition: CBCTool.cc:1592
#define RHO_NBINS
TString("c")
static double getZeroLiveTime(int nIFO, TChain &liv)
Definition: CBCTool.cc:662
#define RHO_BIN
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
float CYS
char odir[1024]
float xslag[6]
TString mdc[4]
#define MAXSNR
Definition: CBCTool.cc:1160
static void doChirpFARPlot(int sel_events, double *recMchirp, double *injMchirp, double *far, TCanvas *c1, TString odir)
Definition: CBCTool.cc:774
float xlag
std::vector< double > vR
float SNR2
static TF1 * doRangePlot(int RHO_NBINS, double *Trho, double *Rrho, double *eRrho, float RHO_MIN, float T_out, TCanvas *c1, TString networkname, TString odir, bool write_ascii)
Definition: CBCTool.cc:451
int m
Definition: cwb_net.C:28
static void CreateDistanceParplots(char *sim_file_name, char *mdc_file_name, char *netdir, TString opt, double MINX, double MAXX, double MAXDISTANCE, int NBIN_DIST, float T_ifar, float T_win, int nIFO)
Definition: CBCTool.cc:1162
int j
Definition: cwb_net.C:28
static double getLiveTime2(TChain &liv)
Definition: CBCTool.cc:641
i drho i
static Long64_t GetTreeIndex(TTree *tree, const char *selection)
Definition: CBCTool.cc:41
#define A1
static double getLiveTime(int nIFO, TChain &liv, int lag_number, int slag_number, int dummy)
Definition: CBCTool.cc:548
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
Definition: ComputeSNR.C:75
char fname3[2048]
static double chip(double m1, double m2, double s1x, double s1y, double s1z, double s2x, double s2y, double s2z)
Definition: CBCTool.cc:1084
fprintf(stdout,"start=%f duration=%f rate=%f\, x.start(), x.size()/x.rate(), x.rate())
char lab[256]
std::vector< double > vdv
wavearray< double > w
Definition: Test1.C:27
#define nIFO
Meyer< double > * S2
static double _final_spin_diff(double a_f, double eta, double delta_m, double S, double Delta)
Definition: CBCTool.cc:867
Definition: mdc.hh:248
TH2F * lSlag
wavearray< double > h
Definition: Regression_H1.C:25
TF1 * f2
TCanvas * c1
i() int(T_cor *100))
double Pi
int ifactor
char netdir[1024]
const int NIFO_MAX
Definition: wat.hh:22
std::vector< double > vsifar
char cut[512]
int l
gNET add & L1
Definition: DrawGNET.C:9
TIter next(twave->GetListOfBranches())
float mchirp
char fname[1024]
static double getFAR(float rho, TH1 *hc, double liveTot)
Definition: CBCTool.cc:728
std::vector< double > veR
std::vector< double > iSNR[NIFO_MAX]
static void AddChip(TString filein, TString treename)
Definition: CBCTool.cc:1129
double xlive
double liveTot
std::vector< double > vifar
float spin[6]
#define A2
static double calc_isco_radius(double a)
Definition: CBCTool.cc:836
vector< mdcpar > par
double e
double VT
bool slagFound
#define RHO_MIN
char sim_file_name[1024]
static double calc_isco_freq(double a)
Definition: CBCTool.cc:850
static TH2F * FillSLagHist(int NIFO_MAX, TChain &live, int NSlag, double SlagMin, double SlagMax)
Definition: CBCTool.cc:741
static void doROCPlot(int bkg_entries, double *rho_bkg, int *index, float RHO_BIN, double liveTot, TF1 *AverageRad, TCanvas *c1, TString odir, bool write_ascii)
Definition: CBCTool.cc:104
double T
Definition: testWDM_4.C:11
std::vector< double > veV
wavearray< int > index
double T_win
cout<< endl;if(write_ascii) { fev.close();for(int l=0;l< nfactor;l++) { fev_single[l].close();} } cout<< "Recovered entries: "<< cnt<< endl;cout<< "Recovered entries: "<< cnt2<< endl;cout<< "Recovered entries cut by frequency: "<< cntfreq<< endl;cout<< "Recovered entries vetoed: "<< countv<< endl;cout<< "dV : "<< dV<< " dV1 : "<< dV1<< endl;internal_volume=4./3. *TMath::Pi() *pow(minDistance[0]/1000., 3.);if(INCLUDE_INTERNAL_VOLUME) { for(int i=0;i< vdv.size();i++) { if(vdv[i] > 0.0) { vdv[i]+=internal_volume;} } for(int i=0;i< RHO_NBINS;i++) { if(Vrho[i] > 0.0) { Vrho[i]+=internal_volume;} } for(int i=0;i< NBINS_MTOT+1;i++) { for(int j=0;j< NBINS_SPIN+1;j++) { if(spin_mtot_volume[i][j] > 0.0) { spin_mtot_volume[i][j]+=internal_volume;} } } for(int i=0;i< NBINS_mass;i++) { for(int j=0;j< NBINS_mass2;j++) { if(volume[i][j] > 0.0) { volume[i][j]+=internal_volume;} } } } Int_t *mindex=new Int_t[vdv.size()];TMath::Sort((int) vdv.size(), &vifar[0], mindex, true);std::vector< double > vV
double mytime[6]
double m2
TBranch * branch
int cnt
Definition: Toolbox.hh:99
Meyer< double > S(1024, 2)
long int num
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
float distance
double T_out
bool write_ascii
float mass[2]
float * shell_volume
char mdc_file_name[1024]
fclose(ftrig)
TMultiGraph * mg
static double Delta
Definition: geodesics.cc:26
TGraphErrors * gr2
int TRIALS
exit(0)