Пример #1
0
Wt::WString sizeToString(std::size_t size)
{
	if (size >= 1024 * 1024 * 1024)
	{
		return Wt::WString::tr("msg-size-gb").arg(to_string_with_precision(size / 1024 / 1024 / 1024., 1));
	}
	if (size >= 1024 * 1024)
	{
		return Wt::WString::tr("msg-size-mb").arg(to_string_with_precision(size / 1024 / 1024., 1));
	}
	else if (size >= 1024)
	{
		return Wt::WString::tr("msg-size-kb").arg(to_string_with_precision(size / 1024., 1));
	}
	else
		return Wt::WString::tr("msg-size-b").arg(size);
}
void printOE(std::string name, float element, entityx::Entity entity, entityx::EntityManager &entities, entityx::EventManager &events)
{
    name = name + to_string_with_precision(element);
    printOE(name, entity, entities, events);
};
Пример #3
0
  void drawpdgstack(std::string const & which_pdg,
		    std::string const & cname,
		    std::string const & dr,
		    std::string const & binning,
		    std::string const & we = "",
		    std::string const & op = "",
		    std::string const & title = "",
		    std::string const & xtitle = "",
		    std::string const & ytitle = "",
		    bool const pdg_sign = true) {

    ofile->cd();
    
    TH1F * hist = getpdgs(which_pdg.c_str(), we);
    if(!hist) {
      std::cout << "drawpdgstack: Empty pdg hist for \"" << which_pdg << "\" with selection \"" << we << "\"\n";
      return;
    }    

    THStack * stack = new THStack("stack", "");
    TLegend * legend = new TLegend(0.6, 0.9, 0.9, 0.6);

    double sig_evtsppot = 0;

    if(tree2) {

      TString draw_str = "";
      draw_str += dr;
      draw_str += ">>h_sig";
      draw_str += binning;

      TCanvas * canvas_pdg_temp = new TCanvas("temp");
      tree2->Draw(draw_str.Data(),
		  we.c_str(),
		  op.c_str());
      delete canvas_pdg_temp;
      TH1F * hist_sig = (TH1F*)gDirectory->Get("h_sig");
      hist_sig->SetLineColor(1);
      hist_sig->SetFillColor(kRed+3);
      hist_sig->Scale(1. / signal_pot * run_pot);

      stack->Add(hist_sig);
      legend->AddEntry(hist_sig, ("Signal: "+to_string_with_precision(hist_sig->Integral())).c_str());
      
      sig_evtsppot = hist_sig->Integral();

    }

    legend->SetHeader(("Total: "+to_string_with_precision((hist->Integral()/background_pot*run_pot + sig_evtsppot))).c_str());
    ((TLegendEntry*)legend->GetListOfPrimitives()->First())->SetTextAlign(22);

    std::vector<int> pdg_vec;
    for(int i = 1; i <= hist->GetNbinsX(); ++i) {

      if(hist->GetBinContent(i) == 0) continue;      
      int const pdg = i+hist->GetBinLowEdge(0);

      if(!pdg_sign) {
	if(std::find(pdg_vec.begin(), pdg_vec.end(), abs(pdg)) != pdg_vec.end())
	  continue;
	pdg_vec.push_back(abs(pdg));
      }
  
      TString hname = "";
      hname += "h_";
      hname += pdg;
      
      TString draw_str = "";
      draw_str += dr;
      draw_str += ">>h_";
      draw_str += pdg;
      draw_str += binning;
      
      TString weight_str = "";
      weight_str += we;
      weight_str += "&&(";
      weight_str += which_pdg;
      weight_str += "==";
      weight_str += pdg;
      if(!pdg_sign && pdg < 0) {
	weight_str += "||";
	weight_str += which_pdg;
	weight_str += "==";
	weight_str += abs(pdg);
      }
      weight_str += ")";
      
      TCanvas * canvas_pdg_temp = new TCanvas("temp");
      tree->Draw(draw_str.Data(),
		 weight_str.Data(),
		 op.c_str());
      delete canvas_pdg_temp;

      int pdg_temp = pdg;
      if(!pdg_sign) pdg_temp = abs(pdg);
      pdg_stuff const & pdg_s = get_pdg_stuff(pdg_temp, pdg_sign);

      TH1F * hist_pdg = (TH1F*)gDirectory->Get(hname.Data());
      hist_pdg->SetLineColor(1);
      hist_pdg->SetFillColor(pdg_s._color);
      hist_pdg->Scale(1. / background_pot * run_pot);
      stack->Add(hist_pdg);
      legend->AddEntry(hist_pdg, (pdg_s._particle_name+": "+to_string_with_precision(hist_pdg->Integral())).c_str());
      
    }
    
    TCanvas * canvas = new TCanvas(cname.c_str());
    stack->Draw();
    stack->SetTitle(title.c_str());
    stack->GetXaxis()->SetTitle(xtitle.c_str());
    stack->GetXaxis()->CenterTitle(); 
    stack->GetYaxis()->SetTitle(ytitle.c_str());
    stack->GetYaxis()->CenterTitle();
    legend->Draw();
    canvas->Write();
    delete stack;
    delete legend;
    delete canvas;
    delete hist;
    
  }