9 #include "TTreeIndex.h" 12 #include "TGraphErrors.h" 13 #include "TMultiGraph.h" 23 #include "TRotation.h" 24 #include "Math/Vector3Dfwd.h" 25 #include "Math/Rotation3D.h" 27 #define MINMAXIFAR 4278. 31 TGraphErrors*
CreateGraphRadiusIFAR(
char*
sim_file_name,
char*
mdc_file_name,
TString SEL,
float shell_volume, Color_t color=kBlue,
TString opt=
"default",
double liveTot=1e6,
float T_ifar=0.0,
float T_win=0.2,
int TRIALS = 1,
int nIFO = 2){
33 float myifar, netcc[3];
46 TFile* filein =
new TFile(sim_file_name);
47 TTree* sim_org =
nullptr;
48 filein->GetObject(
"waveburst",sim_org);
50 if(!sim_org->GetListOfBranches()->FindObject(
"chip")) {
51 cout <<
"Adding Chi_p branch to wave tree"<<endl;
52 cbcTool.
AddChip(sim_file_name,
"waveburst");
54 TTree*
sim = sim_org->CopyTree(
SEL);
55 sim->SetBranchAddress(
"mass", mass);
56 sim->SetBranchAddress(
"factor", &factor);
57 sim->SetBranchAddress(
"range", range);
58 sim->SetBranchAddress(
"chirp", chirp);
59 sim->SetBranchAddress(
"rho", rho);
60 sim->SetBranchAddress(
"netcc", netcc);
61 sim->SetBranchAddress(
"ifar", &myifar);
62 sim->SetBranchAddress(
"time", mytime);
63 sim->SetBranchAddress(
"spin", spin);
66 TFile* filein2 =
new TFile(mdc_file_name);
67 TTree* mdc_org =
nullptr;
68 filein2->GetObject(
"mdc",mdc_org);
70 SEL.ReplaceAll(
"chirp[0]",
"mchirp");
71 if(!mdc_org->GetListOfBranches()->FindObject(
"chip")) {
72 cout <<
"Adding Chi_p branch to mdc tree" << endl;
73 cbcTool.
AddChip(mdc_file_name,
"mdc");
75 TTree*
mdc = mdc_org->CopyTree(
SEL);
76 mdc->SetBranchAddress(
"time",mytime);
77 mdc->SetBranchAddress(
"mass", mass);
78 mdc->SetBranchAddress(
"factor", &factor);
79 mdc->SetBranchAddress(
"distance", &distance);
80 mdc->SetBranchAddress(
"mchirp", &mchirp);
81 mdc->SetBranchAddress(
"spin", spin);
84 std::vector<double>
vdv;
85 std::vector<double>
vifar;
86 std::vector<double> vx;
87 std::vector<double>
vV;
88 std::vector<double>
veV;
89 std::vector<double>
vR;
90 std::vector<double>
veR;
91 std::vector<double>
vsifar;
93 std::vector<double> vVr;
94 std::vector<double> veVr;
95 std::vector<double> vRr;
96 std::vector<double> veRr;
97 std::vector<double> vsrho;
98 TGraphErrors* co_gr =
nullptr;
100 int nevts = (
int)mdc->GetEntries();
102 cout <<
"No events left after cut!"<<endl;
104 vsifar.push_back(0.0);
105 co_gr =
new TGraphErrors(vR.size(), &vsifar[0], &vR[0], 0, 0);
108 float shell_volume_per_injection = shell_volume/nevts;
111 float CYS = 86400.*365.25;
112 if (sim->GetListOfBranches()->FindObject(
"ifar")) {
114 TMath::CeilNint(sim->GetMaximum(
"ifar") /
CYS );
117 cout <<
"Missing ifar branch: either use cbc_plots or add it " 122 if(
opt.Contains(
"rho")) {
123 sim->BuildIndex(
"0",
"rho[1]*10000");
124 }
else if (
opt.Contains(
"time")) {
126 sim->BuildIndex(
"time[0]",
"rho[1]*1000");
129 sim->BuildIndex(
"ifar",
"rho[1]*1000");
131 TTreeIndex *I1=(TTreeIndex*)sim->GetTreeIndex();
132 Long64_t* index1=I1->GetIndex();
138 double mpcTscale = 1.0;
139 for (
int g = 0;
g < (
int)sim->GetEntries();
g++) {
140 sim->GetEntry(index1[
g]);
141 ifactor = (
int)factor - 1;
143 if (myifar <=
T_ifar * CYS) {
150 if ((mytime[0] - mytime[
nIFO]) < -
T_win ||
151 (mytime[0] - mytime[
nIFO]) > 2 *
T_win) {
156 if (
opt.Contains(
"DDistrVolume")){
157 dV = shell_volume_per_injection;
159 else if (
opt.Contains(
"DDistrUniform")){
160 dV = pow(range[1], 2) * shell_volume_per_injection;
162 else if (
opt.Contains(
"DDistrChirpMass")){
163 dV = pow(range[1], 2) * shell_volume_per_injection * pow(chirp[0] / 1.22,5./6.);
165 else if (
opt.Contains(
"Redshift")){
171 cout <<
"No defined distance distribution? " 172 "WARNING: Assuming uniform in volume" 176 dV = shell_volume_per_injection;
180 vifar.push_back(myifar);
181 opt.Contains(
"time") ? vx.push_back(time[0]) : vx.push_back(rho[1]);
191 vV.push_back(vdv[vdv.size()-1]);
192 veV.push_back(pow(vdv[vdv.size()-1], 2));
193 if(vifar[vdv.size()-1]<
MINMAXIFAR*
CYS ){vsifar.push_back(vifar[vdv.size()-1]);}
195 vVr.push_back(vdv[vdv.size()-1]);
196 veVr.push_back(pow(vdv[vdv.size()-1], 2));
197 vsrho.push_back(vx[vdv.size()-1]);
203 for (
int i = vdv.size()-1;
i >= 0;
i--) {
207 if (vifar[
i] > vsifar[0]) {
209 veV[0] += pow(vdv[
i], 2);
211 }
else if (vifar[
i] == vsifar[mcount_ifar]) {
212 vV[mcount_ifar] += vdv[
i];
213 veV[mcount_ifar] += pow(vdv[
i], 2);
215 vsifar.push_back(vifar[
i]);
216 vseifar.push_back(TMath::Sqrt(TMath::Nint(
liveTot * vifar[i])));
217 vV.push_back(vV[mcount_ifar] + vdv[i]);
218 veV.push_back(veV[mcount_ifar] + pow(vdv[i], 2));
222 if (vx[
i] == vsrho[mcount_rho]) {
223 vVr[mcount_rho] += vdv[
i];
224 veVr[mcount_rho] += pow(vdv[
i], 2);
226 vsrho.push_back(vx[
i]);
227 vVr.push_back(vVr[mcount_rho] + vdv[i]);
228 veVr.push_back(veVr[mcount_rho] + pow(vdv[i], 2));
235 for (
int i = 0;
i < (
int) vV.size();
i++) {
236 veV[
i] = TMath::Sqrt(veV[
i]);
239 pow(3. / (4. *
TMath::Pi()* mpcTscale) * vV[i], 1. / 3.));
240 veR.push_back(pow(3. / (4 *
TMath::Pi() * mpcTscale), 1. / 3.) *
241 1. / 3 * pow(vV[i], -2. / 3.) * veV[i]);
245 for (
int i = 0;
i < (
int) vVr.size();
i++) {
246 veVr[
i] = TMath::Sqrt(veVr[
i]);
248 pow(3. / (4. *
TMath::Pi()* mpcTscale) * vVr[i], 1. / 3.));
249 veRr.push_back(pow(3. / (4 *
TMath::Pi() * mpcTscale), 1. / 3.) *
250 1. / 3 * pow(vVr[i], -2. / 3.) * veVr[i]);
260 if(
opt.Contains(
"rho")) {co_gr =
new TGraphErrors(vRr.size(), &vsrho[0], &vRr[0], 0, &veRr[0]);}
261 else {co_gr =
new TGraphErrors(vR.size(), &vsifar[0], &vR[0], 0, &veR[0]);}
267 co_gr->GetXaxis()->SetTitleOffset(1.3);
268 co_gr->GetYaxis()->SetTitleOffset(1.25);
269 co_gr->GetXaxis()->SetTickLength(0.01);
270 co_gr->GetYaxis()->SetTickLength(0.01);
271 co_gr->GetXaxis()->CenterTitle(kTRUE);
272 co_gr->GetYaxis()->CenterTitle(kTRUE);
273 co_gr->GetXaxis()->SetTitleFont(42);
274 co_gr->GetXaxis()->SetLabelFont(42);
275 co_gr->GetYaxis()->SetTitleFont(42);
276 co_gr->GetYaxis()->SetLabelFont(42);
277 co_gr->SetMarkerStyle(20);
278 co_gr->SetMarkerSize(1.0);
279 co_gr->SetMarkerColor(1);
280 co_gr->SetLineColor(color);
281 co_gr->SetLineWidth(3);
283 co_gr->SetFillColor(color);
284 co_gr->SetFillStyle(3001);
289 delete filein, filein2;
290 delete mdc, mdc_org,
sim, sim_org;
291 vifar.clear(); vdv.clear(); vx.clear(); vsifar.clear(); vseifar.clear(); vsrho.clear();
292 vR.clear(); veR.clear(); veRr.clear(); vV.clear(); veV.clear(); vRr.clear(); vVr.clear();
static double g(double e)
std::vector< double > vseifar
std::vector< double > vdv
std::vector< double > vsifar
std::vector< double > veR
std::vector< double > vifar
std::vector< double > veV
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
TGraphErrors * CreateGraphRadiusIFAR(char *sim_file_name, char *mdc_file_name, TString SEL, float shell_volume, Color_t color=kBlue, TString opt="default", double liveTot=1e6, float T_ifar=0.0, float T_win=0.2, int TRIALS=1, int nIFO=2)