40 #define MAX_TREE_SIZE 100000000000LL 56 cout << endl <<
" " << iwfile << endl;
58 TFile *iwroot = TFile::Open(iwfile);
59 if(iwroot==NULL) {cout <<
"Error opening file: " << iwfile << endl;
exit(1);}
61 TTree* iwtree = (TTree *) gROOT->FindObject(
"waveburst");
62 if(iwtree==NULL) {cout <<
"waveburst tree not found !!!" << endl;
exit(1);}
63 int wentries = (
int)iwtree->GetEntries();
64 cout << endl <<
" wntries = " << wentries << endl;
67 TList* ifoList = iwtree->GetUserInfo();
68 int nIFO = ifoList->GetSize();
69 cout << endl <<
" nIFO = " << nIFO << endl << endl;
76 imfile.ReplaceAll(
"wave_",
"mdc_");
77 cout <<
" " << imfile << endl;
79 TFile *imroot = TFile::Open(imfile);
80 if(imroot==NULL) {cout <<
"Error opening file: " << imfile << endl;
exit(1);}
82 TTree* imtree = (TTree *) gROOT->FindObject(
"mdc");
83 if(imtree==NULL) {cout <<
"mdc tree not found !!!" << endl;
exit(1);}
86 imtree->Draw(
"time[0]:redshift",
"",
"goff");
87 int imentries = (
int)imtree->GetSelectedRows();
88 int *mindex =
new int[imentries];
89 double* imtime = imtree->GetV1();
90 double* imredshift = imtree->GetV2();
91 TMath::Sort(imentries,imtime,mindex,
false);
94 double* stime =
new double[imentries];
95 for (Int_t
i=0;
i<imentries;
i++) stime[
i] = imtime[mindex[
i]];
102 owfile.ReplaceAll(
".root",
".U_redshift.root");
103 cout << endl <<
" new output tree file = " << owfile << endl << endl;
106 TFile owroot(owfile,
"recreate");
108 TTree *owtree = (TTree*)iwtree->CloneTree(0);
113 bool redshift_exists=
false;
114 TIter
next(iwtree->GetListOfBranches());
115 while ((branch=(TBranch*)
next())) {
116 if(
TString(
"redshift").CompareTo(branch->GetName())==0) redshift_exists=
true;
120 if (redshift_exists) iwtree->SetBranchAddress(
"redshift",&wredshift);
121 else owtree->Branch(
"redshift",&wredshift,
"redshift/F");
123 double* iwtime =
new double[2*
nIFO];
124 iwtree->SetBranchAddress(
"time",iwtime);
127 for (Int_t
i=0;
i<wentries;
i++) {
128 if (
i%1000==0 &&
i>0) cout <<
" write entry : " <<
i << endl;
130 int sindex =
binarySearch(stime, 0, imentries, iwtime[nIFO]);
131 wredshift = imredshift[mindex[sindex]];
144 omfile.ReplaceAll(
"wave_",
"mdc_");
145 omfile.ReplaceAll(
".root",
".U_redshift.root");
146 TString imfile_base = gSystem->BaseName(imfile.Data());
147 cmd = TString::Format(
"ln -sf %s %s",imfile_base.Data(),omfile.Data());
148 cout << endl <<
" " << cmd << endl << endl;
149 gSystem->Exec(cmd.Data());
152 ilfile.ReplaceAll(
"wave_",
"merge_");
153 ilfile.ReplaceAll(
".root",
".lst");
155 olfile.ReplaceAll(
"wave_",
"merge_");
156 olfile.ReplaceAll(
".root",
".U_redshift.lst");
157 TString ilfile_base = gSystem->BaseName(ilfile.Data());
158 cmd = TString::Format(
"ln -sf %s %s",ilfile_base.Data(),olfile.Data());
159 cout << endl <<
" " << cmd << endl << endl;
160 gSystem->Exec(cmd.Data());
170 int searchPos = (start + end) >> 1;
175 if (array[searchPos] > key)
178 if (array[searchPos] < key)
181 if (array[searchPos] == key)
int binarySearch(double array[], int start, int end, double key)
TIter next(twave->GetListOfBranches())
void AddRedshift2WAVE(TString ifname)