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


C++ Sample::Draw方法代码示例

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


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

示例1: myControlPlots

void myControlPlots(const char *cuttablefilename,
		    const char *qcdcuttablefilename,
		    const char *samplefilename,
		    const plotVar_t plotvars[])
{
  //gROOT->ProcessLine(".L tdrstyle.C");

  TString unwtcutstring, qcdcutstring;

  loadCutString(cuttablefilename, unwtcutstring);
  if (strlen(qcdcuttablefilename))
    loadCutString(qcdcuttablefilename, qcdcutstring);

  //  const char* the_cut = "1";
  //  double BINWIDTH = ((MAXRange-MINRange)/NBINS);

 // Get the input trees:

  vector<Sample *> samples;

  loadSamples(samplefilename,samples);

 // Data

  Sample *sdata = samples[0];
  cout << "ndata =" << sdata->Tree()->GetEntries() <<endl;

  TFile f("plotvar_histo.root", "RECREATE");

  //============================================================
  //  VARIABLE LOOP
  //============================================================

  for (int ivar=0; ; ivar++) {

    plotVar_t pv = plotvars[ivar];
 
    if ( !pv.plotvar.Length() ) break;

    cout << pv.plotvar << "\t"<<pv.MINRange<<"\t" << pv.MAXRange<<"\t" << pv.NBINS<<"\tTHE CUT " << endl;

    if ( sdata->Tree()->Draw(pv.plotvar,"","goff",1) == -1 ) { // check if the variable exists in the tree
      cout << "\t...can't be plotted!" << endl;
      continue;
    }

    TCut the_cut(TString("effwt*puwt*")+unwtcutstring);
    TCut the_cutE(TString("effwt*puwt*puwt*")+unwtcutstring);
    TCut qcd_cut;
    if (qcdcutstring.Length())
      qcd_cut = TCut(TString("effwt*puwt*")+qcdcutstring);

    TCut nullcut("");

    const double BINWIDTH = ((pv.MAXRange-pv.MINRange)/pv.NBINS);

    map<TString, TH1 *> m_histos;
    map<TString, bool> m_stacked;

    double totevents = 0.;
    TH1 * th1qcd = NULL;
    double qcdfrac = 0.;

    //============================================================
    // DRAW THE VARIABLE FOR ALL SAMPLES, CREATE HISTOS
    //============================================================

    for (size_t isamp=0; isamp<samples.size(); isamp++) {
      Sample *s = samples[isamp];

      m_stacked[s->name()] = false;

      TH1 *h;

      if (s->name().EqualTo("data"))            h = s->Draw(pv, the_cut, nullcut); // effwt*puwt==1 for data!
      else if (s->filename().Contains("QCD")) { h = s->Draw(pv, qcd_cut, nullcut);
	th1qcd = h;
	qcdfrac = s->otherscale();
      } else {                                  h = s->Draw(pv, the_cut, the_cutE);
	if (s->stackit()) {
	  totevents += h->Integral();
	}
      }

      map<TString, TH1 *>::iterator mit = m_histos.find(s->name());
      if (mit == m_histos.end()) {
	if (s->stackit()) {
	  h->SetFillColor(s->colorcode());
	  h->SetLineColor(s->colorcode());
	  h->SetLineWidth(0);
	}
	m_histos[s->name()] = h;
      } else {
	mit->second->Add(h);
      }
    }

    //============================================================
    // COUNT EVENTS, RENORM TO DATA, CONSTRUCT THE TSTACK & LEGEND
    //============================================================
//.........这里部分代码省略.........
开发者ID:VPlusJetsAnalyzers,项目名称:VPlusJets,代码行数:101,代码来源:myControlPlots.C


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