TGraphErrors g(TTree *tree, TString alphaName, TString constTermName){ Double_t alpha, constTerm; alphaName.ReplaceAll("-","_"); constTermName.ReplaceAll("-","_"); tree->SetBranchAddress(alphaName,&alpha); tree->SetBranchAddress(constTermName,&constTerm); //Long64_t nEntries=genTree->GetEntries(); TGraphErrors graph; Int_t iPoint=0; tree->GetEntry(0); std::cout << alpha << "\t" << constTerm << std::endl; Double_t alpha2=alpha*alpha; Double_t const2=constTerm*constTerm; for(Double_t energy=20; energy<150; energy+=10){ Double_t addSmearing = (sqrt(alpha2/energy+const2)); graph.SetPoint(iPoint, energy, addSmearing); graph.SetPointError(iPoint,0, 0); iPoint++; } graph.Set(iPoint); tree->ResetBranchAddresses(); graph.Draw("A L"); graph.SetFillColor(kBlue); graph.SetLineColor(kYellow); graph.GetXaxis()->SetTitle("Energy [GeV]"); graph.GetYaxis()->SetTitle("Additional smearing [%]"); return graph; }
TGraphErrors g(TTree *genTree, TString constTermName=""){ Double_t alpha, constTerm; genTree->SetBranchAddress("alpha",&alpha); genTree->SetBranchAddress("constTerm",&constTerm); Long64_t nEntries=genTree->GetEntries(); TH1F h("smearingHist","",10000,0,0.1); TGraphErrors graph; Int_t iPoint=0; for(Double_t energy=20; energy<150; energy+=10){ h.Reset(); for(Long64_t jentry=0; jentry<nEntries; jentry++){ genTree->GetEntry(jentry); h.Fill(sqrt(alpha*alpha/energy+constTerm*constTerm)); } graph.SetPoint(iPoint, energy, h.GetMean()); graph.SetPointError(iPoint,0, h.GetRMS()); iPoint++; } h.SetTitle(constTermName); h.SaveAs("tmp/h-"+constTermName+".root"); graph.Set(iPoint); genTree->ResetBranchAddresses(); graph.Draw("A L3"); graph.SetFillColor(kBlue); graph.SetLineColor(kYellow); graph.GetXaxis()->SetTitle("Energy [GeV]"); graph.GetYaxis()->SetTitle("Additional smearing [%]"); return graph; }
void ExpManager::GetExp1DGraphX(TString NameTitle, double zmin, double zmax, double ymin, double ymax, TString grid){ // do the same thing as for the polar interpolation TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez); fGraph->SetTitle("Experimental Data;X (mm);Magnetic Field (mT)"); fGraph->SetMarkerSize(1.2); fGraph->SetMarkerStyle(20); fGraph->SetMarkerColor(kBlue); fGraph->SetLineColor(kBlue); fGraph->SetLineWidth(2); int graph_counter = 0 ; for (unsigned i=0; i< fExpY.size(); i++) { //cout << " X " << fExpX.at(i) ; if( (fExpY.at(i) >= ymin && fExpY.at(i) <= ymax) && (fExpZ.at(i) >= zmin && fExpZ.at(i) <= zmax) && fGrid.at(i)== grid ){ cout << " < ----- " ; fGraph->SetPoint(graph_counter,fExpX.at(i),fExpB.at(i)); // CHECK, add new the stuff for emag fGraph->SetPointError(graph_counter,fExpXErr.at(i),fExpBErr.at(i)); // CHECK, add new the stuff for emag graph_counter++; } cout << endl ; } fGraph->SetTitle(NameTitle+Form(" Experimental Data : %.2f < Depth < %.2f mm __ %.2f < Y < %.2f mm;X (mm);Magnetic Field (mT)",zmin,zmax,ymin,ymax)); fGraph->SetName(NameTitle+Form("_Exp_Depth_%.2f_%.2fmm_Y_%.2f_%.2fmm",zmin,zmax,ymin,ymax)); fGraph->Write(); }
void LSF() { float x[100], y[100], ex[100], ey[100]; char filename[80]; printf("Enter filename.\n"); scanf("%s",filename); FILE *f = fopen(filename,"r"); if (f == NULL) { sprintf(line,"File %s not found.\n",filename); printf(line); return; } // Read data int i = 0; while (fscanf(f,"%f %f %f",&(x[i]),&(y[i]),&(ey[i])) == 3 ) { i++; } printf("Read %d data points.\n",i); TGraphErrors *tge = new TGraphErrors(i,x,y,ex,ey); tge->SetMarkerStyle(20); tge->SetMarkerColor(kBlue); tge->SetLineColor(kBlue); c1 = new TCanvas("c1","c1",600,600); tge->Draw("AP"); tge->Fit("pol1"); }
void ExpManager::GetSim1DGraphZ(TString NameTitle, double xmin, double xmax, double ymin, double ymax, TString grid ){ // do the same thing as for the polar interpolation TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez); fGraph->SetTitle("Simulated Data;Z (mm);Magnetic Field (mT)"); fGraph->SetMarkerSize(1.2); fGraph->SetMarkerStyle(20); fGraph->SetMarkerColor(kBlue); fGraph->SetLineColor(kBlue); fGraph->SetLineWidth(2); int graph_counter = 0 ; for (unsigned i=0; i< fExpY.size(); i++) { //cout << " X " << fExpX.at(i) ; if( (fExpX.at(i) >= xmin && fExpX.at(i) <= xmax) && (fExpY.at(i) >= ymin && fExpY.at(i) <= ymax) && fGrid.at(i)==grid ){ fGraph->SetPoint(graph_counter,fExpZ.at(i),fSimB.at(i)); fGraph->SetPointError(graph_counter,fExpZErr.at(i),0); graph_counter++; } } fGraph->SetTitle(NameTitle+Form(" Simulated Data : %.2f < X < %.2f mm __ %.2f < Y < %.2f mm;Z (mm);Magnetic Field (mT)",xmin,xmax,ymin,ymax)); fGraph->SetName(NameTitle+Form("_Sim_X_%.2f_%.2fmm_Y_%.2f_%.2fmm",xmin,xmax,ymin,ymax)); fGraph->Write(); }
void DrawSame(char* varToPlot, char* cond, Int_t kColor,TLegend* leg,char* cLeg) { TGraphErrors *g; TIFTree->Draw(varToPlot,cond,"goff"); Int_t nSel=TIFTree->GetSelectedRows(); if ( nSel ) { Double_t *ErrX= new Double_t[nSel]; for ( Int_t i=0; i<nSel; i++) ErrX[i]=0; g = new TGraphErrors(TIFTree->GetSelectedRows(), TIFTree->GetV1(), TIFTree->GetV2(), ErrX, TIFTree->GetV3()); g->SetMarkerStyle(21); g->SetMarkerSize(0.5); g->SetMarkerColor(kColor); g->SetLineColor(kColor); g->Draw("SP"); //draw graph in current pad // g->GetYaxis()->SetRangeUser(40., 100.); leg->AddEntry(g,cLeg); leg->Draw(); delete[] ErrX; } else { cout << "NO rows selected " << endl; } }
/* Determine the correction to be applied to emission spectra by taking a ratio * of an accepted reference to data that was measured in the integrating sphere. */ void RatioEmissionCorrection() { double y[NUM_POINTS + 1]; double corr[NUM_POINTS]; FILE *data = fopen("data/ratio emcorr/POPOP_IS.txt", "r"); FILE *ref = fopen("data/ratio emcorr/POPOPref.txt", "r"); char line[LINE_SIZE]; char* p; int index = 0; while(fgets(line, sizeof(line), data)) { strtok(line, "\n"); double xval = strtod(line, &p); double yval = atof(p); y[index] = yval - 3424.978; index++; } index = 0; while(fgets(line, sizeof(line), ref)) { strtok(line, "\n"); double xval = strtod(line, &p); double yval = atof(p); corr[index] = (yval - 3500) / y[index]; index++; fgets(line, sizeof(line), ref); strtok(line, "\n"); } FILE* result = fopen("correction/ratioCorrectionData.txt", "w"); for (int k = 0; k < NUM_POINTS; k++) { printf("%dnm: %f\n", k + 350, corr[k]); sprintf(line, "%d %f\n", k + 350, corr[k]); fputs(line, result); } fclose(data); fclose(ref); fclose(result); /* VARIATION.C was used to calculate the average fraction of the * standard error over the mean photon count for each of the three * excitation corrections. This is the factor used for error bars. */ double err[NUM_POINTS + 1]; double w[NUM_POINTS + 1]; double y_corr[NUM_POINTS + 1]; for (int n = 0; n < NUM_POINTS; n++) { err[n] = 0.04148067 * corr[n]; w[n] = n + 350; y_corr[n] = y[n] * corr[n]; } TGraphErrors* g = new TGraphErrors(151, w, corr, NULL, err); g->SetTitle("Emission Corrections"); g->SetLineColor(4); g->Draw(); }
void plot_mc(string name="g", double q2=1.9, Int_t n=0) { // SetAtlasStyle(); TGraphErrors *p; TString nn; nn.Form("ave_%s_vs_x_for_Q2=%g",name.c_str(),q2); gDirectory->GetObject(nn,p); // p->Print(); Double_t ratsize = 0.0; TCanvas *c = new TCanvas("PDF","pdf",600,600); TPad *pad1 = new TPad("pad1","pad1",0.,ratsize,1.,1.); pad1->SetLogx(); pad1->Draw(); pad1->cd(); p->GetXaxis()->Set(101,0.0001,1.); p->SetFillColor(kRed-2); p->SetFillStyle(3001); p->SetLineWidth(1); p->SetLineColor(kRed); p->GetYaxis()->SetTitle(name.c_str()); p->GetYaxis()->SetTitleSize(0.06); p->GetYaxis()->SetTitleOffset(1.); p->GetXaxis()->Set(101,0.0001,1.); p->Draw("ALE3"); Double_t av = 0; Double_t av2 = 0; for (Int_t i = 1; i<n+1 ; i++) { nn.Form("%s_vs_x_for_Q^{2}=%g_%i",name.c_str(),q2,i); TGraph *pp = NULL; gDirectory->GetObject(nn,pp); if (pp != NULL) { pp->SetLineColor(kGreen); pp->Draw("L"); av += pp->GetY()[0]; av2 += pp->GetY()[0]*pp->GetY()[0]; cout << i << " "<<pp->GetY()[0] << endl; } } av /= n; av2 = sqrt(av2/n - av*av); // cout << n << " "<<av << " "<< av2<<endl; p->Draw("E3C"); }
int CmpNmuMCData() { double ene[21] = {2.0, 2.05, 2.1, 2.15, 2.175, 2.2, 2.2324, 2.3094, 2.3864, 2.396, 2.5, 2.6444, 2.6464, 2.7, 2.8, 2.9, 2.95, 2.981, 3.0, 3.02, 3.08}; double enee[21] = {0.0}; double Nmu_mc[21] = {73.4868, 24.4878, 106.242, 28.242, 123.445, 171.389, 155.009, 336.687, 412.597, 1314.02, 26.2072, 1117.27, 1111.97, 37.838, 41.3881, 5159.19, 899.304, 924.003, 928.963, 1074.39, 8685.27}; double Nmue_mc[21]; for (int i=0; i<21;i++) Nmue_mc[i] = sqrt(Nmu_mc[i]); double Nmu_da[21] = {91.9, 39.1, 143.0, 25.8, 129.5, 163.7, 159.6, 361.1, 443.5, 1240.1, 22.0, 1081.5, 1073.7, 53.1, 41.9, 5441.4, 894.8, 974.4, 977.4, 1172.0, 8805.7}; double Nmue_da[21]= {11.9, 6.4, 13.5, 5., 12.7, 13.2, 17.1, 24.9, 24.8, 50.5, 4.1, 35.2, 42.7, 7.5, 7.7, 124.6, 32.5, 32.4, 31.6, 35.6, 102.7}; double Nmu_mc_s[21]; double Nmue_mc_s[21]; double Nmu_da_s[21]; double Nmue_da_s[21]; for (int i=0; i<21; i++){ Nmu_mc_s[i] = Nmu_mc[i]/Nmu_da[i]; Nmue_mc_s[i] = Nmue_mc[i]/Nmu_da[i]; Nmu_da_s[i] = Nmu_da[i]/Nmu_da[i]; Nmue_da_s[i] = Nmue_da[i]/Nmu_da[i]; cout << "At "<< ene[i]<<" GeV, Nmu from data is "<< Nmu_da[i]<<", Nmu from MC is "<< Nmu_mc[i]<<endl; //cout << ene[i]<<"\t" << Nmu_da[i]; //cout << "\t" << Nmu_mc[i] << " "<< Nmu_mc_s[i] ; //cout << "\t "<< Nmue_mc[i] << " "<< Nmue_mc_s[i] ; //cout << "\t "<< Nmu_da[i] <<" "<< Nmu_da_s[i]; //cout <<"\t " << Nmue_da[i] <<" "<< Nmue_da_s[i] << endl; } TGraphErrors *gdata = new TGraphErrors(21, ene, Nmu_da_s, enee, Nmue_da_s); TGraphErrors *gmcmu = new TGraphErrors(21, ene, Nmu_mc_s, enee, Nmue_mc_s); gdata->Draw("AP"); gdata->SetFillColor(0); gmcmu->SetFillColor(0); gmcmu->SetLineColor(3); gmcmu->SetMarkerColor(3); gmcmu->Draw("P"); TLegend *lg = new TLegend(0.5,0.5,0.9,0.9); lg->SetFillStyle(0); lg->AddEntry(gdata,"Nmu from data"); lg->AddEntry(gmcmu,"Nmu from MC"); lg->Draw(); }
void plotter(Int_t octant=1){ gROOT->Reset(); gROOT->SetStyle("Plain"); TString runNums[5] = {"14296","15736","16654","17635","18875"}; TCanvas *c1 = new TCanvas(); TGraphErrors *gPos = new TGraphErrors(Form("md%dpos.dat",octant),"%lg %lg %lg"); TGraphErrors *gNeg = new TGraphErrors(Form("md%dneg.dat",octant),"%lg %lg %lg"); gPos->SetMarkerColor(kBlue); gNeg->SetMarkerColor(kRed); gPos->SetLineColor(kBlue); gNeg->SetLineColor(kRed); gPos->SetFillStyle(0); gNeg->SetFillStyle(0); gPos->SetTitle(Form("MD%dPOS",octant)); gNeg->SetTitle(Form("MD%dNEG",octant)); TMultiGraph *gm = new TMultiGraph("gm",Form("1/Yield for MD%d",octant)); gm->Add(gPos); gm->Add(gNeg); gm->Draw("ap"); gm->GetYaxis()->SetTitle("1/Yield (uA/V)"); gm->GetXaxis()->SetTitle("Run Number"); gm->GetXaxis()->SetNdivisions(505,kTRUE); for(Int_t i=0; i<5; i++){ gm->GetXaxis()->SetBinLabel(gm->GetXaxis()->FindBin(150000+i*10000),runNums[i].Data()); } gm->GetXaxis()->SetTitleOffset(1.4); c1->BuildLegend(); }
void gerrors() { TCanvas *mycanvas = new TCanvas("mycanvs","A Simple Graph with error bars",200,10,700,500); // mycanvas->SetFillColor(42); mycanvas->SetGrid(); // mycanvas->GetFrame()->SetFillColor(21); // mycanvas->GetFrame()->SetBorderSize(12); const int n_points =10; #double x_vals [ n_points]= {1,2,3,4,5,6,7,8,9,10}; double y_vals [ n_points]= {6 ,12 ,14 ,20 ,22 ,24 ,35 ,45 ,44 ,53}; double y_errs [ n_points]= {5 ,5 ,4.7 ,4.5 ,4.2 ,5.1,2.9,4.1,4.8,5.43}; TGraphErrors *gr = new TGraphErrors(n_points,x_vals,y_vals,NULL,y_errs); // TGraphErrors graph(n_points,x_vals,y_vals,NULL,y_errs); gROOT -> SetStyle("Plain"); gr->SetTitle("TGraphErrors Example; lengtht [cm];Arb. Units"); gr->SetMarkerColor(kBlue); gr->SetMarkerStyle(kOpenCircle); gr->SetLineColor ( kBlue ) ; gr->Draw("ALP"); //Define a linear function TF1 f("Linear law" ,"[0]+x*[1]" ,.5 ,10.5) ; // Let's make the funcion line nicer f.SetLineColor(kRed); f.SetLineStyle(2); // Fit it to the graph and draw it gr->Fit(&f); f.DrawClone("Same"); // Build and Draw a legend TLegend leg(.1 ,.7 ,.3 ,.9 ,"Lab. Lesson 1"); leg.SetFillColor (0) ; gr->SetFillColor (0) ; leg.AddEntry(gr,"Exp. Points"); leg.AddEntry(&f,"Th. Law"); leg.DrawClone("Same"); // Draw an arrow on the canvas TArrow arrow(8,8,6.2,23,0.02,"----|>"); arrow.SetLineWidth (2) ; arrow.DrawClone ( ) ; // Add some text to the plot TLatex text(8.2,7.5,"#splitline{Maximum}{Deviation}"); text.DrawClone ( ) ; mycanvas->Update(); mycanvas -> Print("example.pdf"); }
void ExpManager::DrawMap(TString NameTitle, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) { TMultiGraph *mg = new TMultiGraph(); //Draw a cross TGraphErrors *frame = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez); frame->SetPoint(0,+0,+100); frame->SetPoint(1,+0,-100); frame->SetPoint(2,0,0); frame->SetPoint(3,-100,0); frame->SetPoint(4,+100,0); frame->SetPoint(5,+0,+0); frame->SetPoint(6,+0,-100); frame->SetMarkerColor(kWhite); frame->SetDrawOption("ap"); //Draw the map TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez); fGraph->SetMarkerSize(1.2); fGraph->SetMarkerStyle(20); fGraph->SetMarkerColor(kBlue); fGraph->SetLineColor(kBlue); fGraph->SetLineWidth(1); //fGraph->SetDrawOption("ap"); int graph_counter = 0 ; for (unsigned i=0; i< fExpY.size(); i++) { if( (fExpX.at(i) >= xmin && fExpX.at(i) <= xmax) && (fExpY.at(i) >= ymin && fExpY.at(i) <= ymax) && (fExpZ.at(i) >= zmin && fExpZ.at(i) <= zmax) ) { fGraph->SetPoint(graph_counter,fExpX.at(i),fExpY.at(i)); fGraph->SetPointError(graph_counter,fExpXErr.at(i),fExpYErr.at(i)); graph_counter++; } } //fGraph->Write(); mg->SetTitle(NameTitle+Form(" Map : %.2f < X < %.2f mm %.2f < Y < %.2f mm %.2f < Z < %.2f mm;X (mm);Y (mm)",xmin,xmax,ymin,ymax,zmin,zmax)); mg->SetName(NameTitle+Form("_Map__X_%.2f_%.2fmm__Y_%.2f_%.2fmm__Z_%.2f_%.2fmm",xmin,xmax,ymin,ymax,zmin,zmax)); mg->Add(frame); mg->Add(fGraph); mg->Write(); }
TGraphErrors* draw_single_spectra( string energy="15", string plc="la", string iCen="0", int color = kRed, string draw_opt = "", double scaler = 1.0 ){ Logger::setGlobalLogLevel( Logger::llAll ); gStyle->SetOptStat( 0 ); string fn = file_name( energy, plc, iCen ); if ( !file_exists( fn ) ) return new TGraphErrors(); INFO( "Loading " << fn ) SpectraLoader sl( fn ); sl = sl * scaler; TGraphErrors* stat = sl.statGraph( ); //stat->Scale( scaler ); // if ( "la" == plc || "ala" == plc){ // stat->SetBinContent( 1, 0 ); // stat->SetBinError( 1, 0 ); // } stat->SetTitle( " ; pT [GeV/c]; dN^{2} / ( N_{evt} 2 #pi pT dpT dy )" ); stat->SetLineColor( color ); stat->SetMarkerStyle( 8 ); stat->SetMarkerColor( color ); stat->Draw( draw_opt.c_str() ); gPad->SetLogy(1); return stat; }
TGraphErrors* getDataMcResponseRatio(TGraphErrors* gData, TGraphErrors* gMc, int aNumberOfPtBins, string XTitle) { Double_t x[aNumberOfPtBins]; Double_t ex[aNumberOfPtBins]; for(int j=0;j<aNumberOfPtBins; j++) { ex[j] = 0.; } Double_t xratio[aNumberOfPtBins]; Double_t ydata[aNumberOfPtBins]; Double_t ymc[aNumberOfPtBins]; Double_t yr[aNumberOfPtBins]; Double_t eydata[aNumberOfPtBins]; Double_t eymc[aNumberOfPtBins]; Double_t eyr[aNumberOfPtBins]; int nBins = 0; for(int i=0; i<aNumberOfPtBins; i++) { gMc->GetPoint(i,x[i],ymc[i]); gData->GetPoint(i,x[i],ydata[i]); eymc[i] = gMc->GetErrorY(i); eydata[i] = gData->GetErrorY(i); if (ymc[i] == 0 || ydata[i] == 0) continue; xratio[nBins] = x[i]; yr[nBins] = ydata[i]/ymc[i]; std::cout << yr[nBins] << std::endl; eyr[nBins] = sqrt(pow(eydata[i]/ymc[i],2)+pow(eymc[i]*ydata[i]/(pow(ymc[i],2)),2)); nBins++; } TGraphErrors *gDataMcResponseratio = new TGraphErrors(nBins,xratio,yr,ex,eyr); gDataMcResponseratio->SetMarkerStyle(20); gDataMcResponseratio->SetMarkerColor(1); gDataMcResponseratio->SetLineColor(1); gDataMcResponseratio->SetMarkerSize(1.0); //gDataMcResponseratio->SetMaximum(1.08); //gDataMcResponseratio->SetMinimum(0.90); gDataMcResponseratio->GetXaxis()->SetTitle(XTitle.c_str()); return gDataMcResponseratio; }
TGraphErrors g(Double_t alpha, Double_t constTerm){ TGraphErrors graph; Int_t iPoint=0; // std::cout << alpha << "\t" << constTerm << std::endl; Double_t alpha2=alpha*alpha; Double_t const2=constTerm*constTerm; for(Double_t energy=20; energy<150; energy+=10){ Double_t addSmearing = (sqrt(alpha2/energy+const2)); graph.SetPoint(iPoint, energy, addSmearing); graph.SetPointError(iPoint,0, 0); iPoint++; } graph.Set(iPoint); graph.Draw("A L"); graph.SetFillColor(kBlue); graph.SetLineColor(kYellow); graph.GetXaxis()->SetTitle("Energy [GeV]"); graph.GetYaxis()->SetTitle("Additional smearing [%]"); return graph; }
TGraphErrors *tools::ratioGraphs(TGraphErrors *g1, TGraphErrors *g2, double erry) { assert(g1); assert(g2); TGraphErrors *g = new TGraphErrors(0); g->SetName(Form("ratio_%s_%s",g1->GetName(),g2->GetName())); g->SetMarkerStyle(g1->GetMarkerStyle()); g->SetMarkerColor(g1->GetMarkerColor()); g->SetLineColor(g1->GetLineColor()); // take ratio only of points that are closer to each other than any others for (int i = 0, j = 0; (i != g1->GetN() && j != g2->GetN());) { double x1m, x1p, x2m, x2p, y, ex, ey; GetPoint(g1, max(i-1,0), x1m, y, ex, ey); GetPoint(g1, min(i+1,g1->GetN()-1), x1p, y, ex, ey); GetPoint(g2, max(j-1,0), x2m, y, ex, ey); GetPoint(g2, min(j+1,g2->GetN()-1), x2p, y, ex, ey); double x1, y1, ex1, ey1; GetPoint(g1, i, x1, y1, ex1, ey1); double x2, y2, ex2, ey2; GetPoint(g2, j, x2, y2, ex2, ey2); if (fabs(x1-x2)<=fabs(x1-x2m) && fabs(x1-x2)<=fabs(x1-x2p) && fabs(x1-x2)<=fabs(x2-x1m) && fabs(x1-x2)<=fabs(x2-x1p)) { int n = g->GetN(); SetPoint(g, n, 0.5*(x1+x2), (y2 ? y1/y2 : 0.), 0.5*fabs(x1-x2), oplus(ey1/y1, ey2/y2) * fabs(y2 ? y1/y2 : 0.) * erry); ++i, ++j; } else (x1<x2 ? ++i : ++j); } // for i, j return g; } // ratioGraphs
void ExpManager::GetExp1DGraphPolar(TString NameTitle, double zmin, double zmax, double anglemin, double anglemax, TString grid) { TGraphErrors *fGraph = new TGraphErrors(); //= new TGraph2DErrors(np, x_array, y_array, bz_array, ex, ey, ez); fGraph->SetTitle("Experimental Data;Radius (mm);Magnetic Field (mT)"); fGraph->SetMarkerSize(1.2); fGraph->SetMarkerStyle(20); fGraph->SetMarkerColor(kBlue); fGraph->SetLineColor(kBlue); fGraph->SetLineWidth(2); int graph_counter = 0 ; for (unsigned i=0; i< fExpR.size(); i++) { if( (fExpTheta.at(i) >= anglemin && fExpTheta.at(i) <= anglemax) && (fExpZ.at(i) >= zmin && fExpZ.at(i) <= zmax) && fGrid.at(i)== grid ){ fGraph->SetPoint(graph_counter,fExpR.at(i),fExpB.at(i)); fGraph->SetPointError(graph_counter,fExpRErr.at(i),fExpBErr.at(i)); graph_counter++; } } fGraph->SetTitle(NameTitle+Form(" Experimental Data : %.2f < Depth < %.2f mm __ %.2f#circ < Angle < %.2f#circ;Radius (mm);Magnetic Field (mT)",zmin,zmax,anglemin,anglemax)); fGraph->SetName(NameTitle+Form("_Exp_Depth_%.2f_%.2fmm_Angle_%.2f_%.2fdeg",zmin,zmax,anglemin,anglemax)); fGraph->Write(); }
void rateStudy() { const int NRUNS = 25; const int NCH = 32; const int NBINS = 32; TCanvas* c1 = new TCanvas("c1", "c1", 800, 600); TMultiGraph *mg = new TMultiGraph(); TLegend *legend=new TLegend(0.65,0.15,0.88,0.55); legend->SetNColumns(4); legend->SetFillColor(0); TH1F* hRate = new TH1F("hRate", "hist", 32.0, 0, 8.0); //Color buffer const int NCOLORS = 32; int color[NCOLORS] = {73, 2, 3, 4, 99, 6, 7, 8, 9, 12, 28, 32, 34, 28, 50, 51, 56, 58, 88, 99, 1, 208, 209, 218, 212, 210, 221, 224, 225, 226, 227, 228 }; ifstream fin; //fin.open("runlist.txt"); fin.open("filter_runlist.txt"); string line = ""; TFile* out = new TFile("outtemp.root", "REACREATE"); TH1F* h = new TH1F("h","hist", NBINS, 0, NBINS); TF1* pois = new TF1("pois","[0]*TMath::Poisson(x,[1])",0,50); TF1* ppp = new TF1("ppp","[0]*TMath::Power(0.5,x*[1])",0.01,1.0); for (int ch = 0; ch < NCH; ++ch) { //if ( ch==26 || ch==27 ) //continue; //Graph points and errors Double_t x[NRUNS]; Double_t y[NRUNS]; Double_t errX[NRUNS] = {0}; Double_t errY[NRUNS] = {0}; int fileCounter = 0; while(getline(fin, line)) { vector<double> data = parse(line); stringstream filePath; filePath << "pmtratestudy/run" << data[0] << "*.root"; cout << "opening file at " << filePath.str() << endl; cout << "file counter: " << fileCounter << " channel=" << ch << endl; //TFile* f = new TFile(filePath.str().c_str()); //TTree* t = (TTree *)f->Get("eventtree"); TChain* t = new TChain("eventtree"); t->Add( filePath.str().c_str() ); out->cd(); x[fileCounter] = data[1]; int nfires[NCH] = {0}; int samples = 0; float chmax = 0.0; t->SetBranchAddress("nfires", &nfires); t->SetBranchAddress("samples", &samples); t->SetBranchAddress("chmax", &chmax); h->Reset(); int nentries = t->GetEntries(); for (int entry = 0; entry < nentries; ++entry) { t->GetEntry(entry); if (chmax < 100.0) { h->Fill(nfires[ch]); } } pois->SetParameter(0,1); pois->SetParameter(1, h->GetMean()); h->Fit(pois,"RQ","",0,50); //TF1 *myfit = (TF1 *)h->GetFunction("pois"); TF1 *myfit = (TF1 *)pois; Double_t lambda = myfit->GetParameter(1); h->Draw(); stringstream histFileName; histFileName << "hist/h" << data[0] << "_ch" << ch << ".png"; c1->SaveAs(histFileName.str().c_str()); //Graph with poisson method #if 1 y[fileCounter] = lambda / ((samples - 1) * 15.625E-6); errY[fileCounter] = myfit->GetParError(1) / ((samples - 1) * 15.625E-6); #endif //Graph with mean method #if 0 y[fileCounter] = h->GetMean() / ((samples - 1) * 15.625E-6); errY[fileCounter] = h->GetMeanError() / ((samples - 1) * 15.625E-6); #endif cout << x[fileCounter] << ", " << y[fileCounter] << " | " << (samples - 1) << endl; delete t; //f->Close(); fileCounter++; } ppp->SetParameter(0,1); ppp->SetParameter(1,0.4); TGraphErrors* gr = new TGraphErrors(NRUNS, x, y, errX, errY); gr->SetLineColor(color[ch % NCOLORS]); cout << "color: " << color[ch % NCOLORS] << endl; gr->SetLineWidth(2); gr->SetMarkerStyle(7); gr->Fit("ppp","R0","Q0",0.045,2.0); TF1 *afit = (TF1 *)gr->GetFunction("ppp"); Double_t aRate = 1/afit->GetParameter(1); if (aRate > 0) { hRate->Fill(aRate); } gr->GetXaxis()->SetTitle("Run Date"); gr->GetYaxis()->SetTitle("Rate [kHz]"); stringstream entryName, fileName; entryName << "Channel" << ch; gr->SetTitle(entryName.str().c_str()); fileName << "plots/" << ch << ".png"; legend->AddEntry(gr, entryName.str().c_str()); gr->Draw("alp"); c1->SaveAs(fileName.str().c_str()); mg->Add(gr); cout << "added plot to mg\n"; fin.clear(); fin.seekg(0, ios::beg); } // loop over channel hRate->Draw(); hRate->Fit("gaus"); c1->SaveAs("hrate.pdf"); mg->Draw("alp"); mg->GetXaxis()->SetTitle("Days since first run"); mg->GetYaxis()->SetTitle("Rate [kHz]"); mg->SetTitle("All channels: Rate vs. Days since first Run"); legend->Draw(); c1->SaveAs("mg.pdf"); }
void profileDistributions(TString dist) { gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetPalette(1); TFile *inF=TFile::Open("~/work/top_539/plotter.root"); TFile *inSystF=TFile::Open("~/work/top_539/plotter_syst.root"); bool isPhi(dist.Contains("phi")); TString profs[]={dist, dist+"toward", dist+"transverse", dist+"away"}; const size_t nprofs= isPhi ? 1 : sizeof(profs)/sizeof(TString); Int_t colors[]={1,kBlue,kRed,kGreen-3}; TString cats[]={"inclusive","away","transverse","toward"}; /* TFile *inNomF=inF; TString nomTTbar="t#bar{t}"; TString nomTTbarTitle="MG+PY"; //TString systList[]={"t#bar{t}systmcatnlo"}; //TString systLabels[]={"MC@NLO+HW"}; //TString systList[]={"t#bar{t}systq2down","t#bar{t}systq2up"}; //TString systLabels[]={"-Q^{2}","+Q^{2}"}; //TString systList[]={"t#bar{t}systmepsdown","t#bar{t}systmepsup"}; // TString systLabels[]={"-ME-PS","+ME-PS"}; */ TFile *inNomF=inSystF; TString nomTTbar="t#bar{t}systtunep11"; TString nomTTbarTitle="P11"; TString systList[]={"t#bar{t}systtunep11nocr","t#bar{t}systtunep11tev"}; TString systLabels[]={"P11-noCR","P11TeV"}; Int_t systColors[]={1,kAzure,kRed-6,kGreen+3}; const size_t nSysts=sizeof(systList)/sizeof(TString); TString ch[]={"emu"}; const size_t nch=sizeof(ch)/sizeof(TString); for(size_t ich=0; ich<nch; ich++) { TCanvas *c=new TCanvas("c"+ch[ich]+dist,"c"+ch[ich]+dist,800,800); c->SetTopMargin(0); c->SetBottomMargin(0); c->Divide(1,nprofs); TCanvas *cratios=new TCanvas("cratios"+ch[ich]+dist,"cratios"+ch[ich]+dist,800,800); cratios->SetTopMargin(0); cratios->SetBottomMargin(0); cratios->Divide(1,nprofs); TCanvas *cproj=new TCanvas("cproj"+ch[ich]+dist,"cproj"+ch[ich]+dist,600,600); TLegend *dataprojLeg=new TLegend(0.5,0.9,0.6,0.7,"Data","brNDC"); TLegend *mcprojLeg=new TLegend(0.7,0.9,0.92,0.7,"MC","brNDC"); for(size_t i=0; i<nprofs; i++) { TH2 *bckgMC = (TH2 *) inF->Get("Z#rightarrow ll/"+ch[ich]+"_"+profs[i]); bckgMC->Add( (TH2 *) inF->Get("VV/"+ch[ich]+"_"+profs[i]) ); bckgMC->Add( (TH2 *) inF->Get("Single top/"+ch[ich]+"_"+profs[i]) ); bckgMC->Add( (TH2 *) inF->Get("W+jets-multijets/"+ch[ich]+"_"+profs[i]) ); //build the total MC with signal alternatives TH2 *MC = (TH2 *) inNomF->Get(nomTTbar+"/"+ch[ich]+"_"+profs[i]) ; Double_t totalTTbar(MC->Integral()); MC->Add(bckgMC); MC->SetDirectory(0); MC->Sumw2(); std::vector<TH2 *> systMC; for(size_t isyst=0; isyst<nSysts; isyst++) { TH2F *h=(TH2F *)inSystF->Get(systList[isyst]+"/"+ch[ich]+"_"+profs[i]) ; h->Scale(totalTTbar/h->Integral()); h->Add(bckgMC); h->Sumw2(); h->SetDirectory(0); systMC.push_back(h); } //get the data TH2 *Data = (TH2 *) inF->Get("data/"+ch[ich]+"_"+profs[i]); Data->SetDirectory(0); Data->Sumw2(); TGraphErrors *MCProf = new TGraphErrors(MC->ProfileX()); MCProf->SetMarkerStyle(24); MCProf->SetFillStyle(0); MCProf->SetName(ch[ich]+profs[i]+"mc"); TGraphErrors *DataProf = new TGraphErrors(Data->ProfileX()); DataProf->SetMarkerStyle(20); DataProf->SetFillStyle(0); DataProf->SetName(ch[ich]+profs[i]+"data"); //build data/MC scale factors std::vector<TGraphErrors *> data2mcProfs; for(size_t isyst=0; isyst<=systMC.size(); isyst++) { TGraphErrors *prof= (isyst==0 ? MCProf : new TGraphErrors(systMC[isyst-1]->ProfileX())); TString baseName(ch[ich]+profs[i]); if(isyst) baseName += systList[isyst]; prof = (TGraphErrors *) prof->Clone(baseName+"data2mc"); for(int ip=0; ip<DataProf->GetN(); ip++) { Double_t x,y,ydata,y_err,ydata_err; prof->GetPoint(ip,x,y); y_err=prof->GetErrorY(ip); DataProf->GetPoint(ip,x,ydata); ydata_err=DataProf->GetErrorY(ip); if(y<=0) continue; prof->SetPoint(ip,x,ydata/y); prof->SetPointError(ip,0,sqrt(pow(ydata*y_err,2)+pow(ydata_err*y,2))/pow(y,2)); } prof->SetFillColor(systColors[isyst]); prof->SetFillStyle(3001+isyst%2); prof->SetTitle( isyst==0 ? nomTTbarTitle : systLabels[isyst-1] ); //prof->SetMarkerStyle(24); prof->SetFillStyle(3001); prof->SetMarkerColor(1+isyst); prof->SetMarkerColor(1+isyst); prof->SetLineColor(1+isyst); data2mcProfs.push_back(prof); } TH1D *MCProjY=MC->ProjectionY(); MCProjY->Scale(1./MCProjY->Integral()); TGraphErrors *MCProj = new TGraphErrors(MCProjY); MCProj->SetMarkerStyle(24); MCProj->SetFillStyle(0); MCProj->SetName(ch[ich]+profs[i]+"projmc"); TH1D *DataProjY=Data->ProjectionY(); DataProjY->Scale(1./DataProjY->Integral()); TGraphErrors *DataProj = new TGraphErrors(DataProjY); DataProj->SetMarkerStyle(20); DataProj->SetFillStyle(0); DataProj->SetName(ch[ich]+profs[i]+"projdata"); MCProj->SetLineColor(colors[i]); MCProj->SetMarkerColor(colors[i]); MCProj->SetFillColor(colors[i]); MCProj->SetFillStyle(1001); DataProj->SetLineColor(colors[i]); DataProj->SetMarkerColor(colors[i]); DataProj->SetFillColor(colors[i]); TPad *p=(TPad *)cproj->cd(); p->SetLeftMargin(0.15); p->SetRightMargin(0.02); p->SetTopMargin(0.05); p->SetLogy(); MCProj->SetFillStyle(0); MCProj->Draw(i==0 ? "al3" : "l3"); MCProj->GetYaxis()->SetRangeUser(1e-5,1.0); MCProj->GetXaxis()->SetTitle( MC->GetYaxis()->GetTitle() ); MCProj->GetYaxis()->SetTitle( "1/N dN/dx" ); MCProj->GetYaxis()->SetTitleOffset(1.8); DataProj->Draw("p"); std::pair<float,int> chi2=computeChiSquareFor(DataProj,MCProj); char buf[200]; sprintf(buf,"#scale[0.7]{#chi^{2}/ndof=%3.1f}", chi2.first/chi2.second ); dataprojLeg->AddEntry(DataProj,buf,"p"); mcprojLeg->AddEntry(MCProj,cats[i],"l"); if(i==0) drawCMSHeader(ch[ich]); p=(TPad *)c->cd(i+1); if(i<nprofs-1) p->SetBottomMargin(0.01); if(i>0) p->SetTopMargin(0); if(i==0)p->SetTopMargin(0.1); if(i==nprofs-1) p->SetBottomMargin(0.15); TGraphErrors *frame=DataProf; frame->Draw("ap"); //frame->GetYaxis()->SetRangeUser(0.54,1.46); frame->GetXaxis()->SetTitle(MC->GetXaxis()->GetTitle()); //frame->GetXaxis()->SetRangeUser(0,4.75); TString yTit("<"); yTit+=MC->GetYaxis()->GetTitle(); yTit +=">"; frame->GetYaxis()->SetTitle(yTit); frame->GetYaxis()->SetLabelSize(0.07); frame->GetYaxis()->SetTitleSize(0.09); frame->GetYaxis()->SetTitleOffset(0.5); frame->GetXaxis()->SetLabelSize(0.07); frame->GetXaxis()->SetTitleSize(0.09); frame->GetXaxis()->SetTitleOffset(0.7); //p->SetGridy(); //DataProf->Draw("p"); MCProf->Draw("p"); if(i==0) { drawCMSHeader(ch[ich],0.08); TLegend *leg=new TLegend(0.6,0.95,1.0,0.99); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->SetTextSize(0.09); leg->AddEntry(DataProf,"data","p"); leg->AddEntry(MCProf,"simulation","p"); leg->SetNColumns(2); leg->Draw(); } TPaveText *pt=new TPaveText(0.15,0.5,0.8,0.85,"brNDC"); pt->SetBorderSize(0); pt->SetFillStyle(0); pt->SetTextAlign(13); pt->SetTextFont(42); pt->SetTextColor(kBlue); pt->SetTextSize(0.08); pt->AddText("[ "+cats[i]+" ]"); if(i==0) { pt->AddText("p_{T}>0.5 GeV"); pt->AddText("|#eta|<2.1"); } pt->Draw(); p=(TPad *) cratios->cd(i+1); if(i<nprofs-1) p->SetBottomMargin(0.01); if(i>0) p->SetTopMargin(0); if(i==0)p->SetTopMargin(0.1); if(i==nprofs-1) p->SetBottomMargin(0.15); frame=data2mcProfs[0]; frame->Draw("a3"); TLine *l=new TLine(frame->GetXaxis()->GetXmin(),1,frame->GetXaxis()->GetXmax(),1); l->Draw(); frame->GetYaxis()->SetRangeUser(0.54,1.46); frame->GetXaxis()->SetTitle(MC->GetXaxis()->GetTitle()); frame->GetYaxis()->SetTitle("Data/Simulation"); frame->GetYaxis()->SetLabelSize(0.07); frame->GetYaxis()->SetTitleSize(0.09); frame->GetYaxis()->SetTitleOffset(0.5); frame->GetXaxis()->SetLabelSize(0.07); frame->GetXaxis()->SetTitleSize(0.09); frame->GetXaxis()->SetTitleOffset(0.7); //p->SetGridy(); for(size_t ip=1; ip<data2mcProfs.size(); ip++) data2mcProfs[ip]->Draw("3"); if(i==0) { drawCMSHeader(ch[ich],0.08); TLegend *leg=new TLegend(0.6,0.94,1.0,0.98); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->SetTextSize(0.09); leg->SetNColumns(data2mcProfs.size()); for(size_t ip=0; ip<data2mcProfs.size(); ip++) leg->AddEntry(data2mcProfs[ip],data2mcProfs[ip]->GetTitle(),"f"); leg->Draw(); } pt=new TPaveText(0.12,0.65,0.8,0.9,"brNDC"); pt->SetBorderSize(0); pt->SetFillStyle(0); pt->SetTextAlign(13); pt->SetTextFont(42); pt->SetTextColor(kBlue); pt->SetTextSize(0.08); pt->AddText("[ "+cats[i]+" ]"); if(i==0) { pt->AddText("p_{T}>0.5 GeV"); pt->AddText("|#eta|<2.1"); } pt->Draw(); } cproj->cd(); dataprojLeg->SetFillStyle(0); dataprojLeg->SetBorderSize(0); dataprojLeg->SetTextFont(42); dataprojLeg->SetTextSize(0.03); dataprojLeg->Draw(); mcprojLeg->SetFillStyle(0); mcprojLeg->SetBorderSize(0); mcprojLeg->SetTextFont(42); mcprojLeg->SetTextSize(0.03); mcprojLeg->Draw(); TString pf(".png"); c->SaveAs(outDir+c->GetName()+pf); cproj->SaveAs(outDir+cproj->GetName()+pf); cratios->SaveAs(outDir+cratios->GetName()+pf); } inF->Close(); inSystF->Close(); }
void v2ExpOpen_pt(bool bSavePlots = true, float rangeYAxis = 0.6, float rangeXAxis = 30, bool bDrawCh = true, const char* inputDir= "../macro_v2/outRoot", // the place where the input root files, with the histograms are const char* figNamePrefix="v2ExpOpen_pt") { gSystem->mkdir(Form("./figs/png"), kTRUE); gSystem->mkdir(Form("./figs/pdf"), kTRUE); setTDRStyle(); // gStyle->SetCanvasPreferGL(1); // read CMS graphs TFile *pfV2Cms_cent = new TFile(Form("%s/NPrp_v2_pt_plotter.root",inputDir)); TGraphAsymmErrors *pgV2Low = (TGraphAsymmErrors *)pfV2Cms_cent->Get("pgV2_low"); TGraphErrors *pgV2LowSyst = (TGraphErrors *)pfV2Cms_cent->Get("pgV2_low_sys"); TGraphErrors *pgV2LowP = (TGraphErrors *)pfV2Cms_cent->Get("pgV2_low_cont"); TGraphAsymmErrors *pgV2High = (TGraphAsymmErrors *)pfV2Cms_cent->Get("pgV2"); TGraphErrors *pgV2HighSyst = (TGraphErrors *)pfV2Cms_cent->Get("pgV2_sys"); TGraphErrors *pgV2HighP = (TGraphErrors *)pfV2Cms_cent->Get("pgV2_cont"); pgV2Low->SetName("pgV2Low"); pgV2LowSyst->SetFillColorAlpha(kViolet-9,0.5); pgV2High->SetName("pgV2High"); pgV2HighSyst->SetFillColorAlpha(kOrange-9,0.5); // ----------------------------------------------------------------------------------------- // ----- charged hadrons TGraphErrors *gChar = new TGraphErrors(19, pTChar, v2Char, chxerr, v2CharSt); TGraphErrors *gChar2 = new TGraphErrors(19, pTChar, v2Char, chxerr, v2CharSt2); TGraphErrors *gCharSys = new TGraphErrors(19, pTChar, v2Char, chxerr2, v2CharSys); gChar->SetName("gChar"); gChar->SetMarkerStyle(20); gChar->SetMarkerColor(kTeal+3); gChar->SetLineColor(kTeal+3); gChar->SetMarkerSize(1.3); gChar2->SetMarkerStyle(24); gChar2->SetMarkerColor(kTeal+4); gChar2->SetLineColor(kTeal+4); gChar2->SetMarkerSize(1.3); gCharSys->SetFillColor(kTeal-9); //----------- D from ALICE TGraphErrors *pgAlice = new TGraphErrors(6, v2AliceX_pt, v2Alice_pt, v2AliceXl, v2AliceStat_pt); TGraphErrors *pgAliceSys = new TGraphErrors(6, v2AliceX_pt, v2Alice_pt, v2AliceXl, v2AliceSyst_pt); TGraphAsymmErrors *pgAliceSysB = new TGraphAsymmErrors(6, v2AliceX_pt, v2Alice_pt, v2AliceXl2, v2AliceXl2, v2AliceSystBLow_pt, v2AliceSystBHigh_pt); pgAlice->SetName("pgAlice"); pgAlice->SetMarkerStyle(kOpenSquare); pgAlice->SetMarkerColor(kGray+2); pgAlice->SetLineColor(kGray+2); pgAlice->SetMarkerSize(1.0); pgAliceSys->SetFillStyle(0); pgAliceSys->SetMarkerStyle(27); pgAliceSys->SetMarkerColor(kGray+2); pgAliceSys->SetLineColor(kGray+2); pgAliceSys->SetMarkerSize(1.7); pgAliceSysB->SetFillColor(kGray); // drawing //------------------------------------------------------------------------ // put everything on one plot TH1D *phAxis_v2 = new TH1D("phAxis_v2",";p_{T} (GeV/c);v_{2}",1,0,rangeXAxis); phAxis_v2->SetDirectory(0); phAxis_v2->GetXaxis()->CenterTitle(true); phAxis_v2->GetXaxis()->LabelsOption("h"); phAxis_v2->GetYaxis()->SetRangeUser(-0.01,rangeYAxis); phAxis_v2->GetYaxis()->SetTitleOffset(1.25); TCanvas *pcCombi = new TCanvas("pcCombi","pcCombi"); phAxis_v2->Draw(); CMS_lumi(pcCombi,12001000,0); pgAliceSysB->Draw("2"); pgAliceSys->Draw("2"); pgAlice->Draw("pz"); if (bDrawCh) { gCharSys->Draw("2"); gChar->Draw("pz"); gChar2->Draw("p"); } pgV2LowSyst->Draw("2"); pgV2Low->Draw("PZ"); pgV2LowP->Draw("P"); pgV2HighSyst->Draw("2"); pgV2High->Draw("PZ"); pgV2HighP->Draw("P"); // --------- legends ---- TLegend *leg = new TLegend(0.2,0.77,0.7,0.89,NULL,"brNDC"); // at top center leg->SetBorderSize(0); leg->SetTextFont(132); leg->SetTextSize(ltxSetTextSize3); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(19); leg->SetFillStyle(0); TLegendEntry *entry, *entry11; entry=leg->AddEntry("cmspr","Open beauty: nonprompt J/#psi",""); entry->SetTextSize(ltxSetTextSize3); entry=leg->AddEntry("pgV2Low", "1.6 < |y| < 2.4","p"); entry->SetTextFont(42); entry->SetTextSize(entrySize); entry=leg->AddEntry("pgV2High", "|y| < 2.4","P"); entry->SetTextFont(42); entry->SetTextSize(entrySize); //--------------------------- TLegend *leg1 = new TLegend(0.2,0.685,0.7,0.765,NULL,"brNDC"); leg1->SetBorderSize(0); leg1->SetTextFont(132); leg1->SetTextSize(ltxSetTextSize3); if (bDrawCh) { TLegendEntry *entry1; entry1=leg1->AddEntry("hpm","Charged hadron",""); entry1->SetTextFont(132); entry1->SetTextSize(ltxSetTextSize3); entry1=leg1->AddEntry("gChar","|#eta| < 0.8","P"); entry1->SetTextFont(42); entry1->SetTextSize(entrySize); } TLegend *leg_alice; if (bDrawCh) { leg_alice = new TLegend(0.2,0.60,0.7,0.68,NULL,"brNDC"); } else { leg_alice = new TLegend(0.2,0.685,0.7,0.765,NULL,"brNDC"); } leg_alice->SetBorderSize(0); leg_alice->SetTextFont(132); leg_alice->SetTextSize(ltxSetTextSize3); leg_alice->SetLineColor(1); leg_alice->SetLineStyle(1); leg_alice->SetLineWidth(1); leg_alice->SetFillColor(19); leg_alice->SetFillStyle(0); TLegendEntry *entry_alice=leg_alice->AddEntry("pgAlice","Open charm: prompt D (ALICE)",""); entry_alice=leg_alice->AddEntry("pgAlice","|y| < 0.8, Cent. 30-50\%","P"); entry_alice->SetTextFont(42); entry_alice->SetTextSize(entrySize); TLatex *lat = new TLatex(); lat->SetNDC(); lat->SetTextFont(42); lat->SetTextSize(ltxSetTextSize2); if (bDrawCh) lat->DrawLatex(0.63,0.52,"Cent. 10-60%"); else lat->DrawLatex(0.63,0.58,"Cent. 10-60%"); leg->Draw(); if (bDrawCh) leg1->Draw(); leg_alice->Draw(); gPad->RedrawAxis(); pcCombi->Update(); if(bSavePlots) { pcCombi->SaveAs(Form("figs/pdf/%s_RaaCh%d.pdf",figNamePrefix,bDrawCh)); pcCombi->SaveAs(Form("figs/png/%s_RaaCh%d.png",figNamePrefix,bDrawCh)); } return; }
chi7223pt_compare() { gROOT->Reset(); gROOT->SetStyle("MyStyle"); // gROOT->LoadMacro("v2pt_12cen_MyDef.C"); // gROOT->LoadMacro("MyDef.C"); gStyle->SetTextFont(43); gStyle->SetLabelFont(43,"x"); gStyle->SetLabelFont(43,"y"); gStyle->SetLabelFont(43,"z"); gStyle->SetTitleFont(43,"x"); gStyle->SetTitleFont(43,"y"); gStyle->SetTitleFont(43,"z"); gStyle->SetEndErrorSize(0); double textsize = 19; //int mcol[8]={kRed,kMagenta,kBlue,kCyan,kGreen,kYellow,kOrange,kGray}; int mcol[8]={kRed,kOrange+1,kBlue,kGreen+1,kCyan,kYellow,kOrange,kGray}; int mcol2[4]={6,2,4,8}; //int msty[8][2]={{20,20},{25,24},{22,22},{28,26},{29,30},{33,27},{34,28},{20,24}}; int msty[8][2]={{20,20},{21,24},{22,29},{23,30},{24,30},{25,27},{28,28},{30,24}}; //float msiz[8]={1.11,0.9,1.2,1.24,1.5,1,1,1}; float msiz[8]={1.11,1.0,1.5,1.2,1.2,1.2,1.2,1.6}; float msiz2[4]={1.5,1.5,1.5,1.5}; // // arrays // const int Mfiles=50; int ndp[Mfiles]; char *cfn[Mfiles]; char *cft[Mfiles]; const int Mpoints=40; double xa[Mfiles][Mpoints],xe[Mfiles][Mpoints]; double ya[Mfiles][Mpoints],ye[Mfiles][Mpoints]; double nxa[Mfiles][Mpoints],nxe[Mfiles][Mpoints]; double nya[Mfiles][Mpoints],nye[Mfiles][Mpoints]; double aexl[Mfiles][Mpoints],aexh[Mfiles][Mpoints]; double aeyl[Mfiles][Mpoints],aeyh[Mfiles][Mpoints]; double ra[Mfiles][Mpoints],re[Mfiles][Mpoints]; const int Mpads=14; char *htit[Mpads]; char *atit[Mpads][3]; double ptit[Mpads][2]; double hxmin[Mpads],hxmax[Mpads]; double hymin[Mpads],hymax[Mpads]; double lxmin[Mpads],lxmax[Mpads]; double lymin[Mpads],lymax[Mpads]; // // Data input // char *cjob="v2pt_12cen_4x3"; int i=-1; // histogram parameter htit[0]="0-5%"; htit[1]="5-10%"; htit[2]="10-15%"; htit[3]="15-20%"; htit[4]="20-25%"; htit[5]="25-30%"; htit[6]="30-35%"; htit[7]="35-40%"; htit[8]="40-50%"; htit[9]="50-60%"; htit[10]="60-70%"; htit[11]="70-80%"; for (int ip=0;ip<Mpads;ip++) { // hxmin[ip]=0.0; hxmax[ip]=11.9; hxmin[ip]=0.0001; hxmax[ip]=10.8; hymin[ip]=0.0001; hymax[ip]=100.099; lxmin[ip]=0.08; lxmax[ip]=0.35; lymin[ip]=0.4; lymax[ip]=0.65; ptit[ip][0]=5.0; ptit[ip][1]=80.08;// position legends atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="#chi_{7}{#Psi_{223}}"; } // // Read data and create vector files // double tmp; const int nw=12; const int npt=16; ifstream inEP; inEP.open("../../tight/outchi7223_corrFlow.txt"); for(int i=0; i<nw; i++){ inEP>>tmp; inEP>>tmp; for(int j=0; j<npt+4; j++){ inEP>>tmp; inEP>>tmp; inEP>>xa[i][j]; inEP>>tmp; inEP>>ya[i][j]; inEP>>ye[i][j]; xe[i][j]=0.0; } } inEP.close(); ifstream inSP; inSP.open("../../loose/outchi7223_corrFlow.txt"); for(int i=0; i<nw; i++){ inSP>>tmp; inSP>>tmp; for(int j=0; j<npt+4; j++){ inSP>>tmp; inSP>>tmp; inSP>>nxa[i][j]; inSP>>tmp; inSP>>nya[i][j]; inSP>>nye[i][j]; nxe[i][j]=0.0; } } inSP.close(); for(int i=0; i<nw-1; i++){ cout<<"sys for cent: "<<i<<endl; for(int j=0; j<10; j++){ cout<<nxa[i][j]<<" "<<fabs(ya[i][j]-nya[i][j])/fabs(ya[i][j])<<" "<<fabs(ye[i][j])/fabs(ya[i][j])<<endl; } } TCanvas *can=new TCanvas("can","can",10,10,1050*0.9,800*0.85); can->Divide(4,3,0,0); //sticks the pads with no space inbetween TH1D *h1[nw]; for (int iw=0;iw<nw;iw++) { can->cd(iw+1); if(iw==3||iw==7||iw==11) gPad->SetRightMargin(0.02); char ch1[8]; sprintf(ch1,"h1_%d",iw); h1[iw] = new TH1D(ch1,"",500,hxmin[iw],hxmax[iw]); h1[iw]->SetMinimum(hymin[iw]); h1[iw]->SetMaximum(hymax[iw]); h1[iw]->SetXTitle(atit[iw][0]); h1[iw]->SetYTitle(atit[iw][1]); h1[iw]->GetXaxis()->CenterTitle(1); h1[iw]->GetYaxis()->CenterTitle(1); // futz with the axes h1[iw]->GetYaxis()->SetNdivisions(606); h1[iw]->GetXaxis()->SetNdivisions(606); h1[iw]->GetYaxis()->SetTitleSize(textsize); h1[iw]->GetYaxis()->SetTitleOffset(3.0); h1[iw]->GetYaxis()->SetLabelSize(textsize); h1[iw]->GetXaxis()->SetTitleSize(textsize); h1[iw]->GetXaxis()->SetTitleOffset(3.0); h1[iw]->GetXaxis()->SetLabelSize(textsize); // h1[iw]->GetXaxis()->SetLabelOffset(1.2); h1[iw]->Draw(); } // // Draw! // cout << "Now Draw!" << endl; TGraphErrors *ge; for (int iw=0;iw<nw;iw++) { can->cd(iw+1); // if (iw==0) { tex=new TLatex(1.5,80.08,"CMS PbPb #sqrt{s_{NN}}=2.76TeV"); tex->SetTextSize(textsize); //tex->Draw(); tex=new TLatex(1.5,70.07,"|#eta|<0.8"); tex->SetTextSize(textsize); tex->Draw(); } if (iw < 4) tex=new TLatex(ptit[iw][0]+2,70.07,htit[iw]); else tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]); if ( iw == 0) tex->SetTextSize(textsize); else if (iw == 8) tex->SetTextSize(textsize); else tex->SetTextSize(textsize); tex->Draw(); // // Legend // TLegend *leg = new TLegend(lxmin[iw],lymin[iw],lxmax[iw],lymax[iw]); leg->SetTextSize(textsize); // // Read data // for (int im=0;im<1;im++) { int j=im*12+iw; int col=1; //if (ndp[j]==0) continue; ge=new TGraphErrors(19,&xa[j][0],&ya[j][0],&xe[j][0],&ye[j][0]); ge->SetTitle(""); ge->SetMarkerStyle(msty[im][1]); // ge->SetMarkerStyle(msty[im]); ge->SetMarkerSize(msiz[im]); ge->SetMarkerColor(col); ge->SetLineWidth(1.2); ge->SetLineColor(col); ge->Draw("pe"); leg->AddEntry(ge,"#chi_{7223} (tight)","p"); } if (iw==1) leg->Draw(); for (int im=0;im<1;im++) { int j=im*12+iw; int col=2; //if (ndp[j]==0) continue; ge=new TGraphErrors(19,&nxa[j][0],&nya[j][0],&nxe[j][0],&nye[j][0]); ge->SetTitle(""); ge->SetMarkerStyle(25); // ge->SetMarkerStyle(msty[im]); ge->SetMarkerSize(msiz[im]); ge->SetMarkerColor(col); ge->SetLineWidth(1.2); ge->SetLineColor(col); ge->Draw("pe"); leg->AddEntry(ge,"#chi_{7223} (loose)","p"); } } cout << "end of process" << endl; can->cd(); can->Print("./figures/chi7223_pt_10cen_sysTrackCuts2760gev.png"); can->Print("./figures/chi7223_pt_10cen_sysTrackCuts2760gev.pdf"); }
void drawResults() { // Syst error: take the max difference double dataSystErrEB[nEtaBins][nPtBinsEB]; for (int ii=0; ii<nPtBinsEB; ii++ ) { if ( fabs(dataEB[0][ii]-dataSystSigEB[0][ii]) > fabs(dataEB[0][ii]-dataSystBackEB[0][ii]) ) dataSystErrEB[0][ii] = fabs(dataEB[0][ii]-dataSystSigEB[0][ii]); else dataSystErrEB[0][ii] = fabs(dataEB[0][ii]-dataSystBackEB[0][ii]); } double dataSystErrEE[nEtaBins][nPtBinsEE]; for (int ii=0; ii<nPtBinsEE; ii++ ) { if ( fabs(dataEE[0][ii]-dataSystSigEE[0][ii]) > fabs(dataEE[0][ii]-dataSystBackEE[0][ii]) ) dataSystErrEE[0][ii] = fabs(dataEE[0][ii]-dataSystSigEE[0][ii]); else dataSystErrEE[0][ii] = fabs(dataEE[0][ii]-dataSystBackEE[0][ii]); } // Tot error: stat + syst double dataErrEB[nEtaBins][nPtBinsEB]; double dataErrEE[nEtaBins][nPtBinsEE]; if (wantSyst) { cout << "systematics added" << endl; for (int ii=0; ii<nPtBinsEB; ii++ ) { dataErrEB[0][ii] = sqrt( dataSystErrEB[0][ii]*dataSystErrEB[0][ii] + dataErrStatEB[0][ii]*dataErrStatEB[0][ii] ); } for (int ii=0; ii<nPtBinsEE; ii++ ) { dataErrEE[0][ii] = sqrt( dataSystErrEE[0][ii]*dataSystErrEE[0][ii] + dataErrStatEE[0][ii]*dataErrStatEE[0][ii] ); } } else { cout << "only statistical error" << endl; for (int ii=0; ii<nPtBinsEB; ii++ ) { dataErrEB[0][ii] = dataErrStatEB[0][ii]; } for (int ii=0; ii<nPtBinsEE; ii++ ) { dataErrEE[0][ii] = dataErrStatEE[0][ii]; } } cout << "================================" << endl; cout << "EB" << endl; for (int ii=0; ii<nPtBinsEB; ii++ ) cout << ii << ", nominal = " << dataEB[0][ii] << ", forSigSyst = " << dataSystSigEB[0][ii] << ", forBkgSyst = " << dataSystBackEB[0][ii] << ", statErr = " << dataErrStatEB[0][ii] << ", systErr = " <<dataSystErrEB[0][ii] << endl; cout << "================================" << endl; cout << "EE" << endl; for (int ii=0; ii<nPtBinsEE; ii++ ) cout << ii << ", nominal = " << dataEE[0][ii] << ", forSigSyst = " << dataSystSigEE[0][ii] << ", forBkgSyst = " << dataSystBackEE[0][ii] << ", statErr = " << dataErrStatEE[0][ii] << ", systErr = " <<dataSystErrEE[0][ii] << endl; cout << "================================" << endl; // Scale factors and errors double sfEB[nEtaBins][nPtBinsEB]; double sfErrTotEB[nEtaBins][nPtBinsEB]; for (int iEta=0; iEta<nEtaBins; iEta++) { for (int iPt=0; iPt<nPtBinsEB; iPt++) { sfEB[iEta][iPt] = dataEB[iEta][iPt]/mcEB[iEta][iPt]; float sigmaDoDEB = dataErrEB[iEta][iPt]/dataEB[iEta][iPt]; float sigmaMCoMCEB = mcErrEB[iEta][iPt]/mcEB[iEta][iPt]; sfErrTotEB[iEta][iPt] = sfEB[iEta][iPt]*sqrt( (sigmaDoDEB*sigmaDoDEB) + (sigmaMCoMCEB*sigmaMCoMCEB) ); } } double sfEE[nEtaBins][nPtBinsEE]; double sfErrTotEE[nEtaBins][nPtBinsEE]; for (int iEta=0; iEta<nEtaBins; iEta++) { for (int iPt=0; iPt<nPtBinsEE; iPt++) { sfEE[iEta][iPt] = dataEE[iEta][iPt]/mcEE[iEta][iPt]; float sigmaDoDEE = dataErrEE[iEta][iPt]/dataEE[iEta][iPt]; float sigmaMCoMCEE = mcErrEE[iEta][iPt]/mcEE[iEta][iPt]; sfErrTotEE[iEta][iPt] = sfEE[iEta][iPt]*sqrt( (sigmaDoDEE*sigmaDoDEE) + (sigmaMCoMCEE*sigmaMCoMCEE) ); } } // Draw all canvases for(int ieta = 0; ieta<nEtaBins; ieta++) { TString cname = "sfEff_"; TCanvas *c1 = new TCanvas(cname, cname, 10,10,700,700); c1->SetFillColor(kWhite); c1->Draw(); TPad *pad1 = new TPad("main","",0, 0.3, 1.0, 1.0); pad1->SetTopMargin(0.20); pad1->SetBottomMargin(0.02); pad1->SetGrid(); TPad *pad2 = new TPad("ratio", "", 0, 0, 1.0, 0.3); pad2->SetTopMargin(0.05); pad2->SetBottomMargin(0.30); pad2->SetGrid(); pad1->Draw(); pad2->Draw(); // Create and fill arrays for graphs for this eta bin double *dataSliceEB = new double[nPtBinsEB]; double *dataSliceErrEB = new double[nPtBinsEB]; double *mcSliceEB = new double[nPtBinsEB]; double *mcSliceErrEB = new double[nPtBinsEB]; double *sfSliceEB = new double[nPtBinsEB]; double *sfSliceErrEB = new double[nPtBinsEB]; for(int ipt = 0; ipt<nPtBinsEB; ipt++) { dataSliceEB [ipt] = dataEB [ieta][ipt]; dataSliceErrEB[ipt] = dataErrEB [ieta][ipt]; mcSliceEB [ipt] = mcEB [ieta][ipt]; mcSliceErrEB [ipt] = mcErrEB [ieta][ipt]; sfSliceEB [ipt] = sfEB [ieta][ipt]; sfSliceErrEB [ipt] = sfErrTotEB [ieta][ipt]; } double *dataSliceEE = new double[nPtBinsEE]; double *dataSliceErrEE = new double[nPtBinsEE]; double *mcSliceEE = new double[nPtBinsEE]; double *mcSliceErrEE = new double[nPtBinsEE]; double *sfSliceEE = new double[nPtBinsEE]; double *sfSliceErrEE = new double[nPtBinsEE]; for(int ipt = 0; ipt<nPtBinsEE; ipt++) { dataSliceEE [ipt] = dataEE [ieta][ipt]; dataSliceErrEE[ipt] = dataErrEE [ieta][ipt]; mcSliceEE [ipt] = mcEE [ieta][ipt]; mcSliceErrEE [ipt] = mcErrEE [ieta][ipt]; sfSliceEE [ipt] = sfEE [ieta][ipt]; sfSliceErrEE [ipt] = sfErrTotEE [ieta][ipt]; } // Create and configure the graphs TGraphErrors *grDataEB = new TGraphErrors(nPtBinsEB, ptBinCentersEB, dataSliceEB, ptBinHalfWidthEB, dataSliceErrEB); TGraphErrors *grMcEB = new TGraphErrors(nPtBinsEB, ptBinCentersEB, mcSliceEB, ptBinHalfWidthEB, mcSliceErrEB); TGraphErrors *grSfEB = new TGraphErrors(nPtBinsEB, ptBinCentersEB, sfSliceEB, ptBinHalfWidthEB, sfSliceErrEB); TGraphErrors *grDataEE = new TGraphErrors(nPtBinsEE, ptBinCentersEE, dataSliceEE, ptBinHalfWidthEE, dataSliceErrEE); TGraphErrors *grMcEE = new TGraphErrors(nPtBinsEE, ptBinCentersEE, mcSliceEE, ptBinHalfWidthEE, mcSliceErrEE); TGraphErrors *grSfEE = new TGraphErrors(nPtBinsEE, ptBinCentersEE, sfSliceEE, ptBinHalfWidthEE, sfSliceErrEE); grDataEB->SetLineColor(kBlack); grDataEB->SetMarkerColor(kBlack); grDataEB->SetMarkerStyle(20); grDataEB->SetMarkerSize(1.); grDataEE->SetLineColor(kBlack); grDataEE->SetMarkerColor(kBlack); grDataEE->SetMarkerStyle(20); grDataEE->SetMarkerSize(1.); int ci = TColor::GetColor("#99ccff"); grMcEB->SetFillColor(kGreen-8); ci = TColor::GetColor("#3399ff"); grMcEB->SetLineColor(kGreen+4); grMcEB->SetMarkerStyle(22); grMcEB->SetMarkerColor(kGreen+4); grMcEB->SetMarkerSize(1.); ci = TColor::GetColor("#99ccff"); grMcEE->SetFillColor(kGreen-8); ci = TColor::GetColor("#3399ff"); grMcEE->SetLineColor(kGreen+4); grMcEE->SetMarkerStyle(22); grMcEE->SetMarkerColor(kGreen+4); grMcEE->SetMarkerSize(1.); ci = TColor::GetColor("#99ccff"); grSfEB->SetFillColor(kGreen-8); ci = TColor::GetColor("#3399ff"); grSfEB->SetLineColor(kGreen+4); grSfEB->SetMarkerStyle(20); grSfEB->SetMarkerColor(kGreen+4); grSfEB->SetMarkerSize(1.); ci = TColor::GetColor("#99ccff"); grSfEE->SetFillColor(kGreen-8); ci = TColor::GetColor("#3399ff"); grSfEE->SetLineColor(kGreen+4); grSfEE->SetMarkerStyle(20); grSfEE->SetMarkerColor(kGreen+4); grSfEE->SetMarkerSize(1.); // Create and configure the dummy histograms on which to draw the graphs TH2F *h1 = new TH2F("dummy1","", 100, 0, 500, 100, 0.6, 1.1); h1->GetYaxis()->SetTitle("Efficiency"); h1->SetStats(0); h1->GetXaxis()->SetLabelSize(0); h1->GetXaxis()->SetNdivisions(505); h1->GetXaxis()->SetDecimals(); h1->GetYaxis()->SetTitleOffset(0.8); h1->GetYaxis()->SetTitleSize(0.05); TH2F *h2 = new TH2F("dummy2","", 100, 0, 500, 100, 0.8, 1.2); h2->GetXaxis()->SetTitle("p_{T} [GeV]"); h2->GetYaxis()->SetTitle("Scale Factor"); h2->GetXaxis()->SetTitleOffset(1.0); h2->GetXaxis()->SetTitleSize(0.1); h2->GetYaxis()->SetTitleOffset(0.4); h2->GetYaxis()->SetTitleSize(0.1); h2->GetXaxis()->SetLabelSize(0.08); h2->GetYaxis()->SetLabelSize(0.08); h2->GetYaxis()->SetNdivisions(505); h2->GetYaxis()->SetDecimals(); h2->SetStats(0); TLegend *leg = new TLegend(0.65,0.1,0.9,0.25); leg->SetFillColor(kWhite); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->AddEntry(grDataEB, "Data", "pl"); leg->AddEntry(grMcEB, "Simulation DY", "pFlE"); TLatex *latLumi = new TLatex(0, 1.15, lumiString); TLatex *latEtaEB = new TLatex(60.0, 0.5, etaLimitsStringArrayEB[ieta]); TLatex *latEtaEE = new TLatex(60.0, 0.5, etaLimitsStringArrayEE[ieta]); // -------------------------------------- // EB // Draw the efficiencies pad1->cd(); h1->Draw(); grMcEB ->Draw("2same"); grMcEB ->Draw("pZ,same"); grDataEB->Draw("PEZ,same"); leg->Draw("same"); latEtaEB->Draw("same"); latLumi->Draw("same"); // Draw the scale factors pad2->cd(); h2->Draw(); grSfEB ->Draw("2same"); grSfEB ->Draw("pEZ,same"); // Save into a file TString fname = cname; fname += "_EB.pdf"; c1->Print(fname); // -------------------------------------- // EE // Draw the efficiencies pad1->cd(); h1->Draw(); grMcEE ->Draw("2same"); grMcEE ->Draw("pZ,same"); grDataEE->Draw("PEZ,same"); leg->Draw("same"); latEtaEE->Draw("same"); latLumi->Draw("same"); // Draw the scale factors pad2->cd(); h2->Draw(); grSfEE ->Draw("2same"); grSfEE ->Draw("pEZ,same"); // Save into a file fname = cname; fname += "_EE.pdf"; c1->Print(fname); } }
void Plots(TString plots="4Jets", TString sys="", bool EvtNorm=false){ /**************** Style ****************/ gROOT->SetStyle("Plain"); gStyle->SetOptFit(1000); gStyle->SetOptStat("emruo"); gStyle->SetOptStat(kFALSE); gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); gROOT->ProcessLine(".L /home/brochero/ttbar/TopCodeljets/tdrStyle.C"); setTDRStyle(); Int_t chatch = 1756; TColor *color = new TColor(chatch, 0.3, 0.5, 0.5, "", 0.45); // alpha = 0.5 TString files = dirnameIn + fl; /**************** Channel ****************/ TString channel[3]; channel[0] = "mujets"; channel[1] = "ejets"; channel[2] = "lepjet"; /**************** Data ****************/ std::vector<histos> DataMu; DataMu = loadhistograms(plots, files + "_DataSingleMu"); std::vector<histos> DataEG; DataEG = loadhistograms(plots, files + "_DataSingleEG"); std::vector<histos> Data; Data = addhistograms(DataMu, DataEG); setuphistograms(Data, kBlack); /**************** ttbar Signal ****************/ std::vector<histos> ttbar_0; ttbar_0 = loadhistograms(plots, files + "_ttbar-PowhegPythia"); setuphistograms(ttbar_0, kRed+1); std::vector<histos> ttbar_1; ttbar_1 = loadhistograms(plots, files + "_ttbar-MCatNLO"); setuphistograms(ttbar_1, kRed+2); std::vector<histos> ttbar_2; ttbar_2 = loadhistograms(plots, files + "_ttbar-Madgraph"); setuphistograms(ttbar_2, kRed+3); /**************** Z+Jets ****************/ std::vector<histos> ZJets; ZJets = loadhistograms(plots, files + "_ZJets"); setuphistograms(ZJets, kAzure-2); /**************** VV ****************/ std::vector<histos> WW; WW = loadhistograms(plots, files + "_WW"); std::vector<histos> WZ; WZ = loadhistograms(plots, files + "_WZ"); std::vector<histos> ZZ; ZZ = loadhistograms(plots, files + "_ZZ"); std::vector<histos> VV; VV = addhistograms(WW, WZ); VV = addhistograms(VV, ZZ); setuphistograms(VV, kYellow-3); /**************** Single Top ****************/ std::vector<histos> tW; tW = loadhistograms(plots, files + "_tW"); std::vector<histos> tbarW; tbarW = loadhistograms(plots, files + "_tbarW"); std::vector<histos> t_tch; t_tch = loadhistograms(plots, files + "_t-tchannel"); std::vector<histos> tbar_tch; tbar_tch = loadhistograms(plots, files + "_tbar-tchannel"); std::vector<histos> Single_top; Single_top = addhistograms(tW, tbarW); Single_top = addhistograms(Single_top, t_tch); Single_top = addhistograms(Single_top, tbar_tch); setuphistograms(Single_top, kPink-3); /**************** W+Jets ****************/ std::vector<histos> WJets; WJets = loadhistograms(plots, files + "_WJets"); setuphistograms(WJets, kGreen-3); /**************** ttbar Bkg ****************/ std::vector<histos> ttbar_bkg; ttbar_bkg = loadhistograms(plots, files + "_ttbar-PowhegPythiaBkg"); setuphistograms(ttbar_bkg, kViolet-3); /**************** QCD ****************/ std::vector<histos> QCD; QCD = loadhistograms(plots, files + "_QCD-MuEnr"); setuphistograms(QCD, kOrange-3); /**************** Stacks ****************/ std::vector<histos> Stack_bkg; std::vector<histos> Stack; histos st_bkg; histos st; for(unsigned int h=0; h<WJets.size(); h++){ TString variable; for(int ch=0; ch<3; ch++){ st.mc[ch] = new THStack(variable, ""); st_bkg.mc[ch] = new THStack(variable, ""); st.mc[ch]->SetHistogram( (TH1F*)WJets[h].hist[ch]->Clone()); st_bkg.mc[ch]->SetHistogram( (TH1F*)WJets[h].hist[ch]->Clone()); } Stack.push_back(st); Stack_bkg.push_back(st_bkg); } //------------------------------------------------------- // Background Stack Stack_bkg = addstack(Stack_bkg, WJets); Stack_bkg = addstack(Stack_bkg, QCD); Stack_bkg = addstack(Stack_bkg, Single_top); Stack_bkg = addstack(Stack_bkg, VV); Stack_bkg = addstack(Stack_bkg, ttbar_bkg); Stack_bkg = addstack(Stack_bkg, ZJets); //------------------------------------------------------- // Stack Stack = addstack(Stack, WJets); Stack = addstack(Stack, QCD); Stack = addstack(Stack, Single_top); Stack = addstack(Stack, VV); Stack = addstack(Stack, ttbar_bkg); Stack = addstack(Stack, ZJets); Stack = addstack(Stack, ttbar_0); //------------------------------------------------------- // other ttbar Generators ttbar_1 = addhistograms(ttbar_1, Stack_bkg); ttbar_2 = addhistograms(ttbar_2, Stack_bkg); /**************** Draw Histos ****************/ TCanvas *histocanvas; histocanvas = new TCanvas("plots", "Plots"); for(unsigned int h=0; h<WJets.size(); h++){ for(int ch=0; ch<3; ch++){ histocanvas->Divide(1,2); TPad *pad[2]; //Plot Pad pad[0] = (TPad*)histocanvas->GetPad(1); pad[0]->SetPad(0.01, 0.23, 0.99, 0.99); pad[0]->SetTopMargin(0.1); pad[0]->SetRightMargin(0.04); //Ratio Pad pad[1] = (TPad*)histocanvas->GetPad(2); pad[1]->SetPad(0.01, 0.02, 0.99, 0.3); gStyle->SetGridWidth(0.5); gStyle->SetGridColor(14); pad[1]->SetGridx(); pad[1]->SetGridy(); pad[1]->SetTopMargin(0.05); pad[1]->SetBottomMargin(0.4); pad[1]->SetRightMargin(0.04); //------------------------------------------------------- // Stack pad[0]->cd(); Stack[h].mc[ch]->Draw("hist"); Stack[h].mc[ch]->GetYaxis()->SetTitle("Events"); Stack[h].mc[ch]->GetYaxis()->SetTitleOffset(1.2); Stack[h].mc[ch]->GetYaxis()->SetTitleSize(0.07); Stack[h].mc[ch]->GetYaxis()->SetLabelSize(0.055); Stack[h].mc[ch]->GetYaxis()->SetNdivisions(607); //Stack[h].mc[ch]->GetYaxis()->SetLabelSize(0.05); TGaxis *hYaxis = (TGaxis*)Stack[h].mc[ch]->GetYaxis(); //hYaxis->SetMaxDigits(3); Stack[h].mc[ch]->GetXaxis()->SetLabelSize(0.0); Stack[h].mc[ch]->GetXaxis()->SetTitle(""); float maxh = Data[h].hist[ch]->GetMaximum(); if(maxh < Stack[h].mc[ch]->GetMaximum()) maxh = Stack[h].mc[ch]->GetMaximum(); Stack[h].mc[ch]->SetMaximum(1.7*maxh); //------------------------------------------------------- // Band error TGraphErrors *thegraph = new TGraphErrors(Stack[h].hist[ch]); thegraph->SetName("thegraph"); thegraph->SetFillStyle(1001); thegraph->SetFillColor(chatch); thegraph->SetLineColor(chatch); thegraph->Draw("e2SAME"); //------------------------------------------------------- // Other ttbar generators ttbar_1[h].hist[ch]->SetLineColor(6); ttbar_1[h].hist[ch]->SetLineStyle(2); ttbar_1[h].hist[ch]->SetFillColor(0); ttbar_1[h].hist[ch]->Draw("histoSAME"); ttbar_2[h].hist[ch]->SetLineColor(8); ttbar_2[h].hist[ch]->SetLineStyle(4); ttbar_2[h].hist[ch]->SetFillColor(0); ttbar_2[h].hist[ch]->Draw("histoSAME"); //------------------------------------------------------- // Data Histogram Data[h].hist[ch]->SetMarkerStyle(20); Data[h].hist[ch]->SetMarkerSize(0.7); Data[h].hist[ch]->Draw("SAME"); /*********************** Legends ***********************/ TLegend *leg; float legx1=0.76; float legy1=0.54; float legx2=0.90; float legy2=0.87; leg = new TLegend(legx1,legy1,legx2,legy2); leg->SetFillColor(0); leg->SetLineColor(1); leg->SetTextFont(62); leg->SetTextSize(0.03); leg->AddEntry(Data[h].hist[ch],"Data","PL"); leg->AddEntry(ttbar_0[h].hist[ch],"t#bar{t} Signal","F"); leg->AddEntry(ZJets[h].hist[ch],"Z+Jets","F"); leg->AddEntry(ttbar_bkg[h].hist[ch],"t#bar{t} Bkg","F"); leg->AddEntry(VV[h].hist[ch],"VV","F"); leg->AddEntry(Single_top[h].hist[ch],"Single t","F"); leg->AddEntry(QCD[h].hist[ch],"QCD","F"); leg->AddEntry(WJets[h].hist[ch],"W+Jets","F"); leg->AddEntry("thegraph","Uncertainty","F"); leg->AddEntry((TObject*)0,"",""); leg->AddEntry(ttbar_1[h].hist[ch],"MC@NLO","L"); leg->AddEntry(ttbar_2[h].hist[ch],"Madgraph","L"); leg->Draw("SAME"); //------------------------------------------------------- // CMS TString htitleCMSChannel[3]; htitleCMSChannel[0] = "#mu^{#pm}+jets channel"; htitleCMSChannel[1] = "e^{#pm}+jets channel"; htitleCMSChannel[2] = "l^{#pm}+jets channel"; titlePr = new TLatex(-20.,50.,"Preliminary"); titlePr->SetNDC(); titlePr->SetTextAlign(12); titlePr->SetX(0.25); titlePr->SetY(0.93); titlePr->SetTextColor(2); titlePr->SetTextFont(42); titlePr->SetTextSize(0.05); titlePr->SetTextSizePixels(24); titlePr->Draw("SAME"); title = new TLatex(-20.,50.,"CMS #sqrt{s} = 13TeV, L = 42 pb^{-1}(50ns)"); title->SetNDC(); title->SetTextAlign(12); title->SetX(0.20); title->SetY(0.83); title->SetTextFont(42); title->SetTextSize(0.05); title->SetTextSizePixels(24); title->Draw("SAME"); chtitle = new TLatex(-20.,50.,htitleCMSChannel[ch]); chtitle->SetNDC(); chtitle->SetTextAlign(12); chtitle->SetX(0.20); chtitle->SetY(0.75); chtitle->SetTextFont(42); chtitle->SetTextSize(0.05); chtitle->SetTextSizePixels(24); chtitle->Draw("SAME"); /*********************** Ratio ***********************/ pad[1]->cd(); //------------------------------------------------------- //Graph Ratio Clone TH1F *Ratio; Ratio = (TH1F*)Data[h].hist[ch]->Clone(); Ratio->Divide(Stack[h].hist[ch]); TH1F *RatioSyst; RatioSyst = (TH1F*)Data[h].hist[ch]->Clone(); RatioSyst->Divide(Stack[h].hist[ch]); // Should be the histogram with the Total Syst. Unc. std::vector<double> ratioContent; for(unsigned int b_r = 1; b_r <= RatioSyst->GetNbinsX(); b_r++){ RatioSyst->SetBinContent(b_r,1.0); //RatioSyst->SetBinError(b_r,0.15); // Tempotal!!! } Ratio->SetMarkerStyle(20); Ratio->SetMarkerSize(0.5); Ratio->SetMarkerColor(1); Ratio->SetLineColor(1); Ratio->SetLineWidth(1); Ratio->SetMaximum(2); Ratio->SetMinimum(0); Ratio->SetTitle(""); Ratio->GetYaxis()->SetTitle("Obs/Exp"); Ratio->GetYaxis()->CenterTitle(); Ratio->GetYaxis()->SetTitleOffset(0.45); Ratio->GetYaxis()->SetTitleSize(0.16); Ratio->GetYaxis()->SetLabelSize(0.15); Ratio->GetYaxis()->SetNdivisions(402); Ratio->GetXaxis()->SetNdivisions(509); Ratio->GetXaxis()->SetTitleOffset(1.1); Ratio->GetXaxis()->SetLabelSize(0.20); Ratio->GetXaxis()->SetTitleSize(0.16); Ratio->SetMinimum(0.6); Ratio->SetMaximum(1.4); TGraphErrors *thegraphRatioSyst = new TGraphErrors(RatioSyst); thegraphRatioSyst->SetFillStyle(1001); thegraphRatioSyst->SetFillColor(chatch); thegraphRatioSyst->SetName("thegraphRatioSyst"); //------------------------------------------------------- //Graph Ratio other ttbar generators TH1F *Ratio_1; Ratio_1 = (TH1F*)Data[h].hist[ch]->Clone(); Ratio_1->Divide(ttbar_1[h].hist[ch]); Ratio_1->SetLineColor(6); Ratio_1->SetLineStyle(2); Ratio_1->SetLineWidth(2); Ratio_1->SetFillColor(0); TH1F *Ratio_2; Ratio_2 = (TH1F*)Data[h].hist[ch]->Clone(); Ratio_2->Divide(ttbar_2[h].hist[ch]); Ratio_2->SetLineColor(8); Ratio_2->SetLineStyle(4); Ratio_2->SetLineWidth(2); Ratio_2->SetFillColor(0); //------------------------------------------------------- // Draw Ratios Ratio->Draw(); thegraphRatioSyst->Draw("e2"); Ratio->Draw("histpSAME"); Ratio_1->Draw("histSAME"); Ratio_2->Draw("histSAME"); /*********************** Save Histos ***********************/ TString dirfigname_pdf=dirnameIn + "figures_" + fl + "/pdf/"; // make a dir if it does not exist!! gSystem->mkdir(dirfigname_pdf, kTRUE); histocanvas->SaveAs(dirfigname_pdf + WJets[h].hist[ch]->GetName() + ".pdf"); // clear Canvas histocanvas->Clear(); } } } //end Plots.C
void offsetpT(int n1=1, int n2=25, float topX=15, float topY=30){ setStyle(); const double R = 0.4; int Rlabel = R*10; string run_name; float luminosity; cout << "Run: " << " lumi " << endl; cin >> run_name >> luminosity; //TFile* mcFile = TFile::Open(Form("SN_campaign2018_Run%s_R4.root",run_name.c_str())); //TFile* dataFile = TFile::Open( Form("/uscms_data/d3/broozbah/2018_sep/CMSSW_10_2_0/src/L1Res/OffsetTreeMaker/Run%s_newcert_R4.root",run_name.c_str()) ); //TFile* dataFile = TFile::Open( Form("/uscms_data/d3/broozbah/2018_sep_RunCv3/CMSSW_10_1_8/src/L1/OffsetTreeMaker/RunCV3_R4.root",run_name.c_str()) ); //TFile* dataFile = TFile::Open( Form("/uscms_data/d3/broozbah/2018_sep_RunBs/CMSSW_10_1_7/src/L1/OffsetTreeMaker/Run%s_R4.root",run_name.c_str()) ); //TFile* dataFile = TFile::Open( Form("/uscms_data/d3/broozbah/2018_sep_RunBV11/CMSSW_10_1_6/src/L1/OffsetTreeMaker/Run%s_upto317885_R4.root",run_name.c_str()) ); //TFile* dataFile = TFile::Open( Form("/uscms_data/d3/broozbah/2018_DataMC/CMSSW_10_1_6/src/L1/OffsetTreeMaker/root_files_R48/Run%s_R4.root",run_name.c_str()) ); //TFile* mcFile = TFile::Open(Form("SN_campaign2018_Run%s_R4.root",run_name.c_str())); //TFile* dataFile = TFile::Open( Form("/uscms_data/d3/broozbah/2018_DataMC/CMSSW_10_1_6/src/L1/OffsetTreeMaker/root_files_R48/Run%s_R4.root",run_name.c_str()) ); TFile* mcFile = TFile::Open("SN_2018_hl_R4.root"); TFile* dataFile = TFile::Open( "RunA_rereco_R4.root" ); TString var_type = "nPU"; // nPU, nPV bool isIndirect = true; // indirectRho bool rhoCentral = false; const int nPoints = n2-n1; int pf_choice; cout << "\n1) All\n2) Assoc. Charged Hadron\n3) Lepton\n4) Photon\n5) Neutral Hadron\n6) HF Tower Hadron\n" << "7) HF Tower EM Particle\n8) Charged Hadron Subtraction\n\n### Enter PF Particle type: "; cin >> pf_choice; cout << endl; TString pf_type = "all"; //default choice if (pf_choice == 2) pf_type = "chm"; else if (pf_choice == 3) pf_type = "lep"; else if (pf_choice == 4) pf_type = "ne"; else if (pf_choice == 5) pf_type = "nh"; else if (pf_choice == 6) pf_type = "hfh"; else if (pf_choice == 7) pf_type = "hfe"; else if (pf_choice == 8) pf_type = "chs"; vector<TH1D*> mcProfiles; vector<TH1D*> dataProfiles; vector<TString> ids = {"ne", "hfe", "nh", "hfh", "chu", "chm"}; for (int n=0; n<nPoints; n++){ if (pf_type.EqualTo("all")){ //add up all histograms TString hname = Form("p_offset_eta_%s%i_", var_type.Data(), n1+n) + ids[ids.size()-1]; mcProfiles.push_back( ((TProfile*) mcFile->FindObjectAny(hname))->ProjectionX( ids[ids.size()-1]+Form("%i_mc",n1+n) ) ); dataProfiles.push_back( ((TProfile*) dataFile->FindObjectAny(hname))->ProjectionX( ids[ids.size()-1]+Form("%i_data",n1+n) ) ); for (int i=0; i<ids.size()-1; i++){ hname = Form("p_offset_eta_%s%i_", var_type.Data(), n1+n) + ids[i]; mcProfiles.back()->Add( ((TProfile*) mcFile->FindObjectAny(hname))->ProjectionX( ids[i]+Form("%i_mc",n1+n) ) ); dataProfiles.back()->Add( ((TProfile*) dataFile->FindObjectAny(hname))->ProjectionX( ids[i]+Form("%i_data",n1+n) ) ); } } else if (pf_type.EqualTo("chs")){ //add up all histograms except chm TString hname = Form("p_offset_eta_%s%i_", var_type.Data(), n1+n) + ids[ids.size()-2]; mcProfiles.push_back( ((TProfile*) mcFile->FindObjectAny(hname))->ProjectionX( ids[ids.size()-2]+Form("%i_mc",n1+n) ) ); dataProfiles.push_back( ((TProfile*) dataFile->FindObjectAny(hname))->ProjectionX( ids[ids.size()-2]+Form("%i_data",n1+n) ) ); for (int i=0; i<ids.size()-2; i++){ hname = Form("p_offset_eta_%s%i_", var_type.Data(), n1+n) + ids[i]; mcProfiles.back()->Add( ((TProfile*) mcFile->FindObjectAny(hname))->ProjectionX( ids[i]+Form("%i_mc",n1+n) ) ); dataProfiles.back()->Add( ((TProfile*) dataFile->FindObjectAny(hname))->ProjectionX( ids[i]+Form("%i_data",n1+n) ) ); } } else{ TString hname = Form("p_offset_eta_%s%i_", var_type.Data(), n1+n) + pf_type; mcProfiles.push_back( ((TProfile*) mcFile->FindObjectAny(hname))->ProjectionX( pf_type+Form("%i_mc",n1+n) ) ); dataProfiles.push_back( ((TProfile*) dataFile->FindObjectAny(hname))->ProjectionX( pf_type+Form("%i_data",n1+n) ) ); } } TProfile* NPUtoRho_mc; TProfile* NPUtoRho_data; if (isIndirect){ TString hname; if (var_type.EqualTo("nPU")) { if (rhoCentral) hname = "p_rhoCentral0_nPU"; else hname = "p_rho_nPU"; } else { if (rhoCentral) hname = "p_rhoCentral0_nPV"; else hname = "p_rho_nPV"; } NPUtoRho_mc = (TProfile*) mcFile->Get(hname); NPUtoRho_data = (TProfile*) dataFile->Get(hname); if (NPUtoRho_data->GetXaxis()->GetBinWidth(1) == 0.5){ NPUtoRho_mc->Rebin(); NPUtoRho_data->Rebin(); } var_type = "indirectRho"; } ofstream writeMC("./plots/" + var_type + "/" + pf_type + Form("_%s/Fall18_17Sep2018%s_V1_MC_L1RC_AK%iPF", run_name.c_str(), run_name.c_str(), Rlabel) + pf_type + ".txt"); ofstream writeData("./plots/" + var_type + "/" + pf_type + Form("_%s/Fall18_17Sep2018%s_V1_DATA_L1RC_AK%iPF", run_name.c_str(), run_name.c_str(), Rlabel) + pf_type + ".txt"); TString header; // changes w.r.t previous versions: 1) TFormula had a bug and we modified accordingly 2) based on Mikko's calculation 1.519 changed to 2.00 if ( var_type.EqualTo("nPV") || var_type.EqualTo("nPU") ) //header = "{1\tJetEta\t3\tJetPt\tJetA\t" + var_type + "\t\tmax(0.0001,1-y*([0]+[1]*(z-1)+[2]*pow(z-1,2))/x)\tCorrection L1Offset}"; //header = "{1\tJetEta\t3\tJetPt\tJetA\t" + var_type + "\t\tmax(0.0001,1-(y/x)*([0]+[1]*(z-1.519)+[2]*pow(z-1.519,2)))\tCorrection L1Offset}"; header = "{1\tJetEta\t3\tJetPt\tJetA\t" + var_type + "\t\tmax(0.0001,1-(y/x)*([0]+[1]*(z-2.00)+[2]*pow(z-2.00,2)))\tCorrection L1Offset}"; else //header = "{1 JetEta 3 JetPt JetA Rho max(0.0001,1-y*([0]+[1]*(z-1.519)+[2]*pow(z-1.519,2))/x) Correction L1FastJet}"; //header = "{1 JetEta 3 JetPt JetA Rho max(0.0001,1-(y/x)*([0]+[1]*(z-1.519)+[2]*pow(z-1.519,2))) Correction L1FastJet}"; header = "{1 JetEta 3 JetPt JetA Rho max(0.0001,1-(y/x)*([0]+[1]*(z-2.00)+[2]*pow(z-2.00,2))) Correction L1FastJet}"; writeMC << header << endl; writeData << header << endl; TF1* f_mc = new TF1("f_mc", "1++x++x*x"); TF1* f_data = new TF1("f_data", "1++x++x*x"); f_mc->SetLineColor(2); f_mc->SetLineWidth(2); f_data->SetLineColor(1); f_data->SetLineWidth(2); for (int i=0; i<ETA_BINS; i++) { vector<double> mc_x, data_x, mc_y, data_y, mc_error, data_error; for (int n=0; n<nPoints; n++){ double mcX = n1+n+0.5; double dataX = n1+n+0.5; if (isIndirect){ mcX = NPUtoRho_mc->GetBinContent( NPUtoRho_mc->FindBin(mcX) ); dataX = NPUtoRho_data->GetBinContent( NPUtoRho_data->FindBin(dataX) ); } mc_x.push_back( mcX ); data_x.push_back( dataX ); mc_y.push_back( mcProfiles[n]->GetBinContent(i+1) ); data_y.push_back( dataProfiles[n]->GetBinContent(i+1) ); mc_error.push_back( 0.02 * mc_y.back() ); data_error.push_back( 0.02 * data_y.back() ); } TGraphErrors* mcGraph = new TGraphErrors(mc_x.size(), &mc_x[0], &mc_y[0], 0, &mc_error[0]); TGraphErrors* dataGraph = new TGraphErrors(data_x.size(), &data_x[0], &data_y[0], 0, &data_error[0]); mcGraph->Fit(f_mc, "Q"); dataGraph->Fit(f_data, "Q"); double area = M_PI*R*R; double x = fabs(etabins[0]) - 0.5*fabs(etabins[i]+etabins[i+1]); if (x < R) { double theta = 2*acos(x/R); double area_seg = 0.5*R*R*theta - x*R*sin(theta/2); area -= area_seg; } writeMC << etabins[i] << setw(8) << etabins[i+1] << setw(8) << 9 << setw(6) << 1 << setw(6) << 3500 << setw(6) << 0 << setw(6) << 10 << setw(6) << 0 << setw(6) << 200 << setw(15) << f_mc->GetParameter(0)/area << setw(15) << f_mc->GetParameter(1)/area << setw(15) << f_mc->GetParameter(2)/area << endl; writeData << etabins[i] << setw(8) << etabins[i+1] << setw(8) << 9 << setw(6) << 1 << setw(6) << 3500 << setw(6) << 0 << setw(6) << 10 << setw(6) << 0 << setw(6) << 200 << setw(15) << f_data->GetParameter(0)/area << setw(15) << f_data->GetParameter(1)/area << setw(15) << f_data->GetParameter(2)/area << endl; TString xTitle = ""; if ( var_type.EqualTo("nPV") ) xTitle = "N_{PV}"; else if ( var_type.EqualTo("nPU") ) xTitle = "#mu"; else if ( var_type.EqualTo("indirectRho") ) xTitle = "<#rho> (GeV)"; TCanvas* c = new TCanvas("c", "c", 600, 600); TH1F* h = new TH1F("h", "h", 100, 0, topX); h->GetXaxis()->SetTitle(xTitle); h->GetYaxis()->SetTitle("Offset p_{T} (GeV)"); h->GetYaxis()->SetTitleOffset(1.05); h->GetYaxis()->SetRangeUser(0, topY); h->Draw(); dataGraph->SetMarkerStyle(20); dataGraph->SetMarkerColor(1); dataGraph->Draw("Psame"); mcGraph->SetMarkerStyle(24); mcGraph->SetMarkerColor(2); mcGraph->SetLineColor(2); mcGraph->Draw("Psame"); TLatex text; text.SetNDC(); text.SetTextSize(0.04); if (pf_type.EqualTo("all")) text.DrawLatex(0.17, 0.96, Form("AK%i PF %4.3f #leq #eta #leq %4.3f", Rlabel, etabins[i], etabins[i+1]) ); else text.DrawLatex(0.17, 0.96, Form("AK%i PF%s %4.3f #leq #eta #leq %4.3f", Rlabel, pf_type.Data(), etabins[i], etabins[i+1]) ); text.DrawLatex(0.2, 0.88, "Data"); text.DrawLatex(0.2, 0.84, Form("#chi^{2}/ndof = %4.2f/%i", f_data->GetChisquare(), f_data->GetNDF() ) ); text.DrawLatex(0.2, 0.8, Form("p0 = %4.3f #pm %4.3f", f_data->GetParameter(0), f_data->GetParError(0) ) ); text.DrawLatex(0.2, 0.76, Form("p1 = %4.3f #pm %4.3f", f_data->GetParameter(1), f_data->GetParError(1) ) ); text.DrawLatex(0.2, 0.72, Form("p2 = %4.4f #pm %4.4f", f_data->GetParameter(2), f_data->GetParError(2) ) ); text.SetTextColor(2); text.DrawLatex(0.2, 0.64, "MC"); text.DrawLatex(0.2, 0.6, Form("#chi^{2}/ndof = %4.2f/%i", f_mc->GetChisquare(), f_mc->GetNDF() ) ); text.DrawLatex(0.2, 0.56, Form("p0 = %4.3f #pm %4.3f", f_mc->GetParameter(0), f_mc->GetParError(0) ) ); text.DrawLatex(0.2, 0.52, Form("p1 = %4.3f #pm %4.3f", f_mc->GetParameter(1), f_mc->GetParError(1) ) ); text.DrawLatex(0.2, 0.48, Form("p2 = %4.4f #pm %4.4f", f_mc->GetParameter(2), f_mc->GetParError(2) ) ); text.SetTextSize(0.035); text.SetTextFont(42); text.SetTextColor(1); text.DrawLatex( 0.8, 0.96, "#sqrt{s} = 13 TeV" ); cout << f_data->GetChisquare() / f_data->GetNDF() << "\t" << f_mc->GetChisquare() / f_mc->GetNDF() << endl; c->Print("./plots/" + var_type + "/" + pf_type + Form("_%s/", run_name.c_str()) + pf_type + "_pT_" + var_type + Form("_eta%4.3f", etabins[i]) + ".pdf"); delete h; delete c; } writeMC.close(); writeData.close(); }
int EffAndCross(char* name) { char line[1000]; TFile *file = new TFile("cross.root","recreate"); ifstream inbescross("cross.txt_665p01"); double xbes[22]; double xebes[22]; double ybes[22]; double yebes[22]; inbescross.getline(line,1000); int idbes=0; while (!inbescross.eof() && idbes<21){ double tmpe, tmpeff, tmpcross, tmpcrosse, tmp; inbescross >> tmpe >> tmp >> tmp>> tmpeff >> tmp >> tmp >> tmpcross >> tmpcrosse >> tmp >> tmp >> tmp ; xbes[idbes] = tmpe; xebes[idbes] = 0; ybes[idbes] = tmpcross; yebes[idbes] = tmpcrosse; idbes++; } TGraphErrors *gbes = new TGraphErrors(idbes,xbes,ybes,xebes,yebes); gbes->SetLineColor(2); gbes->SetMarkerColor(2); gbes->SetFillColor(0); //gbes->Draw("P"); double xx[1000]; double xxe[1000]; double yy[1000]; double yye[1000]; double emat[1000][1000]; int n2=0; ifstream infile2("KKBabar.txt"); if (!infile2.is_open()) return -100; while (!infile2.eof()) { double energy1, energy2; double obs, obse; infile2.getline(line,1000); istringstream iss; iss.str(line); //if (iss.peek()<48 || iss.peek()>57) // not a number //{ // continue; //} //else { char a; iss >> energy1 >> a >> energy2; iss >> obs >> obse; } //std::cout<<"E1: "<< energy1 << "\tE2: "<< energy2 << "\tsigma: "<< obs <<"\terr: "<<obse<<std::endl; xx[n2] = (energy2+energy1)/2.; xxe[n2] = (energy2-energy1)/2.; yy[n2] = obs; yye[n2] = 0; n2 ++; } ifstream infile3("epapsFileKpKm.txt"); if (!infile3.is_open()) return -200; int xid=0,yid=0; while(!infile3.eof()) { infile3.getline(line,1000); istringstream iss; iss.str(line); if ((iss.peek()<48 || iss.peek()>57) && iss.peek()!='-') // not a number { continue; } iss >> emat[xid][yid]; yid++; if (yid==159){ xid++; yid=0; } if (xid==159) break; } //std::cout<<"xid: "<<xid<<"\tyid: "<<yid<<std::endl; for (int i=0; i<159;i++) { yye[i] = sqrt(emat[i][i]); } //--------------------------- //add bes result for (int i=0;i<21;i++){ xx[n2] = xbes[i]; xxe[n2] = 0.001; yy[n2] = ybes[i]; yye[n2] = yebes[i]; n2 ++; } //---------------------------- TCanvas *c2 = new TCanvas(); TGraphErrors *graph1 = new TGraphErrors(n2,xx,yy,xxe,yye); graph1->GetXaxis()->SetTitle("#sqrt{s} (GeV)"); graph1->GetYaxis()->SetTitle("#sigma (nb)"); graph1->SetTitle("Cross section"); //graph1->SetMarkerStyle(5); graph1->SetFillColor(0); graph1->Draw("AP"); ofstream fitxs("fitxsbabar.txt"); double gap = 0.01; TF1 *fit; for (int i=0; xx[i]<1.1-0.0000001;i++){ double xs = yy[i]; //fitxs<<xx[i]<<"\t"<<xs<<"\t"<<0<<endl; fitxs << "xx.push_back(" << xx[i] << ");\tyy.push_back("<< yy[i] << ");\t er.push_back(0);" <<endl; } //fit = new TF1("f0","[0]/(pow(x-[1],2)+pow([2],2))",0.99,1.05); //fit->SetParameter(0,1.0); //fit->SetParameter(1,1.02); //fit->SetParameter(2,0.005); //graph1->Fit(fit,"R","",0.99,1.05); //for (double x=0.99; x<1.05-0.0000001;x+=gap){ // double xs = fit->Eval(x); // fitxs << "xx.push_back(" << x << ");\tyy.push_back("<< xs << ");\t er.push_back(0);" <<endl; //} fit = new TF1("f1","pol2",1.1,1.6); graph1->Fit(fit,"R+","",1.1,1.6); for (double x=1.1; x<1.6-0.0000001;x+=gap){ double xs = fit->Eval(x); //fitxs<<x<<"\t"<<xs<<"\t"<<0<<endl; fitxs << "xx.push_back(" << x << ");\tyy.push_back("<< xs << ");\t er.push_back(0);" <<endl; } fit = new TF1("f2","pol2",1.6,1.76); graph1->Fit(fit,"R+","",1.6,1.779); for (double x=1.6; x<1.779-0.0000001;x+=gap){ double xs = fit->Eval(x); //fitxs<<x<<"\t"<<xs<<"\t"<<0<<endl; fitxs << "xx.push_back(" << x << ");\tyy.push_back("<< xs << ");\t er.push_back(0);" <<endl; } //fit = new TF1("f3","pol2",1.8,2.16); //graph1->Fit(fit,"R+","",1.8,2.16); //for (double x=1.8; x<2.16-0.0000001;x+=gap){ // double xs = fit->Eval(x); // fitxs<<x<<"\t"<<xs<<"\t"<<0<<endl; // //fitxs << "xx.push_back(" << x << ");\tyy.push_back("<< xs << ");\t er.push_back(0);" <<endl; //} // //fit = new TF1("f4","gaus",2.16,2.35); //graph1->Fit(fit,"R+","",2.16,2.4); //for (double x=2.16; x<2.4-0.0000001;x+=gap){ // double xs = fit->Eval(x); // fitxs<<x<<"\t"<<xs<<"\t"<<0<<endl; // //fitxs << "xx.push_back(" << x << ");\tyy.push_back("<< xs << ");\t er.push_back(0);" <<endl; //} // //fit = new TF1("f5","expo",2.35,5); //graph1->Fit(fit,"R+","",2.4,5); //for (double x=2.4; x<5-0.0000001;x+=gap){ // double xs = fit->Eval(x); // fitxs<<x<<"\t"<<xs<<"\t"<<0<<endl; // //fitxs << "xx.push_back(" << x << ");\tyy.push_back("<< xs << ");\t er.push_back(0);" <<endl; //} //fit = new TF1("f4",GausInvx,2.,5,6); //fit->SetNpx(1000); //fit->SetParameters(1,2.25,0.05,0.03,1.8,1.5); //fit->SetParLimits(0, 0.1, 10); //fit->SetParLimits(1, 2.2, 2.4); //fit->SetParLimits(2, 0.03, 0.05); //fit->SetParLimits(3, 0.02, 10); //fit->SetParLimits(4, 1.5, 2); //fit->SetParLimits(5, 1, 2); //fit = new TF1("f4",DGausInvx,2.,5,9); //fit->SetNpx(1000); //fit->SetParameters(0.2, 2.25, 0.05, // 0.03, 1.8, 5, // 0.1, 2.0, 0.05); // //fit->SetParLimits(0, 0.1, 10); //fit->SetParLimits(1, 2.2, 2.3); //fit->SetParLimits(2, 0.03, 0.05); // //fit->SetParLimits(3, 0.02, 10); //fit->SetParLimits(4, -1, 2); //fit->SetParLimits(5, 5, 20); // //fit->SetParLimits(6, 0.1, 0.2); //fit->SetParLimits(7, 1.9, 2.05); //fit->SetParLimits(8, 0.04, 0.08); //graph1->Fit(fit,"R+","",1.8,5); //fit = new TF1("f4",DGausExp,2.,5,8); //fit->SetNpx(1000); //fit->SetParameters(0.2, 2.25, 0.05, // 0.1, 2.0, 0.06, // 0.03, 1.8); // //fit->SetParLimits(0, 0.1, 10); //fit->SetParLimits(1, 2.2, 2.4); //fit->SetParLimits(2, 0.03, 0.052); // //fit->SetParLimits(3, 0.1, 1.0); //fit->SetParLimits(4, 1.9, 2.0); //fit->SetParLimits(5, 0.06, 0.1); // //fit->SetParLimits(6, 0.02, 9); //fit->SetParLimits(7, 0, 1.8); // //graph1->Fit(fit,"R+","",1.75,5); //fit = new TF1("f4",TGaus,2.,5,9); //fit->SetNpx(1000); //fit->SetParameters(0.2, 2.25, 0.05, // 0.1, 2.0, 0.06, // 0.03, 1.8, 1.0); // //fit->SetParLimits(0, 0.1, 10); //fit->SetParLimits(1, 2.2, 2.4); //fit->SetParLimits(2, 0.03, 0.052); // //fit->SetParLimits(3, 0.1, 1.0); //fit->SetParLimits(4, 1.9, 2.0); //fit->SetParLimits(5, 0.06, 0.1); // //fit->SetParLimits(6, 0.02, 90); ////fit->SetParLimits(7, -10, 2); //fit->SetParLimits(7, -10, 2.4); //fit->SetParLimits(8, 0.2, 2); //fit = new TF1("f4",DGausAExp,2.,5,9); //fit->SetNpx(1000); //fit->SetParameters(0.5, 2.2, 30, // 0.1, 2.0, 0.06, // 0.03, 1.8, 1.0); // //fit->SetParLimits(0, 0.1, 100); //fit->SetParLimits(1, 2.1, 2.3); //fit->SetParLimits(2, 10, 60); // //fit->SetParLimits(3, 0.1, 1.0); //fit->SetParLimits(4, 1.9, 2.0); //fit->SetParLimits(5, 0.06, 0.1); // //fit->SetParLimits(6, 0.02, 90); //fit->SetParLimits(7, -10, 2.4); //fit->SetParLimits(8, 0.2, 2); fit = new TF1("f4",AGausDExp,2.,5,9); fit->SetNpx(1000); fit->SetParameters(50, 2.2, 30, 0.1, 2.0, 0.06, 0.1, 2.2, 1.8); fit->SetParLimits(0, 0.1, 100); fit->SetParLimits(1, 2.1, 2.3); fit->SetParLimits(2, 10, 60); fit->SetParLimits(3, 0.1, 1.0); fit->SetParLimits(4, 1.9, 2.1); fit->SetParLimits(5, 0.06, 0.1); fit->SetParLimits(6, 0.02, 90); fit->SetParLimits(7, -10, 2.4); fit->SetParLimits(8, 0.2, 2); graph1->Fit(fit,"R+","",1.77,5); for (double x=1.77; x<5-0.0000001;x+=gap){ double xs = fit->Eval(x); //fitxs<<x<<"\t"<<xs<<"\t"<<0<<endl; fitxs << "xx.push_back(" << x << ");\tyy.push_back("<< xs << ");\t er.push_back(0);" <<endl; } gbes->Draw("P"); file->WriteTObject(c2); graph1->GetXaxis()->SetRangeUser(1.6,3.5); graph1->GetYaxis()->SetRangeUser(0,0.5); c2->Print("cross.pdf"); return 0; }
void result_JES_akPu4PF_(refpt> 75 && refpt < 120)&&(abs(refeta)<2)_Centrality() { //=========Macro generated from canvas: Can_result_0/ //========= (Mon Apr 18 02:39:41 2016) by ROOT version6.02/13 TCanvas *Can_result_0 = new TCanvas("Can_result_0", "",18,40,700,500); gStyle->SetOptFit(1); Can_result_0->Range(-18.75,0.9236134,118.75,1.043845); Can_result_0->SetFillColor(0); Can_result_0->SetBorderMode(0); Can_result_0->SetBorderSize(2); Can_result_0->SetFrameBorderMode(0); Can_result_0->SetFrameBorderMode(0); TMultiGraph *multigraph = new TMultiGraph(); multigraph->SetName("name"); multigraph->SetTitle("JES_akPu4PF"); Double_t Graph_fx1001[4] = { 5, 20, 40, 75}; Double_t Graph_fy1001[4] = { 1.025461, 0.982262, 0.9644553, 0.970611}; Double_t Graph_fex1001[4] = { 5, 10, 10, 25}; Double_t Graph_fey1001[4] = { 0.001598024, 0.0009318739, 0.0008002418, 0.0004502591}; TGraphErrors *gre = new TGraphErrors(4,Graph_fx1001,Graph_fy1001,Graph_fex1001,Graph_fey1001); gre->SetName("Graph"); gre->SetTitle("some title_0"); gre->SetFillColor(1); gre->SetFillStyle(0); TH1F *Graph_Graph1001 = new TH1F("Graph_Graph1001","some title_0",100,0,110); Graph_Graph1001->SetMinimum(0.9573146); Graph_Graph1001->SetMaximum(1.0334); Graph_Graph1001->SetDirectory(0); Graph_Graph1001->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); Graph_Graph1001->SetLineColor(ci); Graph_Graph1001->GetXaxis()->SetLabelFont(42); Graph_Graph1001->GetXaxis()->SetLabelSize(0.035); Graph_Graph1001->GetXaxis()->SetTitleSize(0.035); Graph_Graph1001->GetXaxis()->SetTitleFont(42); Graph_Graph1001->GetYaxis()->SetLabelFont(42); Graph_Graph1001->GetYaxis()->SetLabelSize(0.035); Graph_Graph1001->GetYaxis()->SetTitleSize(0.035); Graph_Graph1001->GetYaxis()->SetTitleFont(42); Graph_Graph1001->GetZaxis()->SetLabelFont(42); Graph_Graph1001->GetZaxis()->SetLabelSize(0.035); Graph_Graph1001->GetZaxis()->SetTitleSize(0.035); Graph_Graph1001->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1001); multigraph->Add(gre,""); Double_t Graph_fx1002[4] = { 5, 20, 40, 75}; Double_t Graph_fy1002[4] = { 1.025808, 0.9823451, 0.964104, 0.9707841}; Double_t Graph_fex1002[4] = { 5, 10, 10, 25}; Double_t Graph_fey1002[4] = { 0.001641175, 0.0009556419, 0.0008206184, 0.000461058}; gre = new TGraphErrors(4,Graph_fx1002,Graph_fy1002,Graph_fex1002,Graph_fey1002); gre->SetName("Graph"); gre->SetTitle("some title_1"); gre->SetFillColor(1); gre->SetFillStyle(0); gre->SetLineColor(2); gre->SetMarkerColor(2); TH1F *Graph_Graph1002 = new TH1F("Graph_Graph1002","some title_1",100,0,110); Graph_Graph1002->SetMinimum(0.9568668); Graph_Graph1002->SetMaximum(1.033866); Graph_Graph1002->SetDirectory(0); Graph_Graph1002->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1002->SetLineColor(ci); Graph_Graph1002->GetXaxis()->SetLabelFont(42); Graph_Graph1002->GetXaxis()->SetLabelSize(0.035); Graph_Graph1002->GetXaxis()->SetTitleSize(0.035); Graph_Graph1002->GetXaxis()->SetTitleFont(42); Graph_Graph1002->GetYaxis()->SetLabelFont(42); Graph_Graph1002->GetYaxis()->SetLabelSize(0.035); Graph_Graph1002->GetYaxis()->SetTitleSize(0.035); Graph_Graph1002->GetYaxis()->SetTitleFont(42); Graph_Graph1002->GetZaxis()->SetLabelFont(42); Graph_Graph1002->GetZaxis()->SetLabelSize(0.035); Graph_Graph1002->GetZaxis()->SetTitleSize(0.035); Graph_Graph1002->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1002); multigraph->Add(gre,""); Double_t Graph_fx1003[4] = { 5, 20, 40, 75}; Double_t Graph_fy1003[4] = { 0.9944711, 0.9453074, 0.9619222, 0.9556338}; Double_t Graph_fex1003[4] = { 5, 10, 10, 25}; Double_t Graph_fey1003[4] = { 0.01053149, 0.005298861, 0.004412705, 0.002663901}; gre = new TGraphErrors(4,Graph_fx1003,Graph_fy1003,Graph_fex1003,Graph_fey1003); gre->SetName("Graph"); gre->SetTitle("some title_2"); gre->SetFillColor(1); gre->SetFillStyle(0); gre->SetLineColor(3); gre->SetMarkerColor(3); TH1F *Graph_Graph1003 = new TH1F("Graph_Graph1003","some title_2",100,0,110); Graph_Graph1003->SetMinimum(0.9335092); Graph_Graph1003->SetMaximum(1.011502); Graph_Graph1003->SetDirectory(0); Graph_Graph1003->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1003->SetLineColor(ci); Graph_Graph1003->GetXaxis()->SetLabelFont(42); Graph_Graph1003->GetXaxis()->SetLabelSize(0.035); Graph_Graph1003->GetXaxis()->SetTitleSize(0.035); Graph_Graph1003->GetXaxis()->SetTitleFont(42); Graph_Graph1003->GetYaxis()->SetLabelFont(42); Graph_Graph1003->GetYaxis()->SetLabelSize(0.035); Graph_Graph1003->GetYaxis()->SetTitleSize(0.035); Graph_Graph1003->GetYaxis()->SetTitleFont(42); Graph_Graph1003->GetZaxis()->SetLabelFont(42); Graph_Graph1003->GetZaxis()->SetLabelSize(0.035); Graph_Graph1003->GetZaxis()->SetTitleSize(0.035); Graph_Graph1003->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1003); multigraph->Add(gre,""); multigraph->Draw("AP"); multigraph->GetXaxis()->SetTitle("Centrality"); multigraph->GetXaxis()->SetLabelFont(42); multigraph->GetXaxis()->SetLabelSize(0.035); multigraph->GetXaxis()->SetTitleSize(0.035); multigraph->GetXaxis()->SetTitleFont(42); multigraph->GetYaxis()->SetTitle("#mu_{Reco./Gen.}"); multigraph->GetYaxis()->SetLabelFont(42); multigraph->GetYaxis()->SetLabelSize(0.035); multigraph->GetYaxis()->SetTitleSize(0.035); multigraph->GetYaxis()->SetTitleFont(42); TLegend *leg = new TLegend(0.68,0.7,0.88,0.85,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("Graph","allJets","l"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("Graph","lightJets","l"); entry->SetLineColor(2); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("Graph","bJets","l"); entry->SetLineColor(3); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); TLatex * tex = new TLatex(0.25,0.7,"#bf{#color[2]{|#eta_{jet}|<2.0 &75<refpt<120}}"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(24); tex->SetLineWidth(2); tex->Draw(); TPaveText *pt = new TPaveText(0.3750575,0.9365254,0.6249425,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); AText = pt->AddText("JES_akPu4PF"); pt->Draw(); Can_result_0->Modified(); Can_result_0->cd(); Can_result_0->SetSelected(Can_result_0); }
void advancedNoiseAnalysis( unsigned int runNumber, unsigned int loop = 1) { string inputFileName = "./histo/run00" + toString( runNumber ) + "-ped-histo.root"; string outputFileName = "./histo/run00" + toString( runNumber ) + "-adv-noise.root"; // before opening the input and the output files, try to see if they // are not opened yet and in case close them before continue TList * listOfOpenedFile = (TList*) gROOT->GetListOfFiles(); for ( int i = 0; i < listOfOpenedFile->GetSize() ; ++i ) { TFile * file = (TFile*) listOfOpenedFile->At( i ) ; TString fileName(file->GetName()); TString inputFileName1( inputFileName.c_str() ); TString outputFileName1( outputFileName.c_str() ); if ( ( fileName.Contains( inputFileName1 ) ) || ( inputFileName1.Contains( fileName ) ) || ( fileName.Contains( outputFileName1 ) ) || ( outputFileName1.Contains( fileName ) ) ) { cout << "Closing " << fileName << " before reopen " << endl; file->Close(); } } // close also all the previously opened canvas TList * listOfOpenedCanvas = (TList*) gROOT->GetListOfCanvases(); for ( int i = 0 ; i < listOfOpenedCanvas->GetSize() ; ++i ) { TCanvas * canvas = (TCanvas*) listOfOpenedCanvas->At( i ); TString canvasName2 = canvas->GetName(); if ( canvasName2.Contains( "det" ) ) { canvas->Close(); } } // now safely open the file TFile * inputFile = TFile::Open( inputFileName.c_str() ) ; TFile * outputFile = TFile::Open( outputFileName.c_str(), "RECREATE") ; TList * outputHistoList = new TList; // look into the inputFile for a folder named string pedeProcessorFolderName = "PedestalAndNoiseCalculator"; TDirectoryFile * pedeProcessorFolder = (TDirectoryFile*) inputFile->Get( pedeProcessorFolderName.c_str() ); if ( pedeProcessorFolder == 0 ) { cerr << "No pedestal processor folder found in file " << inputFileName << endl; return ; } // this folder should contain one folder for each loop. string loopFolderName = "loop-" + toString( loop ); TDirectoryFile * loopFolder = (TDirectoryFile *) pedeProcessorFolder->Get( loopFolderName.c_str() ); if ( loopFolder == 0 ) { cerr << "No " << loopFolderName << " found in file " << inputFileName << endl; return ; } // guess the number of sensors from the number of subfolder in the loopfolder size_t nDetector = loopFolder->GetListOfKeys()->GetSize(); cout << "This file contains " << nDetector << " detectors" << endl; // prepare arrays to store the mean and the rms of the noise distribution if ( noiseMean == NULL ) { delete [] noiseMean; noiseMean = NULL; } if ( noiseRMS == NULL ) { delete [] noiseRMS; noiseRMS = NULL; } if ( channel == NULL ) { delete [] channel; channel = NULL; } noiseMean = new double[ nDetector * kNChan ]; noiseRMS = new double[ nDetector * kNChan ]; channel = new double[ kNChan ]; string canvasName = "comparison"; string canvasTitle = "Noise comparison"; TCanvas * comparisonCanvas = new TCanvas( canvasName.c_str(), canvasTitle.c_str(), 1000, 500 ); comparisonCanvas->Divide(1,2); TPad * topPad = (TPad*) comparisonCanvas->cd(1); topPad->Divide( nDetector ); TPad * middlePad = (TPad *) comparisonCanvas->cd(2); middlePad->Divide( kNChan ); // for each detector we have to get the noise map and to prepare 4 // separe histos and maps for ( unsigned int iDetector = 0; iDetector < nDetector; iDetector++ ) { // get the noise map. string noiseMapName = "detector-" + toString( iDetector ) ; noiseMapName += "/NoiseMap-d" + toString( iDetector ) ; noiseMapName += "-l" + toString( loop ) ; TH2D * noiseMap = ( TH2D* ) loopFolder->Get( noiseMapName.c_str() ); // create a folder in the output file TDirectory * subfolder = outputFile->mkdir( string( "detector_" + toString( iDetector ) ).c_str(), string( "detector_" + toString( iDetector ) ).c_str() ); subfolder->cd(); string canvasName = "det" + toString( iDetector ); string canvasTitle = "Detector " + toString( iDetector ); TCanvas * canvas = new TCanvas( canvasName.c_str(), canvasTitle.c_str(), 1000, 500 ); canvas->Divide( kNChan, 2 ); // ok now start the loop on channels for ( size_t iChan = 0 ; iChan < kNChan ; ++iChan ) { if ( iDetector == 0 ) channel[iChan] = iChan - 0.5; string tempName = "NoiseMap_d" + toString( iDetector ) + "_l" + toString( loop ) + "_ch" + toString( iChan ) ; string tempTitle = "NoiseMap Det. " + toString( iDetector ) + " - Ch. " + toString( iChan ) ; TH2D * noiseMapCh = new TH2D ( tempName.c_str() , tempTitle.c_str(), kXPixel / kNChan , -0.5 + xLimit[ iChan ] , -0.5 + xLimit[ iChan + 1 ], kYPixel, -0.5, -0.5 + kYPixel ); noiseMapCh->SetXTitle("X [pixel]"); noiseMapCh->SetYTitle("Y [pixel]"); noiseMapCh->SetZTitle("Noise [ADC]"); noiseMapCh->SetStats( false ); outputHistoList->Add( noiseMapCh ) ; tempName = "NoiseDist_d" + toString( iDetector ) + "_l" + toString( loop ) + "_ch" + toString( iChan ) ; tempTitle = "NoiseDist Det. " + toString( iDetector ) + " - Ch. " + toString( iChan ) ; TH1D * noiseDistCh = new TH1D( tempName.c_str(), tempTitle.c_str(), 50, 0., 10. ); noiseDistCh->SetXTitle("Noise [ADC]"); noiseDistCh->SetLineColor( kColor[iDetector] ); noiseDistCh->SetLineStyle( iChan + 2 ); noiseDistCh->SetLineWidth( 2 ); outputHistoList->Add( noiseDistCh ); // let's start looping on pixels now for ( size_t yPixel = 1 ; yPixel <= kYPixel ; ++yPixel ) { for ( size_t xPixel = xLimit[ iChan ] + 1; xPixel <= xLimit[ iChan +1 ] ; ++xPixel ) { double noise = noiseMap->GetBinContent( xPixel , yPixel ); noiseMapCh->Fill( xPixel - 1 , yPixel - 1, noise ); noiseDistCh->Fill( noise ); } } canvas->cd( iChan + 1 ) ; noiseMapCh->Draw("colz"); canvas->cd( iChan + kNChan + 1 ); noiseDistCh->Draw(); topPad->cd( iDetector + 1 ); if ( iChan == 0 ) { noiseDistCh->Draw(); } else { noiseDistCh->Draw("same"); } middlePad->cd( iChan + 1 ); if ( iDetector == 0 ) { noiseDistCh->Draw(); } else { noiseDistCh->Draw("same"); } noiseMean[ kNChan * iDetector + iChan ] = noiseDistCh->GetMean(); noiseRMS[ kNChan * iDetector + iChan ] = noiseDistCh->GetRMS(); } canvas->Write(); } canvasName = "summary"; canvasTitle = "Noise summary"; TCanvas * summaryCanvas = new TCanvas( canvasName.c_str(), canvasTitle.c_str(), 1000, 500 ); summaryCanvas->SetGridx(1); TLegend * legend = new TLegend(0.5, 4.8, 1.5, 4.3,"","br");; for ( size_t iDetector = 0 ; iDetector < nDetector ; ++iDetector ) { TGraphErrors * gr = new TGraphErrors( kNChan, channel, &noiseMean[ iDetector * kNChan ], NULL, &noiseRMS[ iDetector * kNChan ] ); gr->SetName( string( "NoisePerChannel_d" + toString( iDetector )).c_str()); gr->SetTitle(string("Detector " + toString( iDetector )).c_str()); gr->GetXaxis()->SetTitle("Channel #"); gr->GetYaxis()->SetTitle("Noise [ADC]"); gr->GetXaxis()->SetNdivisions( 5 ); gr->GetXaxis()->SetLabelSize( 0 ); gr->SetMarkerStyle( iDetector + 1 ); gr->SetMarkerColor( kColor[iDetector] ); gr->SetLineColor( kColor[iDetector] ); gr->SetLineWidth( 2 ); legend->AddEntry( gr, string("Detector " + toString( iDetector )).c_str(), "LP"); if ( iDetector == 0 ) { gr->Draw("ALP"); } else { gr->Draw("LP"); } } legend->Draw(); for ( size_t iChan = 0 ; iChan < kNChan ; ++iChan ) { TPaveLabel * label = new TPaveLabel( iChan - 0.75 , 3.2 , iChan -0.25 , 3, string("Ch " + toString( iChan ) ).c_str()); label->Draw(); } summaryCanvas->Write(); comparisonCanvas->Write(); outputHistoList->Write(); }
void pointsed(TString filename = "btagpatanalyzerpy.root", TString check="") { TString cmssw; // 167 cmssw = "$3.1.0_pre9$"; TFile *f = TFile::Open(filename); ///////////////////////////////////////////////////////////////////////////////////////// std::vector< TString > checks; checks.push_back(""); checks.push_back("Corr30_"); checks.push_back("Corr30t0_"); checks.push_back("Corr30t1_"); checks.push_back("Corr30t2_"); checks.push_back("Corr30t0_nConstituent_"); checks.push_back("Corr30t1_nConstituent_"); checks.push_back("Corr30t2_nConstituent_"); checks.push_back("Uncor10_"); checks.push_back("Uncor10t0_"); checks.push_back("Uncor10t1_"); checks.push_back("Uncor10t2_"); checks.push_back("Uncor10t0_nConstituent_"); checks.push_back("Uncor10t1_nConstituent_"); checks.push_back("Uncor10t2_nConstituent_"); ///////////////////////////////////////////////////////////////////////////////////////// std::vector< TString > taggers; std::vector< TString > labeltag; std::vector< int> colorlines; taggers.push_back( "TC2" );colorlines.push_back( 1 );labeltag.push_back( "TCHE"); taggers.push_back( "TC3" );colorlines.push_back( 2 );labeltag.push_back( "TCHP"); taggers.push_back( "TP" );colorlines.push_back( 3 );labeltag.push_back( "JP"); taggers.push_back( "SSV" );colorlines.push_back( 4 );labeltag.push_back( "SSV"); taggers.push_back( "CSV" );colorlines.push_back( 5 );labeltag.push_back( "CSV"); taggers.push_back( "MSV" );colorlines.push_back( 6 );labeltag.push_back( "CSVMVAB"); taggers.push_back( "SMT" );colorlines.push_back( 8 );labeltag.push_back( "SMT"); taggers.push_back( "BTP" );colorlines.push_back( 9 );labeltag.push_back( "JBP"); taggers.push_back( "SMTbyIP3d" );colorlines.push_back( 11 );labeltag.push_back( "SMTByIP3d"); taggers.push_back( "SMTbyPt" );colorlines.push_back( 12 );labeltag.push_back( "SMTByPt"); taggers.push_back( "SETbyIP3d" );colorlines.push_back( 13 );labeltag.push_back( "SETByIP3d"); taggers.push_back( "SETbyPt" );colorlines.push_back( 14 );labeltag.push_back( "SETByPt"); // taggers.push_back( "IPM" );colorlines.push_back( 11 );labeltag.push_back( "IPMVAB"); // taggers.push_back( "SMNIPT" );colorlines.push_back( 12 );labeltag.push_back( "SMTNoIP"); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //ed for ( size_t ichks = 0; ichks < checks.size(); ++ichks ) { //ed TString check = checks[ichks]; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TString PerfTitle= check; if (check == "") PerfTitle="uncorr pt>30"; if (check == "Corr30_") PerfTitle="pt>30"; if (check == "Corr30t0_") PerfTitle="pt>30, #tracks > 0"; if (check == "Corr30t1_") PerfTitle="pt>30, #tracks > 1"; if (check == "Corr30t2_") PerfTitle="pt>30, #tracks > 2"; if (check == "Corr30t0_nConstituent_") PerfTitle="pt>30, #tracks > 0 & nConstituents >1"; if (check == "Corr30t1_nConstituent_") PerfTitle="pt>30, #tracks > 1 & nConstituents >1"; if (check == "Corr30t2_nConstituent_") PerfTitle="pt>30, #tracks > 2 & nConstituents >1"; if (check == "Uncor10_") PerfTitle="uncorr pt>10"; if (check == "Uncor10t0_") PerfTitle="uncorr pt>10 #tracks > 0"; if (check == "Uncor10t1_") PerfTitle="uncorr pt>10 #tracks > 1"; if (check == "Uncor10t2_") PerfTitle="uncorr pt>10 #tracks > 2"; if (check == "Uncor10t0_nConstituent_") PerfTitle="uncorr pt>10 #tracks > 0 & nConstituents >1"; if (check == "Uncor10t1_nConstituent_") PerfTitle="uncorr pt>10 #tracks > 1 & nConstituents >1"; if (check == "Uncor10t2_nConstituent_") PerfTitle="uncorr pt>10 #tracks > 2 & nConstituents >1"; std::vector< TString > discriminators; for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) { discriminators.push_back( check+"disc"+taggers[itagger]+"_udsg" ); } // discriminators.push_back( "discTC3_udsg" ); // discriminators.push_back( "discTP_udsg" ); TCanvas *cv = new TCanvas("cv","cv",900,900); TMultiGraph *mg =new TMultiGraph(); TLegend *legend0 = new TLegend(0.68,0.12,0.88,0.32); // inverted axis TMultiGraph *mginv =new TMultiGraph(); TLegend *legend1 = new TLegend(0.65,0.18,0.85,0.48); std::ofstream salida("BTagPATop3"+check+".txt"); for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) { TString tag = check+"g"+taggers[itagger]+"_udsg"; TGraphErrors *agraph = (TGraphErrors*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+tag); TGraph *dgraph = (TGraph*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+discriminators[itagger]); // TGraph *udsgvsdgraph = new TGraph(dgraph->GetN(),dgraph->GetY(),dgraph->GetX()); dgraph->Sort(); // udsgvsdgraph->Sort(); TGraphErrors *g = new TGraphErrors(agraph->GetN(),agraph->GetY(),agraph->GetX(),agraph->GetEY(),agraph->GetEX()); g->Sort(); g->SetLineColor(itagger+1); legend0 -> AddEntry(g,taggers[itagger],"l"); mg->Add(g); //inverted axis TGraphErrors *ginv = new TGraphErrors(agraph->GetN(),agraph->GetX(),agraph->GetY(),agraph->GetEX(),agraph->GetEY()); ginv->Sort(); ginv->SetLineColor(colorlines[itagger]); ginv->SetMarkerStyle(8); ginv->SetMarkerColor(colorlines[itagger]); legend1 -> AddEntry(ginv,labeltag[itagger],"l"); mginv->Add(ginv); std::cout << " Tagger: " << tag << std::endl; std::cout << " Loose(10%): " << " cut > " << std::setprecision(4) << dgraph->Eval(0.1) << " b-eff = " << g->Eval(0.1) << std::endl; std::cout << " Medium(1%): " << " cut > " << std::setprecision(4) << dgraph->Eval(0.01) << " b-eff = " << g->Eval(0.01) << std::endl; std::cout << " Tight(0.1%) = " << " cut > " << std::setprecision(4) << dgraph->Eval(0.001) << " b-eff = " << g->Eval(0.001) << std::endl; salida << " " << taggers[itagger] << endl; salida << " #bin \t b-eff \t err-beff \t non-beff \t err-non-b"<< endl; for ( size_t i=0;i< agraph->GetN();i++){ salida << " " << (i+1) << " \t " << agraph->GetX()[i] <<" \t " << agraph->GetEX()[i]<<" \t " << agraph->GetY()[i] <<" \t " << agraph->GetEY()[i] << " "<< endl; } } // cv->SetLogx(); mg->Draw("ALP"); mg->GetYaxis()->SetTitle("b-eff"); mg->GetXaxis()->SetTitle("udsg-mistagging"); legend0 -> Draw(); cv-> SetGrid(); cv-> Print ("BTagPATop"+check+".eps"); cv-> Print ("BTagPATop"+check+".png"); cv->cd(0); cv->SetLogx(); mg->Draw("ALP"); legend0 -> Draw(); cv-> Print ("BTagPATop1"+check+".eps"); cv-> Print ("BTagPATop1"+check+".png"); //inverted axis TCanvas *cvinv = new TCanvas("cvinv","cvinv",700,700); cvinv->SetLogy(0); mginv->Draw("ALP"); mginv->GetXaxis()->SetTitle("b-eff"); mginv->GetYaxis()->SetTitle("udsg-mistagging"); legend1 -> Draw(); cvinv->SetGrid(); cvinv-> Print ("BTagPATop2"+check+".eps"); cvinv-> Print ("BTagPATop2"+check+".png"); cvinv->cd(0); // cvinv->Update(); // cvinv->SetLogx(); // mginv->SetXmin(10^-4); // axis range using a histogram helper TH2D*hpx = new TH2D("hpx",PerfTitle,200,0.0,1.005,200,0.00002,1.05); hpx->SetStats(kFALSE); hpx->Draw(); hpx->GetXaxis()->SetTitle("b-eff"); hpx->GetYaxis()->SetTitle("udsg-mistagging"); cvinv->SetLogy(1); mginv->Draw("AP"); legend1 -> Draw(); cvinv-> Print ("BTagPATop3"+check+".eps"); cvinv-> Print ("BTagPATop3"+check+".png"); //ed} }
void minuitFit() { TH1F::SetDefaultSumw2(); TH1D::SetDefaultSumw2(); cout << "Must Use Same Binning as previous Analysis!" << endl; gStyle->SetOptFit(1111); gStyle->SetOptStat(0); haveName = kFALSE; char fname[100]; TFile* file; Bool_t makePDF = checkMakePDF(); Bool_t makeROOT = checkMakeRoot(); if(makeROOT){ sprintf(fname,"/Users/zach/Research/pythia/200GeVTemplate/FFOutput/%s_FIT.root",FileNameR); file = new TFile(fname,"RECREATE"); if (file->IsOpen()==kFALSE) { std::cout << "!!! Outfile Not Opened !!!" << std::endl; makeROOT = kFALSE; } } char name[1000]; sprintf(name,"/Users/zach/Research/pythia/200GeVTemplate/currentTemplate.root"); TFile *fT = new TFile(name,"READ"); sprintf(name,"/Users/zach/Research/rootFiles/run12NPEhPhi/currentData.root"); TFile *fD = new TFile(name,"READ"); if (fT->IsOpen()==kFALSE || fD->IsOpen()==kFALSE) { std::cout << "!!!!!! Either B,C, or Data File not found !!!!!!" << std::endl << "Looking for currentB.root, currentC.root, and currentData.root" << std::endl; exit(1); } // Set constants and projection bins (from header file anaConst, analysis constants) Float_t lowpt[numPtBins],highpt[numPtBins]; for(Int_t c=0; c< numPtBins; c++){ lowpt[c] = anaConst::lpt[c]; highpt[c] = anaConst::hpt[c]; } Float_t hptCut=anaConst::hptCut; // Make Canvases TCanvas* deltaPhi = new TCanvas("deltaPhi","Pythia Delta Phi",150,0,1150,1000); TCanvas* deltaPhi2 = new TCanvas("deltaPhi2","Pythia Delta Phi",150,0,1150,1000); TCanvas* fitResult0 = new TCanvas("fitResult0","RB Extraction HT0",150,0,1150,1000); TCanvas* fitResult2 = new TCanvas("fitResult2","RB Extraction HT2",150,0,1150,1000); TCanvas* fitResultC = new TCanvas("fitResultC","RB Extraction Combined Trigs",150,0,1150,1000); TCanvas* fitResultP = new TCanvas("fitResultP","RB Previous Analysis",150,0,1150,1000); TCanvas* scaleCheck = new TCanvas("scaleCheck","Check scale diff",150,0,1150,1000); TCanvas* prettyPlot = new TCanvas("prettyPlot","PrettyPlot",150,0,1150,1000); deltaPhi ->Divide(3,3); deltaPhi2 ->Divide(3,3); fitResult0->Divide(3,4); fitResult2->Divide(3,4); fitResultC->Divide(3,4); fitResultP->Divide(2,2); scaleCheck->Divide(1,2); // Get and Draw histos TPaveText* lbl[numPtBins]; TPaveText* stat[4][numPtBins]; char statLabel[100]; char textLabel[100]; Int_t plotbin; Double_t norm0,norm2,normB,normC; // Get ptbin independent hists histoNorms = (TH2F*)fD->Get("histoNorms"); // Get Previous Analysis TFile *file3 = new TFile("/Users/zach/Research/previousNPEhFigures/Chi2_25_35.root"); Hdphi[0] = (TH1D*)file3->Get("fit_25_35"); HpphiD[0] = (TH1D*)file3->Get("De_25_35"); HpphiB[0] = (TH1D*)file3->Get("Be_25_35"); TFile *file4 = new TFile("/Users/zach/Research/previousNPEhFigures/Chi2_55_65.root"); Hdphi[1] = (TH1D*)file4->Get("fit_55_65"); HpphiD[1] = (TH1D*)file4->Get("De_55_65"); HpphiB[1] = (TH1D*)file4->Get("Be_55_65"); for(Int_t ptbin=0; ptbin<numPtBins; ptbin++) { bPtNorms[ptbin] = (TH1F*)fT->Get(Form("beEventTally_%i",ptbin)); cPtNorms[ptbin] = (TH1F*)fT->Get(Form("ceEventTally_%i",ptbin)); norm0 = histoNorms->GetBinContent(histoNorms->GetBin(1,ptbin+1)); norm2 = histoNorms->GetBinContent(histoNorms->GetBin(3,ptbin+1)); normB = bPtNorms[ptbin]->GetBinContent(1); normC = cPtNorms[ptbin]->GetBinContent(1); cout << ptbin << "; 0: " << norm0 << " 2: " << norm2 << endl; if( norm0 == 0) { cout << ptbin << " For this bin, some norm0 = 0" << endl; continue; } if( norm2 == 0 ) { cout << ptbin << " For this bin, some norm2 = 0" << endl; continue; } if( normB == 0 ) { cout << ptbin << " For this bin, some normB = 0" << endl; continue; } if( normC == 0) { cout << ptbin << " For this bin, some normC = 0" << endl; continue; } plotbin = ptbin; // Init necessary plotting tools lbl[ptbin] = new TPaveText(.15,.15,.35,.23,Form("NB NDC%i",ptbin)); sprintf(textLabel,"%.1f < P_{T,e} < %.1f",lowpt[ptbin],highpt[ptbin]); lbl[ptbin]->AddText(textLabel); lbl[ptbin]->SetFillColor(kWhite); projB[ptbin] = (TH1D*)fT->Get(Form("hdPhiRawbe_%i",ptbin)); projC[ptbin] = (TH1D*)fT->Get(Form("hdPhiRawce_%i",ptbin)); projData0[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_0_%i",ptbin)); projData2[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_2_%i",ptbin)); pileupCorrect[ptbin][0] = (TH1D*)fD->Get(Form("pileupCorrection_%i_0",ptbin)); pileupCorrect[ptbin][1] = (TH1D*)fD->Get(Form("pileupCorrection_%i_2",ptbin)); pileupCorrect[ptbin][0]->Sumw2(); pileupCorrect[ptbin][1]->Sumw2(); // Do any rebinning Int_t RB = 1; projB[ptbin]->Rebin(RB); projC[ptbin]->Rebin(RB); projData0[ptbin]->Rebin(RB); projData2[ptbin]->Rebin(RB); // Clone to make plots without effecting fits plotD0[ptbin] = (TH1D*) projData0[ptbin]->Clone(); plotD2[ptbin] = (TH1D*) projData2[ptbin]->Clone(); plotB[ptbin] = (TH1D*) projB[ptbin]->Clone(); plotC[ptbin] = (TH1D*) projC[ptbin]->Clone(); // Set features that are the same in plots projData0[ptbin]->SetLineColor(kBlue); projData2[ptbin]->SetLineColor(kGreen+3); projB[ptbin]->SetLineColor(kRed); projC[ptbin]->SetLineColor(kBlack); projC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5); plotD0[ptbin]->SetLineColor(kBlue); plotD2[ptbin]->SetLineColor(kGreen+3); plotD0[ptbin]->SetMarkerStyle(20); plotD0[ptbin]->SetMarkerColor(kBlue); plotD0[ptbin]->SetMarkerSize(0.4); plotB[ptbin]->SetLineColor(kRed); plotC[ptbin]->SetLineColor(kBlack); plotC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5); combData[ptbin] = (TH1D*) projData0[ptbin]->Clone(); combData[ptbin] -> Add(projData2[ptbin]); combData[ptbin]->SetLineColor(kBlue); combData[ptbin]->SetMarkerStyle(20); combData[ptbin]->SetMarkerColor(kBlue); combData[ptbin]->SetMarkerSize(0.4); combData[ptbin]->SetTitle(""); // Normalize projB[ptbin] -> Scale(1./normB); projC[ptbin] -> Scale(1./normC); projData0[ptbin] -> Scale(1./norm0); projData2[ptbin] -> Scale(1./norm2); plotD0[ptbin] -> Scale(1./norm0); plotD2[ptbin] -> Scale(1./norm2); plotB[ptbin] -> Scale(1./normB); plotC[ptbin] -> Scale(1./normC); combData[ptbin] -> Scale(1./(norm0+norm2)); // Subtract Pileup correction (data only) projData0[ptbin]->Sumw2();projData2[ptbin]->Sumw2(); //projData0[ptbin]->Add(pileupCorrect[ptbin][0],-1); //projData2[ptbin]->Add(pileupCorrect[ptbin][1],-1); // Draw Templates on own plots if(ptbin+1 <= 9) deltaPhi->cd(plotbin+1); if(ptbin+1 > 9) deltaPhi2->cd(ptbin-8); plotC[ptbin]->GetYaxis()->SetRangeUser(-.1,0.8); plotC[ptbin] -> Draw("hist"); plotB[ptbin] -> Draw("same hist"); plotD0[ptbin] -> Draw("same"); plotD2[ptbin] -> Draw("same"); lbl[ptbin] -> Draw("same"); TLegend* leg = new TLegend(0.65,0.6,0.85,0.85); leg->AddEntry(projB[ptbin],"b#bar{b}->NPE","lpe"); leg->AddEntry(projC[ptbin],"c#bar{c}->NPE","lpe"); leg->AddEntry(projData0[ptbin],"HT0","lpe"); leg->AddEntry(projData2[ptbin],"HT2","lpe"); leg->Draw(); deltaPhi->cd(1); Hdphi[0]->Draw("same"); deltaPhi->cd(4); Hdphi[1]->Draw("same"); if(ptbin == 1) { prettyPlot->cd(); plotC[ptbin]->GetYaxis()->SetRangeUser(0,0.35); plotC[ptbin]->SetMarkerStyle(20); plotC[ptbin]->SetMarkerSize(0.6); plotB[ptbin]->SetMarkerStyle(21); plotB[ptbin]->SetMarkerSize(0.6); plotB[ptbin]->SetMarkerColor(kRed); plotD0[ptbin]->SetMarkerStyle(22); plotD0[ptbin]->SetMarkerSize(0.9); plotC[ptbin]->GetXaxis()->SetTitle("#Delta#phi_{NPE-h} (rad)"); plotC[ptbin]->GetYaxis()->SetTitle("#frac{1}{N_{NPE}} #frac{dN}{d(#Delta#phi)}"); plotC[ptbin]->DrawClone("P"); plotB[ptbin]->DrawClone("same P"); plotD0[ptbin]->DrawClone("same P"); TLegend* legPret = new TLegend(0.65,0.6,0.85,0.85); legPret->AddEntry(plotB[ptbin],"B #rightarrow NPE-h, Monte Carlo","LPE"); legPret->AddEntry(plotC[ptbin],"D #rightarrow NPE-h, Monte Carlo","LPE"); legPret->AddEntry(plotD0[ptbin],"NPE-h 2012 STAR Data","LPE"); lbl[ptbin]->Draw("same"); legPret->Draw("same"); } /*// Draw Scale Check scaleCheck->cd(1); TH1F* HT0 = (TH1F*) plotD0[0]->Clone(); HT0->Divide(HT0,Hdphi[0],1,1); HT0->Draw(); scaleCheck->cd(2); TH1F* HT2 = (TH1F*) plotD2[3]->Clone(); HT2->Divide(HT2,Hdphi[1],1,1); HT0->GetXaxis()->SetRangeUser(-3.5,3.5); HT2->GetXaxis()->SetRangeUser(-3.5,3.5); HT2->Draw(); lbl[ptbin]->Draw("same"); TLegend* legSC = new TLegend(0.65,0.6,0.85,0.85); legSC->AddEntry(HT0,"HT0/prevdata","lpe"); legSC->AddEntry(HT2,"HT2/prevdata","lpe"); legSC->Draw();*/ ///////////////////// // Do the actual fits ///////////////////// currentPtBin = ptbin; cout << "!!!!!!! HT0 ptbin: " << highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl; TMinuit* gMinuit = new TMinuit(1); gMinuit->SetFCN(chi2_0); currentPtBin = ptbin; doFit(gMinuit,p01[ptbin],p00[ptbin],e01[ptbin],e00[ptbin]); // assign to plotting variables if(highpt[ptbin] < 6) { pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.; dx[plotCount0] = 0.; ptOFF1[plotCount0] = pT[ptbin]; Rb0[plotCount0] = p01[ptbin];///(p01[ptbin]+p00[ptbin]); eb0[plotCount0] = e01[ptbin]; plotCount0++; } // Plot results fitResult0->cd(ptbin+1); TH1D* dClone = (TH1D*) projData0[ptbin]->Clone(); TH1D* cClone = (TH1D*) projC[ptbin]->Clone(); TH1D* bClone = (TH1D*) projB[ptbin]->Clone(); stat[0][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin)); sprintf(statLabel,"Chi2/NDF: %.2f/%.0f",curChi2,curNDF); stat[0][ptbin]->InsertText(statLabel); stat[0][ptbin]->SetFillColor(kWhite); cClone->Scale((1.-p01[ptbin])*p00[ptbin]); bClone->Scale(p00[ptbin]*p01[ptbin]); // scale by contribution param cClone->Add(bClone); //cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum()); dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi); dClone->GetYaxis()->SetRangeUser(-0.1,0.6); dClone->Draw(); cClone->Draw("same"); stat[0][ptbin]->Draw("same"); lbl[ptbin]->Draw("same"); cout << "!!!!!!! HT2 ptbin: " << highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl; gMinuit->SetFCN(chi2_2); doFit(gMinuit,p21[ptbin],p20[ptbin],e21[ptbin],e20[ptbin]); // assign to plotting variables if(highpt[ptbin] > 3.6) { pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.; ptOFF2[plotCount2] = pT[ptbin]; Rb2[plotCount2] = p21[ptbin];///(p21[ptbin]+p20[ptbin]); eb2[plotCount2] = e21[ptbin]; plotCount2++; } // Plot results fitResult2->cd(ptbin+1); dClone = (TH1D*) projData2[ptbin]->Clone(); cClone = (TH1D*) projC[ptbin]->Clone(); bClone = (TH1D*) projB[ptbin]->Clone(); stat[2][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin)); sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF); stat[2][ptbin]->InsertText(statLabel); stat[2][ptbin]->SetFillColor(kWhite); cClone->Scale((1.-p21[ptbin])*p20[ptbin]); bClone->Scale(p20[ptbin]*p21[ptbin]); // scale by contribution param cClone->Add(bClone); // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum()); dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi); dClone->GetYaxis()->SetRangeUser(-0.1,0.6); dClone->Draw(); cClone->Draw("same"); stat[2][ptbin]->Draw("same"); lbl[ptbin]->Draw("same"); cout << "!!!!!!! HTC ptbin: " << highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl; gMinuit->SetFCN(chi2_C); doFit(gMinuit,pC1[ptbin],pC0[ptbin],eC1[ptbin],eC0[ptbin]); // assign to plotting variables pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.; RbC[plotCount] = pC1[ptbin];///(p21[ptbin]+p20[ptbin]); ebC[plotCount] = eC1[ptbin]; plotCount++; } cout << "!!!!!!! Previous Data: 0"<<" !!!!!!!"<< endl; ////////// // 2.5-3.5 GeV Bin ////////// gMinuit->SetFCN(chi2_P0); doFit(gMinuit,RbP[0],SF[0],EbP[0],eSF[0]); // assign plotting variables pTP[0] = 3.; // Plot results fitResultP->cd(1); /*TH1D* dClone = (TH1D*) Hdphi[0]->Clone(); TH1D* cClone = (TH1D*) projC[0]->Clone(); TH1D* bClone = (TH1D*) projB[0]->Clone();*/ TH1D* dClone = (TH1D*) projData0[0]->Clone(); TH1D* cClone = (TH1D*) HpphiD[0]->Clone(); TH1D* bClone = (TH1D*) HpphiB[0]->Clone(); stat[3][0] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0)); sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF); stat[3][0]->InsertText(statLabel); stat[3][0]->SetFillColor(kWhite); cClone->Scale((1.-RbP[0])*SF[0]); bClone->Scale(RbP[0]*SF[0]); // scale by contribution param cClone->Add(bClone); // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum()); dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi); dClone->GetYaxis()->SetRangeUser(-0.1,0.6); cClone->SetLineColor(kRed); dClone->Draw(); cClone->Draw("same"); stat[3][0]->Draw("same"); //////// // 5.5-6.5 GeV Bin //////// gMinuit->SetFCN(chi2_P1); doFit(gMinuit,RbP[1],SF[1],EbP[1],eSF[1]); // assign plotting variables pTP[1] = 6.; // Plot results fitResultP->cd(2); /*dClone = (TH1D*) Hdphi[1]->Clone(); cClone = (TH1D*) projC[3]->Clone(); bClone = (TH1D*) projB[3]->Clone();*/ dClone = (TH1D*) projData2[3]->Clone(); cClone = (TH1D*) HpphiD[1]->Clone(); bClone = (TH1D*) HpphiB[1]->Clone(); stat[3][1] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0)); sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF); stat[3][1]->InsertText(statLabel); stat[3][1]->SetFillColor(kWhite); cClone->Scale((1.-RbP[1])*SF[1]); bClone->Scale(RbP[1]*SF[1]); // scale by contribution param cClone->Add(bClone); // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum()); dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi); dClone->GetYaxis()->SetRangeUser(-0.1,0.6); cClone->SetLineColor(kRed); dClone->Draw(); cClone->Draw("same"); stat[3][1]->Draw("same"); //////// // Old Data, Old Template /////// gMinuit->SetFCN(chi2_PP); doFit(gMinuit,RbPP[0],SFPP[0],EbPP[0],eSFPP[0]); // assign plotting variables pTPP[0] = 3.; // Plot results fitResultP->cd(3); dClone = (TH1D*) Hdphi[0]->Clone(); cClone = (TH1D*) HpphiD[0]->Clone(); bClone = (TH1D*) HpphiB[0]->Clone(); stat[3][2] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0)); sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF); stat[3][2]->InsertText(statLabel); stat[3][2]->SetFillColor(kWhite); cClone->Scale((1.-RbPP[0])*SFPP[0]); bClone->Scale(RbPP[0]*SFPP[0]); // scale by contribution param cClone->Add(bClone); // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum()); dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi); dClone->GetYaxis()->SetRangeUser(-0.1,0.6); cClone->SetLineColor(kRed); dClone->Draw(); cClone->Draw("same"); stat[3][2]->Draw("same"); // Bin at 6 GeV gMinuit->SetFCN(chi2_PP1); doFit(gMinuit,RbPP[1],SFPP[1],EbPP[1],eSFPP[1]); // assign plotting variables pTPP[1] = 6.; // Plot results fitResultP->cd(4); dClone = (TH1D*) Hdphi[1]->Clone(); cClone = (TH1D*) HpphiD[1]->Clone(); bClone = (TH1D*) HpphiB[1]->Clone(); stat[3][3] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0)); sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF); stat[3][3]->InsertText(statLabel); stat[3][3]->SetFillColor(kWhite); cClone->Scale((1.-RbPP[1])*SFPP[1]); bClone->Scale(RbPP[1]*SFPP[1]); // scale by contribution param cClone->Add(bClone); // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum()); dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi); dClone->GetYaxis()->SetRangeUser(-0.1,0.6); cClone->SetLineColor(kRed); dClone->Draw(); cClone->Draw("same"); stat[3][3]->Draw("same"); // Get FONLL Calc Int_t l=0; char line[1000]; Float_t xF[100],yF[100],minF[100],maxF[100]; ifstream fp("/Users/zach/Research/pythia/200GeVTemplate/FONLL.txt",ios::in); while (!fp.eof()){ fp.getline(line,1000); sscanf(line,"%f %f %f %f",&xF[l],&yF[l],&minF[l],&maxF[l]); // printf("L: %f %f\n",xF[l],yF[l]); l++; } fp.close(); // Get Previous Analysis Int_t p=0; Float_t xP[100],yP[100],dyP[100]; ifstream fp1("/Users/zach/Research/pythia/200GeVTemplate/run5_6.txt",ios::in); while (!fp1.eof()){ fp1.getline(line,1000); sscanf(line,"%f %f %f",&xP[p],&yP[p],&dyP[p]); // printf("L: %f %f\n",xF[l],yF[l]); p++; } fp1.close(); //cout << "at bottom contrib plot" << endl; TCanvas* c1 = new TCanvas("c1","Bottom Contribution",150,0,1150,1000); TGraphErrors *gr0 = new TGraphErrors(plotCount0-1,ptOFF1,Rb0,dx,eb0); TGraphErrors *gr2 = new TGraphErrors(plotCount2-1,ptOFF2,Rb2,dx,eb2); TGraphErrors *grC = new TGraphErrors(plotCount-1,pT,RbC,dx,ebC); TGraphErrors *grF = new TGraphErrors(l-1,xF,yF); TGraphErrors *grFmax = new TGraphErrors(l-1,xF,maxF); TGraphErrors *grFmin = new TGraphErrors(l-1,xF,minF); TGraphErrors *grP = new TGraphErrors(p-1,xP,yP,0,dyP); TGraphErrors *grPr = new TGraphErrors(2,pTP,RbP,0,EbP); TGraphErrors *grPPr = new TGraphErrors(2,pTPP,RbPP,0,EbPP); c1->cd(1); grP->SetTitle(""); grP->GetXaxis()->SetTitle("NPE p_{T} (GeV/c)"); grP->GetYaxis()->SetTitle("r_{B}"); gr0->SetMarkerStyle(20); gr0->SetMarkerSize(1); gr0->SetLineColor(kBlue); gr0->SetMarkerColor(kBlue); gr2->SetMarkerStyle(22); gr2->SetMarkerSize(1); gr2->SetLineColor(kRed); gr2->SetMarkerColor(kRed); grC->SetMarkerStyle(21); grC->SetMarkerSize(1); grC->SetLineColor(kRed); grC->SetMarkerColor(kRed); grP->GetXaxis()->SetLimits(0,10); grP->GetYaxis()->SetRangeUser(0,1); grF->SetLineStyle(1); grFmax->SetLineStyle(2); grFmin->SetLineStyle(2); grP->SetMarkerStyle(33); grP->SetMarkerColor(kBlack); grPr->SetMarkerStyle(29); grPr->SetMarkerColor(9); grPr->SetLineColor(9); grPPr->SetMarkerStyle(29); grPPr->SetMarkerColor(49); grPPr->SetLineColor(49); grP->Draw("AP"); //grC->Draw("same P"); gr2->Draw("same P"); grF->Draw("same"); grFmax->Draw("same"); grFmin->Draw("same"); gr0->Draw("same P"); // grPr->Draw("same P"); //grPPr->Draw("same P"); TLegend* leg2 = new TLegend(0.15,0.68,0.48,0.85); leg2->AddEntry(gr0,"STAR Run 12 - Low p_{T} Analysis","pe"); leg2->AddEntry(gr2,"STAR Run 12 - High p_{T} Analysis","pe"); //leg2->AddEntry(grC,"Combined Trigs","pe"); leg2->AddEntry(grP,"STAR Run 6 Analysis (Stat. Uncertainty)","pe"); // leg2->AddEntry(grPr,"Run 12 Data, Run 5/6 Templates)","pe"); //leg2->AddEntry(grPPr,"Run 5/6 Refit (prev Template)","pe"); leg2->AddEntry(grF,"FONLL Calculation","l"); leg2->Draw("same"); // Write to Root File if open if(makeROOT){ file3->Close(); file4->Close(); file->cd(); grP->Write("PreviousData"); //grC->Write("same P"); gr2->Write("HT2"); grF->Write("FONLL"); grFmax->Write("FONLLmax"); grFmin->Write("FONLLmin"); gr0->Write("HT0"); // grPr->Write("PrevTempMyData"); //grPPr->Write("PrevTempPreData"); } // Make PDF with output canvases if(makePDF) { //Set front page TCanvas* fp = new TCanvas("fp","Front Page",100,0,1000,900); fp->cd(); TBox *bLabel = new TBox(0.01, 0.88, 0.99, 0.99); bLabel->SetFillColor(38); bLabel->Draw(); TLatex tl; tl.SetNDC(); tl.SetTextColor(kWhite); tl.SetTextSize(0.033); char tlName[100]; char tlName2[100]; TString titlename = FileName; int found = titlename.Last('/'); if(found >= 0){ titlename.Replace(0, found+1, ""); } sprintf(tlName, "RUN 12 NPE-h #Delta#phi Correlations"); tl.SetTextSize(0.05); tl.SetTextColor(kWhite); tl.DrawLatex(0.05, 0.92,tlName); TBox *bFoot = new TBox(0.01, 0.01, 0.99, 0.12); bFoot->SetFillColor(38); bFoot->Draw(); tl.SetTextColor(kWhite); tl.SetTextSize(0.05); tl.DrawLatex(0.05, 0.05, (new TDatime())->AsString()); tl.SetTextColor(kBlack); tl.SetTextSize(0.03); tl.DrawLatex(0.1, 0.14, titlename); sprintf(tlName,"TEST"); tl.DrawLatex(0.1, 0.8,tlName); // Place canvases in order TCanvas* temp = new TCanvas(); sprintf(name, "FFOutput/%s.pdf[", FileName); temp->Print(name); sprintf(name, "FFOutput/%s.pdf", FileName); temp = deltaPhi; temp->Print(name); temp = fitResult0; temp->Print(name); temp = fitResult2; temp->Print(name); // temp = fitResultC; // temp->Print(name); temp = c1; temp->Print(name); sprintf(name, "FFOutput/%s.pdf]", FileName); temp->Print(name); } if(makeROOT) { file->Write(); file->Close(); } }
void acceptance_mass() { //=========Macro generated from canvas: c2/c2 //========= (Mon Oct 26 11:11:00 2015) by ROOT version6.02/05 TCanvas *c2 = new TCanvas("c2", "c2",20,42,700,500); gStyle->SetOptStat(0); c2->Range(-1.3125,-0.025,9.8125,0.225); c2->SetFillColor(0); c2->SetBorderMode(0); c2->SetBorderSize(2); c2->SetFrameBorderMode(0); c2->SetFrameBorderMode(0); TH2F *dummy42 = new TH2F("dummy42","dummy4",178,-0.2,8.7,100,0,0.2); dummy42->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); dummy42->SetLineColor(ci); dummy42->GetXaxis()->SetTitle("Mass [GeV]"); dummy42->GetXaxis()->SetLabelFont(42); dummy42->GetXaxis()->SetLabelSize(0.035); dummy42->GetXaxis()->SetTitleSize(0.035); dummy42->GetXaxis()->SetTitleFont(42); dummy42->GetYaxis()->SetTitle("#epsilon_{rec} = N_{rec}/N_{tot}"); dummy42->GetYaxis()->SetLabelFont(42); dummy42->GetYaxis()->SetLabelSize(0.035); dummy42->GetYaxis()->SetTitleSize(0.035); dummy42->GetYaxis()->SetTitleFont(42); dummy42->GetZaxis()->SetLabelFont(42); dummy42->GetZaxis()->SetLabelSize(0.035); dummy42->GetZaxis()->SetTitleSize(0.035); dummy42->GetZaxis()->SetTitleFont(42); dummy42->Draw(""); Double_t Graph0_fx1006[5] = { 0.25, 0.275, 0.3, 2, 8.5}; Double_t Graph0_fy1006[5] = { 0.0865404, 0.08208333, 0.0749858, 0.05958333, 0.1375897}; Double_t Graph0_fex1006[5] = { 0, 0, 0, 0, 0}; Double_t Graph0_fey1006[5] = { 0.0009990599, 0.0009753636, 0.0009926071, 0.0008541653, 0.001244048}; TGraphErrors *gre = new TGraphErrors(5,Graph0_fx1006,Graph0_fy1006,Graph0_fex1006,Graph0_fey1006); gre->SetName("Graph0"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1006 = new TH1F("Graph_Graph1006","Graph",100,0,9.325); Graph_Graph1006->SetMinimum(0.05071871); Graph_Graph1006->SetMaximum(0.1468442); Graph_Graph1006->SetDirectory(0); Graph_Graph1006->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1006->SetLineColor(ci); Graph_Graph1006->GetXaxis()->SetLabelFont(42); Graph_Graph1006->GetXaxis()->SetLabelSize(0.035); Graph_Graph1006->GetXaxis()->SetTitleSize(0.035); Graph_Graph1006->GetXaxis()->SetTitleFont(42); Graph_Graph1006->GetYaxis()->SetLabelFont(42); Graph_Graph1006->GetYaxis()->SetLabelSize(0.035); Graph_Graph1006->GetYaxis()->SetTitleSize(0.035); Graph_Graph1006->GetYaxis()->SetTitleFont(42); Graph_Graph1006->GetZaxis()->SetLabelFont(42); Graph_Graph1006->GetZaxis()->SetLabelSize(0.035); Graph_Graph1006->GetZaxis()->SetTitleSize(0.035); Graph_Graph1006->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1006); gre->Draw(" pl"); Double_t Graph1_fx1007[4] = { 0.25, 0.275, 2, 8.5}; Double_t Graph1_fy1007[4] = { 0.08294682, 0.07862374, 0.06207908, 0.137474}; Double_t Graph1_fex1007[4] = { 0, 0, 0, 0}; Double_t Graph1_fey1007[4] = { 0.0009899688, 0.000956385, 0.0008617826, 0.001242555}; gre = new TGraphErrors(4,Graph1_fx1007,Graph1_fy1007,Graph1_fex1007,Graph1_fey1007); gre->SetName("Graph1"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineColor(2); gre->SetMarkerColor(2); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1007 = new TH1F("Graph_Graph1007","Graph",100,0,9.325); Graph_Graph1007->SetMinimum(0.05346738); Graph_Graph1007->SetMaximum(0.1464664); Graph_Graph1007->SetDirectory(0); Graph_Graph1007->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1007->SetLineColor(ci); Graph_Graph1007->GetXaxis()->SetLabelFont(42); Graph_Graph1007->GetXaxis()->SetLabelSize(0.035); Graph_Graph1007->GetXaxis()->SetTitleSize(0.035); Graph_Graph1007->GetXaxis()->SetTitleFont(42); Graph_Graph1007->GetYaxis()->SetLabelFont(42); Graph_Graph1007->GetYaxis()->SetLabelSize(0.035); Graph_Graph1007->GetYaxis()->SetTitleSize(0.035); Graph_Graph1007->GetYaxis()->SetTitleFont(42); Graph_Graph1007->GetZaxis()->SetLabelFont(42); Graph_Graph1007->GetZaxis()->SetLabelSize(0.035); Graph_Graph1007->GetZaxis()->SetTitleSize(0.035); Graph_Graph1007->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1007); gre->Draw(" pl"); Double_t Graph2_fx1008[5] = { 0.25, 0.275, 0.3, 2, 8.5}; Double_t Graph2_fy1008[5] = { 0.06949495, 0.06748737, 0.0642268, 0.06051768, 0.1364046}; Double_t Graph2_fex1008[5] = { 0, 0, 0, 0, 0}; Double_t Graph2_fey1008[5] = { 0.0009035941, 0.000891407, 0.0008800606, 0.000847272, 0.00123208}; gre = new TGraphErrors(5,Graph2_fx1008,Graph2_fy1008,Graph2_fex1008,Graph2_fey1008); gre->SetName("Graph2"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineColor(3); gre->SetMarkerColor(3); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1008 = new TH1F("Graph_Graph1008","Graph",100,0,9.325); Graph_Graph1008->SetMinimum(0.05187377); Graph_Graph1008->SetMaximum(0.1454334); Graph_Graph1008->SetDirectory(0); Graph_Graph1008->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1008->SetLineColor(ci); Graph_Graph1008->GetXaxis()->SetLabelFont(42); Graph_Graph1008->GetXaxis()->SetLabelSize(0.035); Graph_Graph1008->GetXaxis()->SetTitleSize(0.035); Graph_Graph1008->GetXaxis()->SetTitleFont(42); Graph_Graph1008->GetYaxis()->SetLabelFont(42); Graph_Graph1008->GetYaxis()->SetLabelSize(0.035); Graph_Graph1008->GetYaxis()->SetTitleSize(0.035); Graph_Graph1008->GetYaxis()->SetTitleFont(42); Graph_Graph1008->GetZaxis()->SetLabelFont(42); Graph_Graph1008->GetZaxis()->SetLabelSize(0.035); Graph_Graph1008->GetZaxis()->SetTitleSize(0.035); Graph_Graph1008->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1008); gre->Draw(" pl"); Double_t Graph3_fx1009[5] = { 0.25, 0.275, 0.3, 2, 8.5}; Double_t Graph3_fy1009[5] = { 0.04645202, 0.04597222, 0.04502717, 0.05941919, 0.1359975}; Double_t Graph3_fex1009[5] = { 0, 0, 0, 0, 0}; Double_t Graph3_fey1009[5] = { 0.000747844, 0.0007441589, 0.0007643529, 0.0008400378, 0.001218037}; gre = new TGraphErrors(5,Graph3_fx1009,Graph3_fy1009,Graph3_fex1009,Graph3_fey1009); gre->SetName("Graph3"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineColor(4); gre->SetMarkerColor(4); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1009 = new TH1F("Graph_Graph1009","Graph",100,0,9.325); Graph_Graph1009->SetMinimum(0.03496755); Graph_Graph1009->SetMaximum(0.1465108); Graph_Graph1009->SetDirectory(0); Graph_Graph1009->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1009->SetLineColor(ci); Graph_Graph1009->GetXaxis()->SetLabelFont(42); Graph_Graph1009->GetXaxis()->SetLabelSize(0.035); Graph_Graph1009->GetXaxis()->SetTitleSize(0.035); Graph_Graph1009->GetXaxis()->SetTitleFont(42); Graph_Graph1009->GetYaxis()->SetLabelFont(42); Graph_Graph1009->GetYaxis()->SetLabelSize(0.035); Graph_Graph1009->GetYaxis()->SetTitleSize(0.035); Graph_Graph1009->GetYaxis()->SetTitleFont(42); Graph_Graph1009->GetZaxis()->SetLabelFont(42); Graph_Graph1009->GetZaxis()->SetLabelSize(0.035); Graph_Graph1009->GetZaxis()->SetTitleSize(0.035); Graph_Graph1009->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1009); gre->Draw(" pl"); Double_t Graph4_fx1010[5] = { 0.25, 0.275, 0.3, 2, 8.5}; Double_t Graph4_fy1010[5] = { 0.0157633, 0.01659091, 0.01693182, 0.05516582, 0.1364646}; Double_t Graph4_fex1010[5] = { 0, 0, 0, 0, 0}; Double_t Graph4_fey1010[5] = { 0.0004493916, 0.0004538785, 0.0004584384, 0.0008153701, 0.001219797}; gre = new TGraphErrors(5,Graph4_fx1010,Graph4_fy1010,Graph4_fex1010,Graph4_fey1010); gre->SetName("Graph4"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineColor(6); gre->SetMarkerColor(6); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1010 = new TH1F("Graph_Graph1010","Graph",100,0,9.325); Graph_Graph1010->SetMinimum(0.003076858); Graph_Graph1010->SetMaximum(0.1499215); Graph_Graph1010->SetDirectory(0); Graph_Graph1010->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1010->SetLineColor(ci); Graph_Graph1010->GetXaxis()->SetLabelFont(42); Graph_Graph1010->GetXaxis()->SetLabelSize(0.035); Graph_Graph1010->GetXaxis()->SetTitleSize(0.035); Graph_Graph1010->GetXaxis()->SetTitleFont(42); Graph_Graph1010->GetYaxis()->SetLabelFont(42); Graph_Graph1010->GetYaxis()->SetLabelSize(0.035); Graph_Graph1010->GetYaxis()->SetTitleSize(0.035); Graph_Graph1010->GetYaxis()->SetTitleFont(42); Graph_Graph1010->GetZaxis()->SetLabelFont(42); Graph_Graph1010->GetZaxis()->SetLabelSize(0.035); Graph_Graph1010->GetZaxis()->SetTitleSize(0.035); Graph_Graph1010->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1010); gre->Draw(" pl"); Double_t Graph5_fx1011[4] = { 0.25, 0.275, 2, 8.5}; Double_t Graph5_fy1011[4] = { 0.005542929, 0.005892857, 0.04303571, 0.132096}; Double_t Graph5_fex1011[4] = { 0, 0, 0, 0}; Double_t Graph5_fey1011[4] = { 0.0002638154, 0.0002733515, 0.0007247769, 0.001203145}; gre = new TGraphErrors(4,Graph5_fx1011,Graph5_fy1011,Graph5_fex1011,Graph5_fey1011); gre->SetName("Graph5"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineColor(7); gre->SetMarkerColor(7); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1011 = new TH1F("Graph_Graph1011","Graph",100,0,9.325); Graph_Graph1011->SetMinimum(0); Graph_Graph1011->SetMaximum(0.1461011); Graph_Graph1011->SetDirectory(0); Graph_Graph1011->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1011->SetLineColor(ci); Graph_Graph1011->GetXaxis()->SetLabelFont(42); Graph_Graph1011->GetXaxis()->SetLabelSize(0.035); Graph_Graph1011->GetXaxis()->SetTitleSize(0.035); Graph_Graph1011->GetXaxis()->SetTitleFont(42); Graph_Graph1011->GetYaxis()->SetLabelFont(42); Graph_Graph1011->GetYaxis()->SetLabelSize(0.035); Graph_Graph1011->GetYaxis()->SetTitleSize(0.035); Graph_Graph1011->GetYaxis()->SetTitleFont(42); Graph_Graph1011->GetZaxis()->SetLabelFont(42); Graph_Graph1011->GetZaxis()->SetLabelSize(0.035); Graph_Graph1011->GetZaxis()->SetTitleSize(0.035); Graph_Graph1011->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1011); gre->Draw(" pl"); Double_t Graph6_fx1012[5] = { 0.25, 0.275, 0.3, 2, 8.5}; Double_t Graph6_fy1012[5] = { 0.00155303, 0.001868687, 0.002222281, 0.02356061, 0.1211862}; Double_t Graph6_fex1012[5] = { 0, 0, 0, 0, 0}; Double_t Graph6_fey1012[5] = { 0.0001399232, 0.0001534615, 0.0001707546, 0.000538956, 0.001165513}; gre = new TGraphErrors(5,Graph6_fx1012,Graph6_fy1012,Graph6_fex1012,Graph6_fey1012); gre->SetName("Graph6"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineColor(8); gre->SetMarkerColor(8); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1012 = new TH1F("Graph_Graph1012","Graph",100,0,9.325); Graph_Graph1012->SetMinimum(0); Graph_Graph1012->SetMaximum(0.1344456); Graph_Graph1012->SetDirectory(0); Graph_Graph1012->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1012->SetLineColor(ci); Graph_Graph1012->GetXaxis()->SetLabelFont(42); Graph_Graph1012->GetXaxis()->SetLabelSize(0.035); Graph_Graph1012->GetXaxis()->SetTitleSize(0.035); Graph_Graph1012->GetXaxis()->SetTitleFont(42); Graph_Graph1012->GetYaxis()->SetLabelFont(42); Graph_Graph1012->GetYaxis()->SetLabelSize(0.035); Graph_Graph1012->GetYaxis()->SetTitleSize(0.035); Graph_Graph1012->GetYaxis()->SetTitleFont(42); Graph_Graph1012->GetZaxis()->SetLabelFont(42); Graph_Graph1012->GetZaxis()->SetLabelSize(0.035); Graph_Graph1012->GetZaxis()->SetTitleSize(0.035); Graph_Graph1012->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1012); gre->Draw(" pl"); Double_t Graph7_fx1013[4] = { 0.25, 0.275, 2, 8.5}; Double_t Graph7_fy1013[4] = { 0.0009974747, 0.0009974747, 0.01513298, 0.1061111}; Double_t Graph7_fex1013[4] = { 0, 0, 0, 0}; Double_t Graph7_fey1013[4] = { 0.0001121687, 0.0001121687, 0.0004451866, 0.001147773}; gre = new TGraphErrors(4,Graph7_fx1013,Graph7_fy1013,Graph7_fex1013,Graph7_fey1013); gre->SetName("Graph7"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineColor(9); gre->SetMarkerColor(9); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1013 = new TH1F("Graph_Graph1013","Graph",100,0,9.325); Graph_Graph1013->SetMinimum(0); Graph_Graph1013->SetMaximum(0.1178962); Graph_Graph1013->SetDirectory(0); Graph_Graph1013->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1013->SetLineColor(ci); Graph_Graph1013->GetXaxis()->SetLabelFont(42); Graph_Graph1013->GetXaxis()->SetLabelSize(0.035); Graph_Graph1013->GetXaxis()->SetTitleSize(0.035); Graph_Graph1013->GetXaxis()->SetTitleFont(42); Graph_Graph1013->GetYaxis()->SetLabelFont(42); Graph_Graph1013->GetYaxis()->SetLabelSize(0.035); Graph_Graph1013->GetYaxis()->SetTitleSize(0.035); Graph_Graph1013->GetYaxis()->SetTitleFont(42); Graph_Graph1013->GetZaxis()->SetLabelFont(42); Graph_Graph1013->GetZaxis()->SetLabelSize(0.035); Graph_Graph1013->GetZaxis()->SetTitleSize(0.035); Graph_Graph1013->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1013); gre->Draw(" pl"); Double_t Graph8_fx1014[5] = { 0.25, 0.275, 0.3, 2, 8.5}; Double_t Graph8_fy1014[5] = { 0.0002651515, 0.0004419192, 0.0003815789, 0.006989796, 0.07766414}; Double_t Graph8_fex1014[5] = { 0, 0, 0, 0, 0}; Double_t Graph8_fey1014[5] = { 5.785313e-05, 7.468147e-05, 7.084391e-05, 0.0002975439, 0.0009510256}; gre = new TGraphErrors(5,Graph8_fx1014,Graph8_fy1014,Graph8_fex1014,Graph8_fey1014); gre->SetName("Graph8"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineColor(40); gre->SetMarkerColor(40); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1014 = new TH1F("Graph_Graph1014","Graph",100,0,9.325); Graph_Graph1014->SetMinimum(0); Graph_Graph1014->SetMaximum(0.08645595); Graph_Graph1014->SetDirectory(0); Graph_Graph1014->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1014->SetLineColor(ci); Graph_Graph1014->GetXaxis()->SetLabelFont(42); Graph_Graph1014->GetXaxis()->SetLabelSize(0.035); Graph_Graph1014->GetXaxis()->SetTitleSize(0.035); Graph_Graph1014->GetXaxis()->SetTitleFont(42); Graph_Graph1014->GetYaxis()->SetLabelFont(42); Graph_Graph1014->GetYaxis()->SetLabelSize(0.035); Graph_Graph1014->GetYaxis()->SetTitleSize(0.035); Graph_Graph1014->GetYaxis()->SetTitleFont(42); Graph_Graph1014->GetZaxis()->SetLabelFont(42); Graph_Graph1014->GetZaxis()->SetLabelSize(0.035); Graph_Graph1014->GetZaxis()->SetTitleSize(0.035); Graph_Graph1014->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1014); gre->Draw(" pl"); Double_t Graph9_fx1015[2] = { 0.25, 2}; Double_t Graph9_fy1015[2] = { 6.47017e-05, 0.002367956}; Double_t Graph9_fex1015[2] = { 0, 0}; Double_t Graph9_fey1015[2] = { 1.3794e-05, 6.810597e-05}; gre = new TGraphErrors(2,Graph9_fx1015,Graph9_fy1015,Graph9_fex1015,Graph9_fey1015); gre->SetName("Graph9"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1015 = new TH1F("Graph_Graph1015","Graph",100,0.075,2.175); Graph_Graph1015->SetMinimum(0); Graph_Graph1015->SetMaximum(0.002674577); Graph_Graph1015->SetDirectory(0); Graph_Graph1015->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1015->SetLineColor(ci); Graph_Graph1015->GetXaxis()->SetLabelFont(42); Graph_Graph1015->GetXaxis()->SetLabelSize(0.035); Graph_Graph1015->GetXaxis()->SetTitleSize(0.035); Graph_Graph1015->GetXaxis()->SetTitleFont(42); Graph_Graph1015->GetYaxis()->SetLabelFont(42); Graph_Graph1015->GetYaxis()->SetLabelSize(0.035); Graph_Graph1015->GetYaxis()->SetTitleSize(0.035); Graph_Graph1015->GetYaxis()->SetTitleFont(42); Graph_Graph1015->GetZaxis()->SetLabelFont(42); Graph_Graph1015->GetZaxis()->SetLabelSize(0.035); Graph_Graph1015->GetZaxis()->SetTitleSize(0.035); Graph_Graph1015->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1015); gre->Draw(" pl"); Double_t Graph10_fx1016[2] = { 0.25, 2}; Double_t Graph10_fy1016[2] = { 2.397917e-05, 0.0007142042}; Double_t Graph10_fex1016[2] = { 0, 0}; Double_t Graph10_fey1016[2] = { 9.063167e-06, 4.035479e-05}; gre = new TGraphErrors(2,Graph10_fx1016,Graph10_fy1016,Graph10_fex1016,Graph10_fey1016); gre->SetName("Graph10"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetMarkerStyle(7); gre->SetMarkerSize(5); TH1F *Graph_Graph1016 = new TH1F("Graph_Graph1016","Graph",100,0.075,2.175); Graph_Graph1016->SetMinimum(0); Graph_Graph1016->SetMaximum(0.0008285233); Graph_Graph1016->SetDirectory(0); Graph_Graph1016->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1016->SetLineColor(ci); Graph_Graph1016->GetXaxis()->SetLabelFont(42); Graph_Graph1016->GetXaxis()->SetLabelSize(0.035); Graph_Graph1016->GetXaxis()->SetTitleSize(0.035); Graph_Graph1016->GetXaxis()->SetTitleFont(42); Graph_Graph1016->GetYaxis()->SetLabelFont(42); Graph_Graph1016->GetYaxis()->SetLabelSize(0.035); Graph_Graph1016->GetYaxis()->SetTitleSize(0.035); Graph_Graph1016->GetYaxis()->SetTitleFont(42); Graph_Graph1016->GetZaxis()->SetLabelFont(42); Graph_Graph1016->GetZaxis()->SetLabelSize(0.035); Graph_Graph1016->GetZaxis()->SetTitleSize(0.035); Graph_Graph1016->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1016); gre->Draw(" pl"); TLegend *leg = new TLegend(0.158046,0.5369979,0.5071839,0.8372093,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.045); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("Graph0","c#Tau=0.00 mm","PL"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(7); entry->SetMarkerSize(5); entry->SetTextFont(42); entry=leg->AddEntry("Graph1","c#Tau=0.05 mm","PL"); entry->SetLineColor(2); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(2); entry->SetMarkerStyle(7); entry->SetMarkerSize(5); entry->SetTextFont(42); entry=leg->AddEntry("Graph2","c#Tau=0.10 mm","PL"); entry->SetLineColor(3); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(3); entry->SetMarkerStyle(7); entry->SetMarkerSize(5); entry->SetTextFont(42); entry=leg->AddEntry("Graph3","c#Tau=0.20 mm","PL"); entry->SetLineColor(4); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(4); entry->SetMarkerStyle(7); entry->SetMarkerSize(5); entry->SetTextFont(42); entry=leg->AddEntry("Graph4","c#Tau=0.50 mm","PL"); entry->SetLineColor(6); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(6); entry->SetMarkerStyle(7); entry->SetMarkerSize(5); entry->SetTextFont(42); entry=leg->AddEntry("Graph5","c#Tau=1.00 mm","PL"); entry->SetLineColor(7); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(7); entry->SetMarkerStyle(7); entry->SetMarkerSize(5); entry->SetTextFont(42); entry=leg->AddEntry("Graph6","c#Tau=2.00 mm","PL"); entry->SetLineColor(8); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(8); entry->SetMarkerStyle(7); entry->SetMarkerSize(5); entry->SetTextFont(42); entry=leg->AddEntry("Graph7","c#Tau=3.00 mm","PL"); entry->SetLineColor(9); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(9); entry->SetMarkerStyle(7); entry->SetMarkerSize(5); entry->SetTextFont(42); entry=leg->AddEntry("Graph8","c#Tau=5.00 mm","PL"); entry->SetLineColor(40); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(40); entry->SetMarkerStyle(7); entry->SetMarkerSize(5); entry->SetTextFont(42); leg->Draw(); TPaveText *pt = new TPaveText(0.4195977,0.9339831,0.5804023,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *AText = pt->AddText("dummy4"); pt->Draw(); c2->Modified(); c2->cd(); c2->SetSelected(c2); }