void plot_gain(){ gROOT->Reset(); gROOT->SetStyle("Plain"); gROOT->ForceStyle(); gStyle->SetOptStat(0); gStyle->SetOptFit(1110); gStyle->SetOptTitle(1); gStyle->SetTitleBorderSize(0); gStyle->SetTitleX(0.1f); gStyle->SetTitleW(0.8f); gStyle->SetTextSize(1.5); gStyle->SetTitleFont(132,"xy"); gStyle->SetLabelFont(132,"xy"); // gStyle->SetLabelFont(62,"xy"); gStyle->SetLabelSize(0.09,"xy"); gStyle->SetTitleSize(0.09,"xy"); gStyle->SetTitleOffset(1.2,"x"); gStyle->SetTitleOffset(1.5,"y"); FILE *file1 = fopen("my_test.txt","r"); int id[200]; float x[200]; float ex[200]; float int_led1[200]; float eint_led1[200]; float int_alpha1[200]; float eint_alpha1[200]; float ratio_ref[200]; float eratio_ref[200]; float ch[145][200]; float ech[145][200]; float ch_norm[145]; int ii = 0; float a[145]; float ea[145]; char s1[] = "%d %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f \n"; while (!feof(file1)){ // fscanf(file1,"%d %f %f %f %f \n",&id[ii], &int_led1[ii], &eint_led1[ii], &int_alpha1[ii], &eint_alpha1[ii]); int aa = fscanf(file1,s1,&id[ii], &int_led1[ii], &eint_led1[ii], &int_alpha1[ii], &eint_alpha1[ii], &a[0], &ea[0], &a[1], &ea[1], &a[2], &ea[2],&a[3],&ea[3],&a[4],&ea[4], &a[5], &ea[5], &a[6], &ea[6], &a[7], &ea[7], &a[8], &ea[8], &a[9], &ea[9], &a[10], &ea[10], &a[11], &ea[11], &a[12],&ea[12],&a[13],&ea[13],&a[14],&ea[14],&a[15],&ea[15],&a[16],&ea[16],&a[17],&ea[17],&a[18],&ea[18],&a[19],&ea[19],&a[20],&ea[20],&a[21],&ea[21],&a[22],&ea[22],&a[23],&ea[23], &a[24],&ea[24],&a[25],&ea[25],&a[26],&ea[26],&a[27],&ea[27],&a[28],&ea[28],&a[29],&ea[29],&a[30],&ea[30],&a[31],&ea[31],&a[32],&ea[32],&a[33],&ea[33],&a[34],&ea[34],&a[35],&ea[35], &a[36],&ea[36],&a[37],&ea[37],&a[38],&ea[38],&a[39],&ea[39],&a[40],&ea[40],&a[41],&ea[41],&a[42],&ea[42],&a[43],&ea[43],&a[44],&ea[44],&a[45],&ea[45],&a[46],&ea[46],&a[47],&ea[47], &a[48],&ea[48],&a[49],&ea[49],&a[50],&ea[50],&a[51],&ea[51],&a[52],&ea[52],&a[53],&ea[53],&a[54],&ea[54],&a[55],&ea[55],&a[56],&ea[56],&a[57],&ea[57],&a[58],&ea[58],&a[59],&ea[59], &a[60],&ea[60],&a[61],&ea[61],&a[62],&ea[62],&a[63],&ea[63],&a[64],&ea[64],&a[65],&ea[65],&a[66],&ea[66],&a[67],&ea[67],&a[68],&ea[68],&a[69],&ea[69], &a[70],&ea[70],&a[71],&ea[71],&a[72],&ea[72],&a[73],&ea[73],&a[74],&ea[74],&a[75],&ea[75],&a[76],&ea[76],&a[77],&ea[77],&a[78],&ea[78],&a[79],&ea[79], &a[70],&ea[80],&a[81],&ea[81],&a[82],&ea[82],&a[83],&ea[83],&a[84],&ea[84],&a[85],&ea[85],&a[86],&ea[86],&a[87],&ea[87],&a[88],&ea[88],&a[89],&ea[89], &a[90],&ea[90],&a[91],&ea[91],&a[92],&ea[92],&a[93],&ea[93],&a[94],&ea[94],&a[95],&ea[95],&a[96],&ea[96],&a[97],&ea[97],&a[98],&ea[98],&a[99],&ea[99], &a[100],&ea[100],&a[101],&ea[101],&a[102],&ea[102],&a[103],&ea[103],&a[104],&ea[104],&a[105],&ea[105],&a[106],&ea[106],&a[107],&ea[107],&a[108],&ea[108],&a[109],&ea[109], &a[110],&ea[110],&a[111],&ea[111],&a[112],&ea[112],&a[113],&ea[113],&a[114],&ea[114],&a[115],&ea[115],&a[116],&ea[116],&a[117],&ea[117],&a[118],&ea[118],&a[119],&ea[119], &a[120],&ea[120],&a[121],&ea[121],&a[122],&ea[122],&a[123],&ea[123],&a[124],&ea[124],&a[125],&ea[125],&a[126],&ea[126],&a[127],&ea[127],&a[128],&ea[128],&a[129],&ea[129], &a[130],&ea[130],&a[131],&ea[131],&a[132],&ea[132],&a[133],&ea[133],&a[134],&ea[134],&a[135],&ea[135],&a[136],&ea[136],&a[137],&ea[137],&a[138],&ea[138],&a[139],&ea[139], &a[140],&ea[140],&a[141],&ea[141],&a[142],&ea[142],&a[143],&ea[143]); double tmp = int_led1[ii]/int_alpha1[ii]; double tmp1 = sqrt(pow(eint_led1[ii]/int_led1[ii],2) + pow(eint_alpha1[ii]/int_alpha1[ii],2)); ratio_ref[ii] = tmp; eratio_ref[ii] = tmp*tmp1; cout << endl; cout << id[ii] << " Amp = " << int_led1[ii] << " " << eint_led1[ii] << " Alpha " << int_alpha1[ii] << endl; cout << " Ratio = " << ratio_ref[ii] << " Eratio = " << eratio_ref[ii] << endl; for(int ll = 0; ll < 144; ll++){ ch[ll][ii] = a[ll]; ech[ll][ii] = ea[ll]; if( ch[ll][ii] < 550.) ch[ll][ii] = 0; // if(ll == 2) { // cout << " Run = " << id[ii] << " Amplitude = " << ch[ll][ii] << endl; // } } x[ii] = ii + 1; ii++; } for(int ll = 0; ll < 144; ll++){ ch_norm[ll] = ch[ll][0]; } double norm = ratio_ref[0]; for(int jj = 0; jj < ii; jj++){ ratio_ref[jj] = ratio_ref[jj]/norm; eratio_ref[jj] = eratio_ref[jj]/norm; // cout << ratio_ref[jj] << endl; for(int kk = 0; kk < 144; kk++){ if(ch_norm[kk] > 0.) ch[kk][jj] = ch[kk][jj]/ch_norm[kk]; } } memset(ex,0,sizeof(ex)); c1 = new TCanvas("Reference","Reference", 200, 10, 600, 400); gPad->SetBottomMargin(0.2); TGraphErrors *gr = new TGraphErrors(ii+1, x, ratio_ref, ex, eratio_ref ); gr->SetMarkerStyle(20); gr->SetMarkerSize(0.6); gr->SetMarkerColor(4); // gr->GetXaxis()->SetTitle("Tagger energy (GeV)"); // gr->GetYaxis()->SetTitle("FADC peak (counts)"); gr->SetTitle(""); gr->SetMinimum(0.97); gr->SetMaximum(1.03); gr->Draw("AP"); gStyle->SetTitleSize(0.15,"t"); c4 = new TCanvas("LED ALL","LED ALL", 200, 10, 1400, 1000); c4->Divide(12,12,0.001,0.005); TGraphErrors *gr1[144]; for(int ll = 0; ll < 144; ll++){ int kk = 143 - ll; // if(kk != 12) continue; char title[20]; sprintf(title,"%d \n",kk); // ch[kk][5] += 0.005; gr1[kk] = new TGraphErrors(ii+1, x, ch[kk], ex, ex ); gr1[kk]->SetTitle(title); gr1[kk]->SetMinimum(0.9); gr1[kk]->SetMaximum(1.1); gr1[kk]->SetMarkerStyle(23); gr1[kk]->SetMarkerSize(0.6); gr1[kk]->SetMarkerColor(6); c4->cd(ll+1); gr1[kk]->Draw("AP"); } #if 0 c5 = new TCanvas("EXAMP","EXAMP", 200, 10, 800, 400); // c5->Divide(3,3,0.01,0.01); // c5->Divide(2,1,0.01,0.01); gPad->SetGrid(1); gr1[101]->SetTitle(""); gr1[101]->Draw("AP"); gr1[102]->SetMarkerColor(1); gr1[102]->Draw("Psame"); gr1[103]->SetMarkerColor(4); gr1[103]->Draw("Psame"); gr1[63]->SetMarkerColor(6); gr1[63]->Draw("Psame"); gr1[68]->SetMarkerColor(9); gr1[68]->Draw("Psame"); gr1[43]->SetMarkerColor(2); gr1[43]->Draw("Psame"); #endif #if 0 c5->cd(2); gPad->SetGrid(1); gr1[4]->SetTitle(""); gr1[4]->Draw("AP"); gr1[5]->SetMarkerColor(1); gr1[5]->Draw("Psame"); gr1[131]->SetMarkerColor(4); gr1[138]->Draw("Psame"); gr1[134]->SetMarkerColor(2); gr1[134]->Draw("Psame"); #endif // c5->cd(2); // gr1[101]->SetMarkerColor(2); // gr1[101]->Draw("AP"); // c5->cd(3); // gr1[102]->SetMarkerColor(1); // gr1[102]->Draw("AP"); // c5->cd(4); // gr1[103]->SetMarkerColor(4); // gr1[103]->Draw("AP"); }