当前位置: 首页>>代码示例>>C++>>正文


C++ TCanvas::Delete方法代码示例

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


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

示例1: drawFakeRatePlots

//--------------------------------------------------------------------------------------------------
// Draw the FakeRate histograms and fit functions
//--------------------------------------------------------------------------------------------------
void drawFakeRatePlots( vector<TH1F*> fakeRateHistograms, vector<TF1*> fakeRateFits,
                        vector<string> fakeRateLegendNames , string plotname ,Double_t MAXY = 0.2) {

  assert(fakeRateHistograms.size() == fakeRateFits.size());
  assert(fakeRateHistograms.size() == fakeRateLegendNames.size());
  TCanvas *cv = MakeCanvas("cv", plotname.c_str(), 800, 600);
  
  TLegend *leg1=0;
  leg1 = new TLegend(0.65,0.6,0.9,0.8);   
  leg1->SetBorderSize(1);
  leg1->SetTextSize(0.03);
  
  for (UInt_t i=0; i<fakeRateHistograms.size() ; i++) {    
    //fakeRateHistograms[i]->SetMarkerSize(0.5);
    fakeRateHistograms[i]->SetMarkerColor(COLORS[i]);
    fakeRateHistograms[i]->SetMinimum(0.0);
    fakeRateHistograms[i]->SetMaximum(MAXY);
    fakeRateHistograms[i]->SetLineColor(COLORS[i]);
    fakeRateFits[i]->SetLineColor(COLORS[i]);    
    leg1->AddEntry(fakeRateFits[i], fakeRateLegendNames[i].c_str(), "LP"); 
  
    if (i==0) { 
      fakeRateHistograms[i]->Draw();
    } else {
      fakeRateHistograms[i]->Draw("same");
    }
    fakeRateFits[i]->Draw("same");    
  }

  leg1->Draw();

  string filename = plotname + ".gif";
  cv->SaveAs(filename.c_str());
  cv->Delete();
}
开发者ID:IlariaVai,项目名称:UserCode-1,代码行数:38,代码来源:computeFakeRates.C

示例2: Make1DPlot

void Make1DPlot(TH1F *hist1D, const TString str1D, bool logY, const int xlow, const int xhigh){
  TCanvas *BBB = new TCanvas("BBB", "MET Response",600,450);
  BBB->cd();
  hist1D->GetXaxis()->SetRangeUser(xlow, xhigh); 
  gStyle->SetStatX(0.9);
  gStyle->SetStatY(0.88); 
  gStyle->SetOptStat(111111);
  if(logY)BBB->SetLogy();  
  hist1D->Draw();
  TString name1, name2;
  name1 = str1D+".eps";
  name2 = str1D+".pdf";
  BBB->SaveAs(name1);
  BBB->SaveAs(name2);
  BBB->Delete();
}
开发者ID:asantra,项目名称:FakeRateStudy,代码行数:16,代码来源:SmallNtupleMASTER.C

示例3: getHltAcceptance


//.........这里部分代码省略.........
  
  tmp = prefix;
  tmp += "_";
  tmp += bins;
  tmp += "bins";
  tmp += "_Hlt1TrackAndTrackMuonExcl_Hlt2DiMuonDetached_Background";
  histo_Hlt1TrackAndTrackMuonExcl_Hlt2DiMuonDetached_B->SetName(tmp);
  tmp += "_AsymErrors";
  graph_Hlt1TrackAndTrackMuonExcl_Hlt2DiMuonDetached_B->SetName(tmp);
  tmp = particle;
  tmp += " Hlt1TrackAndTrackMuonExcl_Hlt2DiMuonDetached Acceptance";
  histo_Hlt1TrackAndTrackMuonExcl_Hlt2DiMuonDetached_B->SetTitle(tmp);
  graph_Hlt1TrackAndTrackMuonExcl_Hlt2DiMuonDetached_B->SetTitle(tmp);
  
  RooDataSet* data_sub;
  RooDataSet* data_sub2;
  RooDataSet* data_sub_A_1;
  RooDataSet* data_sub_A_2;
  RooDataSet* data_sub_B_1;
  RooDataSet* data_sub_B_2;
  
  data_sub2 = ((RooDataSet*)data->reduce("CatB>0."));
  
  n_A_1_S.setVal(TMath::Max(data_sub2->sumEntries()/2.,100.));
  n_A_1_B.setVal(TMath::Max(data_sub2->sumEntries()/2.,100.));
  
  model_A_1->fitTo(*data_sub2,RooFit::Minos(kFALSE),Optimize(kFALSE),RooFit::SumW2Error(kTRUE));
  
  rfrac.setConstant();
  frac.setConstant();
  Bmass.setConstant();
  c0.setConstant();
  Bwidth1.setConstant();
  data_sub2->Delete();
  
  for(Int_t i(0); i< bins; i++){
    tmp = "B_TAU < ";
    tmp += binning->binHigh(i);
    tmp += " && B_TAU > ";
    tmp += binning->binLow(i);
    data_sub = (RooDataSet*)data->reduce(tmp);
    data_sub2 = ((RooDataSet*)data_sub->reduce("CatB>0."));
    data_sub_A_1 = ((RooDataSet*)data_sub->reduce("CatA==CatA::CatA1"));
    data_sub_A_2 = ((RooDataSet*)data_sub->reduce("CatA==CatA::CatA2"));
    data_sub_B_1 = ((RooDataSet*)data_sub->reduce("CatB==CatB::CatB1"));
    data_sub_B_2 = ((RooDataSet*)data_sub->reduce("CatB==CatB::CatB2"));
    
    TAU.setRange("fit",binning->binLow(i),binning->binHigh(i));
    TAU.setBin(i);
    
    n_A_1_S.setVal(TMath::Max(data_sub_A_1->sumEntries()/2.,100.));
    n_A_1_B.setVal(TMath::Max(data_sub_A_1->sumEntries()/2.,100.));
    
    c0.setConstant(kFALSE);
    //Bwidth1.setConstant(kFALSE);
    
    //n_A_1_S.setMin(-1000.);
    model_A_1->fitTo(*data_sub2,RooFit::Minos(kFALSE),Optimize(kFALSE),RooFit::SumW2Error(kTRUE));
    n_A_1_S.setMin(0.0000001);
    
    //c0.setConstant();
    //Bwidth1.setConstant();
    
    //n_A_1_S.setMin(-1000.);
    //n_A_2_S.setMin(-1000.);
    //n_B_1_S.setMin(-1000.);
开发者ID:goi42,项目名称:lhcb,代码行数:67,代码来源:getStrippingAcceptance.C

示例4: plotphi

void plotphi(int top, bool phi=kFALSE){
  if (setup("vm","","pol__")==kFALSE) return;
  gStyle->SetOptFit(1111); //pcev = 1111
  //gStyle->SetTitleW(1.5);

  int itop = top-1;
  TFile* fy = _fyexp[itop];

  int nq2wbins = fy->GetNkeys();
  TIter nextkey(fy->GetListOfKeys());
  TKey *key;
  int iq2wbin = 0;
  while (key = (TKey*)nextkey()) {
    TString Q2Wdirname = key->GetName();
    if(Q2Wdirname.EqualTo("hYW_Dir") || Q2Wdirname.EqualTo("hYW"))continue;
    cout << "Q2Wdirname = " << Q2Wdirname << endl;

    THStack* hs[10];
    TF1 *fphi = new TF1("fphi", "([0] + [1]*cos(x*TMath::DegToRad()) + [2]*cos(2*x*TMath::DegToRad()) + [3]*sin(x*TMath::DegToRad()))",0, 360);
    fphi->SetParameter(0,1);
    fphi->SetParameter(1,10);
    fphi->SetParameter(2,20);
    fphi->SetParameter(3,100);
    fphi->SetParName(0, "A");
    fphi->SetParName(1, "B");
    fphi->SetParName(2, "C");
    fphi->SetParName(3, "hPR");
    for (int i = 0; i < 10; i++)
    {
      TString hname_unp = TString::Format("%s/hPhi/Varset1/theta/hphi_%02d",Q2Wdirname.Data(),i+1);
      TString hname_pos = TString::Format("%s/hPhi_POS/Varset1/theta/hphi_%02d",Q2Wdirname.Data(),i+1);
      TString hname_neg = TString::Format("%s/hPhi_NEG/Varset1/theta/hphi_%02d",Q2Wdirname.Data(),i+1);
      cout << "hname_unp = " << hname_unp << endl;
      cout << "hname_pos = " << hname_pos << endl;
      cout << "hname_neg = " << hname_neg << endl;
      TH1D* hunp = (TH1D*)fy->Get(hname_unp);
      TH1D* hpos = (TH1D*)fy->Get(hname_pos);
      TH1D* hneg = (TH1D*)fy->Get(hname_neg);
      if (hunp==NULL || hpos==NULL || hneg==NULL) cout << "histogram not found" << endl;
      hunp->SetLineColor(kBlack);
      hpos->SetLineColor(kRed);
      hneg->SetLineColor(kBlue);
      hunp->Fit(fphi);
      hpos->Fit(fphi);
      hneg->Fit(fphi);

      //! Modify titles
      TObjArray *tarr;
      char t[100];

      TPaveText *ptunp = new TPaveText(0.0, 0.9, 1.0, 1, "NDC");
      TString tunp = hunp->GetTitle();
      tarr = tunp.Tokenize("|");
      sprintf(t, "%s:%s:%s", tarr->At(1)->GetName(), tarr->At(2)->GetName(), tarr->At(3)->GetName());
      ptunp->AddText(tarr->At(0)->GetName());
      ptunp->AddText(t);
      hunp->SetTitle("");

      TPaveText *ptpos = new TPaveText(0.0, 0.9, 1.0, 1, "NDC");
      TString tpos = hpos->GetTitle();
      tarr = tpos.Tokenize("|");
      sprintf(t, "%s:%s:%s", tarr->At(1)->GetName(), tarr->At(2)->GetName(), tarr->At(3)->GetName());
      ptpos->AddText(tarr->At(0)->GetName());
      ptpos->AddText(t);
      hpos->SetTitle("");

      TPaveText *ptneg = new TPaveText(0.0, 0.9, 1.0, 1, "NDC");
      TString tneg = hneg->GetTitle();
      tarr = tneg.Tokenize("|");
      sprintf(t, "%s:%s:%s", tarr->At(1)->GetName(), tarr->At(2)->GetName(), tarr->At(3)->GetName());
      ptneg->AddText(tarr->At(0)->GetName());
      ptneg->AddText(t);
      hneg->SetTitle("");

      //! Draw histograms
      TCanvas *c = new TCanvas(hpos->GetName(),hpos->GetName(),900, 600);
      c->Divide(3,1);
      c->cd(1);
      hunp->Draw();
      ptunp->Draw();
      c->cd(2);
      hpos->Draw();
      ptpos->Draw();
      c->cd(3);
      hneg->Draw();
      ptneg->Draw();
      TString dir = TString::Format("./polobs/top%d/%s/Varset1/theta", top, Q2Wdirname.Data());
      gSystem->mkdir(dir,1);
      c->SaveAs(TString::Format("%s/%s.png", dir.Data(), c->GetName()));
      c->Close();
      c->Delete();
    }
  }
}
开发者ID:arjun-trivedi,项目名称:ana2pi,代码行数:94,代码来源:xsec-tools.092513.pretwoscales.C

示例5: compareChargeDependantFakeRatesPythiaVsMadgraph

//--------------------------------------------------------------------------------------------------
// Make plots of fake rates for different charges
//--------------------------------------------------------------------------------------------------
void compareChargeDependantFakeRatesPythiaVsMadgraph(char *FakeRateFilename , int faketype, int chargetype ) {

  string fakeTypeString = "";
  if (faketype == 11) {
    fakeTypeString = "Electron";
  } else if (faketype == 13) {
    fakeTypeString = "Muon";
  } else {
    cerr << "Error: faketype = " << faketype << " not recognized.\n";
    assert(false);
  }

  //different charges
  string chargeTypeName = "";
  if (chargetype == -1)
    chargeTypeName = "Minus";
  else if (chargetype == 1)
    chargeTypeName = "Plus";
  
  string plotname = chargeTypeName + fakeTypeString + "FakeRateComparisonPythiaVsMadgraph";

  TCanvas *cv = MakeCanvas("cv", plotname.c_str(), 800, 600);
  TLegend *leg1=0;
  leg1 = new TLegend(0.65,0.6,0.9,0.8);   
  leg1->SetBorderSize(1);
  leg1->SetTextSize(0.03);

  int color = 0;
  
  for (int eventType= -1; eventType <= 1; eventType += 2) {
    for (int sample=0;sample<=1;sample++) {

      //sample names
      string sampleName = "";
      if (sample == 0)
        sampleName = "PythiaWJets";
      else if (sample == 1)
        sampleName = "MadgraphWJets";

      string LegendString = sampleName + " ";
     
      string eventTypeName = "";
      if (eventType == -1) {
        eventTypeName = "MinusW";
        LegendString += "-";
      } else if (eventType == 1) {
        eventTypeName = "PlusW";
        LegendString += "+";
      }
      if (chargetype == -1) {        
        LegendString += "-";
      } else if (chargetype == 1) {      
        LegendString += "+";
      }

      
      TFile *file = new TFile(FakeRateFilename, "READ");
      file->cd();
      
      TH1F *tmp = (TH1F*)file->FindObjectAny((chargeTypeName + fakeTypeString + eventTypeName + "FakeRate_Pt_" + sampleName).c_str());
      if (!tmp) {
        cerr << "can't find :"  << chargeTypeName + fakeTypeString + eventTypeName + "FakeRate_Pt_" + sampleName << endl;
        assert(tmp);
      }
      tmp->SetLineColor(COLORS[color]);
      tmp->SetMarkerColor(COLORS[color]);    
      color++;
      leg1->AddEntry(tmp, LegendString.c_str(), "LP");
      if (sample == -1 && eventType == -1)
        tmp->Draw();
      else 
        tmp->Draw("same");
    }
  }
  
  leg1->Draw();

  string filename = plotname + ".gif";
  cv->SaveAs(filename.c_str());
  cv->Delete();
}
开发者ID:IlariaVai,项目名称:UserCode-1,代码行数:84,代码来源:computeFakeRates.C

示例6: compareChargeDependantFakeRates

//--------------------------------------------------------------------------------------------------
// Make plots of fake rates for different charges
//--------------------------------------------------------------------------------------------------
void compareChargeDependantFakeRates(char *FakeRateFilename , string sampleName, int denominatortype, int faketype, 
                                     int onlychargetype = -1000, int onlyeventType = -1000 ) {

  string fakeTypeString = "";
  if (faketype == 11) {
    fakeTypeString = "Electron";
  } else if (faketype == 13) {
    fakeTypeString = "Muon";
  } else {
    cerr << "Error: faketype = " << faketype << " not recognized.\n";
    assert(false);
  }

  string denominatorTypeString = "";
  if (denominatortype == 1) {
    denominatorTypeString = "TrackDenominator";
  }

  string plotname = "ChargeDependant" + fakeTypeString + denominatorTypeString + "FakeRateComparison_" + sampleName;

  TCanvas *cv = MakeCanvas("cv", plotname.c_str(), 800, 600);
  TLegend *leg1=0;
  leg1 = new TLegend(0.65,0.6,0.9,0.8);   
  leg1->SetBorderSize(1);
  leg1->SetTextSize(0.03);

  int color = 0;
  for (int chargetype = -1; chargetype <= 1; chargetype += 2) {
    for (int eventType= -1; eventType <= 1; eventType ++) {

      if (!(onlychargetype == chargetype || onlychargetype == -1000))
        continue;

      if (onlyeventType == 0) {
        if (eventType != 0)
          continue;
      } else {
        if (eventType == 0)
          continue;
      }

      //different charges
      string chargeTypeName = "";
      string LegendString = sampleName + " ";

      string eventTypeName = "";
      if (eventType == -1) {
        eventTypeName = "MinusW";
        LegendString += "-";
      } else if (eventType == 1) {
          eventTypeName = "PlusW";
          LegendString += "+";
      } else if (eventType == 0)
        LegendString += "Fake";
        
      if (chargetype == -1) {
        chargeTypeName = "Minus";
        LegendString += "-";
      } else if (chargetype == 1) {
        chargeTypeName = "Plus";
        LegendString += "+";
      }
           
      TFile *file = new TFile(FakeRateFilename, "READ");
      file->cd();
      
      TH1F *tmp = (TH1F*)file->FindObjectAny((chargeTypeName + fakeTypeString + eventTypeName + denominatorTypeString + "FakeRate_Pt_" + sampleName).c_str());
      if (!tmp) {
        cerr << "can't find :"  << chargeTypeName + fakeTypeString + eventTypeName + denominatorTypeString + "FakeRate_Pt_" + sampleName << endl;
        assert(tmp);
      }
      tmp->SetLineColor(COLORS[color]);
      tmp->SetMarkerColor(COLORS[color]);    
      tmp->SetAxisRange(0,100);

      color++;
      leg1->AddEntry(tmp, LegendString.c_str(), "LP");
      if (chargetype == -1 && eventType == -1)
        tmp->Draw();
      else 
        tmp->Draw("same");
    }
  }
  
  leg1->Draw();

  string filename = plotname + ".gif";
  cv->SaveAs(filename.c_str());
  cv->Delete();
}
开发者ID:IlariaVai,项目名称:UserCode-1,代码行数:93,代码来源:computeFakeRates.C

示例7: compareFakeRates

//--------------------------------------------------------------------------------------------------
// Make plots of electron fake rate from many samples
//--------------------------------------------------------------------------------------------------
void compareFakeRates(char *FakeRateFilename, int faketype , int chargetype , int eventType) {

  string fakeTypeString = "";
  if (faketype == 11) {
    fakeTypeString = "Electron";
  } else if (faketype == 13) {
    fakeTypeString = "Muon";
  } else {
    cerr << "Error: faketype = " << faketype << " not recognized.\n";
    assert(false);
  }

  //different charges
  string chargeTypeName = "";
  if (chargetype == -1)
    chargeTypeName = "Minus";
  else if (chargetype == 1)
    chargeTypeName = "Plus";

  string eventTypeName = "";
  if (eventType == -1)
    eventTypeName = "MinusW";
  else if (eventType == 1)
    eventTypeName = "PlusW";

  string plotname = chargeTypeName + fakeTypeString + eventTypeName + "FakeRateComparison";

  TFile *file = new TFile(FakeRateFilename, "READ");
  file->cd();

  TCanvas *cv = MakeCanvas("cv", plotname.c_str(), 800, 600);
  TLegend *leg1=0;
  leg1 = new TLegend(0.65,0.6,0.9,0.8);   
  leg1->SetBorderSize(1);
  leg1->SetTextSize(0.03);

  TH1F *electronFakeRate_pythiaWJets = (TH1F*)file->FindObjectAny((chargeTypeName + fakeTypeString + eventTypeName + "FakeRate_Pt_PythiaWJets").c_str());
  TH1F *electronFakeRate_madgraphWJets = (TH1F*)file->FindObjectAny((chargeTypeName + fakeTypeString + eventTypeName + "FakeRate_Pt_MadgraphWJets").c_str());
  TH1F *electronFakeRate_pythiaQCDEM = (TH1F*)file->FindObjectAny((chargeTypeName + fakeTypeString + eventTypeName + "FakeRate_Pt_PythiaQCDEM").c_str());
  TH1F *electronFakeRate_madgraphQCD = (TH1F*)file->FindObjectAny((chargeTypeName + fakeTypeString + eventTypeName + "FakeRate_Pt_MadgraphQCD").c_str());

  assert(electronFakeRate_pythiaWJets);
  assert(electronFakeRate_madgraphWJets);
  assert(electronFakeRate_pythiaQCDEM);
  assert(electronFakeRate_madgraphQCD);

  electronFakeRate_pythiaWJets->SetLineColor(kRed);
  electronFakeRate_pythiaWJets->SetMarkerColor(kRed);
  electronFakeRate_madgraphWJets->SetLineColor(kBlue);
  electronFakeRate_madgraphWJets->SetMarkerColor(kBlue);
  electronFakeRate_pythiaQCDEM->SetLineColor(kMagenta);
  electronFakeRate_pythiaQCDEM->SetMarkerColor(kMagenta);
  electronFakeRate_madgraphQCD->SetLineColor(kGreen);
  electronFakeRate_madgraphQCD->SetMarkerColor(kGreen);
 
  leg1->AddEntry(electronFakeRate_pythiaWJets, (chargeTypeName + fakeTypeString + eventTypeName + "PythiaWJets").c_str(), "LP");
  leg1->AddEntry(electronFakeRate_madgraphWJets, (chargeTypeName + fakeTypeString + eventTypeName + "MadgraphWJets").c_str(), "LP"); 
  leg1->AddEntry(electronFakeRate_pythiaQCDEM, (chargeTypeName + fakeTypeString + eventTypeName + "PythiaQCDEM").c_str(), "LP"); 
  leg1->AddEntry(electronFakeRate_madgraphQCD, (chargeTypeName + fakeTypeString + eventTypeName + "MadgraphQCD").c_str(), "LP"); 
 
  electronFakeRate_pythiaWJets->Draw();
  electronFakeRate_madgraphWJets->Draw("same");
  electronFakeRate_pythiaQCDEM->Draw("same");
  electronFakeRate_madgraphQCD->Draw("same");
  leg1->Draw();

  string filename = plotname + ".gif";
  cv->SaveAs(filename.c_str());
  cv->Delete();
}
开发者ID:IlariaVai,项目名称:UserCode-1,代码行数:73,代码来源:computeFakeRates.C


注:本文中的TCanvas::Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。