• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TLegend类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TLegend的典型用法代码示例。如果您正苦于以下问题:C++ TLegend类的具体用法?C++ TLegend怎么用?C++ TLegend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TLegend类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: drawChannelYieldPlot

void drawChannelYieldPlot( DrawBase* db, const std::string& selType, const std::string& bTaggerType, float lumi_fb, const std::string& saveName, std::string additionalCuts ) {


  if( additionalCuts!="" ) additionalCuts += " && ";

  // and now lepton channel definitions:
  std::string sel_mmm = "eventWeight*( " + additionalCuts + " isMZllSignalRegion && leptType==0 && leptType3==0)";
  std::string sel_mme = "eventWeight*( " + additionalCuts + " isMZllSignalRegion && leptType==0 && leptType3==1)";
  std::string sel_eem = "eventWeight*( " + additionalCuts + " isMZllSignalRegion && leptType==1 && leptType3==0)";
  std::string sel_eee = "eventWeight*( " + additionalCuts + " isMZllSignalRegion && leptType==1 && leptType3==1)";



  TLegend* legend = new TLegend( 0.6, 0.57, 0.92, 0.9 );
  legend->SetFillColor(0);
  legend->SetTextSize(0.042);


  THStack* stackMC = new THStack();
  std::vector<TH1D*> vh1_yields_mc;

  std::string yieldsFileName = "yields_"+selType;
  if( saveName!= "" ) yieldsFileName = yieldsFileName + "_" + saveName;
  yieldsFileName = yieldsFileName +"_"+bTaggerType+".txt";

  ofstream yieldsFile(yieldsFileName.c_str());

  yieldsFile << "------------------------" << std::endl;
  yieldsFile << "Yields @ " << lumi_fb << " fb-1" << std::endl;
  yieldsFile << "------------------------" << std::endl;

  yieldsFile << std::endl;
  yieldsFile << "                    (mm)m   \t(mm)e   \t(ee)m   \t(ee)e   \tTotal" << std::endl << std::endl;


  float s_mmm = 0.;
  float s_mme = 0.;
  float s_eem = 0.;
  float s_eee = 0.;
  float s = 0.;

  float b_mmm = 0.;
  float b_mme = 0.;
  float b_eem = 0.;
  float b_eee = 0.;
  float b  = 0.;


  for( unsigned i=0; i<db->get_mcFiles().size(); ++i) {

    // reverse order:
    int iMC = db->get_mcFiles().size()-i-1;

    TTree* tree_mc = (TTree*)(db->get_mcFile(iMC).file->Get("tree_passedEvents"));

    TH1D* h1_mc_mmm = new TH1D("mc_mmm", "", 100, 0., 10000.);
    TH1D* h1_mc_mme = new TH1D("mc_mme", "", 100, 0., 10000.);
    TH1D* h1_mc_eem = new TH1D("mc_eem", "", 100, 0., 10000.);
    TH1D* h1_mc_eee = new TH1D("mc_eee", "", 100, 0., 10000.);

    tree_mc->Project("mc_mmm", "ptZll", sel_mmm.c_str());
    tree_mc->Project("mc_mme", "ptZll", sel_mme.c_str());
    tree_mc->Project("mc_eem", "ptZll", sel_eem.c_str());
    tree_mc->Project("mc_eee", "ptZll", sel_eee.c_str());

    float mmm = lumi_fb*1000.*h1_mc_mmm->Integral();
    float mme = lumi_fb*1000.*h1_mc_mme->Integral();
    float eem = lumi_fb*1000.*h1_mc_eem->Integral();
    float eee = lumi_fb*1000.*h1_mc_eee->Integral();
    float total = mmm + mme + eem + eee;

    char hname[100];
    sprintf( hname, "yields_mc_%d", iMC);
    TH1D* h1_yields_mc = new TH1D(hname, "", 4, 0., 4.);
    h1_yields_mc->SetBinContent( 1, mmm );
    h1_yields_mc->SetBinContent( 2, mme );
    h1_yields_mc->SetBinContent( 3, eem );
    h1_yields_mc->SetBinContent( 4, eee );

    h1_yields_mc->SetFillColor( db->get_mcFile(iMC).fillColor );

    vh1_yields_mc.push_back( (TH1D*)h1_yields_mc );

    stackMC->Add(h1_yields_mc, "HISTO");



    if(  db->get_mcFiles()[iMC].legendName=="t#bar{t} + Z" ) {

      s_mmm += mmm;
      s_mme += mme;
      s_eem += eem;
      s_eee += eee;
      s += total;

    } else {

      yieldsFile << db->get_mcFiles()[iMC].legendName;
      for( unsigned ichar=0; ichar<20-db->get_mcFiles()[iMC].legendName.size(); ++ichar ) yieldsFile << " ";
      yieldsFile << Form("%.4f \t %.4f \t %.4f \t %.4f \t %.4f", mmm, mme, eem, eee, total) << std::endl;
//.........这里部分代码省略.........
开发者ID:amarini,项目名称:pandolf,代码行数:101,代码来源:drawTTZTrilepton.cpp


示例2: MakeSystPlot

void MakeSystPlot(const TString& channel, TFile * input, RooWorkspace * ws, const RooArgList * obs, 
                  const Int_t p, const Int_t up, const Int_t down)
{
    TString pdfname = g_pdfname;
    pdfname.ReplaceAll("$CHANNEL", channel);

    const TString& process = g_processes[p];
    TString systUp = g_systematics[up];
    systUp.ReplaceAll("$CHANNEL", channel);
    systUp.ReplaceAll("$PROCESS", process);
    
    TString systDown = g_systematics[down];
    systDown.ReplaceAll("$CHANNEL", channel);
    systDown.ReplaceAll("$PROCESS", process);

    if (process != "Wj0b" && process != "Wj1b" && process != "Wj2b") {
        if (systUp.Contains("WJModel") || systDown.Contains("WJModel") || systUp.Contains("WJSlope") || systDown.Contains("WJSlope"))
            return;
    }

    if (process != "Zj0b" && process != "Zj1b" && process != "Zj2b") {
        if (systUp.Contains("ZJModel") || systDown.Contains("ZJModel") || systUp.Contains("ZJSlope") || systDown.Contains("ZJSlope"))
            return;
    }
    
    if (process != "TT") {
        if (systUp.Contains("TTModel") || systDown.Contains("TTModel"))
            return;
    }
    
    TH1F * h = (TH1F *) input->Get(channel + "/" + process);
    TH1F * hUp = (TH1F *) input->Get(channel + "/" + process + "_" + systUp);
    TH1F * hDown = (TH1F *) input->Get(channel + "/" + process + "_" + systDown);
    if ((h->Integral() > 0. && hUp->Integral() <= 0.) || h->Integral() <= 0.) {
        TString clonename = hUp->GetName();
        delete hUp;
        hUp = (TH1F*) h->Clone(clonename);
    }
    if ((h->Integral() > 0. && hDown->Integral() <= 0.) || h->Integral() <= 0.) {
        TString clonename = hDown->GetName();
        delete hDown;
        hDown = (TH1F*) h->Clone(clonename);
    }
    if (process == "WH" || process == "ZH" || process == "VH") {
        if (systUp.Contains("eff_b"))
            systUp.ReplaceAll("eff_b", "eff_b_SIG");
        if (systDown.Contains("eff_b"))
            systDown.ReplaceAll("eff_b", "eff_b_SIG");
    }
    RooDataHist * dhUp = new RooDataHist(process + "_" + systUp, "", *obs, hUp);
    ws->import(*dhUp);
    RooDataHist * dhDown = new RooDataHist(process + "_" + systDown, "", *obs, hDown);
    ws->import(*dhDown);
    
    h->SetStats(0);
    h->SetTitle("; BDT");
    h->SetLineColor(1);
    h->SetLineWidth(2);
    h->SetFillColor(0);
    h->SetMarkerStyle(20);
    h->SetMinimum(0.01);
    h->GetXaxis()->CenterTitle();
    
    hUp->SetLineColor(g_upcol);
    hUp->SetLineWidth(2);
    hUp->SetFillColor(0);
    
    hDown->SetLineColor(g_downcol);
    hDown->SetLineWidth(2);
    hDown->SetFillColor(0);
    
    h->Draw("e1");
    hUp->Draw("hist same");
    hDown->Draw("hist same");
    h->Draw("e1 same");
    
    TLegend * leg = new TLegend(0.35, 0.20, 0.92, 0.35);
    leg->SetFillColor(0);
    leg->SetFillStyle(0);
    leg->SetLineColor(0);
    leg->SetShadowColor(0);
    leg->SetTextFont(62);
    //leg->SetTextSize(0.015);
    leg->AddEntry(h, process, "pl");
    leg->AddEntry(hUp, systUp, "l");
    leg->AddEntry(hDown, systDown, "l");
    leg->Draw();

    gPad->RedrawAxis();
    gPad->Modified();
    gPad->Update();
    gPad->Print(pdfname);
    
    delete dhUp;
    delete dhDown;
    delete leg;
    
    return;
}
开发者ID:degrutto,项目名称:VHbbUF,代码行数:99,代码来源:BDTShapeWorkspaceJ11.C


示例3: main

int main(int argc, char** argv){

  TString chfile;
  TString chfileref;
  TString DirectoryLast;
  TString labelData;
  TString labelRef;


  int ntrueargs = 0;
  bool logyFlag = true;
  bool normalize = false;

  for (int i=1; i<argc; ++i) {
      if (argv[i][0] == '-') {
            if (argv[i][1]=='l') logyFlag = false;
            else if (argv[i][1]=='b') gROOT->SetBatch();
            else if (argv[i][1]=='h') return printUsage();
            else if (argv[i][1]=='n') normalize=true;
            else if (argv[i][1]=='D') labelData = argv[i+1];
            else if (argv[i][1]=='R') labelRef= argv[i+1];

      } else {
            ntrueargs += 1;
            if (ntrueargs==1) chfile = argv[i];
            else if (ntrueargs==2) chfileref = argv[i];
            else if (ntrueargs==3) DirectoryLast = argv[i];
      }
  }

  if (ntrueargs<3) return printUsage();

  TRint* app = new TRint("CMS Root Application", 0, 0);

  TString cmssw_version = gSystem->Getenv("CMSSW_VERSION");
  TString chsample = "EWKMu";
  TString chtitle = chsample + " validation for " + cmssw_version;




  //TCanvas* c1 = new TCanvas("c1",chtitle.Data());
  TCanvas* c1 = new TCanvas("c1",chtitle.Data(),0,0,1024,768);
  c1->SetFillColor(0);
  TPaveLabel* paveTitle = new TPaveLabel(0.1,0.93,0.9,0.99, chtitle.Data());
  paveTitle->Draw();
  paveTitle->SetFillColor(0);
  gStyle->SetOptLogy(logyFlag);
  gStyle->SetPadGridX(true);
  gStyle->SetPadGridY(true);
  gStyle->SetOptStat(0);
//  gStyle->SetFillColor(0);

  TPad* pad[4];
  pad[0] = new TPad("pad_tl","The top-left pad",0.01,0.48,0.49,0.92);
  pad[0]->SetFillColor(0); 
  pad[1] = new TPad("pad_tr","The top-right pad",0.51,0.48,0.99,0.92); 
  pad[1]->SetFillColor(0);
  pad[2] = new TPad("pad_bl","The bottom-left pad",0.01,0.01,0.49,0.46); 
  pad[2]->SetFillColor(0);
  pad[3] = new TPad("pad_br","The bottom-right pad",0.51,0.01,0.99,0.46); 
  pad[3]->SetFillColor(0);

  for (unsigned int i=0; i<4; ++i) pad[i]->Draw();
                                                                                
  TLegend* leg = new TLegend(0.6041667,0.7487715,0.9861111,0.9576167);
  leg->SetFillColor(0);
  TFile* input_file = new TFile(chfile.Data(),"READONLY");
  TFile* input_fileref = new TFile(chfileref.Data(),"READONLY");
  bool first_plots_done = false;

  TString directory = DirectoryLast + "/BeforeCuts";

  TDirectory* dir_before = input_file->GetDirectory(directory);
  TDirectory* dirref_before = input_fileref->GetDirectory(directory);
  TList* list_before = dir_before->GetListOfKeys();
  list_before->Print();

  unsigned int list_before_size = list_before->GetSize();
  TString auxTitle = chtitle + ": BEFORE CUTS";
  for (unsigned int i=0; i<list_before_size; i+=4) {
      if (first_plots_done==true) c1->DrawClone();
      paveTitle->SetLabel(auxTitle.Data());
      for (unsigned int j=0; j<4; ++j) {
            pad[j]->cd(); 
            pad[j]->Clear(); 
            if ((i+j)>=list_before_size) continue;

            TH1D* h1 = (TH1D*)dir_before->Get(list_before->At(i+j)->GetName()); 
//            h1->SetLineColor(kBlue);
//            h1->SetMarkerColor(kBlue);
            h1->SetMarkerStyle(21);
            h1->SetLineStyle(1);
            h1->SetLineWidth(3);
            h1->SetTitleSize(0.05,"X");
            h1->SetTitleSize(0.05,"Y");
            TString title=(TString)dir_before->Get(list_before->At(i+j)->GetName())->GetTitle();
            TString name=(TString)dir_before->Get(list_before->At(i+j)->GetName())->GetName(); 
            TString nameD =name+"_MC";
            h1->SetXTitle(title);
//.........这里部分代码省略.........
开发者ID:aashaqshah,项目名称:cmssw-1,代码行数:101,代码来源:WMuNuValidatorMacro.cpp


示例4: showFunctions1d

void showFunctions1d(std::vector<TF1*>& functions, const std::vector<std::string>& legendEntries,
		     const TString& xAxisTitle, double yMin, double yMax, const TString& yAxisTitle, 
		     const std::string& outputFileName)
{
  assert(functions.size() == legendEntries.size());

  TCanvas* canvas = new TCanvas("canvas", "canvas", 800, 600);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2);
  
  canvas->SetLeftMargin(0.12);
  canvas->SetBottomMargin(0.12);

  assert(functions.size() > 0);
  TF1* refFunction = functions[0];

  TH1* dummyHistogram = new TH1F("dummyHistogram", "dummyHistogram", 10, refFunction->GetXmin(), refFunction->GetXmax());
  dummyHistogram->SetStats(false);
  dummyHistogram->SetTitle("");
  dummyHistogram->SetMinimum(-TMath::Log(yMax));
  dummyHistogram->SetMaximum(-TMath::Log(yMax) + 5.);
  
  TAxis* xAxis = dummyHistogram->GetXaxis();
  xAxis->SetTitle(xAxisTitle.Data());
  xAxis->SetTitleOffset(1.15);

  TAxis* yAxis = dummyHistogram->GetYaxis();
  yAxis->SetTitle(Form("-log(%s)", yAxisTitle.Data()));
  yAxis->SetTitleOffset(1.30);

  dummyHistogram->Draw("axis");

  int colors[] = { 1, 2, 3, 4, 5, 6, 7, 15 };
  int numFunctions = functions.size();
  if ( numFunctions > 8 ) {
    std::cerr << "<showFunctions1d>:" << std::endl;
    std::cerr << "Number of functions must not exceed 8 !!" << std::endl;
    assert(0);
  }
  
  for ( int iFunction = 0; iFunction < numFunctions; ++iFunction ) {
    TF1* function = functions[iFunction];
    function->SetLineColor(colors[iFunction]);
    function->SetLineWidth(2);
    function->Draw("same");
  }

  TLegend* legend = new TLegend(0.68, 0.89 - (0.03 + 0.040*numFunctions), 0.89, 0.89, "", "brNDC"); 
  legend->SetBorderSize(0);
  legend->SetFillColor(0);
  legend->SetTextSize(0.035);
  for ( int iFunction = 0; iFunction < numFunctions; ++iFunction ) {
    TF1* function = functions[iFunction];
    const std::string& legendEntry = legendEntries[iFunction];
    legend->AddEntry(function, legendEntry.data(), "l");
  }
  legend->Draw();

  canvas->Update();
  size_t idx = outputFileName.find_last_of('.');
  std::string outputFileName_plot = std::string(outputFileName, 0, idx);
  if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
  canvas->Print(std::string(outputFileName_plot).append(".png").data());
  canvas->Print(std::string(outputFileName_plot).append(".pdf").data());

  delete dummyHistogram;
  delete legend;
  delete canvas;
}
开发者ID:JehadMousa,项目名称:TauAnalysis-CandidateTools,代码行数:69,代码来源:toyMClikelihoods.C


示例5: DarkSusy_mH_125_mGammaD_2000_cT_100_LHE_gammaD_M

void DarkSusy_mH_125_mGammaD_2000_cT_100_LHE_gammaD_M()
{
//=========Macro generated from canvas: cnv/cnv
//=========  (Sun May 24 15:18:26 2015) by ROOT version6.02/05
   TCanvas *cnv = new TCanvas("cnv", "cnv",1,1,904,904);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   cnv->SetHighLightColor(2);
   cnv->Range(-1.526695,-0.2275,1.571513,1.5225);
   cnv->SetFillColor(0);
   cnv->SetBorderMode(0);
   cnv->SetBorderSize(2);
   cnv->SetLogx();
   cnv->SetTickx(1);
   cnv->SetTicky(1);
   cnv->SetLeftMargin(0.17);
   cnv->SetRightMargin(0.03);
   cnv->SetTopMargin(0.07);
   cnv->SetBottomMargin(0.13);
   cnv->SetFrameFillStyle(0);
   cnv->SetFrameBorderMode(0);
   cnv->SetFrameFillStyle(0);
   cnv->SetFrameBorderMode(0);
   
   TH1F *h_gammaD_1_M_dummy86 = new TH1F("h_gammaD_1_M_dummy86","h_gammaD_1_M_dummy",303,0.1,30.1);
   h_gammaD_1_M_dummy86->SetMaximum(1.4);
   h_gammaD_1_M_dummy86->SetLineStyle(0);
   h_gammaD_1_M_dummy86->SetMarkerStyle(20);
   h_gammaD_1_M_dummy86->GetXaxis()->SetTitle("Mass of #gamma_{D} [GeV]");
   h_gammaD_1_M_dummy86->GetXaxis()->SetLabelFont(42);
   h_gammaD_1_M_dummy86->GetXaxis()->SetLabelOffset(0.007);
   h_gammaD_1_M_dummy86->GetXaxis()->SetTitleSize(0.06);
   h_gammaD_1_M_dummy86->GetXaxis()->SetTitleOffset(0.95);
   h_gammaD_1_M_dummy86->GetXaxis()->SetTitleFont(42);
   h_gammaD_1_M_dummy86->GetYaxis()->SetTitle("Fraction of events / 0.1 GeV");
   h_gammaD_1_M_dummy86->GetYaxis()->SetLabelFont(42);
   h_gammaD_1_M_dummy86->GetYaxis()->SetLabelOffset(0.007);
   h_gammaD_1_M_dummy86->GetYaxis()->SetTitleSize(0.06);
   h_gammaD_1_M_dummy86->GetYaxis()->SetTitleOffset(1.35);
   h_gammaD_1_M_dummy86->GetYaxis()->SetTitleFont(42);
   h_gammaD_1_M_dummy86->GetZaxis()->SetLabelFont(42);
   h_gammaD_1_M_dummy86->GetZaxis()->SetLabelOffset(0.007);
   h_gammaD_1_M_dummy86->GetZaxis()->SetTitleSize(0.06);
   h_gammaD_1_M_dummy86->GetZaxis()->SetTitleFont(42);
   h_gammaD_1_M_dummy86->Draw("");
   
   TH1F *h_gammaD_1_M87 = new TH1F("h_gammaD_1_M87","h_gammaD_1_M",303,0.1,30.1);
   h_gammaD_1_M87->SetBinContent(201,1);
   h_gammaD_1_M87->SetBinError(201,0.002500016);
   h_gammaD_1_M87->SetEntries(159998);
   h_gammaD_1_M87->SetDirectory(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#0000ff");
   h_gammaD_1_M87->SetLineColor(ci);
   h_gammaD_1_M87->SetLineWidth(2);
   h_gammaD_1_M87->SetMarkerStyle(20);
   h_gammaD_1_M87->GetXaxis()->SetLabelFont(42);
   h_gammaD_1_M87->GetXaxis()->SetLabelOffset(0.007);
   h_gammaD_1_M87->GetXaxis()->SetTitleSize(0.06);
   h_gammaD_1_M87->GetXaxis()->SetTitleOffset(0.95);
   h_gammaD_1_M87->GetXaxis()->SetTitleFont(42);
   h_gammaD_1_M87->GetYaxis()->SetLabelFont(42);
   h_gammaD_1_M87->GetYaxis()->SetLabelOffset(0.007);
   h_gammaD_1_M87->GetYaxis()->SetTitleSize(0.06);
   h_gammaD_1_M87->GetYaxis()->SetTitleOffset(1.3);
   h_gammaD_1_M87->GetYaxis()->SetTitleFont(42);
   h_gammaD_1_M87->GetZaxis()->SetLabelFont(42);
   h_gammaD_1_M87->GetZaxis()->SetLabelOffset(0.007);
   h_gammaD_1_M87->GetZaxis()->SetTitleSize(0.06);
   h_gammaD_1_M87->GetZaxis()->SetTitleFont(42);
   h_gammaD_1_M87->Draw("SAMEHIST");
   
   TLegend *leg = new TLegend(0.4566667,0.82,0.7822222,0.9066667,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.02777778);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   TLegendEntry *entry=leg->AddEntry("NULL","#splitline{pp #rightarrow h #rightarrow 2n_{1} #rightarrow 2n_{D} + 2 #gamma_{D} #rightarrow 2n_{D} + 4#mu}{#splitline{m_{h} = 125 GeV, m_{n_{1}} = 50 GeV, m_{n_{D}} = 1 GeV}{m_{#gamma_{D}} = 20 GeV, c#tau_{#gamma_{D}} = 100 mm}}","h");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   
   leg = new TLegend(0.17,0.935,0.97,1,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextAlign(22);
   leg->SetTextSize(0.045);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
//.........这里部分代码省略.........
开发者ID:tahuang1991,项目名称:MuJetAnalysis,代码行数:101,代码来源:DarkSusy_mH_125_mGammaD_2000_cT_100_LHE_gammaD_M.C


示例6: finalize2012_gammaJets


//.........这里部分代码省略.........
    var_30[i]->SetTitleOffset(1.25,"Y");
    var_30[i]->SetYTitle(ytitle_30);
    var_30[i]->SetXTitle(axis.c_str());
    var_30[i]->SetLineColor(kBlack);
    var_30[i]->SetLineWidth(2);
    //
    var_50[i]->SetTitle("");
    var_50[i]->SetStats(0);
    var_50[i]->SetTitleOffset(1.25,"Y");
    var_50[i]->SetYTitle(ytitle_50);
    var_50[i]->SetXTitle(axis.c_str());
    var_50[i]->SetLineColor(kBlack);
    var_50[i]->SetLineWidth(2);
    //
    var_75[i]->SetTitle("");
    var_75[i]->SetStats(0);
    var_75[i]->SetTitleOffset(1.25,"Y");
    var_75[i]->SetYTitle(ytitle_75);
    var_75[i]->SetXTitle(axis.c_str());
    var_75[i]->SetLineColor(kBlack);
    var_75[i]->SetLineWidth(2);
    //
    var_90[i]->SetTitle("");
    var_90[i]->SetStats(0);
    var_90[i]->SetTitleOffset(1.25,"Y");
    var_90[i]->SetYTitle(ytitle_90);
    var_90[i]->SetXTitle(axis.c_str());
    var_90[i]->SetLineColor(kBlack);
    var_90[i]->SetLineWidth(2);
  }


  // ----------------------------------------
  TLegendEntry *legge;
  TLegend *leg;
  leg = new TLegend(0.6,0.6,0.85,0.85);
  leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetTextSize(0.05);
  leg->SetFillColor(0);
  legge = leg->AddEntry(var_30[0], "gamma+jets", "f");
  legge = leg->AddEntry(var_30[1], "QCD", "f");

  // mc only plot: data vs background, HLT=30
  var_30[0]->SetFillColor(kBlue-9);
  var_30[0]->Draw("hist");
  var_30[1]->SetFillColor(kMagenta-9);
  var_30[1]->Draw("samehist");
  leg->Draw();
  sprintf(name,"%s%s%s","results_gammaJ/mc_",variableData.c_str(),"_HLT-30.png");
  c0->SaveAs(name);
  sprintf(name,"%s%s%s","results_gammaJ/mc_",variableData.c_str(),"_HLT-30.root");
  c0->SaveAs(name);

  // mc only plot: data vs background, HLT=50
  var_50[0]->SetFillColor(kBlue-9);
  var_50[0]->Draw("hist");
  var_50[1]->SetFillColor(kMagenta-9);
  var_50[1]->Draw("samehist");
  leg->Draw();
  sprintf(name,"%s%s%s","results_gammaJ/mc_",variableData.c_str(),"_HLT-50.png");
  c0->SaveAs(name);
  sprintf(name,"%s%s%s","results_gammaJ/mc_",variableData.c_str(),"_HLT-50.root");
  c0->SaveAs(name);

  // mc only plot: data vs background, HLT=75
  var_75[0]->SetFillColor(kBlue-9);
  var_75[0]->Draw("hist");
开发者ID:CMSROMA,项目名称:GammaJets,代码行数:67,代码来源:finalize2012_gammaJets.C


示例7: overlay_Merged_RecoSmeared

TCanvas* overlay_Merged_RecoSmeared(const vector<string>& folders, 
								const hist_t& h
								)
{

	TLegend *leg  = new TLegend(0.6,0.65,0.9,0.9);
	leg->SetTextFont(42);
	vector<TH1*> hists;
	
	vector<string> jetcoll;
	jetcoll.push_back("reco");
	jetcoll.push_back("gen");
	jetcoll.push_back("smeared");

	stringstream title;
	const string njets("3-5");
	//const string eta("2.5");
	const string eta("5.0");
	title << njets
			<< " Jets, MHT from Jets with P_{T}>30 GeV, |#eta |<" 
			<< eta << ", L = 10 fb^{-1}" << ";" << h.title ;

	for (unsigned j=0; j< jetcoll.size(); ++j)
	{
		TH1* Hist = 0;
		for (unsigned i = 0; i < folders.size(); ++i)
		{
			stringstream histname;
			histname << folders.at(i) << "/" << jetcoll.at(j) << h.name;
			cout << __LINE__ << ": Looking for hist: " << histname.str().c_str() << endl;
			TH1* htemp = GetHist(histname.str());
			
			if (Hist == 0) Hist = htemp;
			else Hist->Add(htemp);
		}
		
		Hist->Rebin(h.rebin);
		Hist->SetTitle(title.str().c_str());
		Hist->SetMarkerStyle(20+j);
		Hist->SetLineWidth(2);
		Hist->SetStats(0);

		stringstream legname;
		if (j==0) 
		{
			legname << "Reco"; 
		} else if (j==1) 
		{
			legname << "Gen"; 
			Hist->SetLineColor(kBlue);
			Hist->SetMarkerColor(kBlue);
		} else if (j==2)
		{
			legname << "Smeared"; 
			Hist->SetLineColor(kRed);
			Hist->SetMarkerColor(kRed);
		}

		const double sum = Hist->Integral(); 
		legname << " (" << sum << ")";
		if (j!=1) leg->AddEntry(Hist, legname.str().c_str());

		hists.push_back(Hist);

	} //end jetcoll
	
	TH1* ratio = dynamic_cast<TH1*> (hists.at(2)->Clone("ratio"));
	ratio->GetYaxis()->SetTitle("Smeared/Reco");
	ratio->SetTitle("");
	ratio->Divide(hists.at(0));
	ratio->GetYaxis()->SetRangeUser(-0.01,2.01);
	//ratio->SetTickLength (+0.01,"Y");

   //TCanvas *c1 = new TCanvas("c1", "c1",15,60,550,600);
   TCanvas *c1 = new TCanvas("c1");
   c1->Range(0,0,1,1);
   c1->SetBorderSize(2);
   c1->SetFrameFillColor(0);
  
// ------------>Primitives in pad: c1_1
   TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.30,0.99,0.99);
   c1_1->Draw();
   c1_1->cd();
   c1_1->SetBorderSize(2);
   c1_1->SetTickx(1);
   c1_1->SetTicky(1);
   c1_1->SetTopMargin(0.1);
   c1_1->SetBottomMargin(0.0);
   //c1_1->SetFrameFillColor(3);
	c1_1->SetLogy();
   
	hists.at(0)->GetYaxis()->CenterTitle(1);
	hists.at(0)->SetLabelFont(42,"XYZ");
	hists.at(0)->SetTitleFont(42,"XYZ");
	hists.at(0)->GetYaxis()->SetTitleOffset(0.8);
	hists.at(0)->SetLabelSize(0.05,"XYZ");
	hists.at(0)->SetTitleSize(0.06,"XYZ");
   hists.at(0)->Draw("P");
   hists.at(2)->Draw("same P");
	leg->Draw();
//.........这里部分代码省略.........
开发者ID:hkaushalya,项目名称:UserCode,代码行数:101,代码来源:overlay_Merged_RecoSmeared.C


示例8: ratioPlots_Zxx

void ratioPlots_Zxx()
{

  // llbb_Mass_reco mfJetEta_450_600 mfJetEta_250_300 lljjMass_reco mjj_HighMass_reco drll_HighMass_reco

   TString Variable = "Zxx_Mass_reco";
//   TString Variable2 = "Zbb_Mass_reco";
   TString x_title = "M_{llxx}";
   Int_t N_Rebin = 10;

   Double_t yTopLimit = 3;

   TFile *f1 = TFile::Open("/home/fynu/amertens/storage/test/MG_PY6_/output/MG_PY6_/MG_PY6v9.root");
   TH1D *h1 = (TH1D*)f1->Get(Variable);
   h1->Sumw2();
//   h1->Add((TH1D*)f1->Get(Variable2));
   h1->SetDirectory(0);
   f1->Close();

   TFile *f2 = TFile::Open("/home/fynu/amertens/storage/test/aMCNLO_PY8_/output/aMCNLO_PY8_/aMCNLO_PY8v9.root");
   TH1D *h2 = (TH1D*)f2->Get(Variable);
   h2->Sumw2();
//   h2->Add((TH1D*)f2->Get(Variable2));
   h2->SetDirectory(0);
   f2->Close();

/*
   TFile *f3 = TFile::Open("/home/fynu/amertens/storage/test/MG_PY8_/output/MG_PY8_/MG_PY8.root");
   TH1D *h3 = (TH1D*)f3->Get(Variable);
   h3->SetDirectory(0);
   f3->Close();
*/
//   h1->Sumw2();
//   h2->Sumw2();
//   h3->Sumw2();

   cout << "MG_PY6      : " << h1->Integral() << endl;
   cout << "[email protected]_PY8 : " << h2->Integral() << endl;


   //h1->Scale(1.0/151456.0);
   //h2->Scale(1.0/1.45192e+09);
   //h2->Scale(1./12132.9);
   h1->Scale(1.0/h1->Integral());
   h2->Scale(1.0/h2->Integral());

   h1->Sumw2();
   h2->Sumw2();



//   h3->Scale(1.0/h3->Integral());

   h1->Rebin(N_Rebin);
   h2->Rebin(N_Rebin);
//   h3->Rebin(N_Rebin);

   TH1D *h1c = h1->Clone();
   h1c->Sumw2();
   TH1D *h2c = h2->Clone();
   h2c->Sumw2();

   TH1D *h1c2 = h1->Clone();
   h1c2->Sumw2();

   h2c->Add(h1c,-1);
   h2c->Divide(h1c);


   h1->SetTitle("");
   h2->SetTitle("");
//   h3->SetTitle("");


   h1->SetLineColor(kRed);
//   h3->SetLineColor(kGreen);

   TCanvas *c1 = new TCanvas("c1","example",600,700);
   TPad *pad1 = new TPad("pad1","pad1",0,0.5,1,1);
   pad1->SetBottomMargin(0);
   gStyle->SetOptStat(0);
   pad1->Draw();
   pad1->cd();
   h2->DrawCopy();
//   h3->DrawCopy("same");
   h1->GetYaxis()->SetLabelSize(0.1);
   h1->GetYaxis()->SetRangeUser(0, 0.2);// ,yTopLimit);
   h1->GetYaxis()->SetTitleSize(0.06);
   h1->GetYaxis()->SetTitleOffset(0.7);



   h1->Draw("same");

   TLegend *leg = new TLegend(0.6,0.7,0.89,0.89);
   leg->SetLineColor(0);
   leg->SetFillColor(0);
   //leg->AddEntry(h1,"t#bar{t} uncertainty","f");
   leg->AddEntry(h1,"MG5 + PY6","l");
   leg->AddEntry(h2,"[email protected] + PY8","l");
//.........这里部分代码省略.........
开发者ID:AlexandreMertens,项目名称:ZAPlotters,代码行数:101,代码来源:ratioPlots_Zxx.C


示例9: makeMETPlots

void makeMETPlots(){

  gStyle->SetOptFit(0);

  TChain *ch = new TChain("t");
  //ch->Add("../output/V00-02-09/highpt/LM6v2_smallTree.root");
  //ch->Add("../output/V00-02-00/LM4_baby.root");
  //ch->Add("../output/V00-02-16/highpt/LM6v2_smallTree_gen_TEMP.root");
  ch->Add("../output/V00-02-18/highpt/LM6v2_smallTree_gen.root");

  vector<TCut> metcuts;
  vector<float> metcutvals;

  metcuts.push_back(TCut("pfmet>200")); metcutvals.push_back(200);
  metcuts.push_back(TCut("pfmet>275")); metcutvals.push_back(275);

  //TCut sel("njets>=2 && ht>100 && !passz");
  TCut sel("foundPair==1 && reco1==1 && reco2==1 && ht>100 && htgen2>100 && ngenjets>=2");

  const unsigned int n = metcuts.size();

  TH1F* hpass[n];
  TH1F* hall[n];

  for( unsigned int i = 0 ; i < metcuts.size() ; ++i){

    hpass[i]   = new TH1F(Form("hpass_%i",i),Form("hpass_%i",i),25,0,500);
    hall[i]    = new TH1F(Form("hall_%i",i), Form("hall_%i",i) ,25,0,500);

    ch->Draw(Form("genmet>>hpass_%i",i),sel+metcuts.at(i));
    ch->Draw(Form("genmet>>hall_%i",i)  ,sel);

  }




  TCanvas *can = new TCanvas();
  can->cd();
  gPad->SetRightMargin(0.1);
  gPad->SetTopMargin(0.1);
  gPad->SetGridx();
  gPad->SetGridy();  
  gStyle->SetOptFit(0);

  TGraphAsymmErrors* gr[n];  
  TLegend *leg = new TLegend(0.6,0.2,0.87,0.4);
  leg->SetFillColor(0);
  leg->SetBorderSize(1);
  leg->SetTextSize(0.03);

  TF1* erf[n];

  TLine line;
  line.SetLineWidth(2);
  line.SetLineStyle(2);

  for( unsigned int i = 0 ; i < metcuts.size() ; ++i){

    //can[i] = new TCanvas(Form("can_%i",i),Form("can_%i",i),500,500);
    //can[i]->cd();
    
    // TF1* efunc = new TF1("efitf", fitf, 0, 500, 3);
    // efunc->SetParameters(1, 100, 10);
    // efunc->SetParNames("norm", "offset", "width");

    erf[i] = new TF1("efitf", fitf, 0, 500, 3);
    erf[i]->SetParameters(1, 100, 30);
    erf[i]->SetParNames("norm", "offset", "width");
    erf[i]->SetLineWidth(2);
    //erf[i]->FixParameter(0,1);

    //erf[i] = new TF1(Form("erf_%i",i),mfitf,0,400);

    //erf[i]->SetParameter(0,100*(i+1));
    //erf[i]->SetParameter(1,10);

    gr[i] = new TGraphAsymmErrors();
    if( i==0 ){
      erf[i]->SetLineColor(1);
      line.SetLineColor(1);
    }

    if( i==1 ){
      line.SetLineColor(2);
      gr[i]->SetLineColor(2);
      gr[i]->SetMarkerColor(2);
      gr[i]->SetMarkerStyle(21);
      erf[i]->SetLineColor(2);
    }
    if( i==2 ){
      gr[i]->SetLineColor(4);
      gr[i]->SetMarkerColor(4);
      gr[i]->SetMarkerStyle(25);
      erf[i]->SetLineColor(4);
    }

    leg->AddEntry(gr[i],Form("E_{T}^{miss}>%.0f GeV",metcutvals.at(i)),"p");

    gr[i]->GetXaxis()->SetRangeUser(0,500);
//.........这里部分代码省略.........
开发者ID:hooberman,项目名称:UserCode,代码行数:101,代码来源:makeMETPlots.C


示例10: makePlots_hlt_eventbyevent_comparison

void makePlots_hlt_eventbyevent_comparison( std::string inputFile_="input.root", std::string target_label_="Target", std::string outputSuffix_="_out" ) {

  TFile *file = new TFile(inputFile_.c_str());

  std::string dirprefix = "Images" + outputSuffix_;
  struct stat st;
  if( stat(dirprefix.c_str(),&st) != 0 )  mkdir(dirprefix.c_str(),0777);

  std::string label_ref = "Reference";
  std::string label_tgt = target_label_;

  TH1D* h_ref = (TH1D*)file->Get("eventbyevent/HLT_Ref");
  TH1D* h_tgt = (TH1D*)file->Get("eventbyevent/HLT_Tgt");
  TH1D* h_tgt_sep = (TH1D*)file->Get("eventbyevent/HLT_Tgt_sep");

  std::map<std::string, int> hlt_counts_per_path_ref_;
  std::map<std::string, int> hlt_counts_per_path_tgt_;
  std::map<double, std::string> hlt_counts_per_path_diff_;

  std::vector<std::string> hlt_common_paths;

  TAxis * axis = h_ref->GetXaxis();

  // loop over target paths
  for( int iPath=0; iPath<h_tgt_sep->GetNbinsX(); iPath++ ){
    std::string name(h_tgt_sep->GetXaxis()->GetBinLabel(iPath+1));
    
    int bin = axis->FindBin(name.c_str());

    if( bin<1 ) continue;

    double cnt_ref = h_ref->GetBinContent(bin);
    double cnt_tgt = h_tgt->GetBinContent(bin);

    int diff = int( cnt_ref - cnt_tgt );
    double rel_diff = double(diff);

    if( cnt_ref>0 )      rel_diff = fabs(cnt_tgt - cnt_ref)/cnt_ref;
    else if( cnt_tgt>0 ) rel_diff = fabs(cnt_tgt - cnt_ref)/cnt_tgt;
    else                 rel_diff = 0.;

    // printf("%s\t %d\t %d\t %d\t %.3f \n",
    // 	   name.c_str(), int(cnt_ref), int(cnt_tgt), diff, rel_diff ); 

    hlt_counts_per_path_ref_[name] = int(cnt_ref);
    hlt_counts_per_path_tgt_[name] = int(cnt_tgt);

    hlt_counts_per_path_diff_[rel_diff] = name;

    if( rel_diff>0.15 ) hlt_common_paths.push_back(name);
  }


  std::map<double, std::string>::reverse_iterator rit;
  for( rit=hlt_counts_per_path_diff_.rbegin(); rit!=hlt_counts_per_path_diff_.rend(); ++rit )
    std::cout << "path: " << rit->second << "\t" << rit->first << "\t" << hlt_counts_per_path_ref_[rit->second] << "\t" << hlt_counts_per_path_tgt_[rit->second] << std::endl;


  int numPaths = int( hlt_counts_per_path_ref_.size() );
  TH1D* h_hlt_ref = new TH1D("h_hlt_ref",";HLT path", numPaths, 0, numPaths );
  TH1D* h_hlt_tgt = new TH1D("h_hlt_tgt",";HLT path", numPaths, 0, numPaths );
  TH1D* h_hlt_diff = new TH1D("h_hlt_diff",";HLT path", numPaths, 0, numPaths );

  int iHLT=0;
  for( std::map<std::string, int>::iterator it=hlt_counts_per_path_ref_.begin(); it!=hlt_counts_per_path_ref_.end(); ++it ){
    iHLT++;
    std::string name = it->first;

    double cnt_ref = double(hlt_counts_per_path_ref_[name]);
    double cnt_tgt = double(hlt_counts_per_path_tgt_[name]);

    double rel_diff = 1.0;
    if( cnt_ref>0 )      rel_diff = (cnt_tgt - cnt_ref)/cnt_ref;
    else if( cnt_tgt>0 ) rel_diff = (cnt_tgt - cnt_ref)/cnt_tgt;
    else                 rel_diff = 0.;

    h_hlt_ref->SetBinContent(iHLT,cnt_ref);
    h_hlt_tgt->SetBinContent(iHLT,cnt_tgt);
    h_hlt_diff->SetBinContent(iHLT,rel_diff);

    h_hlt_ref->GetXaxis()->SetBinLabel(iHLT,name.c_str());
    h_hlt_diff->GetXaxis()->SetBinLabel(iHLT,name.c_str());
  }


  h_hlt_ref->SetStats(0);

  h_hlt_ref->SetLineColor(kBlue);
  h_hlt_tgt->SetLineColor(kRed);

  if( true ){
    // TLegend *legend = new TLegend(0.255,0.78,0.92,0.89);
    TLegend *legend = new TLegend(0.255,0.92,0.92,0.99);

    legend->SetFillColor(kWhite);
    legend->SetLineColor(kWhite);
    legend->SetShadowColor(kWhite);
    legend->SetTextFont(42);
    legend->SetTextSize(0.035);

//.........这里部分代码省略.........
开发者ID:cms-steam,项目名称:Event-by-Event_Validation,代码行数:101,代码来源:makePlots_hlt_eventbyevent_comparison.C


示例11: eventBinning

//================================================
void eventBinning(const Int_t save = 0)
{
  TH1F *hVtxZ = (TH1F*)f->Get(Form("mhVertexZ_%s",trigName[kTrigType]));
  c = draw1D(hVtxZ,"",kFALSE,kFALSE);
  for(int i=0; i<19; i++)
    {
      double value = -100 + i*10 + 10;
      double height = hVtxZ->GetBinContent(hVtxZ->FindFixBin(value));
      TLine *line = GetLine(value,0,value,height,2,1,1);
      line->Draw();
    }
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sVertexZ_Binning.pdf",run_type,run_cfg_name.Data()));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sVertexZ_Binning.png",run_type,run_cfg_name.Data()));
    }

  TH1F *hgRefMultCorr = (TH1F*)f->Get(Form("mhgRefMultCorr_%s",trigName[kTrigType]));
  c = draw1D(hgRefMultCorr,"",kTRUE,kFALSE);
  //double bounds[9] = {472,401,283,193,126,77,44,23,11};
  double bounds[16] = {11,16,23,32,44,59,77,99,126,157,193,235,283,338,401,472};
  for(int i=0; i<16; i++)
    {
      double value = bounds[i];
      double height = hgRefMultCorr->GetBinContent(hgRefMultCorr->FindFixBin(value));
      TLine *line = GetLine(value,0,value,height,2,1,1);
      line->Draw();
    }
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult_Binning.pdf",run_type,run_cfg_name.Data()));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult_Binning.png",run_type,run_cfg_name.Data()));
    }

  // centrality
  TH1F *hgRefMult = (TH1F*)f->Get(Form("mhgRefMult_%s",trigName[kTrigType]));
  hgRefMult->SetLineColor(2);
  c = draw1D(hgRefMult,"",kTRUE,kFALSE);
  hgRefMultCorr->Draw("sames HIST");
  TLegend *leg = new TLegend(0.15,0.3,0.4,0.5);
  leg->SetBorderSize(0);
  leg->SetFillColor(0);
  leg->SetTextSize(0.04);
  leg->AddEntry(hgRefMult,"Raw gRefMult","L");
  leg->AddEntry(hgRefMultCorr,"Corrected gRefMult","L");
  leg->Draw();
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult.pdf",run_type,run_cfg_name.Data()));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sgRefMult.png",run_type,run_cfg_name.Data()));
    }


  TH1F *hCentrality = (TH1F*)f->Get(Form("mhCentrality_%s",trigName[kTrigType]));
  c = draw1D(hCentrality,"",kTRUE,kFALSE);
  if(save) 
    {
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sCentrality.pdf",run_type,run_cfg_name.Data()));
      c->SaveAs(Form("~/Work/STAR/analysis/Plots/%s/ana_EventMixing/%sCentrality.png",run_type,run_cfg_name.Data()));
    }

  // event plane
  TH2F *hExcVsIncRawEP = (TH2F*)f->Get(Form("mhExcVsIncRawEP_%s",trigName[kTrigType]));
  c = draw2D(hExcVsIncRawEP);

  TH1F *hEventPlane = (TH1F*)f->Get(Form("mhEventPlane_%s",trigName[kTrigType]));
  c = draw1D(hEventPlane,"",kFALSE,kFALSE);
}
开发者ID:marrbnl,项目名称:STAR,代码行数:69,代码来源:ana_EventMixing.C


示例12: plotv2

void plotv2(){
    const int ncent = 6;
    const int npt = 25;
    int scale = 1;
    int centbin[ncent+1] = {0,5,10,20,40,60,100};
    gStyle->SetOptFit(kFALSE);
    gStyle->SetOptStat(kFALSE);

    //-----------------TGraphs--------------------------
//TGraphErrors* gr1[ncent];
//TGraphErrors* gr2[ncent];
TGraphErrors* gr[ncent];
//TGraphErrors* grsub1[ncent];
//TGraphErrors* grsub2[ncent];
TGraphErrors* grsub[ncent];
TGraphErrors* grF[ncent];
    
TGraphErrors *grP[ncent];

    for(int icent=0;icent<ncent;icent++){
    
    gr[icent] = new TGraphErrors(Form("v2_cent%d.dat",icent),"%lg %lg %lg");
    grsub[icent] = new TGraphErrors(Form("v2_cent%d_scale%d.dat",icent,scale));
    grF[icent] = new TGraphErrors(Form("../../Ridge3corrfvtx/20GeV/v2_cent%d.dat",icent),"%lg %lg %lg");

//-----------plotting results-----------------------------------------------------
    if(icent<0){
//    grP[icent] = new TGraphErrors(Form("v2_00_%d_BBCS.dat",icent),"%lg %lg %lg");
    grP[icent] = new TGraphErrors(Form("v2_00_%d_FVTX1S.dat",icent),"%lg %lg %lg");
    grP[icent]->SetName(Form("grP_%d",icent));
    grP[icent]->SetMarkerSize(1.2);
    grP[icent]->SetMarkerStyle(20);
    grP[icent]->SetMarkerColor(1);
    grP[icent]->SetLineColor(1);
 }
    TH1D* h = new TH1D(Form("h_%d",icent),"",100,0,5);
    h->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    h->GetYaxis()->SetTitle("v_{2}");
    h->GetXaxis()->SetRangeUser(0,3.5);
    h->GetYaxis()->SetRangeUser(0,0.25);

 float ptv2[npt];
  float eptv2[npt], sptv2[npt];
  float v2data[npt], ev2data[npt], sv2data[npt], asv2data1[npt];
  int npoints = 11;
  ifstream finv2("v2_pt_dAu_00_05_sys.dat");

  //Elliptic flow
  for(int i=0; i<npoints; i++)
    {
      eptv2[i]=0;
      sptv2[i]=0.05;
      finv2>>ptv2[i]>>v2data[i]>>ev2data[i]>>sv2data[i];//>>asv2data1[i];
    }
  finv2.close();

  TGraphErrors *grP0 = new TGraphErrors(npoints, ptv2, v2data, eptv2, ev2data);
  grP0->SetMarkerStyle(23);
  grP0->SetMarkerColor(2);
  TF1 *fun = new TF1("fun","pol4",0,5);
 
  /*
  grP[icent]->Fit("fun","Q0");
    TCanvas *c1 = new TCanvas("c1","",500,500);
    h->Draw();
    TLegend *leg = new TLegend(0.2,0.6,0.4,0.8);
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.04);
    if(icent==0){
    leg->AddEntry(grP,"Event plane","P");
    leg->AddEntry(fun,"pol 4 fit","L");
    }
    leg->AddEntry(gr1[icent],"use cnt-bbc","P");
    leg->AddEntry(gr2[icent],"use cnt-fvtx","P");
    leg->AddEntry(gr[icent],"use 3-sub","P");
    leg->Draw("same");
    grP[icent]->SetMarkerStyle(20);
    grP[icent]->SetMarkerColor(1);
    gr1[icent]->SetMarkerSize(1.2);
    gr1[icent]->SetMarkerStyle(21);
    gr1[icent]->SetMarkerColor(4);
    gr1[icent]->SetLineColor(4);
    gr2[icent]->SetMarkerSize(1.2);
    gr2[icent]->SetMarkerStyle(20);
    gr2[icent]->SetMarkerColor(2);
    gr2[icent]->SetLineColor(2);
    gr[icent]->SetMarkerSize(1.2);
    gr[icent]->SetMarkerStyle(24);
    gr[icent]->SetMarkerColor(1);
    gr[icent]->SetLineColor(1);
    gr1[icent]->Draw("Psame");
    gr2[icent]->Draw("Psame");
    gr[icent]->Draw("Psame");

//  0-5%
  if(icent==0){
 
  fun->Draw("same");
      for(int i=0; i<npoints; i++)
//.........这里部分代码省略.........
开发者ID:XuQiao,项目名称:HI,代码行数:101,代码来源:plotv2.C


示例13: displayMultipleFiles

void displayMultipleFiles(std::string inputTextFile, 
			  std::string var, 
			  std::string xtitle="", std::string ytitle="",
			  std::string output="test", bool logScale=false)
{
  
  setTDRStyle();
  gStyle->SetOptStat(0);

  
  FILE *fTable = fopen(inputTextFile.data(),"r");
   
  int flag=1;   

  std::vector<std::string> dataFile;
  std::vector<std::string> legendName;

  char filename[300];

  while (flag!=-1){
    // first reading input file
    flag=fscanf(fTable,"%s",filename);
    std::string tempFile = filename;

    flag=fscanf(fTable,"%s",filename);
    std::string tempLegend = filename;

    if (flag!=-1) {
      dataFile.push_back(tempFile);
      cout << "Reading " << tempFile.data() << endl;
      legendName.push_back(tempLegend);
      cout << "Legend is " << tempLegend.data() << endl;
    }
  }	 

  int nfile=dataFile.size();
	
  cout << "There are " << nfile << " files to compare" << endl;

  TH1F* h[20];
  TFile* f[20];

  const int NMAXFILE=10;

  if(nfile > NMAXFILE){
    cout << "Too many files!!" << endl;
    return;
  }

  TCanvas* c1 = new TCanvas("c1","",500,500);
  if(logScale)c1->SetLogy(1);
  else c1->SetLogy(0);

  float max=-9999.0;
  int maxHisto=-1;
  
  for(int i=0; i < nfile; i++){
    f[i] = TFile::Open(dataFile[i].data());
    h[i] = (TH1F*)(f[i]->Get(var.data()));
    h[i]->SetXTitle(xtitle.data());  
    h[i]->SetYTitle(ytitle.data());  
    h[i]->GetYaxis()->SetDecimals();
    h[i]->GetYaxis()->SetNdivisions(5);
    h[i]->GetXaxis()->SetNdivisions(5);
    h[i]->SetLineColor(1+i);
    h[i]->SetMarkerColor(1+i);
    h[i]->SetMarkerSize(1);
    h[i]->SetMarkerStyle(21);
    h[i]->Rebin(2);

    cout << "h[" << i << "] mean = " << h[i]->GetMean() << " and width = " << h[i]->GetRMS() << 
      " and entries = " << h[i]->GetEntries() << " and integral = " << 
      h[i]->Integral() << endl;
    

    float scale = 1.0/(float)h[i]->Integral();
    h[i]->Sumw2();
    h[i]->Scale(scale);

    float max1   = h[i]->GetBinError(h[i]->GetMaximumBin()) + h[i]->GetMaximum();

    if(max1>max){max = max1; maxHisto=i;}
  }

//   h[maxHisto]->SetMaximum(0.15);
  h[maxHisto]->SetMaximum(0.1);
  h[maxHisto]->Draw("histe");
  for(int i=0; i<nfile; i++)h[i]->Draw("histesame");
    

  TLegend* leg = new TLegend(0.31,0.425,0.51,0.85);
  leg->SetFillColor(0);
  leg->SetFillStyle(0);
  leg->SetTextSize(0.04);
  leg->SetBorderSize(0);
  leg->SetHeader("|y_{B}| < 0.5");
  for(int i=0; i< nfile; i++)
    leg->AddEntry(h[i], legendName[i].data());
  leg->Draw("same");

//.........这里部分代码省略.........
开发者ID:ramankhurana,

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TLevelSet类代码示例发布时间:2022-05-31
下一篇:
C++ TLeafList类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap