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


C++ TLegend::SetMargin方法代码示例

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


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

示例1: plotMultiplicity

void plotMultiplicity(char target[6], char list[20], char ene[6], char part[4],
		      char dir[12]="histo", char g4ver[20]="G4.9.1.p01") {

  setStyle();
  gStyle->SetOptTitle(0);
  
  char name[1024], sym[10];
  if      (part=="pim") sprintf(sym, "#pi^{-}");
  else if (part=="pip") sprintf(sym, "#pi^{+}");
  else                  sprintf(sym, "p");

  std::vector<std::string> typeOld = typesOld();
  int energy = atoi(ene);
  
  char ofile[100];
  sprintf (ofile, "%s/histo_%s%s_%s_%sGeV.root", dir, target, list, part, ene);
  std::cout << "Input file " << ofile << "\n";
  TFile *fout = TFile::Open(ofile);
  fout->cd();

  char name[160], title[160], ctype[20], ytitle[20], cname[160];
  TH1I *hiMulti[20];
  for (unsigned int ii=0; ii<=(typeOld.size()); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", typeOld[ii-1].c_str());
    sprintf (name, "Multi%s%s%sGeV(%s)", target, list, ene, ctype);
    hiMulti[ii] = (TH1I*)fout->FindObjectAny(name);
    //    std::cout << ii << " (" << ctype << ") " << name << " " << hiMulti[ii] << "\n";
  }

  TCanvas *c[20];
  std::vector<std::string> types = types();
  for (unsigned int ii=0; ii<types.size(); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", types[ii-1].c_str());
    sprintf (cname, "Multiplicity (%s)", ctype);
    hiMulti[ii]->GetXaxis()->SetTitle(cname);
    hiMulti[ii]->SetMarkerStyle(mstyle[ii]);
    hiMulti[ii]->SetMarkerSize(msiz[ii]);
    hiMulti[ii]->SetMarkerColor(mcolor[ii]);
    hiMulti[ii]->SetLineColor(lcolor[ii]);
    hiMulti[ii]->SetLineStyle(lstyle[ii]);
    hiMulti[ii]->SetLineWidth(lwidth[ii]); 

    sprintf(cname, "c_%s%s_%s_%sGeV_Multiplicity(%s)", target, list, part, 
	    ene, ctype);
    c[ii] = new TCanvas(cname, cname, 800, 500);
    hiMulti[ii]->Draw();

    TLegend *leg = new TLegend(0.35, 0.80, 0.8, 0.87);
    char hdr[160];
    sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
    leg->SetHeader(hdr);  leg->SetFillColor(10); leg->SetMargin(0.45);
    leg->SetTextSize(.036); leg->Draw("same");
  }
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:56,代码来源:PlotMultiplicity.C

示例2: overlay_plots

void overlay_plots(const string& fFile0, const string& fFile1, const double fYmax, const string& fPlot, const string& fLegendEnt1, const string& fLegendEnt2, const string& fName) {
  
   TProfile *p[2];
 
   TFile file0(fFile0.c_str());
   TDirectoryFile *subDir = (TDirectoryFile*)file0.Get("offsetAnalysis");
   p[0] = (TProfile*)subDir->Get(fPlot.c_str());

   TFile file1(fFile1.c_str());
   subDir = (TDirectoryFile*)file1.Get("offsetAnalysis");
   p[1] = (TProfile*)subDir->Get(fPlot.c_str()); 

   p[0]->SetTitleOffset(1.5,"Y");
   p[0]->GetXaxis()->SetTitleSize(0.04);
   p[0]->GetYaxis()->SetTitleSize(0.04);
   
   double ymax = ((p[0]->GetMaximum())>(p[1]->GetMaximum())) ? p[0]->GetMaximum() : p[1]->GetMaximum();
   
   p[0]->GetYaxis()->SetRangeUser(0.,fYmax);
   
   TCanvas *c = new TCanvas("c","",800,800);
   c->cd();
  
   p[0]->SetLineWidth(3);
   p[0]->SetLineColor(kRed);
   p[0]->SetFillColor(kRed);
   p[0]->Draw("hist");
   p[1]->SetLineWidth(3);
   p[1]->SetLineColor(kBlack);
   p[1]->SetMarkerStyle(20);
   p[1]->SetMarkerColor(kBlack);
   p[1]->Draw("sames");
   
   TLegend *legend = new TLegend(.57,.77,.9,.87);
   legend->SetBorderSize(1);
   legend->SetFillColor(0);
//    legend->SetFillStyle(0);
   legend->SetMargin(0.12);
   legend->AddEntry(p[0],fLegendEnt1.c_str(),"l");
   legend->AddEntry(p[1],fLegendEnt2.c_str(),"l");
   legend->Draw();
   
   TLatex l;
   l.SetTextAlign(12);
   l.SetTextSize(0.04);
   l.SetTextFont(62);
   l.SetNDC();
   l.DrawLatex(0.15,0.85,"CMS 2009 Preliminary");
   
   string fileName = fName;
   c->SetGridy();
   c->SaveAs(fileName.c_str());
   
   delete legend;
   delete c;
}
开发者ID:ferencek,项目名称:cms-Offset_Analysis,代码行数:56,代码来源:makePlots.C

示例3: BuildLegend

 TLegend* BuildLegend(TCanvas* canvas, Double_t x1, Double_t y1, Double_t x2, Double_t y2, TString& Header) {
   TLegend* leg = (TLegend*)canvas->BuildLegend(x1, y1, x2, y2, Header);
   if (leg) {
     leg->SetTextFont(_DefaultFont);
     leg->SetFillColor(kWhite);
     leg->SetTextSize(0.06);
     leg->SetMargin(0.15);
     leg->SetBorderSize(0.0);
   }
   return leg;
 }
开发者ID:FCALSW,项目名称:FCalClusterer,代码行数:11,代码来源:RootUtils.cpp

示例4: TLegend

TLegend *createLegend(const string &text)
{
    TLegend *legend = new TLegend( .2, .7, .3, .8);
    if (!text.empty())
        legend->SetHeader(text.c_str());

    legend->SetMargin(0.12);
    legend->SetTextSize(0.06);
    legend->SetFillColor(10);
    legend->SetBorderSize(0);

    return legend;
}
开发者ID:PerilousApricot,项目名称:bsm_analyze,代码行数:13,代码来源:fig.C

示例5: studyBinZero


//.........这里部分代码省略.........
                                                                                                    upperCentralityBinLimit);
  
  // Project pT spectra
  TH1D* hSpectraTriggerSel = (TH1D*)hDataTriggerSel->Projection(iPt, "e");
  TH1D* hSpectraTriggerSelVtxCut = (TH1D*)hDataTriggerSelVtxCut->Projection(iPt, "e");
  TH1D* hSpectraTriggerSelVtxCutZ = (TH1D*)hDataTriggerSelVtxCutZ->Projection(iPt, "e");
  TH1D* hSpectraTriggerSelVtxCutZPileUpRej = (TH1D*)hDataTriggerSelVtxCutZPileUpRej->Projection(iPt, "e");
  
  // Normalise histos to 1/Nevt dN/dPt
  normaliseHist(hSpectraTriggerSel, numEvtsTriggerSel);
  normaliseHist(hSpectraTriggerSelVtxCut, numEvtsTriggerSelVtxCut);
  normaliseHist(hSpectraTriggerSelVtxCutZ, numEvtsTriggerSelVtxCutZ);
  normaliseHist(hSpectraTriggerSelVtxCutZPileUpRej, numEvtsTriggerSelVtxCutZPileUpRej);
  
  setupHist(hSpectraTriggerSel, kBlack, "Trigger selection");
  setupHist(hSpectraTriggerSelVtxCut, kRed, "& vertex cut");
  setupHist(hSpectraTriggerSelVtxCutZ, kBlue, "& vertex #it{z} cut");
  setupHist(hSpectraTriggerSelVtxCutZPileUpRej, kGreen, "& pile-up rejection");
  
  TCanvas* canvSpectra = new TCanvas("canvSpectra", "Spectra", 760, 420);
  canvSpectra->SetLogx();
  canvSpectra->SetLogy();
  canvSpectra->SetGrid(0, 0);
  SetCanvasMargins(canvSpectra);
  
  TLegend* leg = new TLegend(0.14, 0.26, 0.62, 0.55);
  leg->SetHeader(Form("MC pp #sqrt{s}=7 TeV, inclusive, %s", etaRange.Data()));
  leg->AddEntry(hSpectraTriggerSel, "", "l");
  leg->AddEntry(hSpectraTriggerSelVtxCut, "", "l");
  leg->AddEntry(hSpectraTriggerSelVtxCutZ, "", "l");
  if (drawPileUp)
    leg->AddEntry(hSpectraTriggerSelVtxCutZPileUpRej, "", "l");
  SetupLegend(leg);
  leg->SetMargin(0.15);
  
  hSpectraTriggerSel->Draw();
  hSpectraTriggerSelVtxCut->Draw("same");
  hSpectraTriggerSelVtxCutZ->Draw("same");
  if (drawPileUp)
    hSpectraTriggerSelVtxCutZPileUpRej->Draw("same");
  
  leg->Draw("same");
  
  // Ratios (take binomial errors, since real sub-samples)
  
  TH1D* hRatioVtxCut = new TH1D(*hSpectraTriggerSelVtxCut);
  hRatioVtxCut->SetName("hRatioVtxCut");
  setupHist(hRatioVtxCut, kBlack, "MB & vtx / MB");
  hRatioVtxCut->GetYaxis()->SetTitle("1/#it{N}_{evt} d#it{N}/d#it{p}_{T}^{gen} ratio");
  hRatioVtxCut->Divide(hRatioVtxCut, hSpectraTriggerSel, 1., 1., "B");
  hRatioVtxCut->GetYaxis()->SetRangeUser(1.08, 1.14);
  
  // Mean ratio of spectra and of Nevt
  TF1* funcRatioVtxCut = new TF1("funcRatioVtxCut", "pol0",
                                 0.15, hRatioVtxCut->GetXaxis()->GetBinUpEdge(hSpectraTriggerSelVtxCut->FindLastBinAbove(0)));
  funcRatioVtxCut->SetLineWidth(2);
  funcRatioVtxCut->SetLineColor(kRed);
  hRatioVtxCut->Fit(funcRatioVtxCut, "N");
  const Double_t meanRatioVtxCut = funcRatioVtxCut->GetParameter(0);
  const Double_t ratioNevtVtxCut = numEvtsTriggerSelVtxCut > 0 ? numEvtsTriggerSel / numEvtsTriggerSelVtxCut : -1.;
  const Double_t doubleRatioMinusOne = meanRatioVtxCut > 0 ? (ratioNevtVtxCut / meanRatioVtxCut - 1.) : -999.;
  
  
  
  TH1D* hRatioVtxCutZ = new TH1D(*hSpectraTriggerSelVtxCutZ);
  hRatioVtxCutZ->SetName("hRatioVtxCutZ");
开发者ID:ktf,项目名称:AliPhysics,代码行数:67,代码来源:studyBinZero.C

示例6: Plotting

void Plotting()
{
  TH1::AddDirectory(kFALSE);
  gStyle->SetCanvasDefH(600);
  gStyle->SetCanvasDefW(600);
  
  gROOT->SetStyle("Plain");
  gStyle->SetPalette(1);
  gStyle->SetFrameBorderMode(0);
  gStyle->SetFrameFillColor(0);
  gStyle->SetCanvasColor(0);
  gStyle->SetTitleFillColor(0);
  gStyle->SetStatColor(0);
  gStyle->SetPadBorderSize(0);
  gStyle->SetCanvasBorderSize(0);
  gStyle->SetOptTitle(0); // at least most of the time
  gStyle->SetOptStat("nemr"); // most of the time, sometimes "nemriou" might be useful to display name, 
  //number of entries, mean, rms, integral, overflow and underflow
  gStyle->SetOptFit(0); // set to 1 only if you want to display fit results
  
  //=================================== Histo for all cut variables ==========================================
  using namespace RooFit;
  using namespace RooStats;
 
  void setWSRange(RooWorkspace *ws);
  void defineMassBkg(RooWorkspace *ws);
  void defineMassSig(RooWorkspace *ws);    

  double RError(double,double,double,double);
  double WeightRatioError(double,double,double,double);
  
  bool is3D =1;
  bool significance = 0;
  bool isHI=0; 
  bool Prompt = 0;
  bool nonPrompt = 1;

  bool savePlot=0;
  bool Binning =0;
  bool ctauFit = 1;
  

  float ptmin=3.0; float ptmax=30.0; float ymin=1.6; float ymax=2.4; bool absRapidity=true; 
  double threshold=0.8; double efficiency=0.9; int centmin=0; int centmax=200;

  ymin=1.6; ymax=2.4; ptmin=3.0; ptmax=30.0; 
  //ymin=1.6; ymax=2.4; ptmin=3.0; ptmax=6.5; 
  //ymin=1.6; ymax=2.4; ptmin=6.5; ptmax=12.0; 
  //ymin=1.6; ymax=2.4; ptmin=12.0; ptmax=30.0; 
  
  //ymin=0.0; ymax=1.6; ptmin=6.5; ptmax=30.0;  
  //ymin=0.0; ymax=1.6; ptmin=6.5; ptmax=9.0;  
  //ymin=0.0; ymax=1.6; ptmin=9.0; ptmax=12.0;  
  //ymin=0.0; ymax=1.6; ptmin=12.0; ptmax=15.0;  
  //ymin=0.0; ymax=1.6; ptmin=15.0; ptmax=20.0;  
  //ymin=0.0; ymax=1.6; ptmin=20.0; ptmax=30.0;  
  
  int range1 = 0; int fbin = 0;
  int range2 = 0; int lbin = 0;
  float xVal = 0.0;

  if(significance){
    range1 = -10;
    range2 = 50;
    fbin = -10; lbin = 50;
    xVal = 11.0;
  }else{
    range1 = -1;
    range2 = 3;
    fbin = -5; lbin = 10;
    xVal = 0.5;
  }

  float lCut=-10.0;
  TLegend *leg = new TLegend(0.38,0.5,0.87,0.75);
  if (isHI)
    leg->SetHeader("PYTHIA: PbPb #sqrt{s_{NN}} = 5.02 TeV");
  else
    leg->SetHeader("PYTHIA: pp #sqrt{s} = 5.02 TeV");
  leg->SetFillStyle(0);
  leg->SetFillColor(0);
  leg->SetBorderSize(0);
  leg->SetMargin(0.15);
  leg->SetTextSize(0.032);
  leg->SetTextColor(2);

  TCut defaultCut = NULL;
  //  TCut defaultCut = "Reco_QQ_sign==0&&Gen_QQ_4mom.M()>3.09&&Gen_QQ_4mom.M()<3.10&&Reco_QQ_4mom.M()>2.9&&Reco_QQ_4mom.M()<3.2&&Reco_QQ_ctauTrue>-10";
  defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.9&&Reco_QQ_4mom.M()<3.2&&Reco_QQ_ctau>-500&&Reco_QQ_ctauTrue>-10";
  if(significance)
    defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.85&&Reco_QQ_4mom.M()<3.25&&Reco_QQ_ctau>-500&&Reco_QQ_ctauErr>-500&&Reco_QQ_ctauTrue>-10";
  if(is3D){
    defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.85&&Reco_QQ_4mom.M()<3.25&&Reco_QQ_ctau3D>-500&&Reco_QQ_ctauTrue3D>-10";
    if(significance)
      defaultCut = "Reco_QQ_sign==0&&Reco_QQ_4mom.M()>2.85&&Reco_QQ_4mom.M()<3.25&&Reco_QQ_ctau3D>-500&&Reco_QQ_ctauErr3D>-500&&Reco_QQ_ctauTrue3D>-10";
  }
  
  TCut ptCut = Form("Reco_QQ_4mom.Pt()>%3.1f&&Reco_QQ_4mom.Pt()<%3.1f",ptmin,ptmax);
  TCut rapCut;
  if (absRapidity)
//.........这里部分代码省略.........
开发者ID:CMS-HIN-dilepton,项目名称:DimuonCADIs,代码行数:101,代码来源:Plotting.C

示例7: plotFR_QCD

void plotFR_QCD(){

  gROOT->Reset();
  gROOT->SetStyle("Plain");
  gStyle->SetStatFormat("6.4f");
  gStyle->SetFitFormat("6.4f");
  int BoxValue = 11111111; //4680;  
  gStyle->SetOptFit(11);
  gStyle->SetOptDate(0);
  gStyle->SetOptTitle(0);
  //gStyle->SetOptStat(BoxValue);
  gStyle->SetOptStat(0);
  gStyle->SetPadBorderMode(0);
  gStyle->SetCanvasColor(0); //(10);
  gStyle->SetPadLeftMargin(0.15);
  gStyle->SetPadBottomMargin(0.15);
  gStyle->SetPalette(0);
  TPaveLabel pl;
  TLatex lt;
  lt.SetTextFont(70);
  lt.SetTextAlign(12);
  lt.SetTextSize(0.07);
  lt.SetTextColor(1);

  TPaveText* tText1 = new TPaveText(0.70, 0.90, 0.90, 0.95, "brNDC");
  tText1->SetBorderSize(0);
  tText1->SetFillColor(0);
  tText1->SetFillStyle(0);
  TText *t1 = tText1->AddText("(13 TeV)");
  tText1->SetTextSize(0.035);
  //tText1->Draw(); 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  TPaveText* tText2 = new TPaveText(0.2, 0.90, 0.4, 0.95, "brNDC");
  tText2->SetBorderSize(0);
  tText2->SetFillColor(0);
  tText2->SetFillStyle(0);
  TText *t2 = tText2->AddText("CMS Spring15 Simulation");
  tText2->SetTextSize(0.035);
  //tText2->Draw(); 


  TLegend *leg = new TLegend(0.17, 0.77, 0.4, 0.85);
  leg->SetBorderSize(0.0);
  leg->SetMargin(0.3);
  leg->SetFillColor(0);
  leg->SetFillStyle(10);
  leg->SetLineColor(0);
  Float_t tsize2 = 0.03;
  leg->SetTextSize(tsize2); 

  
  TFile *_file0 = TFile::Open("ZprimetoMuMu-MC-CMSSW745_FR_QCD_25ns.root");
  

  TH1F *num; _file0->GetObject("h1_Num_Pt_w",num);
  TH1F *den; _file0->GetObject("h1_Den_Pt_w",den);

  TH1F *numMB; _file0->GetObject("h1_Num_Pt_Barrel_w",numMB);
  TH1F *denMB; _file0->GetObject("h1_Den_Pt_Barrel_w",denMB);

  TH1F *numME; _file0->GetObject("h1_Num_Pt_EndCap_w",numME);
  TH1F *denME; _file0->GetObject("h1_Den_Pt_EndCap_w",denME);

  
  double Nbins = num->GetNbinsX();
  cout << "Nbins=" << Nbins << endl;

  int nRebin=10;

  num->Rebin(nRebin);
  den->Rebin(nRebin);

  numMB->Rebin(nRebin);
  denMB->Rebin(nRebin);

  numME->Rebin(nRebin);
  denME->Rebin(nRebin);


  // 
  TH1F *fake=new TH1F("fake","fake",Nbins/nRebin,0.,2000.);
  TH1F *fakeMB=new TH1F("fakeMB","fakeMB",Nbins/nRebin,0.,2000.);
  TH1F *fakeME=new TH1F("fakeME","fakeME",Nbins/nRebin,0.,2000.);
   
  cout << "Bins=" << Nbins/nRebin << endl;

  int* arraysize = new int[1];
  arraysize[0]=Nbins/nRebin;
  Float_t xMB[arraysize[0]],yMB[arraysize[0]],exlMB[arraysize[0]],exhMB[arraysize[0]],eylMB[arraysize[0]],eyhMB[arraysize[0]];


  for (unsigned int i=1; i<=Nbins/nRebin;i++){
    // All Muon
    if (denMB->GetBinContent(i)>0.) {
      fakeMB->SetBinContent(i,double(numMB->GetBinContent(i)/denMB->GetBinContent(i)));

      xMB[i-1]=fakeMB->GetBinCenter(i);
      yMB[i-1]=fakeMB->GetBinContent(i);
      exlMB[i-1]=0.;
      exhMB[i-1]=0.;
//.........这里部分代码省略.........
开发者ID:yangyuchul,项目名称:ZprimeNTU,代码行数:101,代码来源:plotFR_QCD.C

示例8: cmp_ps_polars

//int main(int argc, char** argv)
int cmp_ps_polars()
{
        ifstream infile("cmp_ps_polars.dat");
        char line[1000];
        infile.getline(line,1000);
        int n=0;
        double enes[21];
        double eenes[21];
        double n_p[21];
        double ne_p[21];
        double n_pol[21];
        double ne_pol[21];

        double n_rela[21];
        double ne_rela[21];
         while (!infile.eof()){
	    infile.getline(line,1000);
	    if (line[0]=='\0') continue;
	    istringstream iss;
	    iss.clear();
	    iss.str(line);
	    //iss.seekg(30,ios::beg);
	    iss>>enes[n]>>n_p[n]>>ne_p[n]>>n_pol[n]>>ne_pol[n];
	  //n_pol[n] = n_pol[n];
	  //ne_pol[n] = ne_pol[n];
	    eenes[n] = 0;

	    // relative difference
	    n_rela[n]  = n_pol[n]/n_p[n];
	    ne_rela[n] = n_pol[n]/n_p[n]*sqrt(pow(ne_pol[n]/n_pol[n],2)+pow(ne_p[n]/n_p[n],2));
	    
	    cout<<enes[n]<<"\t"<<(n_rela[n]-1)*100<<endl;
	    
	    n++;
        }

        TGraphErrors* g_p = new TGraphErrors(n,enes,n_p,eenes,ne_p);
        TGraphErrors* g_pol = new TGraphErrors(n,enes,n_pol,eenes,ne_pol);
        g_p->SetMarkerStyle(20);
        g_p->SetMarkerColor(2);
        g_p->SetFillColor(0);
        g_p->SetTitle("");
        g_p->SetLineWidth(2);
        g_p->GetXaxis()->SetNdivisions(505);
        g_p->GetYaxis()->SetNdivisions(505);
        g_p->GetXaxis()->SetTitle("#sqrt{s} (GeV)");
        g_p->GetYaxis()->SetTitle("events");
        g_p->GetXaxis()->SetLabelSize(0.06);
        g_p->GetXaxis()->SetTitleSize(0.06);
        g_p->GetYaxis()->SetLabelSize(0.06);
        g_p->GetYaxis()->SetTitleSize(0.07);
        g_p->GetXaxis()->SetLabelOffset(1.5);
        g_p->GetYaxis()->SetTitleOffset(0.75);
        g_pol->SetMarkerStyle(21);
        g_pol->SetMarkerColor(3);
        g_pol->SetFillColor(0);
        g_pol->SetLineWidth(2);
        
        TLegend *legendf = new TLegend(0.42,0.65,0.95,0.85);
        legendf->SetBorderSize(0); 
        legendf->SetMargin(0.25); 
        legendf->SetFillStyle(0); 
        legendf->AddEntry(g_p,"N from p spectrum");
        legendf->AddEntry(g_pol,"N from polar angle spectrum");

        TCanvas *c1 = new TCanvas();
        TPad *pad1 = new TPad("pad1","pad1",0.05,0.3,1.0,0.98);
        TPad *pad2 = new TPad("pad2","pad2",0.05,0.02,1.0,0.3);
        //c1->SetMargin(0.15,0.1,0.15,0.1);
        pad1->SetTopMargin(0.05);
        pad1->SetBottomMargin(0.02);
        pad2->SetTopMargin(0.05);
        pad2->SetBottomMargin(0.3);
        pad1->Draw();
        pad2->Draw();
        pad1->cd();
 
        g_p->Draw("AP");
        g_pol->Draw("P");
        legendf->Draw();

        pad2->cd();
        pad2->SetGridy();
        // relative comparison
      //TCanvas *c2 = new TCanvas();
      //c2->SetMargin(0.15,0.1,0.15,0.1);
        TGraphErrors* g_rela = new TGraphErrors(n,enes,n_rela,eenes,ne_rela);
        g_rela->SetMarkerStyle(20);
        g_rela->SetMarkerColor(2);
        g_rela->SetFillColor(0);
        g_rela->SetTitle("");
        g_rela->SetLineWidth(2);
        g_rela->GetXaxis()->SetNdivisions(505);
        g_rela->GetYaxis()->SetNdivisions(502);
        g_rela->GetXaxis()->SetTitle("#sqrt{s} (GeV)");
        g_rela->GetYaxis()->SetTitle("N_{pol}/N_{p}");
        g_rela->GetXaxis()->SetLabelSize(0.15);
        g_rela->GetXaxis()->SetTitleSize(0.15);
        g_rela->GetYaxis()->SetLabelSize(0.15);
//.........这里部分代码省略.........
开发者ID:dannielliu,项目名称:KKcross,代码行数:101,代码来源:cmp_ps_polars.C

示例9: produceRatePlots


//.........这里部分代码省略.........
    result_def_2s1b__pat8->SetFillColor(col2);
    result_gem_2s1b__pat8->SetFillColor(col3);

    result_def_3s__pat8->SetFillColor(col1);
    result_def_3s1b__pat8->SetFillColor(col2);
    result_gem_3s1b__pat8->SetFillColor(col3);

    // GMT; CSCTF 2 stubs; CSCTF 2 stubs + ME1/b; CSCTF 2 stubs + ME1/b + GEM -- LOOSE -- Absolute + ratio
    TCanvas* c = new TCanvas("c","c",800,800);
    c->Clear();
    TPad *pad1 = new TPad("pad1","top pad",0.0,0.25,1.0,1.0);
    pad1->Draw();
    TPad *pad2 = new TPad("pad2","bottom pad",0,0.,1.0,.30);
    pad2->Draw();

    pad1->cd();
    pad1->SetLogx(1);
    pad1->SetLogy(1);
    pad1->SetGridx(1);
    pad1->SetGridy(1);
    pad1->SetFrameBorderMode(0);
    pad1->SetFillColor(kWhite);

    result_gmtsing__pat2->Draw("e3");
    result_def_2s__pat2->Draw("same e3");
    result_def_2s1b__pat2->Draw("same e3");
    result_gem_2s1b__pat2->Draw("same e3");
    result_gmtsing__pat2->Draw("same e3");
    result_gmtsing__pat2->GetYaxis()->SetRangeUser(0.1, 10000.);
    result_gmtsing__pat2->GetXaxis()->SetTitle("");
 
    TLegend *leg0 = new TLegend(0.365,0.88,.93,0.93,NULL,"brNDC");
    leg0->SetBorderSize(0);
    leg0->SetMargin(0.235);
    leg0->SetFillStyle(0);
    leg0->SetTextSize(0.04);
    leg0->SetFillStyle(1001);
    leg0->SetFillColor(kWhite);
    leg0->AddEntry(result_gmtsing__pat2,"Standard Configuration (GMT 2012)","f");
    leg0->Draw();
 
    TLegend *leg = new TLegend(0.45,0.68,.93,0.86,"L1 Selections (#geq 2 stations):","brNDC");
    leg->SetMargin(0.25);
    leg->SetBorderSize(0);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    leg->SetTextSize(0.04);
    leg->SetFillStyle(1001);
    leg->SetFillColor(kWhite);
    //    leg->AddEntry((TObject*)0,          "L1 Selections (#geq 2 stations):","");
    leg->AddEntry(result_def_2s__pat2,  "CSC, loose","f");
    leg->AddEntry(result_def_2s1b__pat2,"CSC, tight","f");
    leg->AddEntry(result_gem_2s1b__pat2,"GEM+CSC Integrated Trigger","f");
    leg->Draw();

    leg->Draw();
 
    //    drawL1Label(0.17,0.35);
    drawLumiLabel(0.17,.3);
    drawEtaLabel("1.64","2.14",0.17,.37);
    
    pad2->cd();
    pad2->SetLogx(1);
    pad2->SetLogy(1);
    pad2->SetGridx(1);
    pad2->SetGridy(1);
开发者ID:khotilov,项目名称:GEMCode,代码行数:67,代码来源:produceRateVsPtPlotsForApproval.C

示例10: dNdEta_ThreeMethods_FullTrackingRebinned_DividedByMidRapidValue


//.........这里部分代码省略.........
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(1.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(1.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(1.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(2.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(2.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(2.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(2.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(3.125),0.07);


   //negative eta
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-0.125),3.48);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-0.375),3.38);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-0.625),3.52);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-0.875),3.68);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-1.125),3.71);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-1.375),3.86);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-1.625),3.76);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-1.875),3.66);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-2.125),3.72);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-2.375),3.69);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-2.625),3.56);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-2.875),3.41);
   hEta_UA5_NSD->SetBinContent(hEta_UA5_NSD->FindBin(-3.125),3.15);

   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-0.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-0.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-0.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-0.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-1.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-1.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-1.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-1.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-2.125),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-2.375),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-2.625),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-2.875),0.07);
   hEta_UA5_NSD->SetBinError(hEta_UA5_NSD->FindBin(-3.125),0.07);

   hEta_UA5_NSD->SetMarkerStyle(25);
   hEta_UA5_NSD->SetMarkerSize(1.0);
   //hEta_UA5_NSD->Draw("psame");

   //TLegend *leg = new TLegend(0.20,0.27,0.53,0.47,NULL,"brNDC");
   //TLegend *leg = new TLegend(0.20,0.35,0.53,0.47,NULL,"brNDC"); 
   Float_t ywidth = 0.045*4;

   //TLegend *leg = new TLegend(0.27,0.26,0.70,0.26+ywidth,NULL,"brNDC");
   //TLegend *leg = new TLegend(0.39,0.21,0.82,0.21+ywidth,NULL,"brNDC");
   TLegend *leg = new TLegend(0.45,0.753,0.892,0.93,NULL,"brNDC");


   //leg->SetNColumns(2);
   leg->SetBorderSize(0);
   leg->SetMargin(0.5);
   leg->SetTextFont(62);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   leg->SetTextSize(0.03); 
   leg->SetHeader("      2.36 TeV");
   leg->AddEntry(corr_result_all236,"Hit counting","P");
   leg->AddEntry(hTracklet236,"Tracklet","P");
   leg->AddEntry(hMeasuredFinal2236,"Global tracking","P");


   //cout<<"Number of column "<<leg->GetNColumns()<<endl;
   /*
   leg->AddEntry(corr_result_all236,"","P");
   leg->AddEntry(hTracklet236,"","P"); 
   leg->AddEntry(hMeasuredFinal2236,"","P");
   */

   //TLegend *leg2 = new TLegend(0.20,0.22,0.53,0.35,NULL,"brNDC");
   //TLegend *leg2 = new TLegend(0.50,0.26,0.93,0.47,NULL,"brNDC");
   //TLegend *leg2 = new TLegend(0.39,0.26,0.82,0.26+ywidth,NULL,"brNDC");
   //TLegend *leg2 = new TLegend(0.27,0.21,0.70,0.21+ywidth,NULL,"brNDC"); 
   TLegend *leg2 = new TLegend(0.35,0.75,0.782,0.932,NULL,"brNDC"); 
   leg2->SetMargin(0.37);
   leg2->SetBorderSize(0);
   leg2->SetTextFont(62);
   leg2->SetLineColor(1);
   leg2->SetLineStyle(1);
   leg2->SetLineWidth(1);
   leg2->SetFillColor(0);
   //leg2->SetFillStyle(1001);
   leg2->SetFillStyle(0); 
   leg2->SetTextSize(0.03);
   leg2->SetHeader("   0.9 TeV");
   leg2->AddEntry(corr_result_all,"","P");
   leg2->AddEntry(hMeasuredFinal,"","P"); 
   leg2->AddEntry(hMeasuredFinal2,"","P");

   leg->Draw();
   leg2->Draw();

   printFinalCanvases(MyCanvas,"dNdeta_ThreeMethods_Divided",0,2);
}
开发者ID:CmsHI,项目名称:CVS_ASYoon,代码行数:101,代码来源:dNdEta_ThreeMethods_FullTrackingRebinned_DividedByMidRapidValue.C

示例11: multipleSplinesWithHistogramsVb


//.........这里部分代码省略.........
		yCSplineValues.push_back(cSplineValues.at(1));
	}

	//Histograms______________________________________________________________________________________

	//Time
	int nbins = 100;
	double xlow = 0;
	double xup = 1.;

	TH1D *hTimeB = new TH1D("Time","Timing; time [ms]; Number of Events", nbins, xlow, xup); 
	hTimeB->SetStats(0);
	hTimeB->SetMarkerStyle(10);
	TH1D *hTimeC = new TH1D("TimeC","Timing; time [ms]; Number of Events", nbins, xlow, xup); 
	hTimeC->SetLineColor(kRed);
	hTimeC->SetMarkerStyle(10);
	hTimeC->SetStats(0);

	for(int i=0; i<(int)timec.size(); i++) 
	{
		hTimeB->Fill(timeb.at(i));
		hTimeC->Fill(timec.at(i));	
	}

	//Interpolation
	vector <double> interpB, interpC;
	for(int i = 0; i < (int)yEvents.size(); i++)
	{
		for(int j = 0; j < (int)yEvents[i].size(); j++)
		{
			int indexForB = binarySearch(xBSplineValues[i], xEvents[i][j]);
			int indexForC = binarySearch(xCSplineValues[i], xEvents[i][j]);

			interpB.push_back( (yEvents[i][j]-yBSplineValues[i][indexForB])/yErrorEvents[i][j] );
			interpC.push_back( (yEvents[i][j]-yCSplineValues[i][indexForC])/yErrorEvents[i][j] );
		}
	}	

	//Test graphs for splines
	TGraph *GCspline = new TGraph(xCSplineValues[iEventLook].size(), &xCSplineValues[iEventLook][0], &yCSplineValues[iEventLook][0]);
	GCspline->SetLineColor(kRed);
	TGraph *GBspline = new TGraph(xBSplineValues[iEventLook].size(), &xBSplineValues[iEventLook][0], &yBSplineValues[iEventLook][0]);
	TGraph *Gdata = new TGraph(xEvents[0].size(), &xEvents[iEventLook][0], &yEvents[iEventLook][0]);
		Gdata->SetMarkerStyle(20);

	int nbinsI = 101;
	double xlowI = -0.1;
	double xupI = 0.1;
	TH1D *hInterpB = new TH1D("Interp B","Interpolation; Distance between spline and data normalized by error; Number of Events", nbinsI, xlowI, xupI); 
	for(int i=0; i<(int)interpB.size(); i++) hInterpB->Fill(interpB.at(i));
	hInterpB->SetStats(0);

	TH1D *hInterpC = new TH1D("Interp C","Interpolation; Distance between spline and data normalized by error; Number of Events", nbinsI, xlowI, xupI); 
	for (int i=0; i<(int)interpC.size(); i++) hInterpC->Fill(interpC.at(i));
	hInterpC->SetLineColor(kGreen);
	hInterpC->SetStats(0);	

	//Draws______________________________________________________________________________________

	//Interpolation 
	TLegend *legInterp = new TLegend(0.9,0.70,0.75,0.85);
	legInterp->SetLineColor(kWhite); 
	legInterp->SetFillColor(kWhite);
	legInterp->SetMargin(0.3); 
	legInterp->AddEntry(hInterpB,"b-spline","l");
	legInterp->AddEntry(hInterpC,"c-spline","l");
	legInterp->SetTextSize(0.05);

	TCanvas *c1 = new TCanvas("c1", "Interpolation distance");
	c1->cd();
	hInterpB->Draw("");
	hInterpC->Draw("same");
	legInterp->Draw();

	//Time
	TLegend *legTime = new TLegend(0.9,0.70,0.75,0.85);
	legTime->SetLineColor(kWhite); 
	legTime->SetFillColor(kWhite);
	legTime->SetMargin(0.3); 
	legTime->AddEntry(hTimeB,"b-spline","l");
	legTime->AddEntry(hTimeC,"c-spline","l");
	legTime->SetTextSize(0.05);

	TCanvas *c2 = new TCanvas("c2", "Computation time");
	c2->cd();
	hTimeB->Draw();
//	hTimeC->Draw("same");
	legTime-> Draw();

	TCanvas *c3 = new TCanvas("c3", "Test splines");
	c3->cd();
	Gdata->Draw("ap");
	GCspline->Draw("samel");
	GBspline->Draw("samel");

	//Free the memory used
	gsl_spline_free (spline_GLOB); 
 	gsl_interp_accel_free (acc_GLOB);
	gsl_bspline_free(bw_GLOB);
}
开发者ID:abose2016,项目名称:sip-2015,代码行数:101,代码来源:multipleSplinesWithHistogramsVb.C

示例12: plotTotalKE

void plotTotalKE(char target[6], char list[20], char part[4], 
		 char dir[12]="histo", char g4ver[20]="G4.9.1.p01",
		 bool flag=true) {

  setStyle();
  gStyle->SetOptTitle(0);

  char name[1024];
  char sym[10];
  if      (part=="pim") sprintf(sym, "#pi^{-}");
  else if (part=="pip") sprintf(sym, "#pi^{+}");
  else                  sprintf(sym, "p");

  std::map<string, double> means_300=getMean(target,list,part,"300.0","TotalKE",dir);
  std::map<string, double> means_200=getMean(target,list,part,"200.0","TotalKE",dir);
  std::map<string, double> means_150=getMean(target,list,part,"150.0","TotalKE",dir);
  std::map<string, double> means_100=getMean(target,list,part,"100.0","TotalKE",dir);
  std::map<string, double> means_50 =getMean(target,list,part,"50.0", "TotalKE",dir);
  std::map<string, double> means_30 =getMean(target,list,part,"30.0", "TotalKE",dir);
  std::map<string, double> means_20 =getMean(target,list,part,"20.0", "TotalKE",dir);
  std::map<string, double> means_15 =getMean(target,list,part,"15.0", "TotalKE",dir);
  std::map<string, double> means_9  =getMean(target,list,part,"9.0",  "TotalKE",dir);
  std::map<string, double> means_7  =getMean(target,list,part,"7.0",  "TotalKE",dir);
  std::map<string, double> means_5  =getMean(target,list,part,"5.0",  "TotalKE",dir);
  std::map<string, double> means_3  =getMean(target,list,part,"3.0",  "TotalKE",dir);
  std::map<string, double> means_2  =getMean(target,list,part,"2.0",  "TotalKE",dir);
  std::map<string, double> means_1  =getMean(target,list,part,"1.0",  "TotalKE",dir);
  if (flag) {
    std::map<string, double> means_10 =getMean(target,list,part,"10.0", "TotalKE",dir);
    std::map<string, double> means_8  =getMean(target,list,part,"8.0",  "TotalKE",dir);
    std::map<string, double> means_6  =getMean(target,list,part,"6.0",  "TotalKE",dir);
    std::map<string, double> means_4  =getMean(target,list,part,"4.0",  "TotalKE",dir);
  }

  char ctype[20];
  std::vector<std::string> types   = types();
  std::vector<std::string> typeOld = typesOld();
  //  std::cout << "Number of types " << types.size() << "\n";

  TGraph *gr[20];
  TLegend *leg = new TLegend(0.55, 0.45, 0.9, 0.80);
  char hdr[160];
  sprintf(hdr, "%s+%s (%s-%s)", sym, target, g4ver, list);
  leg->SetHeader(hdr);
  leg->SetFillColor(10);
  leg->SetMargin(0.45);
  leg->SetTextSize(.02);
  sprintf(name, "c_%s_%s_totalKE_%s", part,target,list);
  TCanvas *cc = new TCanvas(name, name, 700, 700);

  for (unsigned int ii=0; ii<=(types.size()); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", typeOld[ii-1].c_str());

    string a(ctype);
    //    std::cout<<a<<" "<< means_300[a]<<std::endl;
    double vx[18], vy[18];
    int np=0;
    vx[np] = 300.0;  vy[np] = means_300[a]; np++;
    vx[np] = 200.0;  vy[np] = means_200[a]; np++;
    vx[np] = 150.0;  vy[np] = means_150[a]; np++;
    vx[np] = 100.0;  vy[np] = means_100[a]; np++;
    vx[np] = 50.0;   vy[np] = means_50[a];  np++;
    vx[np] = 30.0;   vy[np] = means_30[a];  np++;
    vx[np] = 20.0;   vy[np] = means_20[a];  np++;
    vx[np] = 15.0;   vy[np] = means_15[a];  np++;
    if (flag) { vx[np] = 10.0;   vy[np] = means_10[a];  np++;}
    vx[np] = 9.0;    vy[np] = means_9[a];   np++;
    if (flag) { vx[np] = 8.0;    vy[np] = means_8[a];   np++;}
    vx[np] = 7.0;    vy[np] = means_7[a];   np++;
    if (flag) { vx[np] = 6.0;    vy[np] = means_6[a];   np++;}
    vx[np] = 5.0;    vy[np] = means_5[a];   np++;
    if (flag && part != "pro") { vx[np] = 4.0;    vy[np] = means_4[a];   np++;}
    vx[np] = 3.0;    vy[np] = means_3[a];   np++;
    vx[np] = 2.0;    vy[np] = means_2[a];   np++;
    vx[np] = 1.0;    vy[np] = means_1[a];   np++;

    for (int i=0; i<np; i++) vy[i] = vy[i]/vx[i];

    gPad->SetLogx(1);
    gPad->SetGridx(1);
    gPad->SetGridy(1);
    gr[ii] = new TGraph(np, vx,vy);
    sprintf(name, "KE carried by secondaries in %s-%s (%s)", sym, target, list);
    gr[ii]->SetTitle(name);
    gr[ii]->GetXaxis()->SetTitle("Beam Momentum (GeV)");
    gr[ii]->GetYaxis()->SetTitle("Mean Total KE/Beam Momentum");

    gr[ii]->SetMarkerStyle(mstyle[ii]);
    gr[ii]->SetMarkerSize(msiz[ii]);
    gr[ii]->SetMarkerColor(mcolor[ii]);
    gr[ii]->SetLineColor(lcolor[ii]);
    gr[ii]->SetLineStyle(lstyle[ii]);
    gr[ii]->SetLineWidth(lwidth[ii]); 

    gr[ii]->GetYaxis()->SetRangeUser(-0.02, 1.0);
    if (ii!= 0) sprintf (ctype, "%s", types[ii-1].c_str());
    if (ii!= 1) leg->AddEntry(gr[ii], ctype, "lP");
    if (ii==0)      gr[ii]->Draw("APl");
    else if (ii>1)  gr[ii]->Draw("Pl");
//.........这里部分代码省略.........
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:101,代码来源:PlotMultiplicity.C

示例13: plotKE

void plotKE(char target[6], char list[20], char ene[6], char part[4],
	    int typ=0, char dir[12]="histo", char g4ver[20]="G4.9.1.p01") {

  setStyle();
  gStyle->SetOptTitle(0);
  gStyle->SetOptLogy(1);

  char name[1024];
  char sym[10];
  if      (part=="pim") sprintf(sym, "#pi^{-}");
  else if (part=="pip") sprintf(sym, "#pi^{+}");
  else                  sprintf(sym, "p");

  std::vector<std::string> typeOld = typesOld();
  int energy = atoi(ene);
  int bins=energy/4;
  float ener = energy;
  std::cout << "Energy " << ener << "\n";
  
  char ofile[100];
  sprintf (ofile, "%s/histo_%s%s_%s_%sGeV.root", dir, target, list, part, ene);
  std::cout << "Input file " << ofile << "\n";
  TFile *fout = TFile::Open(ofile);
  fout->cd();

  char name[160], title[160], ctype[20], ytitle[20], cname[160], pre[10];
  TH1F *hiKE[20];
  if (typ == 0) sprintf (pre, "KE2");
  else          sprintf (pre, "TotalKE");
  for (unsigned int ii=0; ii<=(typeOld.size()); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", typeOld[ii-1].c_str());
    sprintf (name, "%s%s%s%sGeV(%s)", pre, target, list, ene, ctype);
    hiKE[ii] = (TH1F*)fout->FindObjectAny(name);
    //    std::cout << ii << " (" << ctype << ") " << name << " " << hiKE[ii] <<"\n";
  }

  TCanvas *c[25];
  std::vector<std::string> types = types();
  for (unsigned int ii=0; ii<types.size(); ii++) {
    if      (ii == 0) sprintf (ctype, "All Particles");
    else              sprintf (ctype, "%s", types[ii-1].c_str());
    if (typ == 0) sprintf (cname, "Kinetic Energy of %s (GeV)", ctype);
    else          sprintf (cname, "Total Kinetic Energy of %s (GeV)", ctype);
    hiKE[ii]->GetXaxis()->SetTitle(cname);
    hiKE[ii]->SetMarkerStyle(mstyle[ii]);
    hiKE[ii]->SetMarkerSize(msiz[ii]);
    hiKE[ii]->SetMarkerColor(mcolor[ii]);
    hiKE[ii]->SetLineColor(lcolor[ii]);
    hiKE[ii]->SetLineStyle(lstyle[ii]);
    hiKE[ii]->SetLineWidth(lwidth[ii]); 
    if (bins > 0) hiKE[ii]->Rebin(bins);
    hiKE[ii]->GetXaxis()->SetRangeUser(0.0, ener);

    sprintf(cname, "c_%s%s_%s_%sGeV_%s(%s)", target,list,part,ene,pre,ctype);
    c[ii] = new TCanvas(cname, cname, 800, 500);
    hiKE[ii]->Draw();

    TLegend *leg = new TLegend(0.35, 0.80, 0.8, 0.87);
    char hdr[160];
    sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
    leg->SetHeader(hdr);  leg->SetFillColor(10); leg->SetMargin(0.45);
    leg->SetTextSize(.036); leg->Draw("same");
  }

  TLegend *leg1 = new TLegend(0.50, 0.75, 0.90, 0.90);
  if (typ == 0) sprintf (cname, "Kinetic Energy (GeV)");
  else          sprintf (cname, "Total Kinetic Energy (GeV)");
  hiKE[6]->GetXaxis()->SetTitle(cname);
  char hdr[160];
  sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
  leg1->SetHeader(hdr);  leg1->SetFillColor(10); leg1->SetMargin(0.45);
  sprintf(cname, "c_%s%s_%s_%sGeV_%s(Pion)", target,list,part,ene,pre);
  leg1->SetTextSize(.030); 
  c[19] = new TCanvas(cname, cname, 800, 500);
  hiKE[6]->Draw(); sprintf (ctype, "%s", types[5].c_str()); leg1->AddEntry(hiKE[6], ctype, "l");
  hiKE[5]->Draw("same"); sprintf (ctype, "%s", types[4].c_str()); leg1->AddEntry(hiKE[5], ctype, "l");
  hiKE[4]->Draw("same"); sprintf (ctype, "%s", types[3].c_str()); leg1->AddEntry(hiKE[4], ctype, "l"); leg->Draw("same");

  TLegend *leg2 = new TLegend(0.50, 0.75, 0.90, 0.90);
  if (typ == 0) sprintf (cname, "Kinetic Energy (GeV)");
  else          sprintf (cname, "Total Kinetic Energy (GeV)");
  hiKE[7]->GetXaxis()->SetTitle(cname);
  sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
  leg2->SetHeader(hdr);  leg2->SetFillColor(10); leg2->SetMargin(0.45);
  sprintf(cname, "c_%s%s_%s_%sGeV_%s(Kaon)", target,list,part,ene,pre);
  leg2->SetTextSize(.030); 
  c[20] = new TCanvas(cname, cname, 800, 500);
  hiKE[7]->Draw(); sprintf (ctype, "%s", types[6].c_str()); leg2->AddEntry(hiKE[7], ctype, "l");
  hiKE[8]->Draw("same"); sprintf (ctype, "%s", types[7].c_str()); leg2->AddEntry(hiKE[8], ctype, "l");
  hiKE[9]->Draw("same"); sprintf (ctype, "%s", types[8].c_str()); leg2->AddEntry(hiKE[9], ctype, "l"); leg2->Draw("same");

  TLegend *leg3 = new TLegend(0.50, 0.75, 0.90, 0.90);
  if (typ == 0) sprintf (cname, "Kinetic Energy (GeV)");
  else          sprintf (cname, "Total Kinetic Energy (GeV)");
  hiKE[12]->GetXaxis()->SetTitle(cname);
  sprintf(hdr, "%s+%s at %s GeV (%s-%s)", sym, target, ene, g4ver, list);
  leg3->SetHeader(hdr);  leg3->SetFillColor(10); leg3->SetMargin(0.45);
  sprintf(cname, "c_%s%s_%s_%sGeV_%s(Nucleon)", target,list,part,ene,pre);
  leg3->SetTextSize(.030); 
//.........这里部分代码省略.........
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:101,代码来源:PlotMultiplicity.C

示例14: spike_summarize


//.........这里部分代码省略.........
  float g_max[nEG_g] = {0.3,0.4,0.6,0.35};

  //for(int iEG=0 ; iEG<nEG_g ; iEG++) {
  /*
    for(int iEG=0 ; iEG<2 ; iEG++) {
    for(int iStrict=0 ; iStrict<nStrict ; iStrict++) {
      
    c_evt_contam[iEG][iStrict] = new TCanvas("c_evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict],
    "Spike contamination "+strict_name[iStrict]+" (EG"+trigname[iEG+4]+")",
    0,0,800,600);
      
    c_evt_contam[iEG][iStrict]->SetFillColor(kWhite);
    c_evt_contam[iEG][iStrict]->GetFrame()->SetFillColor(kWhite);

    g_evt_contam[iEG][iStrict][0]->SetMinimum(0);
    g_evt_contam[iEG][iStrict][0]->SetMaximum(g_max[iEG]);      
    g_evt_contam[iEG][iStrict][0]->GetXaxis()->Set(40,0,40);
    g_evt_contam[iEG][iStrict][0]->GetXaxis()->SetTitle("Number of vertices");
    g_evt_contam[iEG][iStrict][0]->GetYaxis()->SetTitle("Fraction of EG events trig. by spikes");

    g_evt_contam[iEG][iStrict][0]->SetTitle( "Spike contamination (EG"+trigname[iEG+4]+")" );

    g_evt_contam[iEG][iStrict][0]->Draw("AP");
    g_evt_contam[iEG][iStrict][1]->Draw("P");
    g_evt_contam[iEG][iStrict][2]->Draw("P");
    g_evt_contam[iEG][iStrict][3]->Draw("P");

    TLegend * leg = new TLegend(0.5,0.70,0.885,0.90,"CMS Preliminary 2011 pp #sqrt{s}=7 TeV","brNDC"); 
    //(x1,y1),(x2,y2)->bottom left , top right
    leg->SetLineColor(1);
    leg->SetTextColor(1);
    leg->SetTextFont(42);
    leg->SetTextSize(0.03);
    leg->SetMargin(0.2);
    leg->SetShadowColor(kWhite);
    leg->SetFillColor(kWhite);
    //
    leg->AddEntry(g_evt_contam[iEG][iStrict][0],"Run 2011B Data","P");
    leg->AddEntry(g_evt_contam[iEG][iStrict][1],"Run 2011B Emul new setting (data)","P");
    leg->AddEntry(g_evt_contam[iEG][iStrict][2],"High PU runs Data","P");
    leg->AddEntry(g_evt_contam[iEG][iStrict][3],"High PU runs Emul new setting (data)","P");
    leg->Draw();

    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".C");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".gif");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".png");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".eps");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".ps");
    c_evt_contam[iEG][iStrict]->Print(dirOut+"evt_contam_EG"+trigname[iEG+4]+"_"+strict_name[iStrict]+".pdf");
    }
    }
  */
  cout << "<--- FINE UNTIL HERE --->" << endl;

  //for(int iEG=0 ; iEG<nEG_g ; iEG++) {
  for(int iEG=1 ; iEG<3 ; iEG++) {
    for(int iStrict=0 ; iStrict<nStrict ; iStrict++) {

      c_evt_contam_err[iEG][iStrict] = new TCanvas("c_evt_contam_err_EG"+trigname[iEG+4]+"_"+strict_name[iStrict],
						   "Spike contamination "+strict_name[iStrict]+" (EG"+trigname[iEG+4]+")",
						   0,0,800,600);

      c_evt_contam_err[iEG][iStrict]->SetFillColor(kWhite);
      c_evt_contam_err[iEG][iStrict]->GetFrame()->SetFillColor(kWhite);

      g_evt_contam_err[iEG][iStrict][0]->SetMinimum(0);
开发者ID:fanbomeng,项目名称:Ecal_Turnon_2012_data,代码行数:67,代码来源:spike_plot_CALOR_dataEmul_2011BHPU.C

示例15: metDistribution


//.........这里部分代码省略.........

  for(Int_t i = 0; i < nFiles; i++) {

    cout<<"fileName : "<<MCfileName[i]<<endl;

    TFile* f = TFile::Open(MCfileName[i].c_str(),"READ");
    if (!f || !f->IsOpen()) {
      cout<<"*******************************"<<endl;
      cout<<"Error opening file \""<<MCfileName[i]<<"\".\nApplication will be terminated."<<endl;
      cout<<"*******************************"<<endl;
      exit(EXIT_FAILURE);
    }

    //cout << "check 1 " << endl;    

    hmet = (TH1D*)f->Get("HYieldsMetBin");
    if (!hmet) {
      cout << "Error: histogram not found in file ' " << MCfileName[i] << "'. End of programme." << endl;
      exit(EXIT_FAILURE);
    }
    hMCmetNoLep.push_back( (TH1D*)hmet->Clone() );

  } 

  THStack* hstack_metNoLep = new THStack("hstack_metNoLep","");

  for (Int_t j = 0; j < nFiles; j++) {

    for (Int_t i = 1; i <= hMCmetNoLep[j]->GetNbinsX(); i++) {

      hMCmetNoLep[j]->SetBinError(i,sqrt(hMCmetNoLep[j]->GetBinContent(i)));

    }

    hMCmetNoLep[j]->SetFillColor(histColor[j]);
    hstack_metNoLep->Add(hMCmetNoLep[j]);

  }

  // now here we go with the canvas
  // TH1D * ratioplot = NULL; // will use it for the ratio plots

  // TPad *subpad_1 = NULL;  // will use it to access specific subpad in canvas
  // TPad *subpad_2 = NULL; 
  TCanvas *c = new TCanvas(canvasName.c_str(),"met distribution");
  c->SetLogy();

  TLegend *leg = new TLegend(0.6,0.55,0.89,0.89);
  
  // subpad_1 = new TPad("pad_1","",0.0,0.28,1.0,1.0);
  // //subpad_1->SetBottomMargin(0);
  // subpad_2 = new TPad("pad_2","",0.0,0.0,1.0,0.32);
  // subpad_2->SetGridy();
  // //subpad_2->SetTopMargin(0);
  // subpad_2->SetBottomMargin(0.3);
  // subpad_1->Draw();
  // subpad_2->Draw();

  //subpad_1->cd();
  hstack_metNoLep->Draw("HIST");
  //hstack_metNoLep->SetMinimum(0.3);
  //hstack_metNoLep->SetMaximum(4000.0);
  TH1D* stackCopy = (TH1D*)(((TH1D*)hstack_metNoLep->GetStack()->Last())->DrawCopy("E2 SAME"));
  stackCopy->SetFillColor(kBlack);
  stackCopy->SetFillStyle(3017);
  hstack_metNoLep->GetXaxis()->SetTitle("#slash{E}_{T} [GeV]");
  hstack_metNoLep->GetXaxis()->SetTitleSize(0.06);
  hstack_metNoLep->GetXaxis()->SetTitleOffset(0.6);
  hstack_metNoLep->GetYaxis()->SetTitle("events");
  hstack_metNoLep->GetYaxis()->SetTitleSize(0.06);
  hstack_metNoLep->GetYaxis()->SetTitleOffset(0.8);
  hstack_metNoLep->GetYaxis()->CenterTitle();
  for (Int_t j = (nFiles-1); j >= 0; j--) {
    leg->AddEntry(hMCmetNoLep[j],Form("%s",MC_TexLabel[j].c_str()),"lf");
  }
  gStyle->SetStatStyle(0);
  leg->Draw(); 
  leg->SetMargin(0.3); 
  leg->SetBorderSize(0);

  // subpad_2->cd();
  // ratioplot = new TH1D(*hratio);
  // ratioplot->Divide(hBRratioOverAxe);
  // ratioplot->SetStats(0);
  // ratioplot->GetXaxis()->SetLabelSize(0.10);
  // ratioplot->GetXaxis()->SetTitle("#slash{E}_{T} [GeV]");
  // ratioplot->GetXaxis()->SetTitleSize(0.15);
  // ratioplot->GetXaxis()->SetTitleOffset(0.8);
  // ratioplot->GetYaxis()->SetLabelSize(0.10);
  // ratioplot->GetYaxis()->SetTitle("ratio");
  // ratioplot->GetYaxis()->SetTitleSize(0.15);
  // ratioplot->GetYaxis()->SetTitleOffset(0.3);
  // ratioplot->GetYaxis()->CenterTitle();
  // ratioplot->GetYaxis()->SetRangeUser(0.5,1.5);
  // ratioplot->GetYaxis()->SetNdivisions(011);
  // ratioplot->DrawCopy("HE");
  // ratioplot->SetMarkerStyle(8);  //medium dot
  c->SaveAs( (plotDirectoryPath + c->GetName() + plotFileExtension).c_str() );

}
开发者ID:cippy,项目名称:CMSSW721_backup_29nov2015,代码行数:101,代码来源:metDistribution.C


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