int DEBUG = 99; void viewamp(int RunNumber, int plane, int paddle, int choice){ // plane: 1-2 // paddle: 1-44 char fnam[128]; if (!choice) { sprintf(fnam,"localdir/run%d/tof_amps_run%d.dat",RunNumber,RunNumber); }else { sprintf(ofnam,"genroot/hists/%06d/tof_amps_run%d.dat",RunNumber,RunNumber); } cout<<"open file: "<>Pl[0][0]>>Pa[0][0]; cout<>dummy>>dummy>>dummy>>dummy>>dummy; } } float X[2][8] = {{5.,4.,3.,2.,-2.,-3.,-4.,-5.},{-5.,-4.,-3.,-2.,2.,3.,4.,5}}; INF>>side>>dummy>>MPV[0][0]>>dMPV[0][0]>>SIG[0][0]; MPV[0][0] -=100.; for (int k=1;k<8;k++){ INF>>Pl[0][k]>>Pa[0][k]>>side>>dummy>>MPV[0][k]>>dMPV[0][k]>>SIG[0][k]; MPV[0][k] -=100.; // subtract pedestal } for (int k=0;k<8;k++){ INF>>Pl[1][k]>>Pa[1][k]>>side>>dummy>>MPV[1][k]>>dMPV[1][k]>>SIG[1][k]; MPV[0][k] -=100.; // subtract pedestal } INF.close(); TGraphErrors *gr[2]; gr[0] = new TGraphErrors(8,X[1],MPV[0],NULL,dMPV[0]); gr[1] = new TGraphErrors(8,X[0],MPV[1],NULL,dMPV[1]); gr[0]->SetMarkerStyle(20); gr[0]->SetMarkerColor(2); gr[1]->SetMarkerStyle(21); gr[1]->SetMarkerColor(4); TF1 *f1 = new TF1("f1","[0]/2.*(exp(-(x*15.7+126.)/[1])+exp(-(x*15.7+126)/[2]))",-5.,5.); TF1 *f2 = new TF1("f2","[0]/2.*(exp(-(x*15.7+126.)/[1])+exp(-(x*15.7+126)/[2]))",-5.,5.); f1->SetLineColor(2); f2->SetLineColor(4); f1->SetParameter(0,1000.); f1->SetParameter(1,70.); f1->SetParameter(2,400.); f1->SetParLimits(0, 10.,100000); f1->SetParLimits(1, 10.,120); f1->SetParLimits(2, 120.,1000); f2->SetParameter(0,1000.); f2->SetParameter(1,70.); f2->SetParameter(2,400.); f2->SetParLimits(0, 10.,100000); f2->SetParLimits(1, 10.,120); f2->SetParLimits(2, 120.,1000); gr[0]->Fit(f1,"","R",-5.,5.); gr[1]->Fit(f2,"","R",-5.,5.); TMultiGraph *mgr = new TMultiGraph(); mgr->Add(gr[0]); mgr->Add(gr[1]); char grtit[128]; sprintf(grtit,"Plane %d Paddle %d",plane,paddle); mgr->SetTitle(grtit); mgr->Draw("AP"); mgr->GetXaxis()->SetTitle("#Delta t [ns]"); mgr->GetYaxis()->SetTitle("ADC amplitude [arb.]"); gPad->SetGrid(); float val[3],dval[3]; TF1 *ff = gr[0]->GetFunction("f1"); TText *t[6]; for (int k=0;k<3;k++){ val[k] = ff->GetParameter(k); dval[k] = ff->GetParError(k); char line[128]; sprintf(line,"p%d: %9.3e +/- %9.3e",k,val[k],dval[k]); t[k] = new TText(0.5,0.85-k*0.04,line); t[k]->SetTextColor(2); t[k]->SetNDC(); t[k]->SetTextSize(0.03); } ff = gr[1]->GetFunction("f2"); for (int k=0;k<3;k++){ val[k] = ff->GetParameter(k); dval[k] = ff->GetParError(k); char line[128]; sprintf(line,"p%d: %9.3e +/- %9.3e",k,val[k],dval[k]); t[k+3] = new TText(0.5,0.7-k*0.04,line); t[k+3]->SetTextColor(4); t[k+3]->SetNDC(); t[k+3]->SetTextSize(0.03); } for (int k=0;k< 6;k++){ t[k]->Draw(); } gPad->Update(); char anam[256]; sprintf(anam,"plots/amplitudes_plane%d_paddle%d_run%d.pdf",plane, paddle, RunNumber); gPad->SaveAs(anam); sprintf(anam,"plots/amplitudes_plane%d_paddle%d_run%d.gif",plane, paddle, RunNumber); gPad->SaveAs(anam); if (DEBUG) { getchar(); } }