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

C++ THStack类代码示例

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

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



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

示例1: stack_ring_contribs

void stack_ring_contribs(const string& fFile, const string& fTitleExt, const string& fNameExt) {
                                
   string title = "<E> in i#eta Ring " + fTitleExt + ";i#eta;<E> [GeV]";
                                
   TFile file(fFile.c_str());   
   file.cd("offsetAnalysis");   
                                
   TH1D *p_AEEREB  = p_AvgEinEREB->ProjectionX();
   TH1D *p_AEEREE  = p_AvgEinEREE->ProjectionX();
   TH1D *p_AEERHB  = p_AvgEinERHB->ProjectionX();
   TH1D *p_AEERHE  = p_AvgEinERHE->ProjectionX();
   TH1D *p_AEERHFl = p_AvgEinERHFl->ProjectionX();
   TH1D *p_AEERHFs = p_AvgEinERHFs->ProjectionX();
   //TH1D *p_AEERHO  = p_AvgEinC5HO->ProjectionX();
         
   p_AEEREB->SetFillColor(50);
   p_AEEREE->SetFillColor(8);
   p_AEERHB->SetFillColor(4);
   p_AEERHE->SetFillColor(6);
   p_AEERHFl->SetFillColor(16);
   p_AEERHFs->SetFillColor(12);
   //p_AEERHO->SetFillColor(7);
   
   TCanvas *c = new TCanvas("c", "",1120,800);
   c->cd();
   
   THStack *hs = new THStack("hs",title.c_str());
   
   hs->Add(p_AEEREB);
   hs->Add(p_AEEREE);
   hs->Add(p_AEERHB);
   hs->Add(p_AEERHE);
   hs->Add(p_AEERHFl);
   hs->Add(p_AEERHFs);
   //hs->Add(p_AEERHO);
   hs->Draw("hist");
   
   TLegend *legend = new TLegend(.6,.55,.68,.85);
   legend->SetBorderSize(1);
   legend->SetFillColor(0);
   //legend->SetFillStyle(0);
   legend->SetTextFont(42);
   legend->AddEntry(p_AEEREB,"EB","f");
   legend->AddEntry(p_AEEREE,"EE","f");
   legend->AddEntry(p_AEERHB,"HB","f");
   legend->AddEntry(p_AEERHE,"HE","f");
   legend->AddEntry(p_AEERHFl,"HFl","f");
   legend->AddEntry(p_AEERHFs,"HFs","f");
   //legend->AddEntry(p_AEERHO,"HO","f");
   legend->Draw();
   
   string fileName = "p_AvgEinER_stacked__" + fNameExt + ".png";
   
   c->SetGridy();
   c->SaveAs(fileName.c_str());

   delete legend;
   delete hs;
   delete c;
}
开发者ID:ferencek,项目名称:cms-Offset_Analysis,代码行数:60,代码来源:ringEnergyStacks.C


示例2: multicolor

void multicolor(Int_t isStack=0) {
   TCanvas *c1 = new TCanvas;
   Int_t nbins = 20;
   TH2F *h1 = new TH2F("h1","h1",nbins,-4,4,nbins,-4,4);
   h1->SetFillColor(kBlue);
   TH2F *h2 = new TH2F("h2","h2",nbins,-4,4,nbins,-4,4);
   h2->SetFillColor(kRed);
   TH2F *h3 = new TH2F("h3","h3",nbins,-4,4,nbins,-4,4);
   h3->SetFillColor(kYellow);
   THStack *hs = new THStack("hs","three plots");
   hs->Add(h1);
   hs->Add(h2);
   hs->Add(h3);
   TRandom r;
   Int_t i;
   for (i=0;i<20000;i++) h1->Fill(r.Gaus(),r.Gaus());
   for (i=0;i<200;i++) {
      Int_t ix = (Int_t)r.Uniform(0,nbins);
      Int_t iy = (Int_t)r.Uniform(0,nbins);
      Int_t bin = h1->GetBin(ix,iy);
      Double_t val = h1->GetBinContent(bin);
      if (val <= 0) continue;
      if (!isStack) h1->SetBinContent(bin,0);
      if (r.Rndm() > 0.5) {
         if (!isStack) h2->SetBinContent(bin,0);
         h3->SetBinContent(bin,val);
      } else {
         if (!isStack) h3->SetBinContent(bin,0);
         h2->SetBinContent(bin,val);
      }
   }
   hs->Draw("lego1");
}
开发者ID:Y--,项目名称:root,代码行数:33,代码来源:multicolor.C


示例3: GetOne

TH1* GetOne(UShort_t sNN, const TString& trigger)
{
  Long_t   p = gROOT->ProcessLine(Form("Drawer::GetStack(0, \"pp\", %d, "
				       "\"%s\", false, true)", 
				       sNN, trigger.Data()));
  THStack* s = (THStack*)p;
  TList*   l = s->GetHists();
  TH1*     h = 0;
  TIter    n(l);
  l->ls();
  while ((h = static_cast<TH1*>(n()))) {
    TString m(h->GetName());
    if (m.EqualTo("dndetaForward_all")) break;
  }

  if (h) {
    switch (sNN) { 
    case  900: h->SetTitle("900GeV");  h->SetMarkerColor(kRed+2);   break;
    case 2760: h->SetTitle("2.76TeV"); h->SetMarkerColor(kGreen+2); break;
    case 7000: h->SetTitle("7TeV");    h->SetMarkerColor(kBlue+2);  break;
    case 8000: h->SetTitle("8TeV");    h->SetMarkerColor(kBlack);   break;
    }
  }

  return h;
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:26,代码来源:Interpolate.C


示例4: simplePlotter

void simplePlotter(){

  const unsigned int n = 6;

  TFile* ftt[n];

  // diboson
  char* names[n] = {"BB-4p-0-500_100TEV_40PileUp",
		    "BB-4p-500-1500_100TEV_40PileUp",
		    "BB-4p-1500-3000_100TEV_40PileUp",
		    "BB-4p-3000-5500_100TEV_40PileUp",
		    "BB-4p-5500-9000_100TEV_40PileUp",
		    "BB-4p-9000-100000_100TEV_40PileUp"};


  char* labels[n] = {"S*_{T} < 1 TeV","S*_{T} 1-2 TeV","S*_{T} 2-3.5 TeV","S*_{T} 3.5-5.5 TeV","S*_{T} 5.5-8.5 TeV","S*_{T} > 8.5 TeV"};

  int   colors[n] = { 2 , 3 , 4 , 5 , 6 , 7 };

  TH1F* hst[n];

  THStack* htstack = new THStack();

  TLegend *leg = new TLegend(0.5,0.5,0.8,0.8);

  for( int i = 0 ; i < n ; i++ ){

    ftt[i] = TFile::Open(Form("output/%s.root",names[i]));
    hst[i] = (TH1F*) ftt[i]->Get("st");
    hst[i]->SetFillColor(colors[i]);

    cout << "Integral " << i << " " << hst[i]->Integral() << endl;

    hst[i]->GetXaxis()->SetTitle("S_{T} [GeV]");
    hst[i]->GetYaxis()->SetTitle("events");

    leg->AddEntry( hst[i] , labels[i] , "lf" );

    htstack->Add(hst[i]);

  }

  TCanvas *c2 = new TCanvas("c2","c2",1200,600);
  c2->cd();
  gStyle->SetOptStat(0);

  gPad->SetLogy();
  htstack->Draw();
  htstack->GetXaxis()->SetTitle("S_{T} [GeV]");
  htstack->GetYaxis()->SetTitle("events");

  TLatex *t = new TLatex();
  t->SetNDC();
  t->DrawLatex(0.5,0.85,"t#bar{t} events, 100 TeV, L = 1 pb^{-1}");

  leg->SetBorderSize(0);
  leg->SetFillColor(0);
  leg->Draw();

}
开发者ID:hooberman,项目名称:FHC,代码行数:60,代码来源:simplePlotter.C


示例5: DrawEmpirical

void DrawEmpirical(const char* filename="Empirical.root", 
		   Bool_t fmd=true)
{
  gStyle->SetOptTitle(0);

  TFile* file = TFile::Open(filename, "READ");
  if (!file) return;

  Double_t yr = 0.3;
  TCanvas* c  = new TCanvas("c","c", 1000,1000);
  TPad*    p1 = new TPad("p1","p1",0,0,1,yr);
  TPad*    p2 = new TPad("p2","p2",0,yr,1,1);
  c->cd(); p1->Draw();
  c->cd(); p2->Draw();
  
  gDirectory->cd("Forward");
  THStack* r = DrawOne(p1, yr, false, gDirectory, "ratios");  
  THStack* e = DrawOne(p2, yr, true, gDirectory, "empirical");

  r->SetMinimum(0.945);
  r->SetMaximum(1.055);
  r->GetXaxis()->SetTitle("#it{#eta}");
  r->GetYaxis()->SetTitle("Ratio to mean");
  e->SetMinimum(0.005);
  e->GetYaxis()->SetTitle("#it{E_{c}}(#it{#eta})");
  TIter nextE(e->GetHists());
  TIter nextR(r->GetHists());
  TH1*  hist = 0;
  Color_t cols[]  = { kRed+2, kGreen+2, kBlue+2, kMagenta+2, 0 };
  Color_t *ptr    = cols;
  Style_t stys[]  = { 20, 21, 22, 23 };
  Style_t* sty    = stys;
  while (*ptr) { 
    hist = static_cast<TH1*>(nextE()); 
    hist->SetMarkerColor(*ptr);
    hist->SetMarkerSize(2);
    hist->SetMarkerStyle(*sty);
    hist = static_cast<TH1*>(nextR()); 
    hist->SetMarkerColor(*ptr);
    hist->SetMarkerSize(2);
    hist->SetMarkerStyle(*sty);
    ptr++;
    sty++;
  }


  TLegend* l = p2->BuildLegend(0.35, .2, .65, .8);
  l->SetFillColor(0);
  l->SetFillStyle(0);
  l->SetBorderSize(0);

  c->Modified();
  c->Update();
  c->cd();
  c->Print("empirical.png");
  
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:57,代码来源:DrawEmpirical.C


示例6: PlotHistsNhitsPerModule

void PlotHistsNhitsPerModule(TFile* f, TTree* tr, TString strMillepedeRes, TString strOutdir)
{
  TString canvName="c_";
  canvName+=strMillepedeRes;
  canvName+="_";
  canvName+=StrPlotType(NHITS);
  canvName.ReplaceAll(".res","");


  //enum {PXB,PXF,TIB,TID,TOB,TEC};
  int colors[6]={1,2,3,4,6,7};
//  TString labels[6]={"PXB","PXF","TIB","TID","TOB","TEC"};

  f->cd();
  TCanvas* canv = new TCanvas(canvName,canvName,600,600);
  canv->SetLogx();
  canv->SetLogy();

  for (int ind=1; ind<=1; ind++){
    TString strHist = "hNhits_";
    strHist+=StrPar(ind);
    TString strCut="label<700000 && ((label%20-1)%9+1)==";
    strCut+=ind;
    TStyle style; 
    style.SetTitleFontSize(0.2);
    THStack *hSt = new THStack("hNhits","# of derivatives (~tracks or hits) per module");
    TLegend *leg = new TLegend(0.75,0.65,0.95,0.95);
    for (int inv=0; inv<6; inv++){
      std::cout<<"- - - - - -"<<std::endl;
      std::cout<<subdLabels[inv]<<":"<<std::endl;
      std::cout<<StrCutSubd(inv)<<": "<<tr->GetEntries(StrCutSubd(inv))<<" parameters"<<std::endl;
      TString strHist1=strHist;
      strHist1+=ind;
      strHist1+=inv;
      TH1F* hValInt = new TH1F(strHist1,strHist1,300,10,15000);  
      TString strCut1 = strCut+TString(" && ")+StrCutSubd(inv);
      tr->Draw(TString("Nhits>>")+strHist1,strCut1,"goff");
      std::cout<<"# hits = "<<(int)hValInt->GetMean()<<"+-"<<(int)hValInt->GetRMS()<<std::endl;
      hValInt->SetLineColor(1);
      hValInt->SetFillColor(colors[inv]);
      hValInt->SetLineWidth(2);
      hSt->Add(hValInt);
      leg->AddEntry(hValInt,subdLabels[inv],"f");
      leg->SetFillColor(0);
    }
    hSt->Draw();
    leg->Draw("same");
    
  }//end of loop over ind

  canvName+=".png";
  TString saveName=strOutdir+canvName;
  canv->SaveAs(saveName);
  saveName.ReplaceAll(".png",".pdf");
  canv->SaveAs(saveName);
}//end of PlotHistsNhitsPerModule
开发者ID:ANSH0712,项目名称:cmssw,代码行数:56,代码来源:PlotFromMillepedeRes.C


示例7: THStack

THStack *stack(TH1** hists, char *hsn = "histstack", char *htn = "stack o hists") {
  int goodcolors[] = { kRed+1, kGreen+1, kBlue, kYellow+1, kMagenta+1, kCyan+1, 9 };
  THStack *hs = new THStack(hsn,htn);
  for (int i = 0; i < 6; i++) {
    hists[i]->SetLineColor(goodcolors[i]);
    if (hists[i]->InheritsFrom("TH2")) hists[i]->SetOption("colz");
    hs->Add(hists[i]);
  }
  return hs;
}
开发者ID:evan-phelps,项目名称:phys-ana-omega,代码行数:10,代码来源:rootutils.C


示例8: THStack

THStack* CutFlow::buildStack(AllSamples samples, Variable variable){

	THStack *hs = new THStack("hs","test");

	hs->Add(samples.qcd->histo);
	hs->Add(samples.vjets->histo);
	hs->Add(samples.single_t->histo);
	hs->Add(samples.ttbar->histo);

	return hs;
}
开发者ID:nikberry,项目名称:PlottingTools,代码行数:11,代码来源:CutFlow.cpp


示例9: Matching_Comp

void Matching_Comp() {

  const int n_Signal = 1;
  const int n_Hist = 33;
  const int n_Category=5;

  const TString File_Name[n_Signal] = {"Tstar_M-1300"};

  int Color[n_Category] = { 628, 412,415,858, 868};//858,
  //EColor Color[n_Hist] = { kRed, kGreen, kBlue, 434,kCyan};

  const TString Hist_Name[n_Hist] = {"Discriminator_sum","Number of subjets gluon had","Number of subjets gluon lep","DeltaR_GluonGluon","DeltaR_TopTop","DeltaR_TopHad_BLep","Pt_Ratio_gluonhad_subjets","DeltaR_gluonhad_subjets","DeltaR_gluonlep_subjets","CSV_gluonLep","CSV_bLep","DeltaR_GluonTop_lep","DeltaR_GluonTop_had","DeltaR_GluonHad_TopLep","DeltaR_GluonLep_TopHad","M_TstarhadTstarlep_Diff_rel","Pt_Ratio_blep_toplep","Pt_Diff_gluonlep_toplep","Pt_Diff_gluonlep_gluonhad","Pt_Diff_gluon_top_lep","Pt_Diff_gluon_top_had","M_Tstarlep_rec","M_Tstarhad_rec","M_toplep","M_tophad","M_Tstar_comb","M_Tstar_ratio","Pt_Tstar_ratio","M_gluon_ratio","M_gluonhad","M_gluonlep","Pt_gluonhad","Pt_gluonlep"};

  const TString Hist_Label[n_Hist] = {"#Chi^{2}","Number of subjets gluon had","Number of subjets gluon lep","#Delta R Gluon Gluon","#Delta R Top Top","#Delta R Top_{Had} B_{Lep}","Pt Ratio gluonhad subjets","#Delta R gluon had subjets","#Delta R gluon had subjets","CSV_gluonLep","CSV bLep","#Delta R gluon top lep","#Delta R gluon top had","#Delta R gluon_{had} top_{lep}","#Delta R gluon_{lep} top_{had}","M_TstarhadTstarlep_Diff_rel","Pt Ratio b_{lep} top_{lep}","Pt Diff gluonlep toplep","Pt Diff gluonlep gluonhad","Pt Diff gluon top lep","Pt Diff gluon top had","T*  Mass, lep","T*  Mass, had","M top lep","M top had","M T* comb","M_Tstar_ratio","Pt_Tstar_ratio","M_gluon_ratio","M_gluonhad","M_gluonlep","Pt gluonhad","Pt gluonlep"};

  const TString Category_Name[n_Category] = {"chi2_gluon_nomatch__HypHists","chi2_gluon_switch__HypHists","chi2_gluonlep_semimatch__HypHists", "chi2_gluonhad_semimatch__HypHists","chi2_gluon_match__HypHists"};//"chi2_gluonhad_semimatch__HypHists",
  const TString Legend_Name[n_Category] = {"No Match","Switched","Semimatch, wrong gluon","Semimatch, gluon", "Match"}; //"Semimatch, gluon",

  TLegend* leg1 = new TLegend(0.67,0.65,0.87,0.87);
  leg1->SetBorderSize(0);

  for(int i = 0; i<n_Signal; i++){
    TFile *signal = new TFile("/nfs/dust/cms/user/multh/RunII_80X_v3/Selection/Nominal/03Feb2017_Relaunch_17Jan2018/Muons/Kinematic_Study/uhh2.AnalysisModuleRunner.MC."+File_Name[i]+".root");

    TH1F *h_signal[n_Hist][n_Category];

    for(int j= 0; j<n_Hist; j++){
      THStack *hs = new THStack("hs","");
      
      for(int k = 0; k<n_Category; k++){
	h_signal[j][k] = (TH1F*)signal->Get(Category_Name[k]+"/"+Hist_Name[j]);
	h_signal[j][k] ->SetFillColor(Color[k]);
	h_signal[j][k] -> SetLineColor(Color[k]);
	h_signal[j][k] ->SetLineWidth(2);
	if(j==0)leg1->AddEntry(h_signal[j][k],Legend_Name[k],"f");

      hs->Add(h_signal[j][k]);

    }    

    TCanvas *b1 = new TCanvas("b1","b1",800,600);
    gStyle->SetOptStat(0);
    hs->Draw("hist");
    hs->GetXaxis()->SetTitle(Hist_Label[j]);
    hs->GetXaxis()->SetTitleSize(0.05);
    leg1->Draw();
    b1->Modified();

    b1->SaveAs("/nfs/dust/cms/user/multh/CMSSW_8_0_26_patch2/src/UHH2/TstarSemiLeptonic/Plots/"+Hist_Name[j]+"_match.pdf");
    }
    
  }
}
开发者ID:multh,项目名称:TstarSemiLeptonic,代码行数:53,代码来源:Matching_Comp.C


示例10: createInputs

void createInputs(int n = 2) 
{
   for(UInt_t i = 0; i < (UInt_t)n; ++i ) {
      TFile *file = TFile::Open(TString::Format("input%d.root",i),"RECREATE");
      TH1F * h = new TH1F("h1","",10,0,100);
      h->Fill(10.5); h->Fill(20.5);
 
      Int_t nbins[5];
      Double_t xmin[5];
      Double_t xmax[5];
      for(UInt_t j = 0; j < 5; ++j) {
         nbins[j] = 10; xmin[j] = 0; xmax[j] = 10;
      }
      THnSparseF *sparse = new THnSparseF("sparse", "sparse", 5, nbins, xmin, xmax);
      Double_t coord[5] = {0.5, 1.5, 2.5, 3.5, 4.5};
      sparse->Fill(coord);
      sparse->Write();
      
      THStack *stack = new THStack("stack","");
      h = new TH1F("hs_1","",10,0,100);
      h->Fill(10.5); h->Fill(20.5);
      h->SetDirectory(0);
      stack->Add(h);
      h = new TH1F("hs_2","",10,0,100);
      h->Fill(30.5); h->Fill(40.5);
      h->SetDirectory(0);
      stack->Add(h);
      stack->Write();

      TGraph *gr = new TGraph(3);
      gr->SetName("exgraph");
      gr->SetPoint(0,1,1);
      gr->SetPoint(1,2,2);
      gr->SetPoint(2,3,3);
      
      gr->Write();
      
      TTree *tree = new TTree("tree","simplistic tree");
      Int_t data = 0;
      tree->Branch("data",&data);
      for(Int_t l = 0; l < 2; ++l) {
         data = l;
         tree->Fill();
      }
      
      file->Write();
      delete file;
   }
}
开发者ID:asmagina1995,项目名称:roottest,代码行数:49,代码来源:execFileMerger.C


示例11: fit

void fit() {
  FILE *ofile;
  ofile = fopen("xsect-integrated-me.txt","w");
  TFile *_file0 = TFile::Open("h3maker-hn.root","update");
  _file0->Delete("*_f;*");
  TH2 *h2xsect = new TH2("hq2wXsect","Q^2:W",32,1.6,3.2,7,1.5,5.1);
  Double_t qbinedges[] = { 1.5, 1.6, 1.8, 2.1, 2.4, 2.76, 3.3, 5.1 };
  h2xsect->GetYaxis()->Set(7,qbinedges);
  TH3 *h3 = (TH3*)_file0->Get("hq2wmmp");
  int qbins = h3->GetZaxis()->GetNbins();
  int wbins = h3->GetYaxis()->GetNbins();
  fprintf(ofile, "W\tQ2\txsect\terror\tpol4p0\tpol4p1\tpol4p2\tpol4p3\tpol4p4\tgN\tgM\tgS\n");
  for (int iq = 0; iq < qbins; iq++) {
    TString hsn = TString::Format("hs%d",iq);
    THStack *hs = (THStack*)_file0->Get(hsn.Data());
    TIter next(hs->GetHists());
    //while (TObject *obj = next()) {
    //TH1 *h = (TH1*)obj;
    while (TH1 *h = (TH1*)next()) {
      float *wq = getwq(h);
      float wval = wq[0];
      float qval = wq[1];
      fitmmp(h);
      TH1 *htmp = (TH1*)h->Clone("hbgsubtracted");
      TF1 *fbg = (TF1*)h->GetListOfFunctions()->FindObject("fbg");
      htmp->Add(fbg,-1);
      double N = htmp->Integral(34,43);
      double qwidth = h3->GetZaxis()->GetBinWidth(iq+1);
      int wbin = h3->GetYaxis()->FindBin(wval);
      double wwidth = h3->GetYaxis()->GetBinWidth(wbin);
      double xsect = N/(0.891*wwidth*qwidth*19.844);
      double err2 = 0;
      for (int immp = 34; immp < 44; immp++) err2 += htmp->GetBinError(immp)*htmp->GetBinError(immp);
      //fprintf(ofile, "%.3f\t%.3f\t%.0f\t%.0f",wval,qval,xsect/(1e6), sqrt(err2)/(1e6));
      fprintf(ofile, "%.3f\t%.3f\t%.3e\t%.3e",wval,qval,xsect/(1e6), sqrt(err2)/(1e6));
      TF1 *ftmp = (TF1*)h->GetListOfFunctions()->At(0);
      int npar = ftmp->GetNpar();
      for (int ipar = 0; ipar < npar; ipar++) fprintf(ofile, "\t%.3e", ftmp->GetParameter(ipar));
      fprintf(ofile, "\n");
    }
    hsn.Append("_f");
    _file0->WriteObject(hs,hsn.Data());
    delete hs;
  }
  fclose(ofile);
  delete _file0;
}
开发者ID:evan-phelps,项目名称:phys-ana-omega,代码行数:47,代码来源:fit.C


示例12: THStack

THStack *getstack(TTree *nt, TString name, TString var, vector<TString> cuts,int bins = 100, float xmin = 0, float xmax = 200)
{
  THStack *hs = new THStack(name,name);
  int N = cuts.size();
  vector<TH1F *> vh(N);
  for (int i=0;i<N;i++) {
    vh[i] = geth(Form("%s%d",name.Data(),i),bins,xmin,xmax);

    vh[i]->SetFillColor(TColor::GetColorDark(i+2));
    vh[i]->SetFillStyle(1001);
    nt->Project(vh[i]->GetName(),var.Data(),Form("weight*(%s)",cuts[i].Data()),"");//,1000);
    hs->Add(vh[i],"hist");
    cout<<vh[i]->Integral()<<endl;
  }
  hs->SetMinimum(1E-2);

  return hs;
}
开发者ID:bjet2015,项目名称:sanitychecks,代码行数:18,代码来源:histbuild.C


示例13: GetHisto

TH1F* GetHisto(TFile* fin, string region, string process, string varname, float& norm, bool do_norm, float input_norm)
{
    string cname = CHANNEL_NAME+string("/")+region+"/"+varname;
    TCanvas* c = (TCanvas*) fin->Get(cname.c_str());
    string hname = "v:"+varname+"|p:"+process+"|r:"+region+string("|c:")+CHANNEL_NAME+string("|t:1DEntries");
    TH1F* h = 0;
    if(VERBOSE>0){
 	 cerr<<"cname :"<<cname<<endl;
   	 cerr<<"histo name: "<<hname<<endl;
   	 cerr<<"pointer: "<<c<<endl;
    } 
    TList* l = c->GetListOfPrimitives();
    TPad* pad = (TPad*) l->At(0);
    THStack* stack = (THStack*) pad->GetPrimitive("");
    h = (TH1F*) stack->GetHists()->FindObject(hname.c_str());
    if(do_norm) h->Scale(input_norm/h->Integral());
    norm = h->Integral();
    return (TH1F*) h->Clone();
}
开发者ID:oneLeptonStopAt13TeV,项目名称:StopAF,代码行数:19,代码来源:MTTailCorrectionClosureTests.C


示例14: superimposeHistos

void superimposeHistos()
{
  TFile* bFile = TFile::Open("Electron_In_Jets_900GeV_bJets.root");
  TFile* cFile = TFile::Open("Electron_In_Jets_900GeV_cJets.root");
  TFile* udsgFile = TFile::Open("Electron_In_Jets_900GeV_udsgJets.root");
  
  TIter next(bFile->GetListOfKeys());
  TFile* newFile = new TFile("testFile.root", "RECREATE");
  while(TKey* key = (TKey*)next())
  {
    TH1F* bHist = (TH1F*)bFile->Get(key->GetName());
    bHist->SetFillColor(2);
    
    TH1F* cHist = (TH1F*)cFile->Get(key->GetName());
    cHist->SetFillColor(3);
    
    TH1F* udsgHist = (TH1F*)udsgFile->Get(key->GetName());
    udsgHist->SetFillColor(4);
    
    THStack* stack = new THStack(bHist->GetName(), bHist->GetTitle());
    stack->Add(udsgHist, "hist ][");
    stack->Add(cHist, "hist ][");
    stack->Add(bHist, "hist ][");
    
    TLegend* legend = new TLegend(0.5, 0.68, 0.88, 0.88);
    legend->AddEntry(bHist, "b-Jets");
    legend->AddEntry(cHist, "c-Jets");
    legend->AddEntry(udsgHist, "udsg-Jets");
    
    TCanvas* canvas = new TCanvas(bHist->GetName());
    stack->Draw();
    stack->GetXaxis()->SetTitle(bHist->GetXaxis()->GetTitle());
    legend->Draw();
    canvas->Write(canvas->GetName());
  }
  
  newFile->Close();
  bFile->Close();
  cFile->Close();
  udsgFile->Close();
}
开发者ID:jdkeller7,项目名称:UserCode,代码行数:41,代码来源:superimposeHistos.C


示例15: Run

  //____________________________________________________________________
  void Run(const char* newName,        const char* oldName,
	   const char* newTitle="New", const char* oldTitle="Old")
  {
    TFile* newFile = TFile::Open(newName,"READ");
    TFile* oldFile = TFile::Open(oldName,"READ");
    if (!newFile || !oldFile) return;

    TH1* newCent = GetH1(newFile, "realCent");
    TH1* oldCent = GetH1(oldFile, "realCent");
    if (!newCent || !oldCent) return;

    TString  t; t.Form("#it{R}=#frac{%s}{%s}", newTitle, oldTitle);
    TCanvas* c     = new TCanvas("c", t, 1200, 800);
    c->SetTopMargin(0.01);
    c->SetRightMargin(0.20);
    fLegend = new TLegend(1-c->GetRightMargin(),
			  c->GetBottomMargin(),
			  1, 1-c->GetTopMargin(),
			  t);
    fLegend->SetFillStyle(0);
    fLegend->SetBorderSize(0);
    THStack* stack = new THStack("ratios","");
			       
    fMin = +1e6;
    fMax = -1e6;
    TH1* one = 0;
    for (Int_t i = newCent->GetNbinsX(); i--;) {
      Double_t c1 = newCent->GetXaxis()->GetBinLowEdge(i+1);
      Double_t c2 = newCent->GetXaxis()->GetBinUpEdge(i+1);
      Info("", "c1=%f c2=%f", c1, c2);
      TH1*     r  = One(newFile, oldFile, c1, c2);    
      if (!r) continue;
      if (!one) {
	one = static_cast<TH1*>(r->Clone("one"));
	one->SetDirectory(0);
	one->Reset();
	for (Int_t j = 1; j <= one->GetNbinsX(); j++) {
	  one->SetBinContent(j,1);
	  one->SetBinError  (j,0);
	}
      }
      // r->Add(one, i-1);
      // r->Scale(TMath::Power(10,i));
      stack->Add(r);
    }
    stack->Draw("nostack");
    stack->SetMinimum(0.95*fMin);
    stack->SetMaximum(1.05*fMax);
    stack->GetHistogram()->SetXTitle("#eta");
    stack->GetHistogram()->SetYTitle("#it{R}");
    fLegend->Draw();
    c->Modified();
    c->Update();
    c->cd();
    c->SaveAs(Form("%sover%s.png", newTitle, oldTitle));
  }  
开发者ID:ktf,项目名称:AliPhysics,代码行数:57,代码来源:CompareResults.C


示例16: DrawOne

THStack* DrawOne(TVirtualPad* p, 
		 Double_t     yr,
		 Bool_t       top,
		 TDirectory*  dir, 
		 const char*  name)
{
  p->cd();
  p->SetFillColor(0);
  p->SetFillStyle(0);
  p->SetLineColor(0);
  p->SetRightMargin(0.01);
  p->SetLeftMargin(0.12);
  p->SetGridx();
  if (top) p->SetBottomMargin(0.001);
  else     p->SetBottomMargin(0.2);
  if (top) p->SetTopMargin(0.02);
  else     p->SetTopMargin(0.0001);
  
  
  THStack* s = static_cast<THStack*>(dir->Get(name));
  s->Draw("nostack");
  Double_t sc = (top ? 1-yr : yr);
  TAxis* ya = s->GetHistogram()->GetYaxis();
  ya->SetLabelSize(1/sc*ya->GetLabelSize());
  ya->SetTitleSize(1/sc*ya->GetTitleSize());
  ya->SetTitleOffset(sc*(ya->GetTitleOffset()+.5));
  ya->SetTitleFont(42);
  ya->SetLabelFont(42);
  TAxis* xa = s->GetHistogram()->GetXaxis();
  xa->SetLabelSize(!top ? 1/yr*xa->GetLabelSize() : 0);
  xa->SetTitleSize(!top ? 1/yr*xa->GetTitleSize() : 0);
  xa->SetTitleOffset(yr*(xa->GetTitleOffset()+2));
  xa->SetTitleFont(42);
  xa->SetLabelFont(42);

  p->Modified();
  p->Update();
  p->cd();

  return s;
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:41,代码来源:DrawEmpirical.C


示例17: plotComparison

void plotComparison(TFile **input, const string &title, const bool &reverse_order = false)
{
    TH1 *qcd = merge("htlep", input, 0, QCD_CHANNELS);
    TH1 *ttjets = get("htlep", input[TTJETS], TTJETS);
    TH1 *zjets = get("htlep", input[ZJETS], ZJETS);
    TH1 *wjets = get("htlep", input[WJETS], WJETS);
    TH1 *data = merge("htlep", input, RERECO, RERECO + DATA_CHANNELS);
    data->SetFillColor(0);
    
    THStack *stack = new THStack();
    stack->Add(qcd);
    stack->Add(ttjets);
    stack->Add(zjets);
    stack->Add(wjets);

    if (reverse_order)
    {
        stack->Draw("h");
        data->Draw("h same");
    }
    else
    {
        data->Draw("h");
        stack->Draw("h same");
    }

    TLegend *legend = createLegend(title.c_str());
    legend->Draw();
}
开发者ID:PerilousApricot,项目名称:bsm_analyze,代码行数:29,代码来源:fig.C


示例18: FromTH1FMakeTHStack

THStack * FromTH1FMakeTHStack(vector<TH1F*> * histo, TString stack_name, vector<TString> * h_description, bool order_size, bool nostack, TString x_axis, TString y_axis, TH1F * data){
 
  if((int) histo->size() != (int) h_description->size()){ Error("Histogram numbers and legend items do not match");}

  THStack * stack = new THStack("stack", stack_name);
  stack->SetTitle("");
  TLegend * legend = new TLegend(0.7,0.5,0.9,0.9);
  legend->SetFillColor(0);

  Int_t h_array_size = (int) histo->size();
  Int_t reorder[h_array_size];
  if(order_size){
    Float_t integral[h_array_size];
    for(int itr = 0; itr < h_array_size; itr++){
      integral[itr] = (*histo)[itr]->Integral();
    }
    for(int itr1 = 0; itr1 < h_array_size; itr1++){
      for(int itr2 = 0; itr2 < h_array_size; itr2++){
	if(itr1 == itr2) continue;
	if(integral[itr1] < integral[itr2]){
	  reorder[itr1] += 1;
	}
      }
    }
  }
  for(int itr = 0; itr < h_array_size; itr++){
    if( nostack ){ stack->Add((*histo)[reorder[itr]], "nostack"); }
    if(!nostack ){ stack->Add((*histo)[reorder[itr]]); }
    legend->AddEntry((*histo)[itr], (*h_description)[itr], "f");
  }
  if(data != NULL){ 
    stack->Add(data, "nostack");
    legend->AddEntry(data, "Data", "p");
  }

  return stack;

}
开发者ID:merlindavies,项目名称:TradeX,代码行数:38,代码来源:FromTH1FMakeTHStack.C


示例19: GetBkgStack

THStack * GetBkgStack(TFile *f, const char * name, const char * xtitle, TLegend * leg, int mode=0){
   char full_name[200];

   if (leg) {
      leg->SetFillStyle(0);
      leg->SetBorderSize(0);
      leg->SetTextSize(0.04);
   }

   sprintf(full_name, "stack_%s", name);
   THStack * stack = new THStack(full_name, "");

   TH1F * h_base = (TH1F *)f->Get(name);
   h_base->SetXTitle(xtitle);
   stack->SetHistogram(h_base);

   if (mode == 0)
   {
/*
      AddHist(stack, leg, f, name, "vbh_h_zz_4l",   "VV > H > ZZ > 4L",  FILL0, MYGREEN2);
      AddHist(stack, leg, f, name, "gg_zz_4l",      "gg > ZZ > 4L",      FILL0, MYORANGE1);
      AddHist(stack, leg, f, name, "gg_zz_2l2l",    "gg > ZZ > 2L2L",    FILL0, MYBLUE1);
      AddHist(stack, leg, f, name, "qq_zz_2e2mu",   "qq > ZZ > 2e2mu",   FILL0, MYCYAN2);
      AddHist(stack, leg, f, name, "gg_h_zz_4l",    "gg > H > ZZ > 4L",  FILL0, MYMAGENTA2);
      AddHist(stack, leg, f, name, "qq_zz_4e",      "qq > ZZ > 4e",      FILL0, MYGREEN1);   
      AddHist(stack, leg, f, name, "qq_zz_4mu",     "qq > ZZ > 4mu",     FILL0, MYORANGE2);  
      AddHist(stack, leg, f, name, "wh_zh_tth_hzz", "HW HW Htt, H > ZZ", FILL0, MYCYAN1);   
      AddHist(stack, leg, f, name, "wh_zh_tth_hww", "HW HZ Htt, H > WW", FILL0, MYMAGENTA1);
*/
      AddHist(stack, leg, f, name, "zh_hzz",  "HZ, H > ZZ",  FILL0, MYCYAN1);   
      AddHist(stack, leg, f, name, "zh_hww",  "HZ, H > WW",  FILL0, MYMAGENTA1);
      AddHist(stack, leg, f, name, "h_zz_4l", "H > ZZ > 4L", FILL0, MYGREEN2);
      AddHist(stack, leg, f, name, "zz_4l",   "ZZ > 4L",     FILL0, MYBLUE2);
   }
   return stack;
}
开发者ID:dburns7,项目名称:Research,代码行数:36,代码来源:mkplots_13tev.C


示例20: plotasym

void plotasym(int top){
  if (setup("vm","","pol__")==kFALSE) return;

  THStack* hs = new THStack(TString::Format("asym_top%d",top), TString::Format("asym_top%d",top));

  int itop = top-1;
  TFile* fy = _fyexp[itop];
  TIter nextkey(fy->GetListOfKeys());
  TKey *key;
  while (key = (TKey*)nextkey()) {
    TString Q2Wdirname = key->GetName();
    if(Q2Wdirname.EqualTo("hYW_Dir") || Q2Wdirname.EqualTo("hYW"))continue;
    cout << "Q2Wdirname = " << Q2Wdirname << endl;
    TString hname = TString::Format("%s/hAsym/Varset1/hAsym_ACC_CORR_phi",Q2Wdirname.Data());
    cout << "hname = " << hname << endl;
    TH1D* h = (TH1D*)fy->Get(hname);
    if (h==NULL) cout << "histogram not found" << endl;
    //h->Draw();
    hs->Add(h,"e1");
  }
  TCanvas *c = new TCanvas(hs->GetName(),hs->GetTitle());
  hs->Draw("pads");

}
开发者ID:arjun-trivedi,项目名称:ana2pi,代码行数:24,代码来源:xsec-tools.092513.pretwoscales.C



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ THTTPHdrVal类代码示例发布时间:2022-05-31
下一篇:
C++ THSpriteSheet类代码示例发布时间: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