示例#1
0
typename Styles::const_iterator find_style(const Styles &styles, const LayerDescription &layer_desc) {
    auto it = styles.find(layer_desc.name);
#if defined(DEBUG)
    if (it == styles.end()) {
        if (debug::renderWarnings) {
            fprintf(stderr, "[WARNING] can't find class named '%s' in style\n",
                    layer_desc.name.c_str());
        }
    }
#endif
    return it;
}
示例#2
0
bool is_invisible(const Styles &styles, const LayerDescription &layer_desc) {
    auto it = find_style(styles, layer_desc);
    if (it == styles.end()) {
        // We don't have a style, so we fall back to the default style which is
        // always visible.
        return false;
    }
    return !it->second.isVisible();
}
示例#3
0
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();
}
示例#4
0
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();
}
示例#5
0
文件: plot.cpp 项目: skhal/bsm_mc
string style(TH1 *h, const string &filename)
{
    typedef shared_ptr<regex> RegexPtr;
    typedef pair<string, RegexPtr> Pattern;
    typedef map<int, Pattern> Styles;

    Styles styles;

    styles[kAzure  - 9 ] = Pattern("Zprime M: 500 GeV w: 50 GeVc", RegexPtr(new regex(".*zprime_m500gev_w50gev-madgraph.*")));
    styles[kAzure  - 8 ] = Pattern("Zprime M: 500 GeV w: 5 GeVc", RegexPtr(new regex(".*zprime_m500gev_w5gev-madgraph.*")));
    styles[kAzure  + 0 ] = Pattern("Zprime M: 750 GeV w: 7.50 GeVc", RegexPtr(new regex(".*zprime_m750gev_w7500mev-madgraph.*")));
    styles[kBlue   - 7 ]  = Pattern("Zprime M: 1000 GeV w: 100 GeVc", RegexPtr(new regex(".*zprime_m1000gev_w100gev-madgraph.*")));
    styles[kBlue   - 10] = Pattern("Zprime M: 1000 GeV w: 10 GeVc", RegexPtr(new regex(".*zprime_m1000gev_w10gev-madgraph.*")));
    styles[kViolet     ] = Pattern("Zprime M: 1250 GeV w: 1.25 GeVc", RegexPtr(new regex(".*zprime_m1250gev_w1250mev-madgraph.*")));
    styles[kPink   + 10] = Pattern("Zprime M: 1500 GeV w: 150 GeVc", RegexPtr(new regex(".*zprime_m1500gev_w150gev-madgraph.*")));
    styles[kPink   + 8 ] = Pattern("Zprime M: 1500 GeV w: 15 GeVc", RegexPtr(new regex(".*zprime_m1500gev_w15gev-madgraph.*")));
    styles[kRed    + 0 ] = Pattern("Zprime M: 2000 GeV w: 200 GeVc", RegexPtr(new regex(".*zprime_m2000gev_w200gev-madgraph.*")));
    styles[kRed    - 9 ] = Pattern("Zprime M: 2000 GeV w: 20 GeVc", RegexPtr(new regex(".*zprime_m2000gev_w20gev-madgraph.*")));
    styles[kOrange + 9 ] = Pattern("Zprime M: 3000 GeV w: 300 GeVc", RegexPtr(new regex(".*zprime_m3000gev_w300gev-madgraph.*")));
    styles[kOrange + 7 ] = Pattern("Zprime M: 3000 GeV w: 30 GeVc", RegexPtr(new regex(".*zprime_m3000gev_w30gev-madgraph.*")));
    styles[kGreen  + 1 ] = Pattern("Zprime M: 4000 GeV w: 400 GeVc", RegexPtr(new regex(".*zprime_m4000gev_w400gev-madgraph.*")));
    styles[kGreen  - 6 ] = Pattern("Zprime M: 4000 GeV w: 40 GeVc", RegexPtr(new regex(".*zprime_m4000gev_w40gev-madgraph.*")));

    h->SetLineWidth(2);

    typedef map<string, string> Titles;

    Titles titles;

    titles["zprime_pt"] = "P_{T,Z'} [GeV/c]";
    titles["zprime_eta"] = "#{eta}_{Z'}";
    titles["zprime_phi"] = "#{phi}_{Z'}";
    titles["top_pt"] = "P_{T,t} [GeV/c]";
    titles["top_eta"] = "#{eta}_{t}";
    titles["top_phi"] = "#{phi}_{t}";
    titles["atop_pt"] = "P_{T,#bar{t}} [GeV/c]";
    titles["atop_eta"] = "#{eta}_{#bar{t}}";
    titles["atop_phi"] = "#{phi}_{#bar{t}}";
    titles["ttbar_dr"] = "#DeltaR(t,#bar{t})";
    titles["mtt"] = "M_{t,#bar{t}}";
    titles["top_hadronic_dr"] = "#DeltaR(W#rightarrowjj,b)";
    titles["top_leptonic_dr"] = "#DeltaR(W#rightarrowl#nu,b)";
    titles["wjj_dr"] = "#DeltaR(j,j)_{W#rightarrowjj}";
    titles["wlnu_dr"] = "#DeltaR(l,b)_{W#rightarrowl#nu}";
    
    boost::smatch matches;
    for(Styles::const_iterator style = styles.begin();
            styles.end() != style;
            ++style)
    {
        if (!regex_match(filename, matches, *style->second.second))
            continue;

        h->SetLineColor(style->first);
        h->SetMarkerColor(style->first);

        for(Titles::const_iterator title = titles.begin();
                titles.end() != title;
                ++title)
        {
            if (title->first == h->GetName())
            {
                h->GetXaxis()->SetTitle(title->second.c_str());

                break;
            }
        }

        return style->second.first;
    }

    return "unknown";
}
示例#6
0
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();
    }
  }
}