// determine the TOF efficiency for TOF-paddles using the data from the root file // hists_runXXXXXXX.root #include #include int DEBUG = 0; bool File_exists_test(char name[]) { struct stat buffer; return (stat (name , &buffer) == 0); } void doeff(int Run, char *fnam){ // try to calculate TOF efficiencies int R = Run; char hnam[128]; sprintf(hnam,"%s",fnam); TFile *INF = new TFile(hnam,"READ"); TString plane[2] = {"X4goodV","Y4goodH"}; float Ratios[2][20][44]; float Counts[2][20][44]; float Norm[2][20][44]; float TheBin[2][20][44]; for (int n=0; n<2; n++){ // loop over both planes for (int k=0;k<20;k++){ // loop over momenta bins float pbin = k*0.5+0.5; sprintf(hnam,"proj_vs_nearest_%s%d",plane[n].Data(),k); TH2F *h2d = (TH2F*)INF->Get(hnam); for (int xbin=2; xbin<46; xbin++){ // loop over paddles TH1D *h = h2d->ProjectionX("h",xbin,xbin); double Ifull = h->Integral(2,h->GetNbinsX()-2); int lb = xbin-1; if (lb<2){ lb = 2; } int hb = xbin+1; if (hb>45){ hb=45; } double Ipeak = h->Integral(lb, hb); TheBin[n][k][xbin-2] = h->Integral(xbin, xbin); double R = 0; if (Ifull>0) { R = Ipeak/Ifull; } Ratios[n][k][xbin-2] = R; Counts[n][k][xbin-2] = Ipeak; Norm[n][k][xbin-2] = Ifull; if (DEBUG){ cout<Draw(); gPad->SetGrid(); gPad->Update(); char ht[128]; //sprintf(ht,"proj_Paddle%d_plane%d_momentum%4.1fGeV.pdf",xbin-1, n,pbin); //gPad->SaveAs(); //sprintf(ht,"proj_Paddle%d_plane%d_momentum%4.1fGeV.gif",xbin-1, n,pbin); //gPad->SaveAs(); getchar(); } } } } ofstream OF; char ofnam[128]; sprintf(ofnam,"VER03/tofeff_run%d.dat",R); OF.open(ofnam); for (int n=0; n<2; n++){ // loop over both planes for (int k=0;k<20;k++){ // loop over momenta bins float pbin = k*0.5+0.5; for (int xbin=0; xbin<44; xbin++){ // loop over paddles OF<