void DrawClus(bool Flag_err,TTree* tree,Double_t *errx,char* varToPlot, char* cond, Int_t kColor, Int_t kMarker, char* Title,char* xTitle,char* yTitle, TLegend *leg, char* cLeg,Double_t downlim,Double_t uplim){ TGraphErrors* g; tree->Draw(varToPlot, cond,"goff"); cout << tree->GetSelectedRows() << endl; if(tree->GetSelectedRows()){ if(Flag_err) g=new TGraphErrors(tree->GetSelectedRows(),tree->GetV1(),tree->GetV2(),errx,tree->GetV3()); else g=new TGraphErrors(tree->GetSelectedRows(),tree->GetV1(),tree->GetV2(),errx,errx); g->SetMarkerStyle(kMarker); g->SetMarkerSize(0.9); g->SetMarkerColor(kColor); g->SetTitle(Title); g->GetXaxis()->SetTitle(xTitle); g->GetXaxis()->CenterTitle(); g->GetYaxis()->SetTitle(yTitle); g->GetYaxis()->CenterTitle(); g->GetYaxis()->SetRangeUser(downlim,uplim); g->Draw("Ap"); leg->AddEntry(g, cLeg,"p"); }else{ cout << "NO rows selected for leave " << varToPlot << endl; } }
//______________________________________________________________________________ // Construct a graph from vectors and y error vector TGraphErrors *LoadGraphFromVectorsWithError(vector<double> xVector, vector<double> yVector, vector<double> yErrorVector, string xTitle, string yTitle) { int n = xVector.size(); if ((xVector.size() == yVector.size()) && (yVector.size() == yErrorVector.size())) { //Create a graph TGraphErrors *gr = new TGraphErrors(n, &xVector[0], &yVector[0], 0, &yErrorVector[0]); gr->SetTitle(""); gr->SetMarkerStyle(20); gr->SetMarkerSize(1.2); gr->SetLineWidth(2); gr->GetXaxis()->SetTitle(xTitle.c_str()); gr->GetXaxis()->CenterTitle(); gr->GetYaxis()->SetTitle(yTitle.c_str()); gr->GetYaxis()->CenterTitle(); return gr; delete gr; } else { TGraphErrors *gr0 = new TGraphErrors(); return gr0; delete gr0; } }
void Draw_CMS_Y1S_RaaVsRap(TLegend *lgd) { const int nbinsRap=6; Double_t RapCMS[nbinsRap]={0.2,0.6,1.0,1.4,1.8,2.2}; Double_t ErrRapCMS[nbinsRap]={0}; Double_t RaaRapCMS[nbinsRap] = {0.402,0.377,0.452,0.461,0.466,0.35}; Double_t RaaRapStatErrCMS[nbinsRap] = {0.025,0.025,0.030,0.034,0.039,0.053}; Double_t RaaRapSystErrCMS[nbinsRap] = {0.0404,0.038,0.046,0.0466,0.0484,0.0373}; TGraphErrors *grRaaRapCMS = new TGraphErrors(nbinsRap, RapCMS, RaaRapCMS, ErrRapCMS, RaaRapStatErrCMS); grRaaRapCMS->SetMarkerStyle(20); grRaaRapCMS->SetMarkerColor(4); grRaaRapCMS->GetYaxis()->SetRangeUser(0,3.0); grRaaRapCMS->GetXaxis()->SetTitle("p_{T}(GeV/c)"); grRaaRapCMS->GetYaxis()->SetTitle("R_{AA}"); TAxis *Xaxis2 = grRaaRapCMS->GetXaxis(); Xaxis2->SetLimits(0.,2.4); grRaaRapCMS->Draw("AP"); TLine *lh4 = new TLine(0.0,1.0,20.0,1.0); lh4->SetLineColor(1); lh4->SetLineStyle(1); lh4->SetLineWidth(2); lh4->Draw("same"); TLatex *tb= new TLatex; tb->SetNDC(); tb->SetTextAlign(12); tb->SetTextColor(1); tb->SetTextSize(0.040); //tb->DrawLatex(0.55,0.22,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); //tb->DrawLatex(0.55,0.16,"#varUpsilon #rightarrow #mu^{+} #mu^{-}, p_{T}^{#varUpsilon} > 0.0 GeV/c"); TBox *RaaRapCMSSys[nbinsRap]; for(int j=0;j<nbinsRap;j++){ RaaRapCMSSys[j] = new TBox(RapCMS[j]-0.1, RaaRapCMS[j]-RaaRapSystErrCMS[j], RapCMS[j]+0.1, RaaRapCMS[j]+RaaRapSystErrCMS[j]); } for(int j=0;j<nbinsRap;j++){ RaaRapCMSSys[j]->SetFillStyle(0000); RaaRapCMSSys[j]->SetLineColor(4); RaaRapCMSSys[j]->Draw("same"); } TBox *CMSGlobalSysRap; CMSGlobalSysRap = new TBox(18-0.2, 1 - 0.083, 18+0.2, 1 + 0.083); CMSGlobalSysRap->SetFillStyle(3001); CMSGlobalSysRap->SetLineColor(4); CMSGlobalSysRap->SetFillColor(4); //CMSGlobalSysRap->Draw("same"); lgd->AddEntry(grRaaRapCMS,"CMS Data", "P"); }
void Draw_ALICEFor_JPsi_RaaVsNpart(TLegend *lgd) { int nbinsALICE=9; Double_t NPartALICE[10]={357,262,187,128,86,53,30,16,8}; Double_t ErrNPartALICE[10]={0}; Double_t RaaALICE[10] = {0.47,0.48,0.51,0.51,0.52,0.61,0.70,0.74,0.94}; Double_t SystErrALICE[10] = {0.03,0.02,0.02,0.02,0.03,0.05,0.06,0.09,0.1}; TGraphErrors *grRaaALICE = new TGraphErrors(nbinsALICE, NPartALICE, RaaALICE, ErrNPartALICE, SystErrALICE); grRaaALICE->SetMarkerStyle(20); grRaaALICE->SetMarkerColor(4); grRaaALICE->GetYaxis()->SetRangeUser(0,1.7); TAxis *Xaxis2 = grRaaALICE->GetXaxis(); Xaxis2->SetLimits(0.,430.0); grRaaALICE->GetXaxis()->SetTitle("N_{Part}"); grRaaALICE->GetYaxis()->SetTitle("R_{AA}"); grRaaALICE->Draw("AP"); TLine *lh3 = new TLine(0.0,1.0,420,1.0); lh3->SetLineColor(1); lh3->SetLineStyle(1); lh3->SetLineWidth(1.5); lh3->Draw("same"); //TLatex *tb= new TLatex; //tb->SetNDC(); //tb->SetTextAlign(12); //tb->SetTextColor(1); //tb->SetTextSize(0.040); //tb->DrawLatex(0.22,0.22,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); //tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c"); TBox *RaaJPsiALICESys[12]; for(int j=0;j<9;j++){ RaaJPsiALICESys[j] = new TBox(NPartALICE[j]-3, RaaALICE[j]-SystErrALICE[j], NPartALICE[j]+3, RaaALICE[j]+SystErrALICE[j]); } for(int j=0;j<9;j++){ RaaJPsiALICESys[j]->SetFillStyle(0000); RaaJPsiALICESys[j]->SetLineColor(4); RaaJPsiALICESys[j]->Draw("same"); } TBox *ALICEGlobalSysJPsi; ALICEGlobalSysJPsi = new TBox(400-5, 1 - 0.14, 400+5, 1 + 0.14); ALICEGlobalSysJPsi->SetFillStyle(3001); ALICEGlobalSysJPsi->SetLineColor(4); ALICEGlobalSysJPsi->SetFillColor(4); ALICEGlobalSysJPsi->Draw("same"); Draw_ALICEMid_JPsi_RaaVsNpart(lgd); lgd->AddEntry(grRaaALICE,"ALICE Data p_{T}^{J/#psi} > 0.0 GeV/c, 2.5 #leq y^{J/#psi} #leq 4.0","P"); }
void Draw_ALICEMid_JPsi_RaaVsNpart(TLegend *lgd) { //ALICE MID rapidity int nbinsALICEMid=3; Double_t NPartALICEMid[3]={357,193,46}; Double_t ErrNPartALICEMid[3]={0}; Double_t RaaALICEMid[3] = {0.82,0.65,0.73}; Double_t SystErrALICEMid[3] = {0.15,0.10,0.16}; TGraphErrors *grRaaALICEMid = new TGraphErrors(nbinsALICEMid, NPartALICEMid, RaaALICEMid, ErrNPartALICEMid, SystErrALICEMid); grRaaALICEMid->SetMarkerStyle(20); grRaaALICEMid->SetMarkerColor(2); //grRaaALICEMid->SetLineColor(2); grRaaALICEMid->GetYaxis()->SetRangeUser(0,1.5); TAxis *Xaxis = grRaaALICEMid->GetXaxis(); Xaxis->SetLimits(0.,430.0); grRaaALICEMid->GetXaxis()->SetTitle("N_{Part}"); grRaaALICEMid->GetYaxis()->SetTitle("R_{AA}"); grRaaALICEMid->Draw("Psame"); //TLatex *tb= new TLatex; //tb->SetNDC(); //tb->SetTextAlign(12); //tb->SetTextColor(1); //tb->SetTextSize(0.040); //tb->DrawLatex(0.55,0.90,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); //tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c"); //tb->DrawLatex(0.55,0.85,"p_{T}^{J/#psi} > 0.0 GeV/c"); TLine *lh3 = new TLine(0.0,1.0,420,1.0); lh3->SetLineColor(1); lh3->SetLineStyle(1); lh3->SetLineWidth(1.5); lh3->Draw("same"); TBox *RaaJPsiALICEMidSys[12]; for(int j=0;j<3;j++){ RaaJPsiALICEMidSys[j] = new TBox(NPartALICEMid[j]-3, RaaALICEMid[j]-SystErrALICEMid[j], NPartALICEMid[j]+3, RaaALICEMid[j]+SystErrALICEMid[j]); } for(int j=0;j<3;j++){ RaaJPsiALICEMidSys[j]->SetFillStyle(0000); RaaJPsiALICEMidSys[j]->SetLineColor(2); RaaJPsiALICEMidSys[j]->Draw("same"); } TBox *ALICEMidGlobalSysJPsi; ALICEMidGlobalSysJPsi = new TBox(385-5, 1 - 0.26, 385+5, 1 + 0.26); ALICEMidGlobalSysJPsi->SetFillStyle(3001); ALICEMidGlobalSysJPsi->SetLineColor(2); ALICEMidGlobalSysJPsi->SetFillColor(2); ALICEMidGlobalSysJPsi->Draw("same"); lgd->AddEntry(grRaaALICEMid,"ALICE Data p_{T}^{J/#psi} > 0.0 GeV/c, |y^{J/#psi}| #leq 1.0","P"); }
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"); }
void Draw_CMS_JPsi_RaaVsRap(TLegend *lgd) { //=============== CMS Raa Vs Rap Data ===============================================================// //AvpT 10.92,9.65,8.92 int nbinsRapCMS=3; Double_t RapCMSD[3]={0.6,1.4,2.0}; Double_t ErrRapCMS[3]={0.6,0.2,0.4}; Double_t RaaRapCMS[3] = {0.31,0.33,0.36}; Double_t RaaRapStatErrCMS[3] = {0.02,0.03,0.03}; Double_t RaaRapSystErrCMS[3] = {0.03,0.04,0.04}; TGraphErrors *grRaaRapCMS = new TGraphErrors(nbinsRapCMS, RapCMSD, RaaRapCMS, ErrRapCMS, RaaRapStatErrCMS); grRaaRapCMS->SetMarkerStyle(20); grRaaRapCMS->SetMarkerColor(2); grRaaRapCMS->GetYaxis()->SetRangeUser(0,1.5); grRaaRapCMS->GetXaxis()->SetTitle("|y|"); grRaaRapCMS->GetYaxis()->SetTitle("R_{AA}"); TAxis *XaxisgrRaaRapCMS = grRaaRapCMS->GetXaxis(); XaxisgrRaaRapCMS->SetLimits(0.0,2.4); grRaaRapCMS->Draw("AP"); TLine *lh_grRaaRapCMS = new TLine(0.0,1.0,2.4,1.0); lh_grRaaRapCMS->SetLineColor(1); lh_grRaaRapCMS->SetLineStyle(1); lh_grRaaRapCMS->SetLineWidth(1.5); lh_grRaaRapCMS->Draw("same"); TLatex *tb= new TLatex; tb->SetNDC(); tb->SetTextAlign(12); tb->SetTextColor(1); tb->SetTextSize(0.040); tb->DrawLatex(0.20,0.20,"Pb+Pb #sqrt{s_{NN}} = 2.76 TeV"); tb->DrawLatex(0.20,0.15,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 6.5 GeV/c"); TBox *RaaRapJPsiCMSSys[4]; for(int j=0;j<3;j++){ RaaRapJPsiCMSSys[j] = new TBox(RapCMSD[j]-0.05, RaaRapCMS[j]-RaaRapSystErrCMS[j], RapCMSD[j]+0.05, RaaRapCMS[j]+RaaRapSystErrCMS[j]); } for(int j=0;j<3;j++){ RaaRapJPsiCMSSys[j]->SetFillStyle(0000); RaaRapJPsiCMSSys[j]->SetLineColor(2); RaaRapJPsiCMSSys[j]->Draw("same"); } TBox *CMSGlobalSysJPsiRap; CMSGlobalSysJPsiRap = new TBox(0.2-0.05, 1 - 0.05, 0.2+0.05, 1 + 0.05); CMSGlobalSysJPsiRap->SetFillStyle(3001); CMSGlobalSysJPsiRap->SetLineColor(2); CMSGlobalSysJPsiRap->SetFillColor(2); CMSGlobalSysJPsiRap->Draw("same"); lgd->AddEntry(grRaaRapCMS,"CMS Data", "P"); }
void Draw_CMS_JPsi_RaaVsNpart(TLegend *lgd) { int nbins = 12; Double_t RaaCMS[20]={0.23,0.24,0.29,0.33,0.38,0.40,0.45,0.41,0.52,0.52,0.64,0.64}; Double_t StatErrCMS[20]={0.01,0.01,0.02,0.02,0.02,0.03,0.03,0.03,0.04,0.04,0.05,0.05}; Double_t SystErrCMS[20]={0.02,0.03,0.03,0.03,0.04,0.04,0.05,0.04,0.05,0.05,0.07,0.13}; Double_t NPartCMS[20]={Npart(0,2),Npart(2,4),Npart(4,6),Npart(6,8),Npart(8,10),Npart(10,12), Npart(12,14),Npart(14,16),Npart(16,18),Npart(18,20),Npart(20,24), Npart(24,40)}; Double_t ErrNPartCMS[20]={0}; TGraphErrors *grRaaCMS = new TGraphErrors(nbins, NPartCMS, RaaCMS, ErrNPartCMS, StatErrCMS); grRaaCMS->SetMarkerStyle(21); grRaaCMS->SetMarkerColor(2); grRaaCMS->GetYaxis()->SetRangeUser(0,1.7); grRaaCMS->GetXaxis()->SetTitle("N_{Part}"); grRaaCMS->GetYaxis()->SetTitle("R_{AA}"); grRaaCMS->Draw("AP"); TBox *RaaJPsiSys[12]; for(int j=0;j<12;j++){ RaaJPsiSys[j] = new TBox(NPartCMS[j]-3, RaaCMS[j]-SystErrCMS[j], NPartCMS[j]+3, RaaCMS[j]+SystErrCMS[j]); } for(int j=0;j<12;j++){ RaaJPsiSys[j]->SetFillStyle(0000); RaaJPsiSys[j]->SetLineColor(6); RaaJPsiSys[j]->Draw("same"); } TLine *lh2 = new TLine(0.0,1.0,400,1.0); lh2->SetLineColor(1); lh2->SetLineStyle(1); lh2->SetLineWidth(2); lh2->Draw("same"); TBox *GlobalSysJPsi; GlobalSysJPsi = new TBox(400-5, 1 - 0.06, 400+5, 1 + 0.06); GlobalSysJPsi->SetFillStyle(3001); GlobalSysJPsi->SetLineColor(6); GlobalSysJPsi->SetFillColor(6); GlobalSysJPsi->Draw("same"); TLatex *tb= new TLatex; tb->SetNDC(); tb->SetTextAlign(12); tb->SetTextColor(1); tb->SetTextSize(0.040); tb->DrawLatex(0.17,0.23,"PbPb #sqrt{s_{NN}} = 2.76 TeV"); tb->DrawLatex(0.17,0.17,"p_{T}^{J/#psi} > 6.5 GeV/c"); lgd->AddEntry(grRaaCMS,"CMS Data", "P"); }
/// /// Plot the discrepancy between the observable and the predicted /// observable when making predictions about observables by scanning /// them. This checks if the chi2 term of the observable is tight enough. /// This only works for 1D scans for now. /// void ParameterEvolutionPlotter::plotObsScanCheck() { vector<RooSlimFitResult*> results = curveResults; cout << "ParameterEvolutionPlotter::plotObsScanCheck() : plotting ..." << endl; TCanvas *c2 = newNoWarnTCanvas("plotObsScanCheck"+getUniqueRootName(), title, 800,600); c2->SetLeftMargin(0.2); // get observable TGraphErrors *g = new TGraphErrors(results.size()); int iGraph = 0; for ( int i=0; i<results.size(); i++ ){ assert(results[i]); // get value of observable float obsValue = results[i]->getParVal(scanVar1); float obsError = w->var(scanVar1)->getError(); // get value of theory prediction setParameters(w,parsName,results[i]); TString thName = scanVar1; thName.ReplaceAll("_obs","_th"); if ( !w->function(thName) ){ cout << "ParameterEvolutionPlotter::plotObsScanCheck() : ERROR : theory value not found: " << thName << endl; continue; } float thValue = w->function(thName)->getVal(); g->SetPoint(iGraph, iGraph, obsValue-thValue); g->SetPointError(iGraph, 0., obsError); iGraph++; } g->SetTitle(scanVar1); g->GetXaxis()->SetTitle("scan step"); g->GetYaxis()->SetTitleSize(0.06); g->GetYaxis()->SetLabelSize(0.04); g->GetYaxis()->SetTitleOffset(1.5); g->GetYaxis()->SetTitle(scanVar1); Int_t ci = 927; TColor *col = new TColor(ci, 0, 0, 1, " ", 0.5); g->SetFillColor(ci); g->SetFillStyle(1001); g->Draw("a3"); g->Draw("lxsame"); c2->Update(); savePlot(c2, "parEvolutionObsSanCheck_"+name+"_"+scanVar1); }
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 DrawFunction(TCanvas *c,char* varToPlot, char* cond, Int_t kColor, char* Title, TLegend *leg, char* cLeg){ c->cd(); // TRACE 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("Ap"); //draw graph in current pad g->SetTitle(Title); g->GetXaxis()->SetTitle("run"); g->GetYaxis()->SetTitle(Title); // g->GetYaxis()->SetRangeUser(40., 100.); leg->AddEntry(g, cLeg); delete[] ErrX; } else { cout << "NO rows selected " << endl; } }
makePlot_check_all() { gStyle->SetOptStat(0); vector< TString > v_infile; // v_infile.push_back( TString("output/fitResults_run001_1layer_sheath.root") ); // v_infile.push_back( TString("output/fitResults_run002_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run003_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run004_2layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run005_2layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run006_3layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run007_4layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run008_2layer_cylinder.root") ); v_infile.push_back( TString("output/fitResults_run009_2layer_cylinder.root") ); // v_infile.push_back( TString("output/fitResults_run010_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run011_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run012_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run013_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run014_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run015_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run016_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run017_2layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run018_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run019_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run020_1layer_sheath.root") ); v_infile.push_back( TString("output/fitResults_run021_1layer.root") ); for ( unsigned f = 0; f < v_infile.size(); f++ ) { cout << "Plot " << v_infile.at(f) << endl; TCanvas *c0 = new TCanvas(); TFile *fin = new TFile( v_infile.at(f) ); TTree *tin = (TTree*)fin->Get("fitResults"); tin->Draw("bshield:bext:bshield_err:bext_err"); TGraphErrors *gshield = new TGraphErrors( tin->GetEntries(), tin->GetV2(), tin->GetV1(), tin->GetV4(), tin->GetV3() ); gshield->SetTitle(v_infile.at(f)); gshield->GetXaxis()->SetTitle("B_{ext} [mT]"); gshield->GetYaxis()->SetTitle("B_{shield} [mT]"); gshield->Draw("AP"); fin->Close(); if ( f == 0 ) c0->Print("plot_check_all.ps("); else if ( f == v_infile.size() - 1 ) c0->Print("plot_check_all.ps)"); else c0->Print("plot_check_all.ps"); } }
TGraphErrors* PlotLightYieldGraph() { string filename; vector<double> x,y,ex,ey; while(1){ cout<<"\n\nEnter next file to process; <enter> to finish."<<endl; getline(cin, filename); if(filename=="") break; //load the tree TTree* Events = GetEventsTree(filename.c_str()); if(!Events) continue; gROOT->ProcessLine(".x analysis/Aliases.C"); double start = Events->GetMinimum("timestamp"); double end = Events->GetMaximum("timestamp"); double error = 0; TString title = TString("Na22 Spectrum, ") + TString(filename)(TRegexp("Run......")); TH1F* hist = new TH1F("Na22Spec",title,200,1000,2500); Events->Draw("sumspec >> Na22Spec","min > 0","e"); double yield = Fit511Photopeak(hist,&error); x.push_back((start+end)/2.); ex.push_back((end-start)/2.); y.push_back(yield); ey.push_back(error); } if(x.size() == 0){ cerr<<"No valid points found!"<<endl; return 0; } TGraphErrors* graph = new TGraphErrors(x.size(),&x[0],&y[0],&ex[0],&ey[0]); graph->Draw("ape"); TAxis* xax = graph->GetXaxis(); xax->SetTitle("Run Time"); xax->SetTimeDisplay(1); xax->SetTimeFormat("%Y/%m/%d"); xax->SetTimeOffset(1,"gmt"); TAxis* yax = graph->GetYaxis(); yax->SetTitle("511 keV Light Yield [pe/keV]"); graph->Draw("ape"); return graph; }
TGraphErrors* diffTGraph(TGraphErrors* g1, TGraphErrors *g2, char* title, char* xtitle, char* ytitle){ Double_t* x1 = g1->GetX(); Double_t* y1 = g1->GetY(); Double_t* ex1 = g1->GetEX(); Double_t* ey1 = g1->GetEY(); Int_t n1 = g1->GetN(); Double_t* x2 = g2->GetX(); Double_t* y2 = g2->GetY(); Double_t* ex2 = g2->GetEX(); Double_t* ey2 = g2->GetEY(); Int_t n2 = g2->GetN(); assert(n1 == n2); Double_t* x = new Double_t[n1]; Double_t* y = new Double_t[n1]; Double_t* ex = new Double_t[n1]; Double_t* ey = new Double_t[n1]; for(int i = 0 ; i < n1 ; i++){ x[i] = 0.5 * ( x1[i] + x2[i] ); ex[i] = 0.5 * sqrt( pow(ex1[i],2) + pow(ex2[i],2) ); ey[i] = sqrt( pow(ey1[i],2) + pow(ey2[i],2) ); y[i] = y2[i] - y1[i]; } TGraphErrors *g = new TGraphErrors(n1,x,y,ex,ey); g->SetTitle(title); g->GetYaxis()->SetTitle(ytitle); g->GetXaxis()->SetTitle(xtitle); g -> SetMarkerStyle(8); g -> SetMarkerSize(0.5); return g; }
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; }
void all(int channels=0, int categ=-1, int sample=2012 /*,bool doSfLepton=true*/){ double bwSigma[40]; int mass[40]; int id[40]; double xLow[40]; double xHigh[40]; int maxMassBin; float masses[1] = {125}; for(int i=0;i<1;++i) { mass[i] = masses[i]; id[i]=masses[i]; xLow[i] = 105.; // getFitEdge(masses[i],width,true); xHigh[i] = 140.; // getFitEdge(masses[i],width,false); //cout << "For mass = " << masses[i] << " width = " << width << "; => Fit Range = [" << xLow[i] << "," << xHigh[i] << "]" << endl; bwSigma[i] = 0.004; } maxMassBin = 1; // 29; // ----------------------- double massV[40],massE[40]; for(int i=0; i<maxMassBin;++i){ massV[i]=mass[i]; massE[i]=0; } double A1Val[40],A1Err[40]; double A2Val[40],A2Err[40]; double a1Val[40],a1Err[40]; double a2Val[40],a2Err[40]; double n1Val[40],n1Err[40]; double n2Val[40],n2Err[40]; double meanCBVal[40],meanCBErr[40]; double sigmaCBVal[40],sigmaCBErr[40]; double meanBWVal[40],meanBWErr[40]; double covQualVal[40]; double fitValues[10]; double fitErrors[10]; double covQual[1]; for(int i=0; i<maxMassBin;++i){ fitSignalShapeW(mass[i],id[i],channels,categ, sample,/* 10.,doSfLepton,*/xLow[i],xHigh[i],bwSigma[i], fitValues,fitErrors,covQual); cout << "a1 value,error: " << fitValues[0] << " , " << fitErrors[0] << endl; a1Val[i]=fitValues[0]; a1Err[i]=fitErrors[0]; cout << "a2 value,error: " << fitValues[1] << " , " << fitErrors[1] << endl; a2Val[i]=fitValues[1]; a2Err[i]=fitErrors[1]; cout << "n1 value,error: " << fitValues[4] << " , " << fitErrors[4] << endl; n1Val[i]=fitValues[4]; n1Err[i]=fitErrors[4]; cout << "n2 value,error: " << fitValues[5] << " , " << fitErrors[5] << endl; n2Val[i]=fitValues[5]; n2Err[i]=fitErrors[5]; cout << "meanCB value,error: " << fitValues[2] << " , " << fitErrors[2] << endl; meanCBVal[i]=fitValues[2]; meanCBErr[i]=fitErrors[2]; cout << "sigmaCB value,error: " << fitValues[6] << " , " << fitErrors[6] << endl; sigmaCBVal[i]=fitValues[6]; sigmaCBErr[i]=fitErrors[6]; cout << "meanBW value,error: " << fitValues[3] << " , " << fitErrors[3] << endl; meanBWVal[i]=fitValues[3]; meanBWErr[i]=fitErrors[3]; cout << "A1 value,error: " << fitValues[7] << " , " << fitErrors[7] << endl; A1Val[i]=fitValues[7]; A1Err[i]=fitErrors[7]; cout << "A2 value,error: " << fitValues[8] << " , " << fitErrors[8] << endl; A2Val[i]=fitValues[8]; A2Err[i]=fitErrors[8]; cout << "covQual of the fit: " << covQual[0] << endl; covQualVal[i] = covQual[0]; } stringstream namefile; namefile << "parameters_channel" << channels<< categ << ".root"; TFile *resultfile = TFile::Open(namefile.str().c_str(),"RECREATE"); TGraphErrors* gA1 = new TGraphErrors(maxMassBin,massV,a1Val,massE,a1Err); TGraphErrors* gA2 = new TGraphErrors(maxMassBin,massV,a2Val,massE,a2Err); TGraphErrors* gN1 = new TGraphErrors(maxMassBin,massV,n1Val,massE,n1Err); TGraphErrors* gN2 = new TGraphErrors(maxMassBin,massV,n2Val,massE,n2Err); TGraphErrors* gMeanCB = new TGraphErrors(maxMassBin,massV,meanCBVal,massE,meanCBErr); TGraphErrors* gSigmaCB = new TGraphErrors(maxMassBin,massV,sigmaCBVal,massE,sigmaCBErr); TGraphErrors* gMeanBW = new TGraphErrors(maxMassBin,massV,meanBWVal,massE,meanBWErr); TGraphErrors* gAA1 = new TGraphErrors(maxMassBin,massV,A1Val,massE,A1Err); TGraphErrors* gAA2 = new TGraphErrors(maxMassBin,massV,A2Val,massE,A2Err); TGraph* gCovQual = new TGraph(maxMassBin,massV,covQualVal); gA1->SetName("gA1"); gA1->SetMarkerStyle(20); gA1->SetMarkerSize(1); gA2->SetName("gA2"); gA2->SetMarkerStyle(20); gA2->SetMarkerSize(1); gN1->SetName("gN1"); gN1->SetMarkerStyle(20); gN1->SetMarkerSize(1); gN2->SetName("gN2"); gN2->SetMarkerStyle(20); gN2->SetMarkerSize(1); gMeanCB->SetName("gMeanCB"); gMeanCB->SetMarkerStyle(20); gMeanCB->SetMarkerSize(1); gSigmaCB->SetName("gSigmaCB"); gSigmaCB->SetMarkerStyle(20); gSigmaCB->SetMarkerSize(1); gMeanBW->SetName("gMeanBW"); gMeanBW->SetMarkerStyle(20); gMeanBW->SetMarkerSize(1); gAA1->SetName("gAA1"); gAA1->SetMarkerStyle(20); gAA1->SetMarkerSize(1); gAA2->SetName("gAA2"); gAA2->SetMarkerStyle(20); gAA2->SetMarkerSize(1); gCovQual->SetName("gCovQual"); gCovQual->SetMarkerStyle(20); gCovQual->SetMarkerSize(1); gA1->SetTitle(""); gA1->GetXaxis()->SetTitle("mass (GeV)"); gA1->GetYaxis()->SetTitle("CB a-parameter"); gA2->SetTitle(""); gA2->GetXaxis()->SetTitle("mass (GeV)"); gA2->GetYaxis()->SetTitle("CB a-parameter"); gN1->SetTitle(""); gN1->GetXaxis()->SetTitle("mass (GeV)"); gN1->GetYaxis()->SetTitle("CB n-parameter"); gN2->SetTitle(""); gN2->GetXaxis()->SetTitle("mass (GeV)"); gN2->GetYaxis()->SetTitle("CB n-parameter"); gMeanCB->SetTitle(""); gMeanCB->GetXaxis()->SetTitle("mass (GeV)"); gMeanCB->GetYaxis()->SetTitle("CB mean"); gSigmaCB->SetTitle(""); gSigmaCB->GetXaxis()->SetTitle("mass (GeV)"); gSigmaCB->GetYaxis()->SetTitle("CB sigma"); gMeanBW->SetTitle(""); gMeanBW->GetXaxis()->SetTitle("mass (GeV)"); gMeanBW->GetYaxis()->SetTitle("BW mean"); gAA1->SetTitle(""); gAA1->GetXaxis()->SetTitle("mass (GeV)"); gAA1->GetYaxis()->SetTitle("Chebyshev a1-parameter"); gAA2->SetTitle(""); gAA2->GetXaxis()->SetTitle("mass (GeV)"); gAA2->GetYaxis()->SetTitle("Chebyshev a2-parameter"); gCovQual->SetTitle(""); gCovQual->GetXaxis()->SetTitle("mass (GeV)"); gCovQual->GetYaxis()->SetTitle("cov. matrix qual."); resultfile->cd(); gA1->Fit("pol0"); gA1->Draw("Ap"); gA1->Write(); gA2->Fit("pol0"); gA2->Draw("Ap"); gA2->Write(); gN1->Fit("pol1"); gN1->Draw("Ap"); gN1->Write(); gN2->Fit("pol1"); gN2->Draw("Ap"); gN2->Write(); gMeanCB->Fit("pol1"); gMeanCB->Draw("Ap"); gMeanCB->Write(); gSigmaCB->Fit("pol1"); gSigmaCB->Draw("Ap"); gSigmaCB->Write(); gAA1->Fit("pol0"); gAA1->Draw("Ap"); gAA1->Write(); gAA2->Fit("pol0"); gAA2->Draw("Ap"); gAA2->Write(); gCovQual->Write(); resultfile->Close(); }
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(); }
map<int,vector<double> > RPCChambersCluster::getReconstructedHits(vector<unsigned> vectorOfReferenceChambers, const int & timeWindow,const int & timeReference,bool & isVerticalTrack,map<int,double> & scintilatorsCoordinates,const bool & keepRecoTrack,TFile * fileForRecoTracks,const int & eventNum,const double & correlationFactor, const ESiteFileType & fileType){ // map<int,vector<double> > mapOfHits; // // the default value for Chi2goodness is 20 //double best_chi2goodnes_value = Chi2goodness+10 ; // this variable is used as reference so that it holds the best chi2 found for a track, so its used only a track with better chi2 to be accepted double currentBestCorrFact = -2; int lastFitPoint = 0; for (int i = 0 ; i < this->getNumberOfChambers() ; i++){ this->getChamberNumber(i+1)->findAllClustersForTriggerTimeReferenceAndTimeWindow(timeReference,timeWindow,5); //cout << "Chamber is " << i+1 << endl; } vector<vector<int> > vectorOfClusterNumberCombinations; if (fileType == kIsCERNrawFile ){ assert(vectorOfReferenceChambers.size() == 3 ); lastFitPoint = 9; for ( int i = 0 ; i < this->getChamberNumber(vectorOfReferenceChambers[0])->getNumberOfClusters() ; i++ ){ for( int j = 0 ; j < this->getChamberNumber(vectorOfReferenceChambers[1])->getNumberOfClusters() ; j++ ){ for( int k = 0 ; k < this->getChamberNumber(vectorOfReferenceChambers[vectorOfReferenceChambers.size()-1])->getNumberOfClusters() ; k++ ){ vector<int> singleCombination; singleCombination.push_back(i+1); singleCombination.push_back(j+1); singleCombination.push_back(k+1); for (int f = 0 ; f < singleCombination.size() ; f++){ if(this->getChamberNumber(vectorOfReferenceChambers[f])->getSizeOfCluster(singleCombination.at(f)) > 5 ) continue; // don't insert combination if there is too big cluster. } vectorOfClusterNumberCombinations.push_back(singleCombination); } } } } if (fileType == kIsBARCrawFile || fileType == kIsGENTrawFile ){ // add implementation for BARC and Ghent stand . lastFitPoint = 5; assert(vectorOfReferenceChambers.size() == 2); for ( int i = 0 ; i < this->getChamberNumber(vectorOfReferenceChambers[0])->getNumberOfClusters() ; i++ ){ for( int j = 0 ; j < this->getChamberNumber(vectorOfReferenceChambers[1])->getNumberOfClusters() ; j++ ){ vector<int> singleCombination; singleCombination.push_back(i+1); singleCombination.push_back(j+1); for (int f = 0 ; f < singleCombination.size() ; f++){ if(this->getChamberNumber(vectorOfReferenceChambers[f])->getSizeOfCluster(singleCombination.at(f)) > 5 ) continue; // don't insert combination if there is too big cluster. } vectorOfClusterNumberCombinations.push_back(singleCombination); } } } string topScintToString, botScintToString; for (int combinationsVectorElement = 0 ; combinationsVectorElement < vectorOfClusterNumberCombinations.size() ; combinationsVectorElement ++){ // the partition logic start here - track could pass more than one partition int direction = 0 ; // direction should describe how the partition changes from one reference chamber to another. It vector<int> RefChamberClusterPartition; bool positive = false; bool negative = false; int partitionPenetrated = 1; // the Y coordinate is the partition number (1 2 or 3 - A B or C) vector<int> clusterNum = vectorOfClusterNumberCombinations.at(combinationsVectorElement); for (int ii = 0; ii < clusterNum.size() ; ii++){ RefChamberClusterPartition.push_back(this->getChamberNumber(vectorOfReferenceChambers[ii])->getXYCoordinatesOfCluster(clusterNum.at(ii)).at(1)); } isVerticalTrack = true; for ( int ii = 0; ii < RefChamberClusterPartition.size() - 1 ; ii++ ){ direction = (RefChamberClusterPartition.at(ii) - RefChamberClusterPartition.at(ii+1)); if (direction != 0) { direction = direction/abs(direction); partitionPenetrated++; } // get only the sign ( +1 or -1) if (direction && direction == -1) { positive = true; isVerticalTrack = false; } if (direction && direction == 1 ) { negative = true; isVerticalTrack = false; } } if ( positive && negative ) continue; // cannot have a track that goes in both direction /* TH1F * histXZ = new TH1F("fitHistogram","XZ plane",110,0,11); histXZ->GetYaxis()->SetRangeUser(-20,52); histXZ->SetMarkerColor(kBlue); histXZ->SetMarkerStyle(kCircle); histXZ->GetXaxis()->SetTitle("Shelf number"); histXZ->GetYaxis()->SetTitle("Channel number"); */ TF1 * fitfunc = new TF1("FitTrack","[0]+x*[1]",0,lastFitPoint+1); TGraphErrors * graphXZ = new TGraphErrors(); graphXZ->GetXaxis()->SetTitle("Shelf number"); graphXZ->GetYaxis()->SetTitle("Channel number"); //graphXZ->SetLineColor(0); graphXZ->SetMarkerColor(kBlack); graphXZ->SetMarkerStyle(kFullCircle); graphXZ->SetName("fit graph"); graphXZ->SetTitle("XZ plane"); graphXZ->GetXaxis()->SetTitle("Muon station"); graphXZ->GetYaxis()->SetTitle("Channel number"); fitfunc->SetLineColor(kBlue); vector<double> coordinates; double xCoordinate = 0; int yCoordinate = 0; int zCoorinate = 0; for (int ii=0 ; ii < vectorOfReferenceChambers.size() ; ii++){ coordinates = this->getChamberNumber(vectorOfReferenceChambers[ii])->getXYCoordinatesOfCluster(clusterNum[ii]); xCoordinate = coordinates.at(0); yCoordinate = coordinates.at(1); zCoorinate = 10*vectorOfReferenceChambers[ii]; Double_t errorValue = this->getChamberNumber(vectorOfReferenceChambers[ii])->getSizeOfCluster(clusterNum[ii]); // histXZ->SetBinContent(zCoorinate,xCoordinate); // histXZ->SetBinError(zCoorinate,errorValue/2); //cout << xCoordinate << " " << yCoordinate << endl; graphXZ->SetPoint(ii,vectorOfReferenceChambers[ii],xCoordinate); graphXZ->SetPointError(ii,0,errorValue/2); } Double_t params[2]; graphXZ->Fit(fitfunc,"RFQ"); fitfunc->GetParameters(params); //cout << "par1 " << params[0] << " par2 " << params[1] << " chi2 " << fitfunc->GetChisquare() << endl; // The resudials - difference between estimated fit value and the middle of the nearest cluster int prevReference = 0 , nextReference = 0 , prevReferencePartition = 0 , nextReferencePartition = 0; bool currentChamberIsReference = false; int startCounter = 0, endCounter = 0; if ( abs(graphXZ->GetCorrelationFactor()) >= correlationFactor && abs(graphXZ->GetCorrelationFactor()) > currentBestCorrFact ) { // in case of only one partition, get the partition number of the first reference point currentBestCorrFact = abs(graphXZ->GetCorrelationFactor()); int referenceChambersIncrementor = 0; bool negativeChannelNumberIsFound = false; // --------- for ( int currentChNumber = 0 ; currentChNumber < this->getNumberOfChambers() ; currentChNumber++ ) { // check where the chamber is according to the reference chambers vector<double> vectorOfpartitionsAndHit; double channelNum = fitfunc->Eval(currentChNumber+1); /** four cases 1. the chamber is before the first reference 2. the chamber is after the last reference 3. the chamber is between two references 4. the chamber is a reference */ for(int refCheck = 0 ; refCheck < vectorOfReferenceChambers.size(); refCheck++){ // find the surounding references if (currentChNumber+1 == vectorOfReferenceChambers.at(refCheck)){ currentChamberIsReference = true; break; } if ( vectorOfReferenceChambers.at(refCheck) > currentChNumber+1 && refCheck == 0 ){ // its before the first reference chamber nextReference = vectorOfReferenceChambers.at(refCheck); nextReferencePartition = this->getChamberNumber(nextReference)->getXYCoordinatesOfCluster(clusterNum[refCheck]).at(1); break; } if ( vectorOfReferenceChambers.at(refCheck) < currentChNumber+1 && refCheck == vectorOfReferenceChambers.size() - 1 ){ // its after the last chamber prevReference = vectorOfReferenceChambers.at(refCheck); prevReferencePartition = this->getChamberNumber(prevReference)->getXYCoordinatesOfCluster(clusterNum[refCheck]).at(1); break; } if ( vectorOfReferenceChambers.at(refCheck) < currentChNumber+1 && vectorOfReferenceChambers.at(refCheck+1) > currentChNumber+1 ){ // its between two references prevReference = vectorOfReferenceChambers.at(refCheck) ; nextReference = vectorOfReferenceChambers.at(refCheck+1); prevReferencePartition = this->getChamberNumber(prevReference)->getXYCoordinatesOfCluster(clusterNum[refCheck]).at(1); nextReferencePartition = this->getChamberNumber(nextReference)->getXYCoordinatesOfCluster(clusterNum[refCheck+1]).at(1); break; } } // end of partition possibilities if(!currentChamberIsReference){ if (nextReference && prevReference == 0){ if (positive){ prevReferencePartition = 1; } if(negative){ prevReferencePartition = this->getChamberNumber(1)->getClones(); } } if (prevReferencePartition && nextReferencePartition == 0){ if (positive){ nextReferencePartition = this->getChamberNumber(1)->getClones(); } if(negative){ nextReferencePartition = 1; } } if (partitionPenetrated == 1 ){ prevReferencePartition = yCoordinate; nextReferencePartition = yCoordinate; int firstRef = vectorOfReferenceChambers.at(0); int lastRef = vectorOfReferenceChambers.at(vectorOfReferenceChambers.size() - 1); int ccham = currentChNumber+1; if(! (lastRef > ccham && firstRef < ccham) ){ // all partitions are possible, chambers are out of the reference scope prevReferencePartition = this->getChamberNumber(1)->getClones(); nextReferencePartition = 1; // 3 in case of ecap chamber } } if (positive){ startCounter = prevReferencePartition; endCounter = nextReferencePartition; } else { startCounter = nextReferencePartition ; endCounter = prevReferencePartition ; } for (int currentCounter = startCounter ; currentCounter <= endCounter; currentCounter ++ ){ assert(currentCounter > 0 && currentCounter < 4); vectorOfpartitionsAndHit.push_back(currentCounter); } } else{ vectorOfpartitionsAndHit.push_back(this->getChamberNumber(currentChNumber+1)->getXYCoordinatesOfCluster(clusterNum[referenceChambersIncrementor]).at(1)); referenceChambersIncrementor ++; } prevReference = 0 ; nextReference = 0 ; prevReferencePartition = 0 ; nextReferencePartition = 0; currentChamberIsReference = false; //cout << "Chamber " << l+1 << " " << coordinates.at(1) << " " << fitfunc->Eval(l+1) << " " << endl; int channelNumberToStore = channelNum; if (channelNumberToStore < 96/this->getChamberNumber(1)->getClones()){ channelNumberToStore += 1; } // add one to represent the fired channel, or none if the channel is on the right border vectorOfpartitionsAndHit.push_back(channelNumberToStore); // the last element is the number of the channel // Debug lines /** cout << "Chamber is " << currentChNumber+1 << " partitions " ; for (int thesize = 0 ; thesize < vectorOfpartitionsAndHit.size() - 1; thesize++){ cout << vectorOfpartitionsAndHit.at(thesize) << " " ; } cout << "channel " << vectorOfpartitionsAndHit.at(vectorOfpartitionsAndHit.size()-1) << endl; */ mapOfHits[currentChNumber+1] = vectorOfpartitionsAndHit; } // ---------- scintilators coordinates estimate for (int scintNum = 0 ; scintNum < 31 ; scintNum++){ if(this->getTriggerObjectNumber(1)->getChannel(scintNum+1)->hasHit() && vectorOfClusterNumberCombinations.size() == 1 ) { if (scintNum < 10) { scintilatorsCoordinates[scintNum+1] = graphXZ->Eval(0); topScintToString = boost::lexical_cast<string>(scintNum+1); } else { scintilatorsCoordinates[scintNum+1] = graphXZ->Eval(lastFitPoint+1); botScintToString = boost::lexical_cast<string>(scintNum+1); } } } } // get only vertical tracks from the A partition if there are only two scint hits if (keepRecoTrack && isVerticalTrack && !mapOfHits.empty() && scintilatorsCoordinates.size() == 2){ graphXZ->SetName(boost::lexical_cast<string>(eventNum).c_str()); string partition; if (mapOfHits.find(vectorOfReferenceChambers.at(0))->second.at(0) == 1) partition = "A"; else if (mapOfHits.find(vectorOfReferenceChambers.at(0))->second.at(0) == 2) partition = "B"; else partition = "C"; graphXZ->SetTitle(("Correlation factor is "+boost::lexical_cast<string>(graphXZ->GetCorrelationFactor()) + " trigger channels top: " + topScintToString + " bottom: " + botScintToString ).c_str()); if(abs(graphXZ->GetCorrelationFactor()) >= correlationFactor) { string scintCombination="_"+topScintToString+"_"+botScintToString+"_"+partition; TDirectory * dir = fileForRecoTracks->GetDirectory(scintCombination.c_str(),true); if(!dir) { //fileForRecoTracks->ls(); fileForRecoTracks->mkdir(scintCombination.c_str()) ; fileForRecoTracks->cd(""); } fileForRecoTracks->cd(scintCombination.c_str()); //cout << fileForRecoTracks->GetPath() << endl; } else{ fileForRecoTracks->cd("") ; fileForRecoTracks->cd("badTracks") ; } graphXZ->Write(graphXZ->GetName(),TObject::kOverwrite); fileForRecoTracks->cd(""); //fileForRecoTracks->Write(graphXZ->GetName(),TObject::kOverwrite); } fitfunc->Delete(); //histXZ->Delete(); graphXZ->Delete(); } return mapOfHits; }
void BDT_cuts_norm(){ gROOT->ProcessLine(".L ~/cern/project/lhcbStyle.C"); lhcbStyle(); const std::string filename("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/normalisation_samples/Lb2JpsipK_2011_2012_signal_withbdt.root"); const std::string treename = "withbdt"; const std::string filenameMC("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/normalisation_samples/Lb2JpsipK_MC_2011_2012_norm_withbdt.root"); TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; TFile* fileMC = TFile::Open( filenameMC.c_str() ); if( !fileMC ) std::cout << "file " << filenameMC << " does not exist" << std::endl; TTree* treeMC = (TTree*)fileMC->Get( treename.c_str() ); if( !treeMC ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- signal, mass shape RooRealVar Lambda_b0_DTF_MASS_constr1("Lambda_b0_DTF_MASS_constr1","m(J/#psi pK^{-})", 5550., 5700., "MeV/c^{2}"); RooRealVar Jpsi_M("Jpsi_M","m(#mu#mu)", 3000., 3200., "MeV/c^{2}"); RooRealVar chi_c_M("chi_c_M","m(J/#psi#gamma)", 3400., 3700., "MeV/c^{2}"); RooRealVar mean("mean","mean", 5630., 5610., 5650.); RooRealVar sigma1("sigma1","sigma1", 10., 1., 100.); RooRealVar sigma2("sigma2","sigma2", 30.0, 5.0, 300.0); RooRealVar alpha1("alpha1","alpha1", 1.0, 0.5, 5.0); RooRealVar n1("n1","n1", 1.8, 0.2, 15.0); RooRealVar alpha2("alpha2","alpha2", -0.5, -5.5, 0.0); RooRealVar n2("n2","n2", 0.7, 0.2, 10.0); //RooRealVar bkgcat_chic("bkgcat_chic","bkgcat_chic", 0, 100); RooRealVar bdtg3("bdtg3", "bdtg3", -1.0, 1.0); RooRealVar frac2("frac2","frac2", 0.3, 0., 1.); RooGaussian gauss1("gauss1","gauss1", Lambda_b0_DTF_MASS_constr1, mean, sigma1); RooGaussian gauss2("gauss2","gauss2", Lambda_b0_DTF_MASS_constr1, mean, sigma2); RooCBShape cb1("cb1","cb1", Lambda_b0_DTF_MASS_constr1, mean, sigma1, alpha1, n1); RooCBShape cb2("cb2","cb2", Lambda_b0_DTF_MASS_constr1, mean, sigma2, alpha2, n2); RooAddPdf sig("sig", "sig", RooArgList(cb1, cb2), RooArgList( frac2 )); RooRealVar cbRatio("cbRatio","cb Ratio", 0.8, 0.1, 1.0); RooRealVar sigYield("sigYield","sig Yield", 4e2, 1e0, 1e6); RooRealVar bgYield("bgYield","bg Yield", 1e4, 1e0, 1e6); //put in values from fit_MC here <<--- DON'T FORGET TO CHANGE THESE IF THE FIT CHANGES!!! /* EXT PARAMETER INTERNAL INTERNAL NO. NAME VALUE ERROR STEP SIZE VALUE 1 alpha1 2.18020e+00 2.85078e-02 1.38432e-04 -2.56034e-01 2 alpha2 -2.79102e+00 6.74385e-02 1.51818e-04 -1.49177e-02 3 cbRatio 3.07172e-01 1.49204e-02 1.72642e-04 -5.69984e-01 4 mean 5.61985e+03 9.58397e-03 5.56682e-05 -9.66293e-02 5 n1 1.49358e+00 8.14447e-02 2.09300e-04 -9.70542e-01 6 n2 1.45276e+00 1.09864e-01 2.59028e-04 -8.39538e-01 7 sigma1 8.46303e+00 1.32851e-01 2.86985e-05 -1.01453e+00 8 sigma2 4.93976e+00 3.42842e-02 5.03572e-06 -1.44512e+00 */ alpha1.setVal( 2.18020e+00 ); alpha2.setVal( -2.79102e+00 ); n1.setVal( 1.49358e+00 ); n2.setVal( 1.45276e+00 ); frac2.setVal( 3.07172e-01 ); sigma1.setVal( 8.46303e+00 ); sigma2.setVal( 4.93976e+00 ); alpha1.setConstant( true ); alpha2.setConstant( true ); frac2.setConstant( true ); n1.setConstant( true ); n2.setConstant( true ); sigma1.setConstant( true ); sigma2.setConstant( true ); // -- bg, mass shape RooRealVar a1("a1","a1", -0.1, -0.5, 0.5); RooChebychev comb("comb","comb", Lambda_b0_DTF_MASS_constr1, a1); RooRealVar mean3("mean3","mean3", 5560., 5500., 5600.); RooRealVar sigma3("sigma3","sigma3", 5., 1., 10.); RooRealVar frac3("frac3","frac", 0.2, 0.0, 0.3); RooGaussian gauss3("gauss3","gauss3", Lambda_b0_DTF_MASS_constr1, mean3, sigma3); //RooAddPdf bg("bg","bg", RooArgList(comb), RooArgList(frac3)); // -- add signal & bg RooAddPdf pdf("pdf", "pdf", RooArgList(sig, comb), RooArgList( sigYield, bgYield)); double efficiencies1[40]; double efficiencies1_error[40]; double bdt_cuts[40]; double efficiencies2[40]; double efficiencies2_error[40]; double sideband_bg_val[40]; double MC_pre = treeMC->GetEntries(); double effvals[40]; //loop starting here for(int i=0; i < 40; i=i+1) { double cut_val = -1.0 + i*0.05; //double cut_val = -1.0; // testing bdt_cuts[i] = cut_val; std::stringstream c; c << "bdtg3" << " >= " << cut_val; const std::string cut = c.str(); //std::cout << cut; RooArgSet obs; obs.add(Lambda_b0_DTF_MASS_constr1); //obs.add(chi_c_Mp); //obs.add(mass_pK); obs.add(Jpsi_M); obs.add(chi_c_M); obs.add(bdtg3); RooDataSet ds("ds","ds", obs, RooFit::Import(*tree), RooFit::Cut(cut.c_str())); RooPlot* plot = Lambda_b0_DTF_MASS_constr1.frame(); RooFitResult * result = pdf.fitTo( ds, RooFit::Extended() ); double sig_val = sigYield.getVal(); double bg_val = bgYield.getVal(); double sig_error = sigYield.getError(); double bg_error = bgYield.getError(); double efficiency1 = (sig_val)/(sqrt(sig_val + bg_val)); efficiencies1[i] = efficiency1; double efficiency1_error_sq = (pow(sig_error,2)/(sig_val+bg_val) + (pow(sig_val,2)*(pow(sig_error,2)+pow(bg_error,2))/(4*pow((sig_val+bg_val),3)))); double efficiency1_error = sqrt(efficiency1_error_sq); efficiencies1_error[i] = efficiency1_error; /* double MC_post = treeMC->GetEntries(cut.c_str()); double eff_val = MC_post/MC_pre; //something here to get the sideband background count Lambda_b0_DTF_MASS_constr1.setRange("R", 5650., 5700.); RooFitResult * sideband = bg.fitTo( ds, RooFit::Range("R") ); sideband->Print(); Lambda_b0_DTF_MASS_constr1.setRange("R", 5650., 5700.); RooAbsReal* integral = pdf.createIntegral(Lambda_b0_DTF_MASS_constr1, RooFit::Range("R")); //std::cout << integral->getVal() << std::endl; //std::cout << integral->getError() << std::endl; //Double_t sideband_bg_val = integral->getVal(); //double sideband_bg_error = integral->getError(); std::stringstream r; r << "bdtg3" << " >= " << cut_val << " && Lambda_b0_DTF_MASS_constr1 >= 5650 && Lambda_b0_DTF_MASS_constr1 <= 5700"; const std::string cut2 = r.str(); double integ = tree->GetEntries(cut2.c_str()); //double integ = integral->getVal(); double efficiency2 = eff_val/(5./2. + sqrt(integ)); efficiencies2[i] = efficiency2; effvals[i]=eff_val; std::cout << "\n" << integ << std::endl; std::cout << "\n" << eff_val << std::endl; std::cout << "\n" << efficiency2 << std::endl; */ //double efficiency2_error = efficiency2*sqrt(pow(eff_error/eff_val,2)+(1/(4*sideband_bg_val))*pow(sideband_bg_error/(5/2+sideband_bg_val),2)); //std::cout << "\n\n" << "BDT cut value = " << cut_val << "\n" ; //std::cout << "S = " << sig_val << " +/- " << sig_error << "\n" ; //std::cout << "B = " << bg_val << " +/- " << bg_error << "\n" ; //std::cout << "S/sqrt(S+B) = " << efficiency << " +/- " << efficiency_error << "\n\n" ; //ds.plotOn( plot ); //pdf.plotOn( plot ); //RooPlot* plotPullMass = mass.frame(); //plotPullMass->addPlotable( plot->pullHist() ); //plotPullMass->SetMinimum(); //plotPullMass->SetMaximum(); //std::cout << cut_val; } TCanvas *c1 = new TCanvas(); //double zeros[20]; //for (i=0, i<20, i++) zeros[i]=0.0; TGraphErrors* graph = new TGraphErrors(40, bdt_cuts, efficiencies1, 0, efficiencies1_error); graph->SetTitle("S/sqrt(S+B) vs BDTG3 cut"); //graph->SetMarkerColor(4); //graph->SetMarkerStyle(20); //graph->SetMarkerSize(1.0); graph->GetXaxis()->SetTitle("BDTG3 cut (>)"); graph->GetXaxis()->SetRangeUser(-1.0,1.0); graph->GetYaxis()->SetTitle("S/sqrt(S+B)"); //graph->Fit("pol5"); graph->Draw("AP"); c1->SaveAs("~/cern/plots/bdt_cuts_norm/Lb2JpsipK_2011_2012_BDTG3_cuts_S_sqrtS+B.pdf"); //return c1; //std::cout << efficiencies1_error[5] << std::endl; //gStyle->SetOptFit(1011); /*TCanvas *c2 = new TCanvas(); TGraph* graph2 = new TGraph(40, bdt_cuts, efficiencies2); graph2->SetTitle("eff/[5/2+sqrt(B)] vs BDTG3 cut"); graph2->SetMarkerColor(4); graph2->SetMarkerStyle(20); graph2->SetMarkerSize(1.0); graph2->GetXaxis()->SetTitle("BDTG3 cut (>)"); graph2->GetXaxis()->SetRangeUser(-1.0,1.0); graph2->GetYaxis()->SetTitle("eff/[5/2+sqrt(B)]"); //graph2->Fit("pol7"); graph2->Draw("AP"); c2->SaveAs("~/cern/plots/bdt_cuts_norm/Lb2JpsipK_2011_2012_BDTG3_cuts_Punzi.png"); //return c2; */ /* TCanvas* c = new TCanvas(); TPad* pad1 = new TPad("pad1","pad1", 0, 0.3, 1, 1.0); pad1->SetBottomMargin(0.1); pad1->SetTopMargin(0.1); pad1->Draw(); c->cd(); TPad* pad2 = new TPad("pad2","pad2", 0, 0, 1, 0.3); pad2->SetBottomMargin(0.1); pad2->SetTopMargin(0.0); pad2->Draw(); //pdf.plotOn( plot, RooFit::Components( DfbPdf ), RooFit::LineColor( kRed ), RooFit::LineStyle(kDashed) ); //pdf.plotOn( plot, RooFit::Components( promptPdf ), RooFit::LineColor( kBlue ), RooFit::LineStyle(kDotted) ); //pdf.plotOn( plot, RooFit::Components( bgPdf ), RooFit::LineColor( kOrange ), RooFit::LineStyle(kDashDotted) ); pad1->cd(); plot->Draw(); pad2->cd(); plotPullMass->Draw("AP"); c->SaveAs(out_file_mass); RooStats::SPlot* sData = new RooStats::SPlot("sData","An SPlot", ds, &pdf, RooArgList(sigYield, bgYield) ); RooDataSet * dataw_z = new RooDataSet(ds.GetName(),ds.GetTitle(),&ds,*(ds.get()),0,"sigYield_sw") ; */ /* TCanvas* d = new TCanvas(); RooPlot* w_mass_chicp = mass_chicp.frame(); dataw_z->plotOn(w_mass_chicp, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_mass_chicp->Draw(); d->SaveAs("m_chicp_sweighted.png"); TCanvas* e = new TCanvas(); RooPlot* w_mass_pK = mass_pK.frame(); dataw_z->plotOn(w_mass_pK, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_mass_pK->Draw(); e->SaveAs("m_pK_sweighted.png"); */ /* TCanvas* f = new TCanvas(); RooPlot* w_mass_Jpsi = mass_Jpsi.frame(); dataw_z->plotOn(w_mass_Jpsi, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_mass_Jpsi->Draw(); f->SaveAs("m_Jpsi_sweighted.png"); TCanvas* g = new TCanvas(); RooPlot* w_mass_Chic = mass_Chic.frame(); dataw_z->plotOn(w_mass_Chic, RooFit::DataError(RooAbsData::SumW2), RooFit::Binning(20)) ; w_mass_Chic->Draw(); g->SaveAs("m_Chic_sweighted.png"); */ }
void makePlots(vector<inputValues> b, vector<inputValues> t, vector<outputValues> o, double cut) { // Plot output values vs pulse width TGraphErrors * eLPlot = new TGraphErrors(); TGraphErrors * ePsiPlot = new TGraphErrors (); eLPlot->SetTitle("Average Number of LED-induced Photoelectrons per Trigger"); ePsiPlot->SetTitle("Single-photoelectron Response Mean Amplitude"); eLPlot->SetMarkerColor(4); ePsiPlot->SetMarkerColor(4); eLPlot->SetMarkerStyle(21); ePsiPlot->SetMarkerStyle(21); for (int i = 0; i < b.size(); i++) { for (int j = 0; j < t.size(); j++) { eLPlot->SetPoint((i+1)*j, t[j].pw, o[(i+1)*j].eL); eLPlot->SetPointError((i+1)*j, 0.02, sqrt(o[(i+1)*j].v_eL)); ePsiPlot->SetPoint((i+1)*j, t[j].pw, o[(i+1)*j].ePsi); ePsiPlot->SetPointError((i+1)*j, 0.02, sqrt(o[(i+1)*j].v_ePsi)); } } TCanvas * eL_c = new TCanvas("eL_c", "eL Canvas", 200, 10, 700, 500); eLPlot->GetXaxis()->SetTitle("LED Pulse Width / (ns)"); eLPlot->GetYaxis()->SetTitle("Photoelectrons / Trigger"); eLPlot->Draw("AP"); TCanvas * ePsi_c = new TCanvas("ePsi_c", "ePsi Canvas", 200, 10, 700, 500); ePsiPlot->GetXaxis()->SetTitle("LED Pulse Width / (ns)"); ePsiPlot->GetYaxis()->SetTitle("Mean Amplitude / (mV)"); ePsiPlot->GetYaxis()->SetRangeUser(0.3, 1.6); ePsiPlot->Draw("AP"); TF1 * fit = new TF1("fit", "[0]", 0, 10); ePsiPlot->Fit(fit); // Plot spectra TCanvas * spectra_c = new TCanvas("spectra_c", "Spectra Canvas", 200, 10, 700, 500); spectra_c->SetLogy(); for (int i = t.size() - 1; i >= 0; i--) { t[i].h->SetLineColor(i+2); t[i].h->SetLineWidth(2); t[i].h->Draw("SAME"); t[i].h->SetStats(0); t[i].h->SetTitle("PMT Spectra of Pulsed LED w/ Varying Pulse Width"); t[i].h->GetXaxis()->SetTitle("Amplitude / (mV)"); t[i].h->GetYaxis()->SetTitle("Events"); t[i].h->GetYaxis()->SetRangeUser(0.5, 20000); } b[0].h->SetLineColor(1); b[0].h->SetLineWidth(2); b[0].h->Draw("SAME"); b[0].h->SetStats(0); TLine * cutLine_t = new TLine(-1*cut, 0.0, -1*cut, 20000.0); cutLine_t->SetLineWidth(2); cutLine_t->SetLineColor(1); cutLine_t->SetLineStyle(2); cutLine_t->Draw(); TLine * meanLine_t = new TLine(b[0].e + 0.89, 0.0, b[0].e + 0.89, 20000.0); meanLine_t->SetLineWidth(2); meanLine_t->SetLineColor(2); meanLine_t->SetLineStyle(2); meanLine_t->Draw(); // Add legend //TLegend * leg = new TLegend(0.1, 0.7, 0.48, 0.9); //leg->SetHeader("Legend"); //leg->AddEntry(t[0].h, " // Plot background //TCanvas * b_c = new TCanvas("b_c", "Background Canvas", 200, 10, 700, 500); //b_c->SetLogy(); ////b[0].h->Sumw2(); ////b[0].h->Draw(); //b[0].h->GetYaxis()->SetRangeUser(1.0, 100000.0); //b[0].h->SetTitle("Background PMT Spectrum"); //b[0].h->GetXaxis()->SetTitle("Amplitude / (mV)"); //b[0].h->GetYaxis()->SetTitle("Events"); //TLine * cutLine_b = new TLine(cut, 0.0, cut, 1000000.0); //cutLine_b->SetLineWidth(2); //cutLine_b->Draw(); }
void AnalyzeData(char *DataFile = "drs4_peds_5buffers.dat", Int_t nevt, Int_t startEv = 1, char *PedFile, Int_t DrawExtraGraphs = 0) { // Redefine DOMINO Depth in ADC counts const Float_t DominoDepthADC = pow(2, DOMINO_DEPTH); // open file FILE *fdata = OpenDataFile(DataFile); struct channel_struct *p; struct channel_struct *dep; // create histograms // create list of histograms for channels and distribution TList *DistChList = new TList(); TH1F *distch; // histo with distribution of cell-charge, for each channel TList *DistChSubList = new TList(); TH1F *distchsub; // histo with distribution of cell-charge, pedestals subtracted, for each channel TList *DistCh0SubList = new TList(); TH1F *distch0sub; // histo with distribution of cell-charge, pedestals subtracted, // channel 0 subtracted for each channel TList *grPedList = new TList(); TGraphErrors *grPed; // for each channel, pedestal value and RMS for each cell is plotted TList *hCellList = new TList(); TH1F *hCell; // charge distribution for each cell (DOMINO_NCELL x DOMINO_NCH histos) TList *hCellSubList = new TList(); TH1F *hCellSub; // charge distribution for each cell (DOMINO_NCELL x DOMINO_NCH histos), pedestal subtracted TList *hRMSList = new TList(); TH1F *hRMSdist; // histo with RMS distribution (statistical RMS of distribution) TList *hRMSFitList = new TList(); TH1F *hRMSFitdist; // histo with RMS distribution (RMS of Gaussian fit) TList *grDataList = new TList(); TGraphErrors *grData; // charge-cell and RMS for each cell is plotted TList *grDataSubList = new TList(); TGraphErrors *grDataSub; // pedestal subtracted charge-cell and RMS for each cell is plotted for (int h = 0; h < DOMINO_NCH; h++) { // TString title = "Data Dist channel"; title += h; distch = new TH1F(title, title, DominoDepthADC, 0., DominoDepthADC); DistChList->Add(distch); // TString title = "Data Dist Ped Sub channel"; title += h; distchsub = new TH1F(title, title, DominoDepthADC, -DominoDepthADC/2, DominoDepthADC/2); DistChSubList->Add(distchsub); // TString title = "Data Dist Ped Ch0 Sub channel"; title += h; distch0sub = new TH1F(title, title, DominoDepthADC, -DominoDepthADC/2, DominoDepthADC/2); DistCh0SubList->Add(distch0sub); // TString title = "Pedestal ch"; title += h; grPed = new TGraphErrors(DOMINO_NCELL); grPed->SetTitle(title); grPedList->Add(grPed); // TString title = "Data ch"; title += h; grData = new TGraphErrors(DOMINO_NCELL); grData->SetTitle(title); grDataList->Add(grData); // // Mean data and RMS for each channel and cell TString title = "Data PedSubtracted ch"; title += h; grDataSub = new TGraphErrors(DOMINO_NCELL); grDataSub->SetTitle(title); grDataSubList->Add(grDataSub); // for (int ch = 0; ch < DOMINO_NCELL; ch++) { // data distribution histos TString title = "Data ch"; title += h; title += " cell"; title += ch; hCell = new TH1F(title, title, DominoDepthADC, 0., DominoDepthADC); hCellList->Add(hCell); // data (ped subtracted) distribution histos TString title = "Data PedSub ch"; title += h; title += " cell "; title += ch; hCellSub = new TH1F(title, title, 2 * DominoDepthADC, -1 * DominoDepthADC, DominoDepthADC); hCellSubList->Add(hCellSub); } // Data-RMS distribution histos TString title = "RMSDist channel"; title += h; hRMSdist = new TH1F(title, title, 100, 0, 20.); hRMSList->Add(hRMSdist); // Data-RMS (calculated through a fit) distribution histos TString title = "RMSFitDist channel"; title += h; hRMSFitdist = new TH1F(title, title, 100, 0, 20.); hRMSFitList->Add(hRMSFitdist); } //-------------- // // calculate or read pedestals from file grPedList = OpenPedestals(PedFile); // return; // // ====== Read data file and subtract the pedestals // // Count number of events in data file int nevtDataMax = 0; while (!feof(fdata)) { fread((void *) &event_data, 1, sizeof(event_data), fdata); nevtDataMax++; } printf("nevtDataMax: %d\n", nevtDataMax); if (nevt > (nevtDataMax - startEv) || nevt == 0) nevt = nevtDataMax - startEv; cout << endl << "==>> Processing " << nevt << " events from file " << DataFile << endl; rewind(fdata); Int_t ievt = 1; // go to first event (startEv) while (ievt < startEv) { fread((void *) &event_data, 1, sizeof(event_data), fdata); if (feof(fdata)) break; ievt++; } // filling ievt = 1; Int_t flagEnd = 0; Double_t chtmp; Double_t PedVal, itmp, Ch0Val; // loop on events cout << endl << " --- read DATA file:" << fdata << endl; while (ievt <= nevt && !flagEnd) { fread((void *) &event_data, 1, sizeof(event_data), fdata); if (feof(fdata)) flagEnd = 1; if (ievt % (nevt / 10 + 1) == 0) cout << "*" << endl; p = (struct channel_struct *) &event_data.ch[0]; // read bunch of data dep = (struct channel_struct *) &event_data.ch[1]; // read bunch of data TGraphErrors *grCh0 = new TGraphErrors(DOMINO_NCELL); // loop on channels for (int h = 0; h < DOMINO_NCH; h++) { // loop on cells distch = (TH1F *) DistChList->At(h); distchsub = (TH1F *) DistChSubList->At(h); grPed = (TGraphErrors *) grPedList->At(h); distch0sub = (TH1F *) DistCh0SubList->At(h); if(h==0) { for(i = 0; i < DOMINO_NCELL;i++) { grPed->GetPoint(i, itmp, PedVal); chtmp = (Double_t)(p->data[i]); chtmp = chtmp - PedVal; grCh0->SetPoint(i,itmp, chtmp); } } for (int i = 0; i < DOMINO_NCELL; i++) { // Read pedestal value for this cell grPed->GetPoint(i, itmp, PedVal); grCh0->GetPoint(i, itmp, Ch0Val); // cout << itmp << ", " << PedVal << endl; // Read calibration correction for this cell // CalFact = //charge distribution for each cell, pedestal subtracted chtmp = (Double_t)(p->data[i]); // data value // cout << "tcell, tcell, depth: " << chtmp << "," << p->data[i] << "," << deptmp << endl; distch->Fill(chtmp); // Check data value: must be within DOMINO Depth // if(chtmp > DominoDepthADC) // cout << " === WARNING!!! Channel " << h << " Cell " << i << " has value " << chtmp << endl; // cout << "Charge: " << p->data[i] << endl; ((TH1 *) hCellList->At(h * DOMINO_NCELL + i))->Fill(chtmp); // Now the pedestal is subtracted chtmp = chtmp - PedVal; distchsub->Fill(chtmp); ((TH1 *) hCellSubList->At(h * DOMINO_NCELL + i))->Fill(chtmp); chtmp = chtmp - Ch0Val; distch0sub->Fill(chtmp); } p++; // next channel } ievt++; // next event } cout << endl; // now mean and RMS for each cell are computed and save in histos and graphs cout << " --- filling data histos and grphs " << endl; TF1 *fgauss = new TF1("fgauss", Gauss, -10., 10., 3); fgauss->SetParLimits(0, 0.1, 10000.); fgauss->SetParLimits(1, 0., 4096.); fgauss->SetParLimits(2, 0.1, 20.); Float_t mean, rms, meansub, rmssub; for (int h = 0; h < DOMINO_NCH; h++) { // for (int h=5; h<6; h++){ cout << " Channel:" << h << endl; hRMSdist = (TH1F *) hRMSList->At(h); hRMSFitdist = (TH1F *) hRMSFitList->At(h); grData = (TGraphErrors *) grDataList->At(h); grDataSub = (TGraphErrors *) grDataSubList->At(h); for (int ch = 0; ch < DOMINO_NCELL; ch++) { // data distribution histos // cout << "cell:" << ch << " index:" << h*DOMINO_NCELL+ch << " Mean,RMS:"<<hCell->GetMean()<< "," << hCell->GetRMS()<<endl; hCell = (TH1F *) hCellList->At(h * DOMINO_NCELL + ch); mean = hCell->GetMean(); rms = hCell->GetRMS(); hCellSub = (TH1F *) hCellSubList->At(h * DOMINO_NCELL + ch); meansub = hCellSub->GetMean(); rmssub = hCellSub->GetRMS(); fgauss->SetParameter(0, (Double_t) nevt / 4.); fgauss->SetParameter(1, mean); fgauss->SetParameter(2, rms); // hCell->Fit("fgauss","QN0"); grData->SetPoint(ch, ch, mean); grData->SetPointError(ch, 0, rms); grDataSub->SetPoint(ch, ch, meansub); // grDataSub->SetPointError(ch,0.5,rmssub); grDataSub->SetPointError(ch, 0.5, 2.1); hRMSdist->Fill(rms); hRMSFitdist->Fill(fgauss->GetParameter(2)); // cout << "cell:" << ch << " index:" << h*DOMINO_NCELL+ch << " Mean,RMS:"<< mean << "," << rms<<endl; } } Double_t x, y, chtmp, x1, x2, y1, y2; /*TList *grCellCalibList = OpenCalibFile("CalibrationData1000events.root"); TGraphErrors *grCellCalib; TGraphErrors *grDataSubCalib = new TGraphErrors(DOMINO_NCELL); grDataSubCalib->SetTitle("Data after calibration correction"); grDataSub = (TGraphErrors *) grDataSubList->At(anaChannel); for(ch = 0; ch < DOMINO_NCELL; ch++) { grCellCalib = ((TGraphErrors *) grCellCalibList->At(ch)); grCellCalib->Fit("pol3", "Q"); TF1 *pol3fit = ((TF1 *) grCellCalib->GetFunction("pol3")); grDataSub->GetPoint(ch, x, y); chtmp = y - (Double_t)(pol3fit->Eval(y/3.25)); grDataSubCalib->SetPoint(ch, x, chtmp); } TCanvas *cGrTest = new TCanvas("grTest", "test per vedere i dati", 1000,1000); grDataSubCalib->Draw("APEL");*/ TString Title = "Charge Distribution per channel"; gStyle->SetOptFit(111); TCanvas *cdistch = new TCanvas("cdistch", Title, 1000, 1000); cdistch->Divide(3, 3); for (int i = 0; i < DOMINO_NCH; i++) { cdistch->cd(i + 1); TH1 *dhist = (TH1 *) DistChList->At(i); dhist->DrawCopy(); dhist->SetLineWidth(1); dhist->Fit("gaus", "Q"); dhist->GetFunction("gaus")->SetLineColor(4); dhist->GetFunction("gaus")->SetLineWidth(2); } TString Title = "Charge Distribution Pedestals Subtracted per channel"; TCanvas *cdistchsub = new TCanvas("cdistchsub", Title, 1000, 1000); cdistchsub->Divide(3, 3); for (int i = 0; i < DOMINO_NCH; i++) { cdistchsub->cd(i + 1); TH1 *dsubhist = (TH1 *) DistChSubList->At(i); dsubhist->DrawCopy(); dsubhist->SetLineWidth(1); dsubhist->Fit("gaus", "Q"); dsubhist->GetFunction("gaus")->SetLineColor(4); dsubhist->GetFunction("gaus")->SetLineWidth(2); } TString Title = "Charge Distribution Pedestals and Ch0 Subtracted per channel"; TCanvas *cdistch0sub = new TCanvas("cdistch0sub", Title, 1000, 1000); cdistch0sub->Divide(3, 3); for (int i = 0; i < DOMINO_NCH; i++) { cdistch0sub->cd(i + 1); TH1 *dch0subhist = (TH1 *) DistCh0SubList->At(i); dch0subhist->DrawCopy(); dch0subhist->SetLineWidth(1); dch0subhist->Fit("gaus", "Q"); dch0subhist->GetFunction("gaus")->SetLineColor(4); dch0subhist->GetFunction("gaus")->SetLineWidth(2); } TCanvas *cDataSubTest = new TCanvas("cDataSubTest", "Data after pedestal subtraction", 1000, 1000); cDataSubTest->Divide(1,8); for (h = 0; h< DOMINO_NCH; h++) { grDataSub = (TGraphErrors *) grDataSubList->At(h); cDataSubTest->cd(h+1); grDataSub->GetYaxis()->SetLabelSize(0.06); grDataSub->GetXaxis()->SetLabelSize(0.06); grDataSub->Draw("APE"); } TCanvas *cDataSubTestCh5 = new TCanvas("cDataSubTestCh5", "Data after pedestal subtraction Ch5", 1200, 800); grDataSub = (TGraphErrors *) grDataSubList->At(anaChannel); grDataSub->GetYaxis()->SetLabelSize(0.06); grDataSub->GetYaxis()->SetTitle("ADC Counts"); grDataSub->GetXaxis()->SetTitle("Cell"); grDataSub->GetXaxis()->SetLabelSize(0.06); TLine *refval = new TLine(0,350,1024,350); refval->SetLineWidth(3); refval->SetLineStyle(2); refval->SetLineColor(2); TLine *i1 = new TLine(121,-50,121,800); i1->SetLineStyle(2); TLine *i2 = new TLine(291,-50,291,800); i2->SetLineStyle(2); TLine *i3 = new TLine(461,-50,461,800); i3->SetLineStyle(2); TLine *i4 = new TLine(632,-50,632,800); i4->SetLineStyle(2); TLine *i5 = new TLine(803,-50,803,800); i5->SetLineStyle(2); TLine *i6 = new TLine(975,-50,975,800); i6->SetLineStyle(2); TLine *ireal1 = new TLine(121+20,600,121+20,800); ireal1->SetLineWidth(3); ireal1->SetLineColor(4); TLine *ireal2 = new TLine(291-20,600,291-20,800); ireal2->SetLineWidth(3); ireal2->SetLineColor(4); TLine *ireal3 = new TLine(461+20,600,461+20,800); ireal3->SetLineWidth(3); ireal3->SetLineColor(4); TLine *ireal4 = new TLine(632-20,600,632-20,800); ireal4->SetLineWidth(3); ireal4->SetLineColor(4); TLine *ireal5 = new TLine(803+20,600,803+20,800); ireal5->SetLineWidth(3); ireal5->SetLineColor(4); TLine *ireal6 = new TLine(975-20,600,975-20,800); ireal6->SetLineWidth(3); ireal6->SetLineColor(4); grDataSub->Draw("APE"); refval->Draw("SAME"); i1->Draw("SAME"); i2->Draw("SAME"); i3->Draw("SAME"); i4->Draw("SAME"); i5->Draw("SAME"); i6->Draw("SAME"); ireal1->Draw("SAME"); ireal2->Draw("SAME"); ireal3->Draw("SAME"); ireal4->Draw("SAME"); ireal5->Draw("SAME"); ireal6->Draw("SAME"); TCanvas *cDataTest = new TCanvas("cDataTest", "Raw Data", 1000,1000); cDataTest->Divide(1,8); for(h = 0; h < DOMINO_NCH; h++) { cDataTest->cd(h+1); grData = (TGraphErrors *) grDataList->At(h); grData->SetMarkerStyle(20); grData->SetMarkerSize(0.5); grData->Draw("APE"); } // save root file with graph containing channel 5 data after pedestals subtraction. /* cout << "test" << endl; TString OutFile = DataSubFile; TFile *f = new TFile(OutFile,"RECREATE"); int h = anaChannel; TString key="DataSubGraph"; key += h; ((TGraphErrors*)grDataSubList->At(h))->Write(key); f->Close(); cout << " ---- Write data on file " << endl; */ // =======================================================// // =====================Matteo's Code=====================// // =======================================================// /* Int_t cht, incCht, decCht, xflag, nPeriods, iMax, iMin; Double_t xdiff, incDiff, decDiff, incDiffTemp, decDiffTemp, incXDiff, decXDiff; Double_t fitMax, fitMin, fitPeriod, chisquare; Double_t DominoXval[DOMINO_NCELL]; Double_t DominoYval[DOMINO_NCELL]; Double_t FitXval[DOMINO_NCELL]; Double_t FitYval[DOMINO_NCELL]; // opens grDataSub.root TString FileName = DataSubFile; TGraphErrors *grDataSub; int h = anaChannel; TFile *f = new TFile(FileName); TString key = "DataSubGraph"; key += h; grDataSub = (TGraphErrors *) f->Get(key); f->Close(); // Create a new graph with channel 5 data TGraphErrors *grDataSubAnaCh; int h = anaChannel; grDataSubAnaCh = (TGraphErrors *) grDataSubList->At(h); TGraphErrors *grDataSubFix = grDataSubAnaCh->Clone(); TGraphErrors *grRes = new TGraphErrors(DOMINO_NCELL); TList *grResPeriodList = new TList(); Double_t xtemp, ytemp, DominoMax, DominoMin; for (int ch = 0; ch < DOMINO_NCELL; ch++){ // get domino-output point and save in array grDataSubAnaCh->GetPoint(ch, DominoXval[ch], DominoYval[ch]); } // find the domino point with max y-value iMax = 0; for(int ch = 0; ch < DOMINO_NCELL; ch++) { if(DominoYval[ch] > DominoYval[iMax]) { DominoMax = DominoYval[ch]; iMax = ch; } } cout << "DominoMax e': " << DominoMax << endl; // find the domino point with min y-value iMin = 0; for (int ch = 0; ch < DOMINO_NCELL; ch++) { if(DominoYval[ch] < DominoYval[iMin]) { DominoMin = DominoYval[ch]; iMin = ch; } } cout << "DominoMin e': " << DominoMin << endl; // remove points from the graph that will be used for fit for (int ch = 0; ch < DOMINO_NCELL; ch++){ grDataSubFix->GetPoint(ch, xtemp, ytemp); if(ytemp > 0.8*DominoMax || ytemp < 0.2*DominoMin) grDataSubFix->RemovePoint(ch); } TF1 *fsin = new TF1("fsin", sigSin, 0., 1024., 4); fsin->SetParameters(600., DOMINO_NCELL / 4., 150., 150.); fsin->SetParNames("amplitude", "Period", "Phase", "DC-Offset"); grDataSubFix->Fit("fsin"); TF1 *fsinFit = grDataSubFix->GetFunction("fsin"); fsinFit->SetParNames("amplitude", "Period", "Phase", "DC-Offset"); chisquare = grDataSub->Chisquare(fsinFit); cout << "il chi quadro della funzione di fit e' : " << chisquare << endl; for (int ch = 0; ch < DOMINO_NCELL; ch++) { // get Fit-value and save in array FitXval[ch] = DominoXval[ch]; FitYval[ch] = fsinFit->Eval(FitXval[ch]); } fitPeriod = fsinFit->GetParameter("Period"); cout << "il periodo della funzione e': " << fitPeriod << endl; nPeriods = (Int_t) (DOMINO_NCELL/fitPeriod); cout << "il numero di periodi della funzione e': " << nPeriods << endl; fitMax = fsinFit->GetMaximum(); cout << "il massimo della funzione e': " << fitMax << endl; fitMin = fsinFit->GetMinimum(); cout << "il minimo della funzione e': " << fitMin << endl; // computes the y difference between the ch-domino point and the i-fit point // and stops when the difference changes sign // // first and last points are not included in the cicle // // if the fit point y-value is bigger or smaller than the fit function max*0.8 or min*0.2 // the point is removed for (int ch = 1; ch < DOMINO_NCELL - 1; ch++) { if(FitYval[ch] > 0.8*fitMax || FitYval[ch] < 0.2*fitMin) { grRes->RemovePoint(ch); continue; } incDiff = DominoYval[ch] - FitYval[ch]; incDiffTemp = DominoYval[ch] - FitYval[ch + 1]; decDiff = DominoYval[ch] - FitYval[ch]; decDiffTemp = DominoYval[ch] - FitYval[ch - 1]; if(abs(incDiffTemp) < abs(incDiff) || (sign(incDiff) != sign(incDiffTemp) && abs(decDiffTemp) > abs(decDiff))) { for (int i = ch; i < DOMINO_NCELL; i++, incDiff = incDiffTemp) { incDiffTemp = DominoYval[ch] - FitYval[i]; if (sign(incDiff) != sign(incDiffTemp)) { if(abs(incDiffTemp) < abs(incDiff)) incCht = i; else incCht = i - 1; break; } } xflag = 1; } else if(abs(decDiffTemp) < abs(decDiff) || (sign(decDiff) != sign(decDiffTemp) && abs(incDiffTemp) > abs(incDiff))) { for (int j = ch; j >= 0 ; j--, decDiff = decDiffTemp) { decDiffTemp = DominoYval[ch] - FitYval[j]; if (sign(decDiff) != sign(decDiffTemp)) { if(abs(decDiffTemp) < abs(decDiff)) decCht = j; else decCht = j + 1; break; } } xflag = -1; } if(xflag == 1) xdiff = FitXval[incCht] - DominoXval[ch]; else xdiff = FitXval[decCht] - DominoXval[ch]; grRes->SetPoint(ch, (Double_t) ch, xdiff); } cout << "Draw Time Residuals" << endl; TString Title = "Time Residuals"; TCanvas *timeres = new TCanvas("timeres", Title, 1200, 780); grRes->SetMarkerStyle(20); grRes->SetMarkerSize(0.3); grRes->GetYaxis()->SetLabelSize(0.12); grRes->GetXaxis()->SetLabelSize(0.12); grRes->Draw("APE"); // The previous graph is now split in N graphs, where N is the number of fit periods // this will be needed to set the function phase // // iMax = 0; // // for(ch = 0; ch < fitPeriod - 1; ch++) { // if(FitYval[ch] > FitYval[iMax]) iMax = ch; // } cout << "il primo massimo ha l'indice : " << iMax << endl; for (i = 0; i < nPeriods; i++) { TGraphErrors *grResPeriod = new TGraphErrors((Int_t) fitPeriod); grResPeriodList->Add(grResPeriod); for(ch = i*fitPeriod + 1; ch < fitPeriod + (i*fitPeriod); ch++) { if(FitYval[ch] > 0.8*fitMax || FitYval[ch] < 0.2*fitMin) { grResPeriod->RemovePoint(ch); continue; } incDiff = DominoYval[ch] - FitYval[ch]; incDiffTemp = DominoYval[ch] - FitYval[ch + 1]; decDiff = DominoYval[ch] - FitYval[ch]; decDiffTemp = DominoYval[ch] - FitYval[ch - 1]; if(abs(incDiffTemp) < abs(incDiff) || (sign(incDiff) != sign(incDiffTemp) && abs(decDiffTemp) > abs(decDiff))) { for (int k = ch; k < k*fitPeriod + fitPeriod; k++, incDiff = incDiffTemp) { incDiffTemp = DominoYval[ch] - FitYval[k]; if (sign(incDiff) != sign(incDiffTemp)) { if(abs(incDiffTemp) < abs(incDiff)) incCht = k; else incCht = k - 1; break; } } xflag = 1; } else if(abs(decDiffTemp) < abs(decDiff) || (sign(decDiff) != sign(decDiffTemp) && abs(incDiffTemp) > abs(incDiff))) { for (int j = ch; j > i*fitPeriod; j--, decDiff = decDiffTemp) { decDiffTemp = DominoYval[ch] - FitYval[j]; if (sign(decDiff) != sign(decDiffTemp)) { if(abs(decDiffTemp) < abs(decDiff)) decCht = j; else decCht = j + 1; break; } } xflag = -1; } if(xflag == 1) xdiff = FitXval[incCht] - DominoXval[ch]; else xdiff = FitXval[decCht] - DominoXval[ch]; grResPeriod->SetPoint(ch - i*fitPeriod, (Double_t) (ch - i*fitPeriod), xdiff); } } TCanvas *timeresperiod = new TCanvas("timeresperiod", "Time Residuals Period", 1200, 780); for(i = 0; i < nPeriods; i++) { grResPeriod = ((TGraphErrors *) grResPeriodList->At(i)); grResPeriod->SetMarkerStyle(20); grResPeriod->SetMarkerSize(0.3); grResPeriod->GetYaxis()->SetLabelSize(0.12); grResPeriod->GetXaxis()->SetLabelSize(0.12); grResPeriod->Draw("APEsame"); } cout << "Draw Data - Pedestals Subtracted" << endl; TString Title = "Average Charge - Pedestal subtracted"; TCanvas *csubdata = new TCanvas("csubdata", Title, 1200, 780); grDataSubAnaCh->SetMarkerStyle(20); grDataSubAnaCh->SetMarkerSize(0.3); grDataSubAnaCh->GetYaxis()->SetLabelSize(0.12); grDataSubAnaCh->GetXaxis()->SetLabelSize(0.12); grDataSubAnaCh->Draw("APE"); fsinFit->Draw("same"); */ // draw extra graphs if (DrawExtraGraphs == 1) { cout << " ----- DRAW Results ------" << endl; //================ DRAW Results ================== TCanvas *c = new TCanvas("ctmp", "test", 800, 800); c->Divide(3, 3); for (int pad = 1; pad < 10; pad++) { c->cd(pad); ((TH1 *) hCellList->At(pad * 512 + 219))->DrawCopy(); hCellSub = (TH1F *) hCellSubList->At(pad * 512 + 219); hCellSub->SetLineColor(2); hCellSub->DrawCopy("same"); } cout << "Draw RMS distributions" << endl; TString Title = "RMS distributions per channel"; TCanvas *c4 = new TCanvas("c4", Title, 700, 700); c4->Divide(3, 3); for (int i = 0; i < DOMINO_NCH; i++) { c4->cd(i + 2); hRMSdist = (TH1F *) hRMSList->At(i); hRMSFitdist = (TH1F *) hRMSFitList->At(i); hRMSFitdist->SetLineColor(2); hRMSFitdist->DrawCopy(); hRMSdist->DrawCopy("same"); } TList *grDataCh0SubList = new TList(); TGraphErrors *grDataCh0Sub; for(h = 0; h< DOMINO_NCELL; h++) { grDataCh0Sub = new TGraphErrors(DOMINO_NCELL); grDataCh0SubList->Add(grDataCh0Sub); } TGraphErrors *grDataSubCh0 = (TGraphErrors *) grDataSubList->At(6); for(h = 0; h < DOMINO_NCH; h++) { grDataSub = (TGraphErrors *) grDataSubList->At(h); grDataCh0Sub = (TGraphErrors *) grDataCh0SubList->At(h); for(ch = 0; ch < DOMINO_NCELL; ch++) { grDataSubCh0->GetPoint(ch, x1, y1); grDataSub->GetPoint(ch, x2, y2); grDataCh0Sub->SetPoint(ch, x1 , y2 - y1); } } TCanvas *cDataCH0Sub = new TCanvas("cDataCH0Sub","cDataCH0Sub", 1000,1000); cDataCH0Sub->Divide(1,8); for(h = 0; h < DOMINO_NCH; h++) { cDataCH0Sub->cd(h+1); grDataCh0Sub = (TGraphErrors *) grDataCh0SubList->At(h); grDataCh0Sub->GetYaxis()->SetLabelSize(0.12); grDataCh0Sub->GetXaxis()->SetLabelSize(0.12); grDataCh0Sub->Draw("APEL"); } cout << "Draw Data - Pedestals Subtracted" << endl; TString Title = "Average Charge - Pedestal subtracted"; TCanvas *csubdata = new TCanvas("csubdata", Title, 1000, 1000); csubdata->Divide(3,3); for(h = 0; h < DOMINO_NCH; h++) { csubdata->cd(h+1); TString title = "DataSub channel "; title += h; TH1F *hCellDataSub = new TH1F(title, title, 100, -20, 20); grDataSub = (TGraphErrors *) grDataSubList->At(h); for(ch = 0; ch < DOMINO_NCELL; ch++) { grDataSub->GetPoint(ch, x, y); hCellDataSub->Fill(y); } hCellDataSub->Fit("gaus", "Q"); hCellDataSub->GetXaxis()->SetTitle("ADC Counts"); hCellDataSub->GetFunction("gaus")->SetLineColor(4); hCellDataSub->DrawCopy(); } cout << "breakpoint" << endl; TCanvas *csubdata2 = new TCanvas("csubdata2", "DataSub for every channel", 1000, 1000); TString title = "DataSub every channel "; TH1F *hCellChDataSubTot = new TH1F(title, title, 100, -20, 20); for(h = 0; h < DOMINO_NCH; h++) { grDataSub = (TGraphErrors *) grDataSubList->At(h); for(ch = 0; ch < DOMINO_NCELL; ch++) { grDataSub->GetPoint(ch, x, y); hCellChDataSubTot->Fill(y); } hCellChDataSubTot->Fit("gaus", "Q"); hCellChDataSubTot->GetXaxis()->SetTitle("ADC Counts"); hCellChDataSubTot->GetFunction("gaus")->SetLineColor(4); hCellChDataSubTot->Draw(); } cout << "Draw Pedestals" << endl; TString Title = "Pedestals"; TCanvas *c2 = new TCanvas("c2", Title, 1050, 780); c2->SetBorderMode(0); c2->SetBorderSize(0.); c2->Divide(1, 8); // gStyle->SetCanvasBorderMode(0.); // gStyle->SetCanvasBorderSize(0.); Double_t x, y; for (int h = 0; h < DOMINO_NCH; h++) { c2->cd(h + 1); grPed = ((TGraphErrors *) grPedList->At(h)); grPed->SetMarkerStyle(20); grPed->SetMarkerSize(0.5); grPed->GetYaxis()->SetLabelSize(0.12); grPed->GetXaxis()->SetLabelSize(0.12); // cout << " err:" << grPed->GetErrorY(102) << " " ; // cout << x << "--" << y << endl; grPed->Draw("APE"); } cout << "Draw Data - Average charge" << endl; TString Title = "Average_Charge"; TCanvas *cdata = new TCanvas("cdata", Title, 1050, 780); cdata->Divide(1, 8); Double_t x, y; for (int h = 0; h < DOMINO_NCH; h++) { cdata->cd(h + 1); grData = ((TGraphErrors *) grDataList->At(h)); grData->SetMarkerStyle(20); grData->SetMarkerSize(0.3); grData->GetYaxis()->SetLabelSize(0.12); grData->GetXaxis()->SetLabelSize(0.12); grData->GetPoint(10, x, y); // cout << x << "-" << y << endl; grData->Draw("APE"); } cout << "Draw Data - Pedestals Subtracted" << endl; TString Title = "Average Charge - Pedestal subtracted"; TCanvas *csubdata = new TCanvas("csubdata", Title, 1200, 780); csubdata->Divide(1, 8); TF1 *fsin = new TF1("fsin", sigSin, 0., 1024., 4); TH1D *resDist = new TH1D("resDist", "Residuals Signal", 100, -100., 100.); cout << "Draw Data - Pedestals Subtracted" << endl; TString Title = "Residuals"; TCanvas *residuals = new TCanvas("residuals", Title, 1200, 780); resDist->DrawCopy(); } fclose(fdata); hCellList->Delete(); hCellSubList->Delete(); hRMSList->Delete(); hRMSFitList->Delete(); }
void howManyPe7_17_evening(){ cout << "Starting" << endl; const int numRuns = 6; const char* files[numRuns] = { "../../crunchedFiles/run_00480_crunched.root", "../../crunchedFiles/run_00481_crunched.root", "../../crunchedFiles/run_00482_crunched.root", "../../crunchedFiles/run_00483_crunched.root", "../../crunchedFiles/run_00484_crunched.root", "../../crunchedFiles/run_00485_crunched.root", }; gStyle->SetOptFit(1); gStyle->SetOptStat(0); double pes[16]; double peErrors[16]; double gains[16]; double gainErrors[16]; TCanvas* c1 = new TCanvas(); cout << "starting loop " << endl; for(int row = 2; row < 6; ++row){ for(int col = 2; col < 6; ++col){ vector<double> means; vector<double> sigs; vector<double> meanErrs; vector<double> sigErrs; for (int i = 0; i < numRuns; ++i){ TFile* f = new TFile(files[i]); TTree* t = (TTree*) f->Get("t"); t->Draw(Form("sipm%i%i.energy>>histo%i%i", row,col,row,col),Form("sipm%i%i.valid",row,col)); TH1F* h = (TH1F*) gROOT->FindObject(Form("histo%i%i",row,col)); h->Fit("gaus","0q"); if(h->GetFunction("gaus")->GetParameter(1)>250){ means.push_back(h->GetFunction("gaus")->GetParameter(1)); sigs.push_back(h->GetFunction("gaus")->GetParameter(2)); meanErrs.push_back(h->GetFunction("gaus")->GetParError(1)); sigErrs.push_back(h->GetFunction("gaus")->GetParError(2)); } } vector<double> variances; vector<double> varianceErrors; for(int i = 0; i < means.size(); ++i){ variances.push_back(sigs[i]*sigs[i]); varianceErrors.push_back(2*sigs[i]*sigErrs[i]); } if(means.size() > 1){ TGraphErrors* linGraph = new TGraphErrors(means.size(), &means[0], &variances[0], &meanErrs[0], &varianceErrors[0]); TGraphErrors* quadGraph = new TGraphErrors(means.size(), &means[0], &variances[0], &meanErrs[0], &varianceErrors[0]); linGraph->SetMarkerStyle(20); linGraph->Fit("pol1","q"); linGraph->SetTitle(Form("SiPM %i%i", row, col)); linGraph->GetFunction("pol1")->SetLineColor(kBlue); linGraph->GetXaxis()->SetTitle("Mean"); linGraph->GetYaxis()->SetTitle("#sigma^{2}"); quadGraph->SetMarkerStyle(20); quadGraph->Fit("pol2","q"); quadGraph->GetFunction("pol2")->SetLineColor(kRed); linGraph->Draw("ap"); quadGraph->Draw("psame"); UInt_t index = (row-2)*4 + (col-2); pes[index] = 1.0/linGraph->GetFunction("pol1")->GetParameter(1)*means[0]; gains[index] = linGraph->GetFunction("pol1")->GetParameter(1); gainErrors[index] = linGraph->GetFunction("pol1")->GetParError(1); peErrors[index] = TMath::Sqrt((1/gains[index]*meanErrs[0])*(1/gains[index]*meanErrs[0])+ (means[0]/(gains[index]*gains[index])*gainErrors[index])*(means[0]/(gains[index]*gains[index])*gainErrors[index])); /* pes[drs] = 1.0/quadGraph->GetFunction("pol2")->GetParameter(1)*means[0]; gains[drs] = quadGraph->GetFunction("pol2")->GetParameter(1); gainErrors[drs] = quadGraph->GetFunction("pol2")->GetParError(1); peErrors[drs] = TMath::Sqrt((1/gains[drs]*meanErrs[0])*(1/gains[drs]*meanErrs[0])+ (means[0]/(gains[drs]*gains[drs])*gainErrors[drs])*(means[0]/(gains[drs]*gains[drs])*gainErrors[drs])); */ delete linGraph; delete quadGraph; } else if (means.size()==1){ UInt_t index = (row-2)*4 + (col-2); UInt_t mean = means[0]; UInt_t sig = sigs[0]; UInt_t meanErr = meanErrs[0]; UInt_t sigErr = sigErrs[0]; pes[index] = mean*mean/sig/sig; gains[index] = mean/pes[index]; gainErrors[index] = TMath::Sqrt((2*sig/mean*sigErr)*(2*sig/mean*sigErr)+(sig*sig/mean/mean*meanErr)*(sig*sig/mean/mean*meanErr)); peErrors[index] = TMath::Sqrt((2*mean/sig/sig*sigErr)*(2*mean/sig/sig*sigErr)+(2*mean*mean/sig/sig/sig*sigErr)*(2*mean*mean/sig/sig/sig*sigErr)); } else{ UInt_t index = (row-2)*4 + (col-2); pes[index] = -1; gains[index] = -1; peErrors[index] = -1; gainErrors[index] = -1; } } } for(int i = 0; i <16; ++i){ cout << "SiPM " << 2+i/4 << 2+i%4 << " --- " << "p1 : " << gains[i] << ", " << pes[i] << " photoelectrons at open filter, " << gains[i]*pes[i] << "calibration constant." << endl; } TGraphErrors* peGainGraph = new TGraphErrors(16, gains, pes, gainErrors, peErrors); peGainGraph->SetMarkerStyle(20); peGainGraph->GetXaxis()->SetTitle("gain"); peGainGraph->GetYaxis()->SetTitle("PE at open filter"); c1->SetGridx(); c1->SetGridy(); peGainGraph->Draw("ap"); cout << "drew graph " << endl; TCanvas* c2 = new TCanvas(); TH2F* peMap = new TH2F("pes","PE Map", 4,0,4,4,0,4); for(int i = 0; i < 16; ++i){ peMap->Fill(.5+i%4, 3.5-i/4, pes[i]); } peMap->GetXaxis()->SetLabelOffset(99); peMap->GetYaxis()->SetLabelOffset(99); c2->SetTickx(0); c2->SetTicky(0); peMap->Draw("TEXT"); TCanvas* c3 = new TCanvas(); TH2F* gainMap = new TH2F("gains","Gain Map", 4,0,4,4,0,4); for(int i = 0; i < 16; ++i){ gainMap->Fill(.5+i%4, 3.5-i/4, gains[i]); } gainMap->GetXaxis()->SetLabelOffset(99); gainMap->GetYaxis()->SetLabelOffset(99); gainMap->Draw("TEXT"); }
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(); }
int plotEfromTree(){//main std::string baseDir = "../PLOTS/gitV00-02-04/version23/e-/"; std::string baseDirPi = "../PLOTS/gitV00-02-04/version23/pi-/"; bool isEM = baseDir.find("e-")!=baseDir.npos; TString pSuffix = ""; const bool doVsE = true; unsigned genEn[]={10,15,18,20,25,30,35,40,45,50,60,80}; const unsigned nGenEn=sizeof(genEn)/sizeof(unsigned); // unsigned nx=0,ny=0; // if (nGenEn>12) {nx=5;ny=3;} // else if (nGenEn > 10) // {nx=4;ny=3;} // else if (nGenEn > 6) // {nx=5;ny=2;} // else if (nGenEn > 4) // {nx=3;ny=2;} // else if (nGenEn > 2) // {nx=2;ny=2;} // else // {nx=nGenEn;ny=1;} // mycE->Divide(nx,ny); // std::cout << " Divide: " << nx << " " << ny << std::endl; const unsigned nLimits = 10;//5; const double pElim[nLimits] = {3,4,5,6,7,8,9,10,11,12}; const unsigned idxRef = 2; const unsigned nEPts = 2;//14; TString EnamesE[nEPts] = { "G4", //"G4mipcut", //"G4Noise12", //"G4Noise15", //"G4Noise20", //"G4XT2d5Noise", //"G4XT3d5Noise", //"G4XT5Noise", //"G4Rand1156N3Noise", //"G4Rand1156N6Noise", //"G4Rand925N3Noise", //"G4Rand925N6Noise", "G4XT2d5Rand1156N3Noise12", //"G4XT3d5Rand925N6Noise15" }; TString EnamesC[nLimits]; for (unsigned ilim(0);ilim<nLimits;++ilim){ std::ostringstream bname; bname << "Cglobal_" << static_cast<unsigned>(pElim[ilim]) << "mip"; EnamesC[ilim] = bname.str(); } unsigned nPts = nEPts+nLimits; TString Enames[nPts]; for (unsigned i(0);i<nPts;++i){ if (i<nEPts) Enames[i] = EnamesE[i]; else Enames[i] = EnamesC[i-nEPts]; } int marker[14] = {20,28,21,22,23,21,22,23,24,24,25,25,26,27}; int color[14] = {1,1,kRed-2,kRed,kRed+2,kGreen-2,kGreen,kGreen+2,kCyan,kBlue,kYellow,kYellow+2,kViolet-1,kViolet+1}; const unsigned nCanvas = nPts+6; TCanvas *myc[nCanvas]; TCanvas *mycinv[nPts]; for (unsigned iC(0);iC<nCanvas;++iC){ std::ostringstream lName; lName << "myc" << iC; myc[iC] = new TCanvas(lName.str().c_str(),lName.str().c_str(),1); lName.str(""); if (iC<nPts){ lName << "mycinv" << iC; mycinv[iC] = new TCanvas(lName.str().c_str(),lName.str().c_str(),1); } } double offsetVal[nPts]; double slopeVal[nPts]; double aVal[nPts]; double bVal[nPts]; double cVal[nPts]; for (unsigned iP(0); iP<nPts; ++iP){ offsetVal[iP] = 0; slopeVal[iP] = 1; aVal[iP] = 1; bVal[iP] = 0; cVal[iP] = 0; } for (unsigned iC(0); iC<4;++iC){//calib TLegend *leg = new TLegend(0,0,1,1); leg->SetFillColor(10); float meanE[nGenEn][nPts]; float rmsE[nGenEn][nPts]; float meanEerr[nGenEn][nPts]; float rmsEerr[nGenEn][nPts]; float meanFitE[nGenEn][nPts]; float rmsFitE[nGenEn][nPts]; float meanFitEerr[nGenEn][nPts]; float rmsFitEerr[nGenEn][nPts]; gStyle->SetOptStat(0); std::string plotDir; if (iC==1 || iC==3) plotDir = baseDir+"calib/"; else if (iC==2) { baseDir = baseDirPi; isEM = false; plotDir = baseDir; for (unsigned iP(0); iP<nEPts; ++iP){ slopeVal[iP] = slopeVal[iP]/1.19; } } else plotDir = baseDir; for (unsigned iE(0); iE<nGenEn; ++iE){ std::cout << "- Processing energy : " << genEn[iE] << std::endl; TFile *inputFile = 0; std::ostringstream linputStr; linputStr << baseDir << "validateCalice_e" << genEn[iE] << pSuffix << ".root"; inputFile = TFile::Open(linputStr.str().c_str()); if (!inputFile) { std::cout << " -- Error, input file " << linputStr.str() << " cannot be opened. Exiting..." << std::endl; return 1; } else std::cout << " -- File " << inputFile->GetName() << " successfully opened." << std::endl; TTree *tree = (TTree*)gDirectory->Get("Estudy"); if (!tree) { std::cout << " Tree not found." << std::endl; return 1; } else std::cout << " tree found." << std::endl; //extract histos extractMeanEnergy(color,marker,tree,nPts, Enames,genEn[iE], meanE[iE],rmsE[iE], meanEerr[iE],rmsEerr[iE], meanFitE[iE],rmsFitE[iE], meanFitEerr[iE],rmsFitEerr[iE], plotDir, offsetVal,slopeVal, aVal,bVal,cVal); inputFile->Close(); }//loop on energies std::ostringstream saveName; saveName.str(""); TGraphErrors *calib[nPts]; TGraphErrors *sigma[nPts]; TGraphErrors *reso[nPts]; TGraphErrors *calibinv[nPts]; TGraphErrors *calibFit[nPts]; TGraphErrors *deltaFit[nPts]; TGraphErrors *sigmaFit[nPts]; TGraphErrors *resoFit[nPts]; TGraphErrors * gr[nPts]; TGraphErrors * grDelta[nPts]; TGraphErrors *groffset = new TGraphErrors(); TGraphErrors *grslope = new TGraphErrors(); //draw all in one plot TPad *upperTot = plot_ratio(myc[nPts], true); TPad *lowerTot = plot_ratio(myc[nPts], false); if (!upperTot || !lowerTot){ std::cout << " Pb..." << upperTot << " " << lowerTot << std::endl; return 1; } //extract linearity for (unsigned iP(0); iP<nPts; ++iP){ TString lSuf = "_"; lSuf += iP; //draw calibration curves calib[iP] = new TGraphErrors(); calib[iP]->SetName("calib"+lSuf); calib[iP]->SetMarkerStyle(marker[iP]); calib[iP]->SetLineColor(color[iP]); calib[iP]->SetLineStyle(3); calib[iP]->SetMarkerColor(color[iP]); calib[iP]->SetTitle(""); sigma[iP] = (TGraphErrors *) calib[iP]->Clone("sigma"+lSuf); reso[iP] = (TGraphErrors *) calib[iP]->Clone("reso"+lSuf); calibFit[iP] = (TGraphErrors *) calib[iP]->Clone("calibFit"+lSuf); calibFit[iP]->SetMarkerStyle(marker[iP]); calibFit[iP]->SetLineStyle(1); calibFit[iP]->SetLineColor(color[iP]); calibFit[iP]->SetMarkerColor(color[iP]); calibinv[iP] = (TGraphErrors *) calibFit[iP]->Clone("calibinv"+lSuf); deltaFit[iP] = (TGraphErrors *) calibFit[iP]->Clone("deltaFit"+lSuf); sigmaFit[iP] = (TGraphErrors *) calibFit[iP]->Clone("sigmaFit"+lSuf); resoFit[iP] = (TGraphErrors *) calibFit[iP]->Clone("resoFit"+lSuf); for (unsigned iE(0); iE<nGenEn; ++iE){ Int_t np=calib[iP]->GetN(); calib[iP]->SetPoint(np,genEn[iE],meanE[iE][iP]); calib[iP]->SetPointError(np,0.0,meanEerr[iE][iP]); sigma[iP]->SetPoint(np,genEn[iE],rmsE[iE][iP]); sigma[iP]->SetPointError(np,0.0,rmsEerr[iE][iP]); reso[iP]->SetPoint(np,doVsE?genEn[iE] : 1/sqrt(genEn[iE]),rmsE[iE][iP]/meanE[iE][iP]); double err = rmsE[iE][iP]/meanE[iE][iP]*sqrt(pow(rmsEerr[iE][iP]/rmsE[iE][iP],2)+pow(meanEerr[iE][iP]/meanE[iE][iP],2)); reso[iP]->SetPointError(np,0,err); calibinv[iP]->SetPoint(np,meanFitE[iE][iP],genEn[iE]); calibinv[iP]->SetPointError(np,meanFitEerr[iE][iP],0.01*genEn[iE]); calibFit[iP]->SetPoint(np,genEn[iE],meanFitE[iE][iP]); calibFit[iP]->SetPointError(np,0.0,meanFitEerr[iE][iP]); sigmaFit[iP]->SetPoint(np,genEn[iE],rmsFitE[iE][iP]); sigmaFit[iP]->SetPointError(np,0.0,rmsFitEerr[iE][iP]); resoFit[iP]->SetPoint(np,doVsE?genEn[iE] : 1/sqrt(genEn[iE]),rmsFitE[iE][iP]/meanFitE[iE][iP]); double errFit = rmsFitE[iE][iP]/meanFitE[iE][iP]*sqrt(pow(rmsFitEerr[iE][iP]/rmsFitE[iE][iP],2)+pow(meanFitEerr[iE][iP]/meanFitE[iE][iP],2)); resoFit[iP]->SetPointError(np,0,errFit); }//loop on energies TPad *upper = plot_ratio(myc[iP], true); TPad *lower = plot_ratio(myc[iP], false); if (!upper || !lower){ std::cout << " Pb..." << upper << " " << lower << std::endl; return 1; } //draw inverted calib mycinv[iP]->cd(); gPad->SetGridx(1); gPad->SetGridy(1); gr[iP] = calibinv[iP]; //gr[iP]->GetXaxis()->SetLabelSize(0.06); //gr[iP]->GetXaxis()->SetTitleSize(0.06); //gr[iP]->GetYaxis()->SetLabelSize(0.06); //gr[iP]->GetYaxis()->SetTitleSize(0.06); //gr[iP]->GetXaxis()->SetTitleOffset(0.7); //gr[iP]->GetYaxis()->SetTitleOffset(0.8); gr[iP]->SetTitle(Enames[iP]); gr[iP]->Draw("ap"); gr[iP]->GetYaxis()->SetTitle("Beam energy [GeV]"); if (iC==0) gr[iP]->GetXaxis()->SetTitle("Corrected energy deposited [MIPs]"); else gr[iP]->GetXaxis()->SetTitle("Corrected energy deposited [GeV]"); //gr[iP]->GetXaxis()->SetTitle(doVsE?"Beam energy [GeV]" :"1/#sqrt{Beam energy} [1/#sqrt{GeV}]"); char buf[500]; //TF1 *fitFunc=new TF1("calib","[0]+[1]*x",gr->GetXaxis()->GetXmin(),gr->GetXaxis()->GetXmax()); TF1 *fitFuncinv=new TF1("calibinv","[0]*x+[1]*x*x+[2]*x*x*x",gr[iP]->GetXaxis()->GetXmin(),gr[iP]->GetXaxis()->GetXmax()); fitFuncinv->SetLineColor(1); gr[iP]->Fit(fitFuncinv,"RME"); gr[iP]->GetFunction("calibinv")->SetLineColor(color[iP]); TLatex lat; lat.SetTextColor(1); sprintf(buf,"<E> #propto E #times (a + b #times E +c #times E^{2})"); lat.DrawLatex(genEn[0],gr[iP]->GetYaxis()->GetXmax()*0.9,buf); sprintf(buf,"a = %3.3f #pm %3.3f %s",fitFuncinv->GetParameter(0),fitFuncinv->GetParError(0),iC==0?"MIPs":"GeV"); lat.DrawLatex(genEn[0],gr[iP]->GetYaxis()->GetXmax()*(0.8),buf); sprintf(buf,"b = %3.3f #pm %3.3f %s/GeV",fitFuncinv->GetParameter(1),fitFuncinv->GetParError(1),iC==0?"MIPs":"GeV"); lat.DrawLatex(genEn[0],gr[iP]->GetYaxis()->GetXmax()*(0.7),buf); sprintf(buf,"c = %3.6f #pm %3.6f %s/GeV",fitFuncinv->GetParameter(2),fitFuncinv->GetParError(2),iC==0?"MIPs":"GeV"); lat.DrawLatex(genEn[0],gr[iP]->GetYaxis()->GetXmax()*(0.6),buf); sprintf(buf,"chi2/NDF = %3.3f/%d = %3.3f",fitFuncinv->GetChisquare(),fitFuncinv->GetNDF(),fitFuncinv->GetChisquare()/fitFuncinv->GetNDF()); lat.DrawLatex(genEn[0],gr[iP]->GetYaxis()->GetXmax()*(0.5),buf); if (iP>=nEPts && iC==2) { aVal[iP] = fitFuncinv->GetParameter(0); bVal[iP] = fitFuncinv->GetParameter(1); cVal[iP] = fitFuncinv->GetParameter(2); } mycinv[iP]->Update(); saveName.str(""); saveName << plotDir << "/CalibEshower_" << Enames[iP]; mycinv[iP]->Update(); mycinv[iP]->Print((saveName.str()+".png").c_str()); mycinv[iP]->Print((saveName.str()+".pdf").c_str()); //draw calib upper->cd(); gPad->SetGridx(1); gPad->SetGridy(1); gr[iP] = calibFit[iP]; gr[iP]->GetXaxis()->SetLabelSize(0.06); gr[iP]->GetXaxis()->SetTitleSize(0.06); gr[iP]->GetYaxis()->SetLabelSize(0.06); gr[iP]->GetYaxis()->SetTitleSize(0.06); gr[iP]->GetXaxis()->SetTitleOffset(0.7); gr[iP]->GetYaxis()->SetTitleOffset(0.8); gr[iP]->SetTitle(Enames[iP]); gr[iP]->SetMaximum(std::max(calib[iP]->GetMaximum(),calibFit[iP]->GetMaximum())); gr[iP]->Draw("ap"); calib[iP]->Draw("pl"); gr[iP]->GetXaxis()->SetTitle(""); if (iC==0) gr[iP]->GetYaxis()->SetTitle("Average energy deposited [MIPs]"); else gr[iP]->GetYaxis()->SetTitle("Average energy deposited [GeV]"); //gr[iP]->GetXaxis()->SetTitle(doVsE?"Beam energy [GeV]" :"1/#sqrt{Beam energy} [1/#sqrt{GeV}]"); //TF1 *fitFunc=new TF1("calib","[0]+[1]*x",gr->GetXaxis()->GetXmin(),gr->GetXaxis()->GetXmax()); TF1 *fitFunc=new TF1("calib","[0]+[1]*x",9,51); fitFunc->SetLineColor(1); gr[iP]->Fit(fitFunc,"RME"); gr[iP]->GetFunction("calib")->SetLineColor(color[iP]); lat.SetTextColor(1); sprintf(buf,"<E> #propto a + b #times E "); lat.DrawLatex(genEn[0],gr[iP]->GetYaxis()->GetXmax()*0.9,buf); sprintf(buf,"a = %3.3f #pm %3.3f %s",fitFunc->GetParameter(0),fitFunc->GetParError(0),iC==0?"MIPs":"GeV"); lat.DrawLatex(genEn[0],gr[iP]->GetYaxis()->GetXmax()*(0.8),buf); sprintf(buf,"b = %3.3f #pm %3.3f %s/GeV",fitFunc->GetParameter(1),fitFunc->GetParError(1),iC==0?"MIPs":"GeV"); lat.DrawLatex(genEn[0],gr[iP]->GetYaxis()->GetXmax()*(0.7),buf); sprintf(buf,"chi2/NDF = %3.3f/%d = %3.3f",fitFunc->GetChisquare(),fitFunc->GetNDF(),fitFunc->GetChisquare()/fitFunc->GetNDF()); lat.DrawLatex(genEn[0],gr[iP]->GetYaxis()->GetXmax()*(0.6),buf); groffset->SetPoint(iP,iP,fitFunc->GetParameter(0)); groffset->SetPointError(iP,0.0,fitFunc->GetParError(0)); if (iC==0) offsetVal[iP] = fitFunc->GetParameter(0); if (iP>=nEPts && iC==0) offsetVal[iP] = offsetVal[1]; grslope->SetPoint(iP,iP,fitFunc->GetParameter(1)); grslope->SetPointError(iP,0.0,fitFunc->GetParError(1)); if (iC==0) slopeVal[iP] = fitFunc->GetParameter(1); if (iP>=nEPts && iC==0) slopeVal[iP] = slopeVal[1]; //groffset->GetXaxis()->SetBinLabel(iP+1,Enames[iP].Data()); //grslope->GetHistogram()->GetXaxis()->SetBinLabel(iP+1,Enames[iP].Data()); //draw deltaE/E vs E lower->cd(); gPad->SetLogx(0); gPad->SetGridx(1); gPad->SetGridy(1); for (unsigned iE(0);iE<nGenEn;++iE){ if (iC<1){ deltaFit[iP]->SetPoint(iE,genEn[iE],( ((meanFitE[iE][iP]-fitFunc->GetParameter(0))/fitFunc->GetParameter(1))-genEn[iE])/genEn[iE]); deltaFit[iP]->SetPointError(iE,0.0,meanFitEerr[iE][iP]/fitFunc->GetParameter(1)*1./genEn[iE]); } else { deltaFit[iP]->SetPoint(iE,genEn[iE],(meanFitE[iE][iP]-genEn[iE])/genEn[iE]); deltaFit[iP]->SetPointError(iE,0.0,meanFitEerr[iE][iP]/genEn[iE]); } } grDelta[iP] = deltaFit[iP]; grDelta[iP]->SetTitle(""); if (iC<2){ grDelta[iP]->SetMinimum(-0.03); grDelta[iP]->SetMaximum(0.03); } else { grDelta[iP]->SetMinimum(-0.1); grDelta[iP]->SetMaximum(0.1); } grDelta[iP]->GetXaxis()->SetLabelSize(0.15); grDelta[iP]->GetXaxis()->SetTitleSize(0.15); grDelta[iP]->GetYaxis()->SetLabelSize(0.12); grDelta[iP]->GetYaxis()->SetTitleSize(0.15); grDelta[iP]->GetXaxis()->SetTitleOffset(0.5); grDelta[iP]->GetYaxis()->SetTitleOffset(0.3); grDelta[iP]->Draw("ap"); //grDelta[iP]->GetYaxis()->SetRangeUser(0,grDelta->GetYaxis()->GetXmax()); grDelta[iP]->GetXaxis()->SetTitle("Beam energy [GeV]"); grDelta[iP]->GetYaxis()->SetTitle("(#Delta E)/E"); myc[iP]->Update(); saveName.str(""); saveName << plotDir << "/CalibE_" << Enames[iP]; myc[iP]->Update(); myc[iP]->Print((saveName.str()+".png").c_str()); myc[iP]->Print((saveName.str()+".pdf").c_str()); upperTot->cd(); gPad->SetGridx(1); gPad->SetGridy(1); if (iP==0) gr[iP]->Draw("ap"); else gr[iP]->Draw("psame"); lowerTot->cd(); gPad->SetGridx(1); gPad->SetGridy(1); if (iP==0) grDelta[iP]->Draw("ap"); else grDelta[iP]->Draw("psame"); myc[nPts+1]->cd(); gPad->SetGridx(1); gPad->SetGridy(1); sigmaFit[iP]->SetTitle(""); sigmaFit[iP]->SetMaximum(std::max(sigma[iP]->GetMaximum(),sigmaFit[iP]->GetMaximum())); if (iP==0) sigmaFit[iP]->Draw("ap"); else sigmaFit[iP]->Draw("p"); //sigma[iP]->Draw("pl"); sigmaFit[iP]->GetXaxis()->SetTitle("Beam energy [GeV]"); if (iC==0) sigmaFit[iP]->GetYaxis()->SetTitle("RMS energy deposited [MIPs]"); else sigmaFit[iP]->GetYaxis()->SetTitle("RMS energy deposited [GeV]"); leg->AddEntry(sigmaFit[iP],Enames[iP],"P"); myc[nPts+2]->cd(); gPad->SetGridx(1); gPad->SetGridy(1); resoFit[iP]->SetTitle(""); //resoFit[iP]->SetMaximum(std::max(reso[iP]->GetMaximum(),resoFit[iP]->GetMaximum())); if (iP==0) resoFit[iP]->Draw("ap"); else resoFit[iP]->Draw("p"); //reso[iP]->Draw("pl"); resoFit[iP]->GetXaxis()->SetTitle("Beam energy (GeV)"); resoFit[iP]->GetYaxis()->SetTitle("Relative energy resolution"); TF1* fitref =new TF1("reso","sqrt([0]/x+[1]+[2]/(x*x))",resoFit[iP]->GetXaxis()->GetXmin(),resoFit[iP]->GetXaxis()->GetXmax()); if (isEM) fitref->SetParameters(0.215*0.215,0.007*0.007,0.06*0.06); else { if (iP<nEPts) fitref->SetParameters(0.518*0.518,0.04*0.04,0.18*0.18); else fitref->SetParameters(0.436*0.436,0.0*0.0,0.18*0.18); } fitref->SetLineColor(4); fitref->SetLineStyle(2); fitref->Draw("same"); lat.SetTextColor(4); //sprintf(buf,"CALICE"); sprintf(buf,"CALICE s=%3.3f, c=%3.3f, n=%3.3f",sqrt(fitref->GetParameter(0)),sqrt(fitref->GetParameter(1)),sqrt(fitref->GetParameter(2))); if (iP==0) lat.DrawLatex(30,resoFit[iP]->GetYaxis()->GetXmax()*0.9,buf); myc[iP]->Clear(); myc[iP]->cd(); gPad->SetGridx(1); gPad->SetGridy(1); resoFit[iP]->SetMaximum(std::max(reso[iP]->GetMaximum(),resoFit[iP]->GetMaximum())); resoFit[iP]->GetXaxis()->SetLabelSize(0.05); resoFit[iP]->GetXaxis()->SetTitleSize(0.05); resoFit[iP]->GetYaxis()->SetLabelSize(0.05); resoFit[iP]->GetYaxis()->SetTitleSize(0.05); //resoFit[iP]->GetXaxis()->SetTitleOffset(0.7); resoFit[iP]->GetYaxis()->SetTitleOffset(1.2); resoFit[iP]->Draw("ap"); //reso[iP]->Draw("l"); bool addNoiseTerm = false; if (iP>0) addNoiseTerm = true; TF1 *fitFunc2; if (doVsE){ fitFunc2 =new TF1("reso","sqrt([0]/x+[1])",resoFit[iP]->GetXaxis()->GetXmin(),resoFit[iP]->GetXaxis()->GetXmax()); if (addNoiseTerm) fitFunc2 =new TF1("reso","sqrt([0]/x+[1]+[2]/(x*x))",resoFit[iP]->GetXaxis()->GetXmin(),resoFit[iP]->GetXaxis()->GetXmax()); } else { fitFunc2 =new TF1("reso","sqrt([0]*x*x+[1])",resoFit[iP]->GetXaxis()->GetXmin(),resoFit[iP]->GetXaxis()->GetXmax()); if (addNoiseTerm) fitFunc2 =new TF1("reso","sqrt([0]*x*x+[1]+[2]*x*x*x*x)",resoFit[iP]->GetXaxis()->GetXmin(),resoFit[iP]->GetXaxis()->GetXmax()); } fitFunc2->SetParameter(0,0.2); fitFunc2->SetParLimits(0,0,1); fitFunc2->SetParameter(1,0.01); fitFunc2->SetParLimits(1,0,1); if (addNoiseTerm) { if (!isEM) fitFunc2->SetParameter(2,0.18*0.18); else fitFunc2->SetParameter(2,0.06*0.06); fitFunc2->SetParLimits(2,0,2); if (!isEM) fitFunc2->FixParameter(2,0.18*0.18); else fitFunc2->FixParameter(2,0.06*0.06); } fitref->Draw("same"); resoFit[iP]->Fit(fitFunc2,"RME+"); resoFit[iP]->GetFunction("reso")->SetLineColor(color[iP]); fitFunc2->SetLineColor(color[iP]); fitFunc2->Draw("same"); double sigmaStoch = sqrt(fitFunc2->GetParameter(0)); double sigmaStochErr = fitFunc2->GetParError(0)/(2*sigmaStoch); double sigmaConst = sqrt(fitFunc2->GetParameter(1)); double sigmaConstErr = fitFunc2->GetParError(1)/(2*sigmaConst); double sigmaNoise = 0; double sigmaNoiseErr = 0; if (addNoiseTerm) { sigmaNoise = sqrt(fitFunc2->GetParameter(2)); sigmaNoiseErr = fitFunc2->GetParError(2)/(2*sigmaNoise); } lat.SetTextColor(1); sprintf(buf,"#frac{#sigma}{E} #propto #frac{s}{#sqrt{E}} #oplus c #oplus #frac{n}{E}"); double Emin = doVsE?50 : 1/sqrt(genEn[nGenEn-1]); lat.DrawLatex(Emin,resoFit[iP]->GetYaxis()->GetXmax()*0.94,buf); sprintf(buf,"s=%3.3f #pm %3.3f",sigmaStoch,sigmaStochErr); lat.DrawLatex(Emin,resoFit[iP]->GetYaxis()->GetXmax()*0.84,buf); sprintf(buf,"c=%3.3f #pm %3.3f",sigmaConst,sigmaConstErr); lat.DrawLatex(Emin,resoFit[iP]->GetYaxis()->GetXmax()*0.74,buf); sprintf(buf,"chi2/NDF = %3.3f/%d = %3.3f",fitFunc2->GetChisquare(),fitFunc2->GetNDF(),fitFunc2->GetChisquare()/fitFunc2->GetNDF()); //lat.DrawLatex(Emin,resoFit[iP]->GetYaxis()->GetXmax()*0.54,buf); if (addNoiseTerm) { sprintf(buf,"n=%3.2f",sigmaNoise); lat.DrawLatex(Emin,resoFit[iP]->GetYaxis()->GetXmax()*0.64,buf); } lat.SetTextColor(4); //sprintf(buf,"CALICE s=%3.3f, c=%3.3f, n=%3.3f",sqrt(fitref->GetParameter(0)),sqrt(fitref->GetParameter(1)),sqrt(fitref->GetParameter(2))); sprintf(buf,"CALICE"); lat.DrawLatex(70,resoFit[iP]->GetYaxis()->GetXmin()*1.35,buf); lat.SetTextColor(1); lat.DrawLatex(20,resoFit[iP]->GetYaxis()->GetXmax()*1.03,"Geant4 QGSP_BERT, #pi^{-} gun"); myc[iP]->Update(); saveName.str(""); saveName << plotDir << "/ResoE_" << Enames[iP]; myc[iP]->Update(); myc[iP]->Print((saveName.str()+".png").c_str()); myc[iP]->Print((saveName.str()+".pdf").c_str()); }//loop on points saveName.str(""); saveName << plotDir << "/Linearity_all";// << Enames[iP]; myc[nPts]->Update(); myc[nPts]->Print((saveName.str()+".png").c_str()); myc[nPts]->Print((saveName.str()+".pdf").c_str()); myc[nPts+1]->Update(); saveName.str(""); saveName << plotDir << "/RMSE_all";// << Enames[iP]; myc[nPts+1]->Update(); myc[nPts+1]->Print((saveName.str()+".png").c_str()); myc[nPts+1]->Print((saveName.str()+".pdf").c_str()); myc[nPts+2]->Update(); saveName.str(""); saveName << plotDir << "/Ereso_all";// << Enames[iP]; myc[nPts+2]->Update(); myc[nPts+2]->Print((saveName.str()+".png").c_str()); myc[nPts+2]->Print((saveName.str()+".pdf").c_str()); //myc[nPts+1]->Divide(1,2); myc[nPts+3]->cd(); gPad->SetGridx(1); gPad->SetGridy(1); groffset->SetTitle(""); groffset->GetXaxis()->SetTitle("Point"); groffset->GetYaxis()->SetTitle("Offset"); groffset->SetMarkerStyle(21); groffset->Draw("ap"); saveName.str(""); saveName << plotDir << "/Offset";// << Enames[iP]; myc[nPts+3]->Update(); myc[nPts+3]->Print((saveName.str()+".png").c_str()); myc[nPts+3]->Print((saveName.str()+".pdf").c_str()); myc[nPts+4]->cd(); gPad->SetGridx(1); gPad->SetGridy(1); grslope->SetTitle(""); grslope->GetXaxis()->SetTitle("Point"); grslope->GetYaxis()->SetTitle("Slope"); grslope->SetMarkerStyle(21); grslope->Draw("ap"); saveName.str(""); saveName << plotDir << "/Slope";// << Enames[iP]; myc[nPts+4]->Update(); myc[nPts+4]->Print((saveName.str()+".png").c_str()); myc[nPts+4]->Print((saveName.str()+".pdf").c_str()); myc[nPts+5]->cd(); leg->Draw(); saveName.str(""); saveName << plotDir << "/Legend";// << Enames[iP]; myc[nPts+5]->Update(); myc[nPts+5]->Print((saveName.str()+".png").c_str()); myc[nPts+5]->Print((saveName.str()+".pdf").c_str()); }//calib return 0; }
// The actual job void signalEfficiency_w(int channel, double sqrts, int process, double JES, ofstream* txtYields) { TString schannel; if (channel == 1) schannel = "4mu"; else if (channel == 2) schannel = "4e"; else if (channel == 3) schannel = "2e2mu"; else cout << "Not a valid channel: " << channel << endl; TString schannelFilename = (schannel=="2e2mu"?"2mu2e":schannel); // adapt to naming convention of tree files TString sprocess; if (process == ggH) sprocess = "ggH"; else if (process == qqH) sprocess = "qqH"; else if (process == ZH) sprocess = "ZH"; else if (process == WH) sprocess = "WH"; else if (process == ttH) sprocess = "ttH"; else cout << "Not a valid channel: " << process << endl; TString sjes; if (JES==0.) sjes=""; else if (JES>0.) sjes="_up"; else if (JES<0.) sjes="_down"; TString ssqrts = (long) sqrts + TString("TeV"); // Print table with yields (*txtYields) << endl << endl << left << setw(7) << "*** Summary: " << sprocess << " process, sqrts = " << fixed << setprecision(0) <<sqrts << " TeV, channel = " << schannel << " ***" << endl << endl; (*txtYields) << left << setw(7) << "mH" << setw(13) << "XS*BR" << setw(13) << "Eff unt" << setw(13) << "Yield unt" << setw(13) << "Eff tag" << setw(13) << "Yield tag" << setw(13) << "Eff TOT" << setw(13) << "Yield TOT" << setw(13) << "Eff unt" << setw(13) << "Yield unt" << setw(13) << "Eff tag" << setw(13) << "Yield tag" << setw(13) << "Eff TOT" << setw(13) << "Yield TOT" << setw(13) << "n. raw" << setw(13) << "n. W pwg" << setw(13) << "n. W PU" << setw(13) << "n. W eff" << setw(13) << endl << left << setw(7) << " " << setw(13) << " " << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(in MW)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full)" << setw(13) << "(full U+T)" << setw(13) << "(full U+T)" << setw(13) << "(full U+T)" << setw(13) << "(full U+T)" << endl << endl; cout << "process = " << sprocess << " schannel = " << schannel << " sqrts = " << sqrts << " JES = " << JES <<endl; TString totoutfile = "CardFragments/signalEfficiency_" + ssqrts + "_" + schannel + sjes + ".txt"; TString ratiooutfile = "CardFragments/signalEfficiency_" + ssqrts + "_" + schannel + sjes + "_ratio.txt"; TString jetyieldoutfile = "CardFragments/signalEfficiency_" + ssqrts + "_" + schannel + sjes + "_jetyields.txt"; // Create card fragments using new powheg samples ofstream oftot; ofstream ofrat; if (process==ggH) { oftot.open(totoutfile,ios_base::out); ofrat.open(ratiooutfile,ios_base::out); } else { oftot.open(totoutfile,ios_base::out | ios_base::app); ofrat.open(ratiooutfile,ios_base::out | ios_base::app); } ftot = new TFile("sigFigs" + ssqrts +"/eff_" + sprocess + "_" + schannel + sjes + (useNewGGHPowheg ? ".root" : "_oldPwg.root"),"RECREATE"); fratio = new TFile("sigFigs" + ssqrts +"/eff_" + sprocess + "_" + schannel + sjes + (useNewGGHPowheg ? "_ratio.root" : "_ratio_oldPwg.root"),"RECREATE"); gSystem->AddIncludePath("-I$ROOFITSYS/include"); setTDRStyle(false); gStyle->SetStatX(-0.5); int nPoints=0; int* masses=0; double* mHVal=0; // Pick the correct set of mass points, set subpath TString filepath; if (process==ggH){ if (useNewGGHPowheg) { if (sqrts==7) { nPoints = nPoints7TeV_p15; masses = masses7TeV_p15; mHVal = mHVal7TeV_p15; filepath = filePath7TeV; } else if (sqrts==8) { nPoints = nPoints8TeV_p15; masses = masses8TeV_p15; mHVal = mHVal8TeV_p15; filepath = filePath8TeV; } } else { // OLD powheg samples if (sqrts==7) { nPoints = nPoints7TeV; masses = masses7TeV; mHVal = mHVal7TeV; filepath = filePath7TeV; } else if (sqrts==8) { nPoints = nPoints8TeV; masses = masses8TeV; mHVal = mHVal8TeV; filepath = filePath8TeV; } } } else if (process==qqH) { if (sqrts==7) { nPoints = nVBFPoints7TeV; masses = VBFmasses7TeV; mHVal = mHVBFVal7TeV; filepath = filePath7TeV; } else if (sqrts==8) { nPoints = nVBFPoints8TeV; masses = VBFmasses8TeV; mHVal = mHVBFVal8TeV; filepath = filePath8TeV; } } else if (process==ZH || process==WH || process==ttH) { if (sqrts==7) { nPoints = nVHPoints7TeV; masses = VHmasses7TeV; mHVal = mHVHVal7TeV; filepath = filePath7TeV; } else if (sqrts==8) { nPoints = nVHPoints8TeV; masses = VHmasses8TeV; mHVal = mHVHVal8TeV; filepath = filePath8TeV; } } float xMax = masses[nPoints-1]+10; const int arraySize=200; assert (arraySize>=nPoints); double totefficiencyVal[arraySize]; double totefficiencyErr[arraySize]; double dijetratioVal[arraySize]; double dijetratioErr[arraySize]; double totefficiencyValInMW[arraySize]; double totefficiencyErrInMW[arraySize]; double dijetratioValInMW[arraySize]; double dijetratioErrInMW[arraySize]; // Define the object to compute XS and BRs HiggsCSandWidth *myCSW = new HiggsCSandWidth(gSystem->ExpandPathName("$CMSSW_BASE/src/Higgs/Higgs_CS_and_Width/txtFiles/")); TString infile; TGraph gJys(nPoints); for (int i = 0; i < nPoints; i++){ // Compute XS and BR double xsTimesBR = 0.; double BRH4e = myCSW->HiggsBR(12,masses[i]); double BRH2e2mu = myCSW->HiggsBR(13,masses[i]); double BRHZZ = myCSW->HiggsBR(11,masses[i]); double BR = BRHZZ; if (process==ggH || process==qqH) { if (channel==fs4mu || channel==fs4e) BR = BRH4e; else BR = BRH2e2mu; } if (process==ggH) xsTimesBR = BR*myCSW->HiggsCS(1,masses[i],sqrts); else if (process==qqH) xsTimesBR = BR*myCSW->HiggsCS(2,masses[i],sqrts); else if (process==ZH) xsTimesBR = BR*myCSW->HiggsCS(3,masses[i],sqrts); else if (process==WH) xsTimesBR = BR*myCSW->HiggsCS(4,masses[i],sqrts); else if (process==ttH) xsTimesBR = BR*myCSW->HiggsCS(5,masses[i],sqrts); if (process==ggH) { if (useNewGGHPowheg){ infile = filepath+ "/" + schannelFilename + "/HZZ4lTree_powheg15" + (masses[i]>200?"H":"jhuGenV3H") + (long)masses[i] + ".root"; } else { infile = filepath+ "/" + schannelFilename + "/HZZ4lTree_H" + (long)masses[i] + ".root"; } } else if (process==qqH) infile = filepath+ "/" + schannelFilename + "/HZZ4lTree_VBFH" + (long)masses[i] + ".root"; else if (process==WH || process==ZH || process==ttH) infile = filepath+ "/" + schannelFilename + "/HZZ4lTree_" + sprocess + (long)masses[i] + ".root"; TFile *f = TFile::Open(infile) ; TTree *t1 = (TTree*) f->Get("SelectedTree"); float MC_weight_norm, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC; float MC_weight_noxsec; float GenHPt; //int NJets; short genProcessId=0; // short NJets30; vector<double> *JetPt=0; vector<double> *JetSigma=0; float ZZMass; t1->SetBranchAddress("MC_weight_norm",&MC_weight_norm); // For efficiency vs "proper" final state t1->SetBranchAddress("MC_weight_noxsec",&MC_weight_noxsec); // For efficiency vs all gen events t1->SetBranchAddress("MC_weight_powhegWeight",&MC_weight_powhegWeight); t1->SetBranchAddress("MC_weight_PUWeight",&MC_weight_PUWeight); t1->SetBranchAddress("MC_weight_dataMC",&MC_weight_dataMC); //t1->SetBranchAddress("NJets",&NJets); t1->SetBranchAddress("genProcessId",&genProcessId); t1->SetBranchAddress("JetPt",&JetPt); t1->SetBranchAddress("JetSigma",&JetSigma); // t1->SetBranchAddress("NJets30",&NJets30); t1->SetBranchAddress("GenHPt",&GenHPt); t1->SetBranchAddress("ZZMass",&ZZMass); //Initialize counters for non-dijet events Counts* untagInMW = new Counts(); Counts* untagAll = new Counts(); Counts* dijetInMW = new Counts(); Counts* dijetAll = new Counts(); // Find window width // FIXME move to external function double valueWidth = myCSW->HiggsWidth(0,masses[i]); double windowVal = max(valueWidth,1.); double lowside = 100.; double highside = 1000.0; if (masses[i] >= 275){ lowside = 180.0; highside = 650.0; } if (masses[i] >= 350){ lowside = 200.0; highside = 900.0; } if (masses[i] >= 500){ lowside = 250.0; highside = 1000.0; } if (masses[i] >= 700){ lowside = 350.0; highside = 1400.0; } double low_M = max( (masses[i] - 20.*windowVal), lowside); double high_M = min((masses[i] + 15.*windowVal), highside); // // Load Higgs pT weights for old powheg // TFile* fW; TH1D* h_HPtWeight; // TString fW_str = "./HPtWeights/weight_"; // fW_str += (long)masses[i]; // fW_str += (TString)".root"; // cout << fW_str << endl; // if (process==ggH) { // fW = TFile::Open(fW_str,"READ"); // h_HPtWeight = (TH1D*)fW->Get("h_weight"); // } for (int a = 0; a < t1->GetEntries(); a++){ t1->GetEntry(a); // Skip VH events that do not belong to the right gen prod mechanism. This is no longer necessary with the proper VH samples if ((process==ZH && genProcessId!=24) || (process==WH && genProcessId!=26) || (process==ttH && (genProcessId!=121 && genProcessId!=122))) continue; // We use the efficiency vs. generated events in the proper FS for ggH, VBF, and the efficiency vs all generated events for VH, ttH float effw = MC_weight_norm; if (process==ZH) { effw = MC_weight_noxsec*filter_eff_ZH_8TeV; } else if (process==WH){ effw = MC_weight_noxsec*filter_eff_WH_8TeV; } else if (process==ttH){ effw = MC_weight_noxsec*filter_eff_ttH_8TeV; } // double HPtWeight = 1.; // if (process==ggH) HPtWeight = h_HPtWeight->GetBinContent(h_HPtWeight->FindBin(GenHPt)); // //cout << "Higgs pT weight = " << HPtWeight << endl; // effw*=HPtWeight; int NJets=0; double jetptc=0; for (unsigned int j=0; j<JetPt->size();j++){ if (JES==0.) jetptc=JetPt->at(j); else if (JES!=0.) jetptc=JetPt->at(j)*(1+JES*JetSigma->at(j)); if (jetptc>30.) NJets++; } // Untagged if (NJets<2){ untagAll->incrCounters(effw, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC); if ( (ZZMass>low_M && ZZMass<high_M) ) untagInMW->incrCounters(effw, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC); } else{ // Dijet dijetAll->incrCounters(effw, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC); if ( (ZZMass>low_M && ZZMass<high_M) ) dijetInMW->incrCounters(effw, MC_weight_PUWeight, MC_weight_powhegWeight, MC_weight_dataMC); } } // FIXME: the 7TeV old samples are assumed to have the ad-hoc correction factor for the mll>12 gen cut, // except for the 124,125,126 new samples. As this factor is accounted for in the x-section, we have to // apply it here. float m = masses[i]; if (!useNewGGHPowheg && process==ggH && sqrts==7 && m>=123.9 && m<=126.1) { float mllCorr = 0.5 + 0.5*erf((m-80.85)/50.42); untagAll->totalCtr = untagAll->totalCtr/mllCorr; untagAll->eff_noweight=untagAll->eff_noweight/mllCorr; untagInMW->totalCtr = untagInMW->totalCtr/mllCorr; untagInMW->eff_noweight=untagInMW->eff_noweight/mllCorr; dijetAll->totalCtr = dijetAll->totalCtr/mllCorr; dijetAll->eff_noweight=dijetAll->eff_noweight/mllCorr; dijetInMW->totalCtr = dijetInMW->totalCtr/mllCorr; dijetInMW->eff_noweight=dijetInMW->eff_noweight/mllCorr; } if (verbose) { cout << " m = " << masses[i] << " :" <<endl; cout << "Selected non-dijet events (all) = " << untagAll->numEventsRaw << " Powheg Wtd= " << untagAll->numEventsPowheg << " PU Wtd= " << untagAll->numEventsPU << " Data/MC Wtd= " << untagAll->numEventsDataMC << " Efficiency= " << untagAll->totalCtr << endl; cout << "Selected non-dijet events (in mass window) = " << untagInMW->numEventsRaw << " Powheg Wtd= " << untagInMW->numEventsPowheg << " PU Wtd= " << untagInMW->numEventsPU << " Data/MC Wtd= " << untagInMW->numEventsDataMC << " Efficiency= " << untagInMW->totalCtr << endl; cout << "Selected dijet events (all) = " << dijetAll->numEventsRaw << " Powheg Wtd= " << dijetAll->numEventsPowheg << " PU Wtd= " << dijetAll->numEventsPU << " Data/MC Wtd= " << dijetAll->numEventsDataMC << " Efficiency= " << dijetAll->totalCtr << endl; cout << "Selected dijet events (in mass window) = " << dijetInMW->numEventsRaw << " Powheg Wtd= " << dijetInMW->numEventsPowheg << " PU Wtd= " << dijetInMW->numEventsPU << " Data/MC Wtd= " << dijetInMW->numEventsDataMC << " Efficiency= " << dijetInMW->totalCtr << endl; } // All events totefficiencyVal[i] = untagAll->totalCtr + dijetAll->totalCtr; cout << "All events: " << sprocess << " " << m << " " << totefficiencyVal[i]<<endl; totefficiencyErr[i] = sqrt(untagAll->sumw2 + dijetAll->sumw2); dijetratioVal[i]=dijetAll->totalCtr/totefficiencyVal[i]; dijetratioErr[i]=sqrt(pow(untagAll->totalCtr,2)*dijetAll->sumw2 + pow(dijetAll->totalCtr,2)*untagAll->sumw2)/pow(totefficiencyVal[i],2); // FIXME: misses 1 term // Events inside the mass window totefficiencyValInMW[i] = untagInMW->totalCtr + dijetInMW->totalCtr; cout << "Events in mass window: " << sprocess << " " << m << " " << totefficiencyValInMW[i]<<endl; totefficiencyErrInMW[i] = sqrt(untagInMW->sumw2 + dijetInMW->sumw2); dijetratioValInMW[i]=dijetInMW->totalCtr/totefficiencyValInMW[i]; dijetratioErrInMW[i]=sqrt(pow(untagInMW->totalCtr,2)*dijetInMW->sumw2 + pow(dijetInMW->totalCtr,2)*untagInMW->sumw2)/pow(totefficiencyValInMW[i],2); // Write yields to output file double lumi = -1.; sqrts == 7 ? lumi = lumi7TeV*1000 : lumi = lumi8TeV*1000; double yieldTot = xsTimesBR*lumi*totefficiencyVal[i]; double yieldTag = xsTimesBR*lumi*dijetratioVal[i]*totefficiencyVal[i]; double yieldUnt = xsTimesBR*lumi*untagAll->totalCtr; double yieldTotInMW = xsTimesBR*lumi*totefficiencyValInMW[i]; double yieldTagInMW = xsTimesBR*lumi*dijetratioValInMW[i]*totefficiencyValInMW[i]; double yieldUntInMW = xsTimesBR*lumi*untagInMW->totalCtr; int prec = 3; if (process>=3) prec=5; (*txtYields) << left << setw(7) << fixed << setprecision(0) << masses[i] << setw(13) << fixed << setprecision(7) << xsTimesBR << setw(13) << fixed << setprecision(prec) << untagInMW->totalCtr << setw(13) << yieldUntInMW << setw(13) << dijetratioValInMW[i]*totefficiencyValInMW[i] << setw(13) << yieldTagInMW << setw(13) << fixed << setprecision(prec) << totefficiencyValInMW[i] << setw(13) << yieldTotInMW << setw(13) << fixed << setprecision(prec) << untagAll->totalCtr << setw(13) << yieldUnt << setw(13) << dijetratioVal[i]*totefficiencyVal[i] << setw(13) << yieldTag << setw(13) << totefficiencyVal[i] << setw(13) << yieldTot << setw(13) << fixed << setprecision(0) << untagAll->numEventsRaw + dijetAll->numEventsRaw << setw(13) << fixed << setprecision(2) << untagAll->numEventsRaw + dijetAll->numEventsPowheg << setw(13) << untagAll->numEventsPU + dijetAll->numEventsPU << setw(13) << untagAll->numEventsDataMC + dijetAll->numEventsDataMC << endl; f->Close(); gJys.SetPoint(i,masses[i],yieldTagInMW/yieldUntInMW); } TF1 *fitJys = new TF1("fitJys","pol3",100,1000); gJys.Fit(fitJys); (*txtYields) << endl << endl << endl; TGraphErrors* totgrEff; TGraphErrors* ratgrEff; if (process==ggH || process==qqH){ totgrEff = new TGraphErrors( nPoints, mHVal, totefficiencyVal, 0, totefficiencyErr); ratgrEff = new TGraphErrors( nPoints, mHVal, dijetratioVal, 0, dijetratioErr); } else { totgrEff = new TGraphErrors( nPoints, mHVal, totefficiencyValInMW, 0, totefficiencyErrInMW); ratgrEff = new TGraphErrors( nPoints, mHVal, dijetratioValInMW, 0, dijetratioErrInMW); } totgrEff->SetMarkerStyle(20); ratgrEff->SetMarkerStyle(20); //ICHEP parametrization //TF1 *polyFunc= new TF1("polyFunc","([0]+[1]*TMath::Erf( (x-[2])/[3] ))*([4]+[5]*x+[6]*x*x)", 110., xMax); //polyFunc->SetParameters(-4.42749e+00,4.61212e+0,-6.21611e+01,1.13168e+02,2.14321e+00,1.04083e-03,4.89570e-07); TF1 *polyFunctot= new TF1("polyFunctot","([0]+[1]*TMath::Erf( (x-[2])/[3] ))*([4]+[5]*x+[6]*x*x)+[7]*TMath::Gaus(x,[8],[9])", 110., xMax); polyFunctot->SetParameters(-4.42749e+00,4.61212e+0,-6.21611e+01,1.13168e+02,2.14321e+00,1.04083e-03,4.89570e-07, 0.03, 200, 30); polyFunctot->SetParLimits(7,0,0.2); polyFunctot->SetParLimits(8,160,210); polyFunctot->SetParLimits(9,10,70); if (process!=ggH && process!=qqH) { polyFunctot->FixParameter(7,0); polyFunctot->FixParameter(8,0); polyFunctot->FixParameter(9,1); } // if (channel==fs4mu && sqrts==7) { // polyFunctot->SetParLimits(7,0,0.035); // polyFunctot->SetParLimits(8,160,210); // polyFunctot->SetParLimits(9,30,50); // } polyFunctot->SetLineColor(4); TString cname = "eff" + sprocess + ssqrts + "_" + schannel; TCanvas *ctot = new TCanvas(cname,cname); ctot->SetGrid(); TString outname = "sigFigs" + ssqrts +"/eff_" + sprocess + "_" + schannel + "_" + sjes; if (!useNewGGHPowheg) outname+="_oldPwg"; totgrEff->Fit(polyFunctot,"Rt"); TString xaxisText = "m_{" + schannel + "}"; totgrEff->GetXaxis()->SetTitle(xaxisText); TString yaxisText = "Efficiency, " + sprocess + ", " + schannel; totgrEff->GetYaxis()->SetTitle(yaxisText); totgrEff->SetMinimum(0.0); totgrEff->SetMaximum(1.0); if (process>=3) totgrEff->SetMaximum(0.0035); totgrEff->Draw("AP"); polyFunctot->Draw("sames"); ctot->Print(outname+".eps"); //ctot->Print(outname+".png"); // Does not work in batch? ctot->Print(outname+".pdf"); //ctot->Print(outname+".root"); ftot->cd(); totgrEff->Write("TotalEfficiency"); ftot->Close(); cout << endl; cout << "------- Parameters for " << sprocess << " " << schannel << " sqrts=" << sqrts << endl; cout << " a1 = " << polyFunctot->GetParameter(0) << endl; cout << " a2 = " << polyFunctot->GetParameter(1) << endl; cout << " a3 = " << polyFunctot->GetParameter(2) << endl; cout << " a4 = " << polyFunctot->GetParameter(3) << endl; cout << " b1 = " << polyFunctot->GetParameter(4) << endl; cout << " b2 = " << polyFunctot->GetParameter(5) << endl; cout << " b3 = " << polyFunctot->GetParameter(6) << endl; cout << " g1 = " << polyFunctot->GetParameter(7) << endl; cout << " g2 = " << polyFunctot->GetParameter(8) << endl; cout << " g3 = " << polyFunctot->GetParameter(9) << endl; cout << "---------------------------" << endl << endl; // Create card fragments using new powheg samples string oftotprocess; if (process==ggH) oftotprocess=""; else oftotprocess=sprocess; if (process==ggH) { oftot << endl; oftot << "## signal efficiency ##" << endl; } oftot << "signalEff " << oftotprocess << "a1 " << polyFunctot->GetParameter(0) << endl; oftot << "signalEff " << oftotprocess << "a2 " << polyFunctot->GetParameter(1) << endl; oftot << "signalEff " << oftotprocess << "a3 " << polyFunctot->GetParameter(2) << endl; oftot << "signalEff " << oftotprocess << "a4 " << polyFunctot->GetParameter(3) << endl; oftot << "signalEff " << oftotprocess << "b1 " << polyFunctot->GetParameter(4) << endl; oftot << "signalEff " << oftotprocess << "b2 " << polyFunctot->GetParameter(5) << endl; oftot << "signalEff " << oftotprocess << "b3 " << polyFunctot->GetParameter(6) << endl; oftot << "signalEff " << oftotprocess << "g1 " << polyFunctot->GetParameter(7) << endl; oftot << "signalEff " << oftotprocess << "g2 " << polyFunctot->GetParameter(8) << endl; oftot << "signalEff " << oftotprocess << "g3 " << polyFunctot->GetParameter(9) << endl; oftot << endl; oftot.close(); cname = "eff" + sprocess + ssqrts + "_" + schannel + "_ratio"; TCanvas *crat = new TCanvas(cname,cname); crat->SetGrid(); outname = "sigFigs" + ssqrts +"/eff_" + sprocess + "_" + schannel + "_" + sjes + "_ratio"; if (!useNewGGHPowheg) outname+="_oldPwg"; TF1 *ratiofit=0; if (process==ggH || process==qqH) ratiofit = new TF1("ratiofit","([0]+[1]*x+[2]*x*x)",110.,xMax); if (process==ZH || process==WH || process==ttH ) ratiofit = new TF1("ratiofit","([0]+[1]*x)",110.,xMax); ratgrEff->Fit(ratiofit,"Rt"); ratgrEff->GetXaxis()->SetTitle(xaxisText); TString yaxisratio = "Dijet ratio, " + sprocess + ", " + schannel; ratgrEff->GetYaxis()->SetTitle(yaxisratio); ratgrEff->SetMinimum(0.0); ratgrEff->SetMaximum(1.0); ratgrEff->Draw("AP"); crat->Print(outname+".eps"); //crat->Print(outname+".png"); // Does not work in batch? crat->Print(outname+".pdf"); //crat->Print(outname+".root"); fratio->cd(); ratgrEff->Write("Ratio"); fratio->Close(); cout << endl; cout << "------- Parameters for " << sprocess << " " << schannel << " sqrts=" << sqrts << endl; cout << " a1 = " << ratiofit->GetParameter(0) << endl; cout << " a2 = " << ratiofit->GetParameter(1) << endl; if (process==ggH || process==qqH) cout << " a3 = " << ratiofit->GetParameter(2) << endl; cout << "---------------------------" << endl << endl; if (process==ggH) { ofrat<<"## jet tagged/untagged ratio"<<endl; ofrat<<"jetYieldRatio "<<fitJys->GetParameter(0)<<"+("<<fitJys->GetParameter(1)<<"*@0)+("<<fitJys->GetParameter(2)<<"*@0*@0)+("<<fitJys->GetParameter(3)<<"*@0*@0*@0)"<< endl <<endl; ofrat << "## signal efficiency ratios ##" << endl; } ofrat << "signalEff tagged_" << sprocess << "_ratio " << ratiofit->GetParameter(0) << "+(" << ratiofit->GetParameter(1) << "*@0)"; if (process==ggH || process==qqH) ofrat << "+(" << ratiofit->GetParameter(2) << "*@0*@0)" << endl; else if (process==ZH || process==WH ) ofrat << endl; else if (process==ttH) ofrat << endl << endl; ofrat.close(); // deviations cout << "Deviations..." << endl; double maxResidual=0; for (int i = 0; i < nPoints; i++){ double eval = polyFunctot->Eval(masses[i]); double residual = (eval - totefficiencyVal[i]); maxResidual = max(maxResidual,fabs(residual)); if (verbose) cout << "For mass, " << masses[i] << ": measured value is " << totefficiencyVal[i] << " and difference from function is " << residual <<endl; } cout << "Largest residual= " << maxResidual << endl; delete fitJys; delete myCSW; delete polyFunctot; delete ratiofit; }
void plotNsig(){ vector<RooWorkspace*> w (13); vector<string> limits (14); vector<TFile*> f(13); Double_t* nsig = new Double_t[13]; Double_t* err_nsig = new Double_t[13]; Double_t* pt = new Double_t[13]; Double_t* err_pt = new Double_t[13]; Double_t* norm_lumi = new Double_t[13]; Double_t* scale_fact = new Double_t[13]; norm_lumi[0]=2.831017; norm_lumi[1]=2.831017; norm_lumi[2]=22.020492; norm_lumi[3]=22.020492; norm_lumi[4]=132.115; norm_lumi[5]=132.115; norm_lumi[6]=132.115; norm_lumi[7]=276.515; norm_lumi[9]=276.515; norm_lumi[8]=276.515; norm_lumi[10]=276.515; norm_lumi[11]=276.515; norm_lumi[12]=276.515; pt[0]=43.5; pt[1]=56.; pt[2]=69.; pt[3]=81.5; pt[4]=92.; pt[5]=96.5; pt[6]=102.; pt[7]=107.5; pt[8]=113.5; pt[9]=121.5; pt[10]=132.5; pt[11]=151.; pt[12]=210.; err_pt[0]=3.5; err_pt[1]=8.; err_pt[2]=4.; err_pt[3]=8.5; err_pt[4]=2.; err_pt[5]=2.5; err_pt[6]=3.; err_pt[7]=2.5; err_pt[8]=3.5; err_pt[9]=4.5; err_pt[10]=6.5; err_pt[11]=12.; err_pt[12]=47.; limits[0]="40"; limits[1]="47"; limits[2]="65"; limits[3]="73"; limits[4]="90"; limits[5]="94"; limits[6]="99"; limits[7]="105"; limits[8]="110"; limits[9]="117"; limits[10]="126"; limits[11]="139"; limits[12]="163"; limits[13]="1000"; scale_fact[0]= 0.997614 * 0.989847; //scF_presel * sc_F_sel_okMVA005 scale_fact[1]= 0.999025 * 0.993679; //scF_presel * sc_F_sel_okMVA005 scale_fact[2]= 0.999965 * 0.993734; //scF_presel * sc_F_sel_okMVA005 scale_fact[3]= 1.00087 * 0.993787; //scF_presel * sc_F_sel_okMVA005 scale_fact[4]= 1.00163 * 0.993832; //scF_presel * sc_F_sel_okMVA005 scale_fact[5]= 1.00195 * 0.993851; //scF_presel * sc_F_sel_okMVA005 scale_fact[6]= 1.00235 * 0.993875; //scF_presel * sc_F_sel_okMVA005 scale_fact[7]= 1.00275 * 0.993898; //scF_presel * sc_F_sel_okMVA005 scale_fact[8]= 1.00318 * 0.993924; //scF_presel * sc_F_sel_okMVA005 scale_fact[9]= 1.00376 * 0.993958; //scF_presel * sc_F_sel_okMVA005 scale_fact[10]= 1.00401 * 0.993973; //scF_presel * sc_F_sel_okMVA005 scale_fact[11]= 1.00401 * 0.993973; //scF_presel * sc_F_sel_okMVA005 scale_fact[12]= 1.00401 * 0.993973; //scF_presel * sc_F_sel_okMVA005 for(int i=0; i<w.size(); i++){ f[i] = new TFile(("workspace_fit_EB_data_WP095_pt"+limits[i]+"_"+limits[i+1]+".root").c_str(), "READ"); w[i] =(RooWorkspace*)f[i]->Get("w_data"); nsig[i] = (((RooRealVar*)w[i]->var("N_sig_real"))->getVal())/(2.*err_pt[i]*norm_lumi[i]*scale_fact[i]); err_nsig[i] = (((RooRealVar*)w[i]->var("N_sig_real"))->getError())/(2.*err_pt[i]*norm_lumi[i]*scale_fact[i]); } TGraphErrors* g = new TGraphErrors(13, pt, nsig, err_pt, err_nsig); g->GetXaxis()->SetTitle("p_{T}^{#gamma} [GeV]"); g->GetYaxis()->SetTitle("d #sigma/d p_{T}^{#gamma} (ev[pb])/[GeV]"); TCanvas* c = new TCanvas("","", 1); g->Draw("ap"); TLatex* tex_m = new TLatex(); tex_m->SetNDC(); tex_m->SetTextAlign(12); tex_m->SetTextSize(0.037); tex_m->SetLineWidth(2); tex_m->DrawLatex(0.25,0.94,"CMS Preliminary 8 TeV"); c->SaveAs("plotNsig.png"); c->SaveAs("plotNsig.pdf"); c->SetLogy(); c->SaveAs("plotNsig_log.png"); c->SaveAs("plotNsig_log.pdf"); }
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 Draw_ALICEFor_JPsi_RaaVspT(TLegend *legend_ratio) { // Centrality, rapidity and transverse momentum dependence of // J/psi suppression in Pb-Pb collisions at sqrt{s} = 2.76 TeV ALICE // arxiv.1311.0214v1 //================= ALICE Forward Rapidity Raa Vs Pt ===================================// int nbinsPtALICEFor=7; Double_t PtALICEFor[7]={0.50,1.50,2.50,3.50,4.50,5.50,7.0}; Double_t ErrPtALICEFor[7]={0}; //Double_t RaaPtALICEFor[7] = {0.61,0.53,0.45,0.38,0.37,0.34,0.35}; //Double_t RaaPtStatErrALICEFor[7] = {0.06,0.04,0.03,0.04,0.05,0.06,0.07}; //Double_t RaaPtSystErrALICEFor[7] = {0.08,0.07,0.06,0.05,0.05,0.05,0.04}; Double_t RaaPtALICEFor[7] = {0.78,0.68,0.52,0.43,0.41,0.32,0.36}; Double_t RaaPtStatErrALICEFor[7] = {0.08,0.05,0.04,0.04,0.05,0.05,0.08}; Double_t RaaPtSystErrALICEFor[7] = {0.11,0.08,0.06,0.05,0.05,0.04,0.04}; TGraphErrors *grRaaPtALICEFor = new TGraphErrors(nbinsPtALICEFor, PtALICEFor, RaaPtALICEFor, ErrPtALICEFor, RaaPtStatErrALICEFor); grRaaPtALICEFor->SetMarkerStyle(20); grRaaPtALICEFor->SetMarkerColor(4); grRaaPtALICEFor->SetMarkerSize(1.3); grRaaPtALICEFor->SetLineColor(1); grRaaPtALICEFor->GetYaxis()->SetRangeUser(0,1.5); grRaaPtALICEFor->GetXaxis()->SetTitle("p_{T}(GeV/c)"); grRaaPtALICEFor->GetYaxis()->SetTitle("R_{AA}"); TLine *lh4 = new TLine(0.0,1.0,7.6,1.0); lh4->SetLineColor(1); lh4->SetLineStyle(1); lh4->SetLineWidth(1.5); //lh4->Draw("same"); TLatex *tb= new TLatex; tb->SetNDC(); tb->SetTextAlign(12); tb->SetTextColor(1); tb->SetTextSize(0.040); TBox *RaaPtJPsiALICEForSys[12]; for(int j=0;j<7;j++){ RaaPtJPsiALICEForSys[j] = new TBox(PtALICEFor[j]-0.4, RaaPtALICEFor[j]-RaaPtSystErrALICEFor[j], PtALICEFor[j]+0.4, RaaPtALICEFor[j]+RaaPtSystErrALICEFor[j]); } for(int j=0;j<7;j++){ RaaPtJPsiALICEForSys[j]->SetFillStyle(1001); RaaPtJPsiALICEForSys[j]->SetFillColor(kAzure-4); RaaPtJPsiALICEForSys[j]->SetLineColor(1); } TBox *ALICEGlobalSysJPsiPtFor; //ALICEGlobalSysJPsiPtFor = new TBox(7.2-0.2, 1 - 0.14, 7.2+0.2, 1 + 0.14); //ALICEGlobalSysJPsiPtFor = new TBox(18.424,0.858,19.165,1.137); // By Abd ALICEGlobalSysJPsiPtFor = new TBox(18.424,1.0-0.08,19.165,1.0+0.08); // By Abd ALICEGlobalSysJPsiPtFor->SetFillStyle(3001); ALICEGlobalSysJPsiPtFor->SetLineColor(4); ALICEGlobalSysJPsiPtFor->SetFillColor(4); grRaaPtALICEFor->Draw("sameP"); for(int j=0;j<7;j++) RaaPtJPsiALICEForSys[j]->Draw("sameL"); grRaaPtALICEFor->Draw("Psame"); ALICEGlobalSysJPsiPtFor->Draw("sameL"); legend_ratio->SetTextColor(4); //tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c"); //legend_ratio->AddEntry(grRaaPtALICEFor,"ALICE: J/#psi #rightarrow #mu^{+} #mu^{-}, 2.5 < |y| < 2.4 & p_{T}^{J/#psi} > 0.0 GeV/c", "P"); legend_ratio->AddEntry(grRaaPtALICEFor,"J/#psi ALICE: 2.5 < |y| < 2.4", "P"); }