int main () { //findgraph ( 2, 3, .1, .0001, 5, &fsqrt, "Find square Root of 5"); //findgraph (10,500, 5, .0000001, 5487, &fsqrt, "Find square Root of 5487"); findgraph ( 0, 1, .1, .0001, 0, &hw2p1, "hw2p1"); findgraph ( 1, 3.2, .1, .0001, 0, &hw2p2, "hw2p2"); findgraph ( 1, 2, .1, .0001, 0, &hw2p3, "hw2p3"); findgraph (-1, 0, .01, .001, 0, &hw2p4, "hw2p4"); secant (-1, 0, .001, 0, &hw2p4, "hw2p4"); falseposition (-1, 0, .001, 0, &hw2p4, "hw2p4"); findgraph (-1, 0, .01, .00001, 0, &hw2p5, "hw2p5 from -1 to 0"); findgraph ( 0, 1, .01, .00001, 0, &hw2p5, "hw2p5 from 0 to 1"); findgraph (-1 , 1, .1, .00001, 0, &hw2p5, "hw2p5 from 0 to 1"); findpoint (0, 2, 0, 1, .001, 8, &hw2p6, "hw2p6"); // testing the point function //findpoint (0, 2, 1, 1, .001, 8, &hw2p6, "hw2p6"); //findpoint (1, 3, 2, 4, .001, 8, &hw2p6, "hw2p6"); //findpoint (1, 4, 0, 2, .001, 8, &hw2p6, "hw2p6"); //findpoint (1, 8, 18, 0, .001, 8, &hw2p6, "hw2p6"); findgraph (0, 1, .1, .01, 12.4, &hw2p7a, "hw2p7 trough with 12.4 volume"); ///* printf ("finding a range of values for testing.\n"); long double i; for (i=0; i< 1; i=i+.1){ char name[40]; sprintf(name, "hw2p7 %Lf", i); //findgraph (0, 1, .01, .00001, i, &hw2p7, name); hw2p7(i, 0); hw2p7a(i, 0); } //*/ //findgraph (-1, 3, .1, .001, 38, &hw2ptri, "hw2ptri full"); //findgraph (-1, 3, .1, .001, 10, &hw2ptri, "hw2ptri half full"); //findgraph (-1, 3, .1, .001, .1, &hw2ptri, "hw2ptri empty"); //findgraph ( 0, 2, .1, .00000001, 0, &fex, "fex"); }
void findcent() { const int color[10] = {2,3,4,5,6,7,8,4,3,2}; const double centbin[] = {0,0.005,0.01,0.05,0.1,0.2,0.3,0.4,0.6,1.0}; //const double centbin[] = {0,0.001,0.005,0.01,0.05,0.1,0.2,0.4,0.6,1.0}; //double centbin[101]; //for(int i=0;i<101;i++){ // centbin[i]=i*0.01; //} const double erf = 1e-5; int ncent = (int)sizeof(centbin)/sizeof(double); //TFile *f = TFile::Open("merged_AnapAlfvtxor.root"); //TFile *f = TFile::Open("merged_AnapAlfvtxand.root"); //TFile *f = TFile::Open("merged_AnapAlfvtxsouth.root"); TFile *f = TFile::Open("merged_AnaMWGppmb.root"); // TH2F* pc1hitsbbcdis = (TH2F*)f->Get("pc1hitsbbcdis"); // TH1F* pc1hitsdis = (TH1F*)f->Get("pc1hitsdis"); // TH2F* hbbcntrk = (TH2F*)f->Get("hbbcnbbc"); TH2F* hbbcntrk = (TH2F*)f->Get("hnfvtxtrkbbc"); // hbbcntrk->RebinX(3); // TH1F* bbcsouthdis = (TH1F*)pc1hitsbbcdis->ProjectionX(0,-1); TH1F* bbcsouthdis = (TH1F*)hbbcntrk->ProjectionX(0,-1); // TH2F* bbcsouthdis = (TH2F*)hbbcntrk->Clone("bbcsouthdis"); bbcsouthdis->SetTitle("BBC charge distribution"); bbcsouthdis->GetXaxis()->SetTitle("BBC charge"); bbcsouthdis->GetYaxis()->SetTitle("# of Events"); // pc1hitsdis->SetTitle("PC1 hits distribution"); // pc1hitsdis->GetXaxis()->SetTitle("PC1 hits"); // pc1hitsdis->GetYaxis()->SetTitle("# of Events"); ofstream fstr("centbin_bbcmb.txt"); // fstr<<"centbin"<<"\t"<<"bbcsouth"<<"\t"<<"pc1hits"<<"\t"<<"bbc ratio"<<"\t"<<"pc1hits ratio"<<endl; fstr<<"centbin"<<"\t"<<"bbc"<<"\t"<<"bbc ratio"<<endl; vector<double> bbcs; // vector<double> pc1hs; for(int icent = 0; icent < ncent; icent++){ double bbcskp = findpoint(bbcsouthdis,centbin[icent]); // double pc1hskp = findpoint(pc1hitsdis,centbin[icent]); if(bbcskp<0) bbcskp = 0; // if(pc1hskp<0) pc1hskp = 0; bbcs.push_back(bbcskp); cout<<bbcskp<<","; // pc1hs.push_back(pc1hskp); } for(int icent = 0; icent < ncent; icent++){ // fstr<<centbin[icent]<<"\t"<<bbcs[icent]<<"\t"<<pc1hs[icent]<<"\t"<<bbcsouthdis->Integral(bbcsouthdis->FindBin(bbcs[icent]+erf),bbcsouthdis->FindBin(bbcs[0]-erf))/bbcsouthdis->Integral(bbcsouthdis->FindBin(bbcs[ncent-1]-erf),bbcsouthdis->FindBin(bbcs[0]+erf))<<"\t"<<pc1hitsdis->Integral(pc1hitsdis->FindBin(pc1hs[icent]+erf),pc1hitsdis->FindBin(pc1hs[0]-erf))/pc1hitsdis->Integral(pc1hitsdis->FindBin(pc1hs[ncent-1]-erf),pc1hitsdis->FindBin(pc1hs[0]+erf))<<endl; fstr<<centbin[icent]<<"\t"<<bbcs[icent]<<"\t"<<bbcsouthdis->Integral(bbcsouthdis->FindBin(bbcs[icent]+erf),bbcsouthdis->FindBin(bbcs[0]-erf))/bbcsouthdis->Integral(bbcsouthdis->FindBin(bbcs[ncent-1]-erf),bbcsouthdis->FindBin(bbcs[0]+erf))<<endl; //fstr<<centbin[icent]<<"\t"<<bbcs[icent]<<"\t"<<bbcsouthdis->Integral(bbcsouthdis->GetXaxis()->FindBin(bbcs[icent]+erf),bbcsouthdis->GetXaxis()->FindBin(bbcs[0]-erf),bbcsouthdis->GetYaxis()->FindBin(bbcs[icent]+erf),bbcsouthdis->GetYaxis()->FindBin(bbcs[0]-erf))/bbcsouthdis->Integral(bbcsouthdis->FindBin(bbcs[ncent-1]-erf,bbcs[ncent-1]-erf),bbcsouthdis->FindBin(bbcs[0]+erf,bbcs[0]+erf))<<endl; } TCanvas *c1 = new TCanvas(); //c1->SetLogx(); c1->SetLogy(); // c1->SetLogz(); bbcsouthdis->GetXaxis()->SetRangeUser(0,500); // bbcsouthdis->GetYaxis()->SetRangeUser(0,100); bbcsouthdis->Draw(); for(int icent = 0; icent < ncent; icent++){ TH1F* bbcs_t = (TH1F*)bbcsouthdis->Clone(Form("bbcs_%d",icent)); bbcs_t->GetXaxis()->SetRangeUser(bbcs[icent+1]-erf,bbcs[icent]+erf); //bbcs_t->GetYaxis()->SetRangeUser(bbcs[icent+1]-erf,bbcs[icent]+erf); bbcs_t->SetFillColor(color[icent]); bbcs_t->Draw("HIST same"); } c1->Print("bbcaddcent.png"); /* TCanvas *c2 = new TCanvas(); c2->SetLogy(); pc1hitsdis->Draw(); for(int icent = 0; icent < ncent; icent++){ TH1F* pc1hs_t = (TH1F*)pc1hitsdis->Clone(Form("pc1hs_%d",icent)); pc1hs_t->GetXaxis()->SetRangeUser(pc1hs[icent+1]-erf,pc1hs[icent]+erf); pc1hs_t->SetFillColor(color[icent]); pc1hs_t->Draw("HIST same"); } c2->Print("pc1hits.png"); */ }