Logo coherent WaveBurst  
Library Reference Guide
Logo
ChangeRhoStatistic.C
Go to the documentation of this file.
1 //
2 // Author : Gabriele Vedovato
3 // this macro is used to redefine the rho statistic
4 
5 void ChangeRhoStatistic(TString iwfile, bool simulation=false) {
6 // -------------------------------------------------------------------------------------------------------------
7 
8  #define TREE_NAME "waveburst"
9 
10  char cmd[1024];
11 
12  cout << endl;
13  TString owfile = iwfile;
14  owfile.ReplaceAll(".root",".C_newrho.root");
15  cout << "owave : " << owfile << endl;
16  cout << "iwave : " << iwfile << endl;
17 
18  cout << endl;
19  TString omfile = owfile;
20  omfile.ReplaceAll(".root",".lst");
21  omfile.ReplaceAll("wave_","merge_");
22  cout << "omerge : " << omfile << endl;
23 
24  TString imfile = omfile;
25  imfile.ReplaceAll(".C_newrho.lst",".lst");
26  cout << "imerge : " << imfile << endl;
27 
28  sprintf(cmd,"cd merge;ln -sf ../%s ../%s",imfile.Data(),omfile.Data());
29  cout << cmd << endl;
30  gSystem->Exec(cmd);
31 
32  cout << endl;
33  TString olfile = owfile;
34  olfile.ReplaceAll("wave_","live_");
35  cout << "olive : " << olfile << endl;
36 
37  TString ilfile = olfile;
38  ilfile.ReplaceAll(".C_newrho.root",".root");
39  cout << "ilive : " << ilfile << endl;
40 
41  sprintf(cmd,"cd merge;ln -sf ../%s ../%s",ilfile.Data(),olfile.Data());
42  cout << cmd << endl;
43  if(!simulation) gSystem->Exec(cmd);
44 
45  cout << endl;
46  TString oMfile = owfile;
47  oMfile.ReplaceAll("wave_","mdc_");
48  cout << "omdc : " << oMfile << endl;
49 
50  TString iMfile = oMfile;
51  iMfile.ReplaceAll(".C_newrho.root",".root");
52  cout << "imdc : " << iMfile << endl;
53  cout << endl;
54 
55  sprintf(cmd,"ln -sf %s %s",iMfile.Data(),oMfile.Data());
56  sprintf(cmd,"cd merge;ln -sf ../%s ../%s",iMfile.Data(),oMfile.Data());
57  cout << cmd << endl;
58  if(simulation) gSystem->Exec(cmd);
59 
61  TFile f1(iwfile);
62  TTree *itree = (TTree*)f1.Get(TREE_NAME);
63  itree->Draw("rho[1]:penalty","","goff");
64  Int_t nentries = (Int_t)itree->GetSelectedRows();
65 
66  float* irho = new float[2];
67  itree->SetBranchAddress("rho", irho);
68  float* inetcc = new float[4];
69  itree->SetBranchAddress("netcc", inetcc);
70  float ipenalty;
71  itree->SetBranchAddress("penalty", &ipenalty);
72 
73  TFile f(owfile,"recreate");
74  TTree *otree = (TTree*)itree->CloneTree(0);
75 
76  float* orho = new float[2];
77  otree->SetBranchAddress("rho", orho);
78 
79  for (Int_t i=0;i<nentries;i++) {
80  if (i%100000==0 && i>0) cout << "write entry : " << i << "/" << nentries << endl;
81  itree->GetEntry(i);
82  //cout << irho[0] << " " << irho[1] << " " << ipenalty << endl;
83  //orho[0] = irho[0];
84  orho[0] = irho[0]*sqrt(ipenalty);
85  orho[1] = irho[1]*sqrt(ipenalty);
86  otree->Fill();
87  }
88  otree->Write();
89 
90  gSystem->Exit(0);
91 }
92 
Int_t nentries
Definition: TimeSortTree.C:24
TString("c")
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
Definition: ComputeSNR.C:75
void ChangeRhoStatistic(TString iwfile, bool simulation=false)
TTree * otree
#define TREE_NAME
float irho
char cmd[1024]
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
TTree * itree
simulation
Definition: cwb_eced.C:26