void THDM_Comp(TString HigTag = "100", int PDFindex=5, int isPLep = 0){ int nHis = 2, nPads = 3; Styles style; style.setPadsStyle(nPads); //style.PadRightMargin = 0.029; style.PadLeftMargin = 0.151; style.yTitleOffset = 1.06; style.applyStyle(); TCanvas can("can","2HDM PDFs"); can.Divide(nPads,1); double legW = 0.3, legH = 0.18; double legX = 1-style.PadRightMargin-0.01-legW, legY = 1-style.PadTopMargin-0.01; TLegend leg(legX, legY-legH, legX+legW, legY); leg.SetTextSize(style.LabelSize); leg.SetFillColor(0); leg.SetTextFont(style.nFont); leg.SetBorderSize(0); TString Name, Variable[] = {"trueQ2", "trueCTL", "candPstarLep"}, legName[4]; TString xTitle[] = {"q_{true}^{2} (GeV^{2})", "cos(#theta_{#tau,true})", "p*_{l} (GeV)"}; TString yTitle[] = {"Density/(GeV^{2})","Density","Density/(GeV)"}; TString Cuts = "weight*(MCTaumode>0&&(MCType=="; Cuts += PDFindex; Cuts += "||MCType=="; Cuts += PDFindex+6; Cuts += "))"; TString Folder[] = {"AWG82/ntuples/Arxivsmall/FitRAllHigx", "AWG82/ntuples/small/FitRAllHigx"}; TString EndName[] = {"_RunAll.root", "_RunAll.root"}; TString LegName[] = {"ME", "ME + p_{l}"}; int nBins = 20, color[] = {4,1,28}; if(HigTag=="000") color[1] = 2; //double maxH[] = {0,0,0}, tBmH[4], limX[3][2] = {{3, 12}, {0, 3.2}, {0, 2.2}}; double maxH[] = {0,0,0}, tBmH[4], limX[3][2] = {{3, 12}, {-1, 1}, {0, 2.2}}; if(isPLep){ Variable[2] = "truePLep"; limX[2][1] = 3; xTitle[2] = "p_{l,true} (GeV)"; } TH1F *Histo[3][4]; for(int his=0; his<nHis; his++){ TString cName = Folder[his]; cName += HigTag; cName += EndName[his]; //cout<<"Reading "<<cName<<endl; TChain chain("ntp1"); chain.Add(cName); tBmH[his] = HigTag.Atof()/100.; legName[his] = LegName[his]; for(int pad=0; pad<nPads; pad++){ can.cd(pad+1); Name = "Histo"; Name += pad; Name += his; Histo[pad][his] = new TH1F(Name, "",nBins,limX[pad][0],limX[pad][1]); TString vari = Variable[pad]; //if(pad==1 && PDFindex==6) vari = "acos(trueCTL)"; if(pad==1 && PDFindex==5) vari = "cos(trueCTL)"; chain.Project(Name, vari, Cuts); Histo[pad][his]->SetLineWidth(2); Histo[pad][his]->SetLineColor(color[his]); Histo[pad][his]->Scale(nBins/Histo[pad][his]->Integral()/(limX[pad][1]-limX[pad][0])); if(maxH[pad]<Histo[pad][his]->GetMaximum()) maxH[pad]=Histo[pad][his]->GetMaximum(); if(pad==0) leg.AddEntry(Histo[pad][his], legName[his]); } } for(int pad=0; pad<nPads; pad++){ can.cd(pad+1); for(int his=0; his<nHis; his++){ if(his==0) { Histo[pad][his]->SetMinimum(0); Histo[pad][his]->SetMaximum(maxH[pad]*1.05); Histo[pad][his]->Draw(""); style.setTitles(Histo[pad][his],xTitle[pad],yTitle[pad]); }else Histo[pad][his]->Draw("same"); } if(pad==2) leg.Draw(); } TString epsName = "public_html/THDM_Comp_"; epsName += HigTag; epsName += "_"; epsName += PDFindex; epsName += ".eps"; can.SaveAs(epsName); for(int pad=0; pad<nPads; pad++) for(int his=0; his<nHis; his++) if(Histo[pad][his]) Histo[pad][his]->Delete(); }
void THDM_MC(int PDFindex=5, int isPLep = 1){ Styles style; style.setPadsStyle(2); style.PadRightMargin = 0.029; style.PadLeftMargin = 0.151; style.yTitleOffset = 1.06; style.applyStyle(); TCanvas can("can","2HDM PDFs"); can.Divide(2,1); double legW = 0.32, legH = 0.27; double legX = 1-style.PadRightMargin-0.01-legW, legY = 1-style.PadTopMargin-0.01; TLegend leg(legX, legY-legH, legX+legW, legY); leg.SetTextSize(style.LabelSize); leg.SetFillColor(0); leg.SetTextFont(style.nFont); leg.SetBorderSize(0); TString Name, HigTag[] = {"000", "030", "050", "100"}, Variable[] = {"candM2Tru","truePstarLep"}, legName[4]; TString xTitle[] = {"m_{miss,true}^{2} (GeV^{2})", "p*_{l,true} (GeV)"}, yTitle[] = {"Density/(GeV^{2})","Density/(GeV)"}; TString Cuts = "MCType=="; Cuts += PDFindex; int nHis = 4, nBinPDF[] = {100,100}, color[] = {2,4,28,1}; double maxH[] = {0,0}, tBmH[4], limX[2][2] = {{-1,10},{0,2.2}}; if(isPLep){ Variable[1] = "truePLep"; limX[1][1] = 3; xTitle[1] = "p_{l,true} (GeV)"; } TH1F *Histo[2][4]; for(int his=0; his<nHis; his++){ TString cName = "AWG82/generator/4M"; cName += HigTag[his]; cName += "Dxtaunu.root"; //TString cName = "AWG82/generator/Archive/4MEvtGen_Hig"; cName += HigTag[his]; cName += "Dxtaunu.root"; TChain chain("GqaMCAnalysis/ntp1"); chain.Add(cName); tBmH[his] = HigTag[his].Atof()/100.; legName[his] = "t#beta/m_{H} = "; legName[his] += RoundNumber(tBmH[his],1); if(fabs(tBmH[his])<1e-6) legName[his] = "SM"; for(int pad=0; pad<2; pad++){ can.cd(pad+1); Name = "Histo"; Name += pad; Name += his; Histo[pad][his] = new TH1F(Name, "",nBinPDF[pad],limX[pad][0],limX[pad][1]); chain.Project(Name, Variable[pad], Cuts); Histo[pad][his]->SetLineWidth(2); Histo[pad][his]->SetLineColor(color[his]); Histo[pad][his]->Scale(nBinPDF[pad]/Histo[pad][his]->Integral()/(limX[pad][1]-limX[pad][0])); if(maxH[pad]<Histo[pad][his]->GetMaximum()) maxH[pad]=Histo[pad][his]->GetMaximum(); if(pad==0) leg.AddEntry(Histo[pad][his], legName[his]); } } for(int pad=0; pad<2; pad++){ can.cd(pad+1); for(int his=0; his<nHis; his++){ if(his==0) { Histo[pad][his]->SetMaximum(maxH[pad]*1.05); Histo[pad][his]->Draw("c"); style.setTitles(Histo[pad][his],xTitle[pad],yTitle[pad]); }else Histo[pad][his]->Draw("c same"); } if(pad==1) leg.Draw(); } TString epsName = "public_html/THDM_MC_"; epsName += PDFindex; epsName += ".eps"; can.SaveAs(epsName); for(int pad=0; pad<2; pad++) for(int his=0; his<nHis; his++) Histo[pad][his]->Delete(); }
void MC_EexComponents(){ Styles style; style.setPadsStyle(1); style.applyStyle(); TString NameTrees[3] = {"AWG82/ntuples/small/RAll_RunAll.root", "AWG82/ntuples/small/uds_RunAll.root", "AWG82/ntuples/small/ccbar_RunAll.root"}; TChain gen("ntp1"), cont("ntp1"); gen.Add(NameTrees[0]); for(int t=1; t<3; t++) cont.Add(NameTrees[t]); double totMCB = 0, totuds = 0, totccbar = 0, totdata = 0, totOffdata = 0; getNumberB(NameTrees[0], "All", totMCB, totdata, totuds, totccbar, totOffdata); double wuds = totMCB/totuds*2.09/1.05; double nTotal, yield[4], maxi; // TString cuts[] = {"(candPMiss>0.2&&candQ2>4&&candType==2&&(MCType==2||MCType==4||MCType==6))*weight", // "(candPMiss>0.2&&candQ2>4&&candType==2&&(MCType==1||MCType==3||MCType==5||MCType>6))*weight", // "(candPMiss>0.2&&candQ2>4&&candType==2&&(MCType==0))*weight", // "(candPMiss>0.2&&candQ2>4&&candType==2)*weight"}; TString cuts[] = {"(candMvaDl>0.48&&candPMiss>0.2&&candQ2>4&&candType==2&&(MCType==2||MCType==4||MCType==6))*weight", //"(candPMiss>0.2&&candQ2>4&&candType==2&&(MCType==1||MCType==3||MCType==5||MCType>6))*weight", "(candMvaDl>0.48&&candPMiss>0.2&&candQ2>4&&candType==2&&(MCType>12))*weight", "(candMvaDl>0.48&&candPMiss>0.2&&candQ2>4&&candType==2&&(MCType==0))*weight", "(candMvaDl>0.48&&candPMiss>0.2&&candQ2>4&&candType==2)*weight"}; TH1F *hCount = new TH1F("hCount","",100,-4,12); for(int i=0; i<3; i++) { gen.Draw("candM2>>hCount",cuts[i]); yield[i] = hCount->Integral(); } cont.Draw("candM2>>hCount",cuts[3]); yield[3] = hCount->Integral()*wuds; gen.Draw("candM2>>hCount",cuts[3]); nTotal = hCount->Integral(); nTotal += yield[3]; hCount->Delete(); TCanvas can("can","BDT variables");TPad *cPad; //can.Divide(2,4); TString Variable[] = {"candEExtra","candDeltaE","candDmass","candDeltam", "candBTagDmass","candBTagDeltam","candTagChargedMult-0.5","candCosT"}; // int bins[] = {32,24,40,22,24,22,7,40}, colors[] = {4,2,1,8}; // double xrange[8][2] = {{0,1.6}, {-0.072,0.072}, {1.94,2.06}, {0.13,0.152}, // {1.841,1.889}, {0.13,0.152}, {1.5,8.5}, {-1,1}}; int bins[] = {10,24,40,22,20,15,7,40}, colors[] = {4,2,1,8}; double xrange[8][2] = {{0,0.5}, {-0.072,0.072}, {1.94,2.06}, {0.13,0.152}, {1.841,1.889}, {0.13,0.152}, {1.5,8.5}, {-1,1}}; TString yTitleEnd[] = {"50 MeV)", "6 MeV)", "3 MeV)", "1 MeV)", "2 MeV)", "1 MeV)", "",""}; TString xTitle[] = {"E_{Extra} (GeV)", "#DeltaE (GeV)", "", "", "", "", "B_{tag} charged multiplicity", "cos(#Delta#theta_{T})"}; TString labels[] = {"Signal + norm.", "D**l#nu", "Other BB", "Continuum"}; double legW = 0.3, legH = 0.3; double legX = 1-style.PadRightMargin-0.02, legY = 1-style.PadTopMargin-0.02; TLegend leg(legX-legW, legY-legH, legX, legY); leg.SetTextSize(style.LabelSize); leg.SetFillColor(0); leg.SetTextFont(style.nFont); leg.SetBorderSize(0); TH1F* h[8][4]; for(int pad=0; pad<1; pad++){ cPad = (TPad *)can.cd(pad+1); maxi = -99; for(int i=0; i<4; i++) { TString hname = "h"; hname += pad; hname += i; h[pad][i] = new TH1F(hname,"",bins[pad],xrange[pad][0],xrange[pad][1]); h[pad][i]->SetLineWidth(2); h[pad][i]->SetLineColor(colors[i]); TString vari = Variable[pad]; vari += ">>"; vari += hname; if(i<3) gen.Draw(vari,cuts[i]); else cont.Draw(vari,cuts[i]); if(pad==0) { h[pad][i]->Integral(); //labels[i] += RoundNumber(yield[i]*100,0,nTotal); labels[i] += "%)"; leg.AddEntry(h[pad][i],labels[i]); } h[pad][i]->Scale(1000/h[pad][i]->Integral()); if(h[pad][i]->GetMaximum()>maxi) maxi = h[pad][i]->GetMaximum(); } if(pad==0) maxi *= 1.1; if(pad==6) h[pad][0]->SetNdivisions(207,"x"); h[pad][0]->SetMaximum(maxi*1.1); h[pad][0]->SetMinimum(0); h[pad][0]->Draw(); if(pad==0) { style.fixYAxis(h[pad][0],cPad); style.applyStyle(); leg.Draw(); } else { h[pad][0]->SetTitleOffset(style.yTitleOffset,"y"); cPad->SetLeftMargin(style.PadLeftMargin); } TString yTitle = "Entries/("; if(pad<6) yTitle += yTitleEnd[pad]; else if(pad==6) yTitle = "Entries"; else yTitle = "Entries/(0.05)"; style.setTitles(h[pad][0],xTitle[pad],yTitle); h[pad][3]->Draw("same");h[pad][2]->Draw("same");h[pad][1]->Draw("same");h[pad][0]->Draw("same"); } TString pName = "public_html/MC_EexComponents.eps"; can.SaveAs(pName); for(int pad=0; pad<1; pad++){ for(int i=0; i<4; i++){ h[pad][i]->Delete(); } } }