#include #include #include #include #include #include #include #include #include #include // flexible script to handle different locations for the data // using the variable "choice" // usage: viewampall.C(RUNNUMBER, CHOICE) // CHOICE secelcts different location of the input data // input data file is tof_amps_run%d.dat // output data file is attenuation_run%d.dat // float Norm[2][2][44]; float d1[2][2][44]; float d2[2][2][44]; float dNorm[2][2][44]; float ed1[2][2][44]; float ed2[2][2][44]; void viewampPaddle(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(fnam,"genroot/hists/%06d/tof_amps_run%d.dat",RunNumber,RunNumber); } TCanvas *c1 = new TCanvas("c1","Plots", 900, 600); //cout<>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.; // subract pedestal 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[1][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 (Run %d)",plane,paddle,RunNumber); mgr->SetTitle(grtit); mgr->Draw("AP"); mgr->GetXaxis()->SetTitle("#Delta t [ns]"); mgr->GetYaxis()->SetTitle("ADC amplitude (ped. subtr.) [20cnts/10mV]"); // during 2016 spring run c1->SetGridx(); c1->SetGridy(); 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); Norm[pl][0][pa] = val[0]; dNorm[pl][0][pa] = dval[0]; d1[pl][0][pa] = val[1]; ed1[pl][0][pa] = dval[1]; d2[pl][0][pa] = val[2]; ed2[pl][0][pa] = dval[2]; 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); Norm[pl][1][pa] = val[0]; dNorm[pl][1][pa] = dval[0]; d1[pl][1][pa] = val[1]; ed1[pl][1][pa] = dval[1]; d2[pl][1][pa] = val[2]; ed2[pl][1][pa] = dval[2]; 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(); } c1->Modified(); char anam[256]; sprintf(anam,"plots/amplitudes_plane%d_paddle%d_run%d.pdf",plane, paddle, RunNumber); c1->SaveAs(anam); sprintf(anam,"plots/amplitudes_plane%d_paddle%d_run%d.gif",plane, paddle, RunNumber); c1->SaveAs(anam); } void viewampall(int R, int choice){ for (int p=0;p<2;p++){ for (int pad=0; pad<44; pad++) { if ((pad<21) || (pad>22)) { viewampPaddle(R, p+1, pad+1,choice); } } } char fnam[256]; if (!choice) { sprintf(fnam,"localdir/run%d/attenuation_run%d.dat",R,R); }else { sprintf(fnam,"genroot/hists/%06d/attenuation_run%d.dat",R,R); } ofstream OF(fnam); for (int p=0;p<2;p++){ for (int pad=0; pad<44; pad++) { for (int side=0;side<2;side++){ OF<