27 #include "TTreeIndex.h" 30 #include "TGraphErrors.h" 31 #include "TMultiGraph.h" 41 #include "TRotation.h" 42 #include "Math/Vector3Dfwd.h" 43 #include "Math/Rotation3D.h" 45 #define MINMAXIFAR 4278. 48 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){
50 float myifar, netcc[3];
63 TFile* filein =
new TFile(sim_file_name);
64 TTree* sim_org =
nullptr;
65 filein->GetObject(
"waveburst",sim_org);
67 if(!sim_org->GetListOfBranches()->FindObject(
"chip")) {
68 cout <<
"Adding Chi_p branch to wave tree"<<endl;
69 cbcTool.
AddChip(sim_file_name,
"waveburst");
71 TTree*
sim = sim_org->CopyTree(
SEL);
72 sim->SetBranchAddress(
"mass", mass);
73 sim->SetBranchAddress(
"factor", &factor);
74 sim->SetBranchAddress(
"range", range);
75 sim->SetBranchAddress(
"chirp", chirp);
76 sim->SetBranchAddress(
"rho", rho);
77 sim->SetBranchAddress(
"netcc", netcc);
78 sim->SetBranchAddress(
"ifar", &myifar);
79 sim->SetBranchAddress(
"time", mytime);
80 sim->SetBranchAddress(
"spin", spin);
83 TFile* filein2 =
new TFile(mdc_file_name);
84 TTree* mdc_org =
nullptr;
85 filein2->GetObject(
"mdc",mdc_org);
87 SEL.ReplaceAll(
"chirp[0]",
"mchirp");
88 if(!mdc_org->GetListOfBranches()->FindObject(
"chip")) {
89 cout <<
"Adding Chi_p branch to mdc tree" << endl;
90 cbcTool.
AddChip(mdc_file_name,
"mdc");
92 TTree*
mdc = mdc_org->CopyTree(
SEL);
93 mdc->SetBranchAddress(
"time",mytime);
94 mdc->SetBranchAddress(
"mass", mass);
95 mdc->SetBranchAddress(
"factor", &factor);
96 mdc->SetBranchAddress(
"distance", &distance);
97 mdc->SetBranchAddress(
"mchirp", &mchirp);
98 mdc->SetBranchAddress(
"spin", spin);
101 std::vector<double>
vdv;
102 std::vector<double>
vifar;
103 std::vector<double> vrho;
104 std::vector<double>
vV;
105 std::vector<double>
veV;
106 std::vector<double>
vR;
107 std::vector<double>
veR;
108 std::vector<double>
vsifar;
110 std::vector<double> vVr;
111 std::vector<double> veVr;
112 std::vector<double> vRr;
113 std::vector<double> veRr;
114 std::vector<double> vsrho;
115 TGraphErrors* co_gr =
nullptr;
117 int nevts = (
int)mdc->GetEntries();
119 cout <<
"No events left after cut!"<<endl;
121 vsifar.push_back(0.0);
122 co_gr =
new TGraphErrors(vR.size(), &vsifar[0], &vR[0], 0, 0);
125 float shell_volume_per_injection = shell_volume/nevts;
128 float CYS = 86400.*365.25;
129 if (sim->GetListOfBranches()->FindObject(
"ifar")) {
131 TMath::CeilNint(sim->GetMaximum(
"ifar") /
CYS );
134 cout <<
"Missing ifar branch: either use cbc_plots or add it " 139 if(
opt.Contains(
"rho")) {
140 sim->BuildIndex(
"0",
"rho[1]*10000");
142 sim->BuildIndex(
"ifar",
"rho[1]*1000");
144 TTreeIndex *I1=(TTreeIndex*)sim->GetTreeIndex();
145 Long64_t* index1=I1->GetIndex();
151 double mpcTscale = 1.0;
152 for (
int g = 0;
g < (
int)sim->GetEntries();
g++) {
153 sim->GetEntry(index1[
g]);
154 ifactor = (
int)factor - 1;
156 if (myifar <=
T_ifar * CYS) {
163 if ((mytime[0] - mytime[
nIFO]) < -
T_win ||
164 (mytime[0] - mytime[
nIFO]) > 2 *
T_win) {
169 if (
opt.Contains(
"DDistrVolume")){
170 dV = shell_volume_per_injection;
172 else if (
opt.Contains(
"DDistrUniform")){
173 dV = pow(range[1], 2) * shell_volume_per_injection;
175 else if (
opt.Contains(
"DDistrChirpMass")){
176 dV = pow(range[1], 2) * shell_volume_per_injection * pow(chirp[0] / 1.22,5./6.);
178 else if (
opt.Contains(
"Redshift")){
179 dV =
VT/(double)nevts;
184 cout <<
"No defined distance distribution? " 185 "WARNING: Assuming uniform in volume" 189 dV = shell_volume_per_injection;
193 vifar.push_back(myifar);
194 vrho.push_back(rho[1]);
204 vV.push_back(vdv[vdv.size()-1]);
205 veV.push_back(pow(vdv[vdv.size()-1], 2));
206 if(vifar[vdv.size()-1]<
MINMAXIFAR*
CYS ){vsifar.push_back(vifar[vdv.size()-1]);}
208 vVr.push_back(vdv[vdv.size()-1]);
209 veVr.push_back(pow(vdv[vdv.size()-1], 2));
210 vsrho.push_back(vrho[vdv.size()-1]);
216 for (
int i = vdv.size()-1;
i >= 0;
i--) {
220 if (vifar[
i] > vsifar[0]) {
222 veV[0] += pow(vdv[
i], 2);
224 }
else if (vifar[
i] == vsifar[mcount_ifar]) {
225 vV[mcount_ifar] += vdv[
i];
226 veV[mcount_ifar] += pow(vdv[
i], 2);
228 vsifar.push_back(vifar[
i]);
229 vseifar.push_back(TMath::Sqrt(TMath::Nint(
liveTot * vifar[i])));
230 vV.push_back(vV[mcount_ifar] + vdv[i]);
231 veV.push_back(veV[mcount_ifar] + pow(vdv[i], 2));
235 if (vrho[
i] == vsrho[mcount_rho]) {
236 vVr[mcount_rho] += vdv[
i];
237 veVr[mcount_rho] += pow(vdv[
i], 2);
239 vsrho.push_back(vrho[
i]);
240 vVr.push_back(vVr[mcount_rho] + vdv[i]);
241 veVr.push_back(veVr[mcount_rho] + pow(vdv[i], 2));
248 for (
int i = 0;
i < (
int) vV.size();
i++) {
249 veV[
i] = TMath::Sqrt(veV[
i]);
252 pow(3. / (4. *
TMath::Pi()* mpcTscale) * vV[i], 1. / 3.));
253 veR.push_back(pow(3. / (4 *
TMath::Pi() * mpcTscale), 1. / 3.) *
254 1. / 3 * pow(vV[i], -2. / 3.) * veV[i]);
258 for (
int i = 0;
i < (
int) vVr.size();
i++) {
259 veVr[
i] = TMath::Sqrt(veVr[
i]);
261 pow(3. / (4. *
TMath::Pi()* mpcTscale) * vVr[i], 1. / 3.));
262 veRr.push_back(pow(3. / (4 *
TMath::Pi() * mpcTscale), 1. / 3.) *
263 1. / 3 * pow(vVr[i], -2. / 3.) * veVr[i]);
273 if(
opt.Contains(
"rho")) {co_gr =
new TGraphErrors(vRr.size(), &vsrho[0], &vRr[0], 0, &veRr[0]);}
274 else {co_gr =
new TGraphErrors(vR.size(), &vsifar[0], &vR[0], 0, &veR[0]);}
280 co_gr->GetXaxis()->SetTitleOffset(1.3);
281 co_gr->GetYaxis()->SetTitleOffset(1.25);
282 co_gr->GetXaxis()->SetTickLength(0.01);
283 co_gr->GetYaxis()->SetTickLength(0.01);
284 co_gr->GetXaxis()->CenterTitle(kTRUE);
285 co_gr->GetYaxis()->CenterTitle(kTRUE);
286 co_gr->GetXaxis()->SetTitleFont(42);
287 co_gr->GetXaxis()->SetLabelFont(42);
288 co_gr->GetYaxis()->SetTitleFont(42);
289 co_gr->GetYaxis()->SetLabelFont(42);
290 co_gr->SetMarkerStyle(20);
291 co_gr->SetMarkerSize(1.0);
292 co_gr->SetMarkerColor(1);
293 co_gr->SetLineColor(color);
294 co_gr->SetLineWidth(3);
296 co_gr->SetFillColor(color);
297 co_gr->SetFillStyle(3001);
302 delete filein, filein2;
303 delete mdc, mdc_org,
sim, sim_org;
304 vifar.clear(); vdv.clear(); vrho.clear(); vsifar.clear(); vseifar.clear(); vsrho.clear();
305 vR.clear(); veR.clear(); veRr.clear(); vV.clear(); veV.clear(); vRr.clear(); vVr.clear();
static double g(double e)
std::vector< double > vseifar
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)
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