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


C++ TChain::GetAlias方法代码示例

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


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

示例1: BkgFluctuation

void BkgFluctuation(TString infname = "../ntv6_datambv3rand_djcalo_c0to30_offset0.root",
                    TCut myCut = "cent<30", char *title = "",bool drawLegend = false,
                    bool drawSys = true
		    )
{
  gStyle->SetHistLineWidth(2);
  // ===========================================================
  // Get Input
  // ===========================================================
  TChain* t = new TChain("ntjt");
  t->Add(infname);
  t->AddFriend("tcone",infname);
  cout << infname << ": " << t->GetEntries() << endl;
  t->SetAlias("cptsub0Merge0","cpt[0][1]+cpt[0][2]-(cptbg[0][1]+cptbg[0][2])");
  t->SetAlias("cptsub0Merge1","cpt[0][3]-(cptbg[0][3])");
  t->SetAlias("cptsub0Merge2","cpt[0][4]+cpt[0][5]-(cptbg[0][4]+cptbg[0][5])");
  t->SetAlias("cptsub0Merge3","(Sum$(cpt[0])-cpt[0][0])-(Sum$(cptbg[0])-cptbg[0][0])");

  // ===========================================================
  // Analysis Setup
  // ===========================================================
  TH1::SetDefaultSumw2();
   const int nBin = 3;
   double bins[nBin+1] = {1.,4,8,160};  
  TCut evtCut = "nljet>100&&abs(nljetacorr)<1.6&&aljet>50&&abs(aljetacorr)<1.6&&jdphi>2./3*TMath::Pi()&&!maskEvt";
  TCut exclusion = "abs(nljetacorr)>0.8"; //&&abs(aljetacorr)>0.8";
  evtCut = evtCut&&exclusion;
  //Int_t colors[7] = {kBlue, kCyan-3, kYellow+1, kOrange+1, kGreen+2, kMagenta, kRed };
  Int_t colors[7] = {kYellow+2, kGreen+2,kRed };
  
  // ===========================================================
  // Book Histograms
  // ===========================================================
  vector<TH1D*> vhBgSub;
  for (Int_t i=0; i<nBin+1; ++i) {
    vhBgSub.push_back(new TH1D(Form("hBgSub_%d"),";(Sig Cone #Sigma p_{T}) - (Bkg Cone #Sigma p_{T}) (GeV/c);fraction;",50,-300,300));
  }

  Float_t numEvt = t->GetEntries(evtCut&&myCut);
  cout << "Total Sel evt: " << numEvt << endl;
  for (Int_t i=0; i<nBin+1; ++i) {
    TString var(Form("cptsub0Merge%i",i));
    cout << "Sel evt: " << t->GetEntries(evtCut&&myCut&&var) << endl;
    cout << "var: " << t->GetAlias(var) << endl;
    t->Project(vhBgSub[i]->GetName(),var,(evtCut&&myCut&&var)*"weight");
    Float_t mean = vhBgSub[i]->GetMean();
    Float_t rms = vhBgSub[i]->GetRMS();
    cout << "bgsub mean: " << mean << " rms: " << rms << endl;
    vhBgSub[i]->Scale(1./numEvt);
    cout << "Bin " << i << " rms/sqrt(250): " << rms/sqrt(250)
      << " r=0: " << rms/sqrt(250.)*sqrt(fracArea(0))
      << " r=0.8: " << rms/sqrt(250.)*sqrt(fracArea(0.8)) << endl;
  }

  TCanvas * c2 = new TCanvas("c2","c2",600,600);
  c2->SetLogy();
  vhBgSub[nBin]->SetAxisRange(1e-5,5,"Y");
  vhBgSub[nBin]->Draw("E");
  for (Int_t i=0; i<nBin; ++i) {
    vhBgSub[i]->SetLineColor(colors[i]);
    vhBgSub[i]->Draw("same hist");
  }
  vhBgSub[nBin]->Draw("Esame");

  TLegend *leg = new TLegend(0.19,0.70,0.53,0.92);
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetTextSize(0.035);
  leg->AddEntry(vhBgSub[nBin],"CMS 0-30%","");
  leg->AddEntry(vhBgSub[nBin],"Random Cone (MB Sample)","");
  leg->AddEntry(vhBgSub[nBin],Form("> %.1f GeV/c",bins[0]),"pl");
  for (int i=0;i<nBin;++i) {
    if (i!=nBin-1){
      leg->AddEntry(vhBgSub[i],Form("%.1f - %.1f GeV/c",bins[i],bins[i+1]),"l");
    } else {
      leg->AddEntry(vhBgSub[i],Form("> %.1f GeV/c",bins[i]),"l");
    }
  }
  leg->Draw();
}
开发者ID:CmsHI,项目名称:CVS_SavedFMa,代码行数:80,代码来源:BkgFluctuation.C


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