本文整理汇总了C++中TProfile::SetAxisRange方法的典型用法代码示例。如果您正苦于以下问题:C++ TProfile::SetAxisRange方法的具体用法?C++ TProfile::SetAxisRange怎么用?C++ TProfile::SetAxisRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TProfile
的用法示例。
在下文中一共展示了TProfile::SetAxisRange方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: overlayTProfiles
TProfile* overlayTProfiles(TH2F* hdata, TH2F* hdy, float ymin, float ymax, TString savename)
{
// See how the mean of the dimumass changes vs some variable by making TProfiles of a 2D histogram with the Dimu mass as the y axis.
// Compare data to MC and save the results as png files.
TString dataname = TString("Golden_JSON_DoubleMuon_Data");
TString dyname = TString("Drell_Yan_Monte_Carlo_2015");
// Make TProfiles from them to see how the mean changes vs the x variable.
TProfile* pdata = hdata->ProfileX();
pdata->SetLineColor(1);
pdata->SetLineWidth(3);
pdata->SetTitle(hdata->GetTitle());
pdata->GetYaxis()->SetTitle(hdata->GetYaxis()->GetTitle());
TProfile* pdy = hdy->ProfileX();
pdy->SetLineColor(2);
pdy->SetLineWidth(3);
pdy->SetTitle(hdy->GetTitle());
pdy->GetYaxis()->SetTitle(hdy->GetYaxis()->GetTitle());
std::cout<< "hdata: " << hdata << std::endl;
std::cout<< "hdy: " << hdy << std::endl;
std::cout<< "pdata: " << pdata << std::endl;
std::cout<< "pdy: " << pdy << std::endl;
TCanvas* c = new TCanvas();
c->SetGridx(kTRUE);
c->SetGridy(kTRUE);
// Draw data and MC on the same plot
// Have to draw the same plots twice to get error bars and a curve through the error bars.
c->cd();
// hdata->Draw("colz");
pdata->SetAxisRange(ymin,ymax,"Y");
pdata->Draw("hist c");
pdata->Draw("E X0 same");
pdy->Draw("hist c same");
pdy->Draw("E X0 same");
// Stat box alignment
DiMuPlottingSystem* dps = new DiMuPlottingSystem();
dps->arrangeStatBox(c);
// Legend
TLegend* l = new TLegend(0.15, 0.15, 0.7, 0.25, "", "brNDC");
l->AddEntry(pdata, dataname, "l");
l->AddEntry(pdy, dyname, "l");
l->Draw("same");
c->Print(savename);
return pdata;
}
示例2: Dcurvature
void Dcurvature(const char *chargechoice = "plus", double ptmin=20){
TString sign=chargechoice;
gStyle->SetPalette(1);
gStyle->SetOptStat("e");
// double ptmin=20;
double ptmax=200;
double etamax=2.1;
int ptbins=(ptmax-ptmin)/10;
double ptbinwidth=(ptmax-ptmin)/ptbins;
int etabins=21;
int phibins=21;
TProfile3D *khistptetaphi = new TProfile3D("DeltaCurv(pt,eta,phi)","DeltaCurv(pt,eta,phi) "+sign,ptbins,ptmin,ptmax,etabins,-etamax,etamax,phibins,-3.14,3.14);
khistptetaphi->GetXaxis()->SetTitle("Pt");
khistptetaphi->GetYaxis()->SetTitle("Eta");
khistptetaphi->GetZaxis()->SetTitle("Phi");
TProfile2D *khistpteta = new TProfile2D("DeltaCurv(pt,eta)","DeltaCurv(pt,eta) "+sign,ptbins,ptmin,ptmax,etabins,-etamax,etamax);
khistpteta->GetXaxis()->SetTitle("Pt");
khistpteta->GetYaxis()->SetTitle("Eta");
TProfile2D *khistptphi = new TProfile2D("DeltaCurv(pt,phi)","DeltaCurv(pt,phi) "+sign,ptbins,ptmin,ptmax,phibins,-3.14,3.14);
khistptphi->GetXaxis()->SetTitle("Pt");
khistptphi->GetYaxis()->SetTitle("Phi");
TProfile *khistpt = new TProfile("DeltaCurv(pt)","DeltaCurv(pt) "+sign,ptbins,ptmin,ptmax);
khistpt->GetXaxis()->SetTitle("Pt");
khistpt->SetAxisRange(-0.001,0.001,"Y");
TProfile *khisteta = new TProfile("DeltaCurv(eta)","DeltaCurv(eta) "+sign,etabins,-etamax,etamax);
khistpt->GetXaxis()->SetTitle("Eta");
TProfile *khistphi = new TProfile("DeltaCurv(phi)","DeltaCurv(phi) "+sign,phibins,-3.14,3.14);
khistpt->GetXaxis()->SetTitle("Phi");
TObjArray *khistptbins= new TObjArray();
for (int i=0; i<ptbins; i++) {
TString name="DeltaCurv(eta,phi), pt bin ";
name+=int(ptmin+i*(ptmax-ptmin)/ptbins);
name+=TString(", charge ")+sign;
TProfile2D *ist = new TProfile2D(name.Data(),name.Data(),phibins,-3.14,3.14,etabins,-etamax,etamax);
ist->SetAxisRange(-0.002,0.002,"Z");
khistptbins->Add(ist);
}
TFile *f = new TFile("RecoRoutines_Z-selection_ZJets_TuneZ2_7TeV_alpgen_tauola.rew8.corr1.root","read");
TTree *tree;
f->GetObject("SingleMuPtScale/"+sign+"muonstree",tree);
Double_t MCPt;
Double_t MCEta;
Double_t MCPhi;
Double_t RecoPt;
Double_t RecoEta;
Double_t RecoPhi;
Double_t EvWeight;
tree->SetBranchAddress("RecoPt",&RecoPt);
tree->SetBranchAddress("RecoEta",&RecoEta);
tree->SetBranchAddress("RecoPhi",&RecoPhi);
tree->SetBranchAddress("MCPt",&MCPt);
tree->SetBranchAddress("MCEta",&MCEta);
tree->SetBranchAddress("MCPhi",&MCPhi);
tree->SetBranchAddress("EvWeight",&EvWeight);
long nentries = tree->GetEntriesFast();
for (int i=0; i<nentries; i++){
tree->GetEntry(i);
if (RecoPt<ptmin || RecoPt>ptmax || RecoEta<-etamax || RecoEta>etamax) continue;
double quantity=(MCPt-RecoPt)/MCPt/RecoPt;
khistptetaphi->Fill(RecoPt,RecoEta,RecoPhi,quantity,EvWeight);
khistpteta->Fill(RecoPt,RecoEta,quantity,EvWeight);
khistptphi->Fill(RecoPt,RecoPhi,quantity,EvWeight);
((TProfile2D*)(khistptbins->At(int((RecoPt-ptmin)/ptbinwidth))))->Fill(RecoPhi,RecoEta,quantity,EvWeight);
khistpt->Fill(RecoPt,quantity,EvWeight);
khisteta->Fill(RecoEta,quantity,EvWeight);
khistphi->Fill(RecoPhi,quantity,EvWeight);
}
TCanvas *c1 = new TCanvas();
khistptetaphi->Draw("BOX");
TCanvas *c2 = new TCanvas();
c2->Divide(2,1);
c2->cd(1);
khistpteta->Draw("BOX");
c2->cd(2);
khistptphi->Draw("BOX");
TCanvas *c2b = new TCanvas();
c2b->Divide(3,1);
c2b->cd(1);
khistpt->Draw();
c2b->cd(2);
//.........这里部分代码省略.........
示例3: balanceMetVsAj
void balanceMetVsAj(TString infname = "dj_HCPR-J50U-hiGoodMergedTracks_OfficialSelv2_Final0_120_50.root",TCut myCut = "cent<30", char *title = "",bool drawLegend = false)
{
TFile *inf = new TFile(infname);
TTree *t = (TTree*)inf->Get("ntjt");
const int nBin = 3;
double bins[nBin+1] = {0.5,4,8,1000};
double colors[nBin] = {kOrange-8,kBlue-3,kRed};
// Selection cut
TCut evtCut = "nljet>100&&abs(nljetacorr)<2&&aljet>50&&abs(aljetacorr)<2&&jdphi>2./3*TMath::Pi()&&!maskEvt";
cout << "Sel evt: " << t->GetEntries(evtCut&&myCut) << endl;
TProfile *p[nBin];
for (int i=0;i<nBin;i++)
{
p[i] = new TProfile(Form("p%d",i),"",5,0.0001,0.49999);
t->Project(Form("p%d",i),Form("-1*metxMerged%d:Aj",i), "1"*(evtCut&&myCut));
p[i]->SetLineColor(colors[i]);
p[i]->SetMarkerColor(colors[i]);
}
TProfile *pall = new TProfile("pall","",5,0.0001,0.49999);
pall->SetXTitle("A_{J}");
pall->SetYTitle("<#slash{p}_{T}^{#parallel}> (GeV/c)");
pall->GetXaxis()->CenterTitle();
pall->GetYaxis()->CenterTitle();
pall->SetNdivisions(505);
t->Project("pall","-1*metx:Aj", "1"*(evtCut&&myCut));
pall->SetAxisRange(-50,50,"Y");
pall->SetMarkerSize(1);
pall->Draw("E");
for (int i=0;i<nBin;++i) {
p[i]->SetLineWidth(3);
p[i]->Draw("e hist same");
}
pall->Draw("E same");
// Legend
TLegend *leg = new TLegend(0.10,0.68,0.70,0.96);
leg->SetFillStyle(0);
leg->SetBorderSize(0);
leg->SetTextFont(63);
leg->SetTextSize(16);
leg->AddEntry(pall,Form("> %.1f GeV/c",bins[0]),"pl");
for (int i=0;i<nBin;++i) {
if (i!=nBin-1){
leg->AddEntry(p[i],Form("%.1f - %.1f GeV/c",bins[i],bins[i+1]),"l");
} else {
leg->AddEntry(p[i],Form("> %.1f GeV/c",bins[i]),"l");
}
}
if (drawLegend) leg->Draw();
TLine * l0 = new TLine(0,0,0.5,0);
l0->SetLineStyle(2);
l0->Draw();
TText *titleText = new TText(0.3,30,title);
titleText->Draw();
}
示例4: plotMETVsJetPhi
void plotMETVsJetPhi(int num=-1)
{
char *title="";
if (num!=-1) {
title = Form("%d",num);
}
TFile *inf = new TFile("nt_dj_mix100_Gen.root");
TTree *tGen = (TTree*) inf->FindObjectAny("ntjt");
tGen->SetName("gen");
TFile *inf2 = new TFile("nt_dj_mix100.root");
TTree *tReco = (TTree*) inf2->FindObjectAny("ntjt");
tReco->SetName("reco");
TFile *inf3 = new TFile("nt_dj_HyUQ80v4_djcalo_genp_100_50.root");
TTree *tGen2 = (TTree*) inf3->FindObjectAny("ntjt");
tGen2->SetName("gen2");
TFile *inf4 = new TFile("dj_HyUQ80v4_djcalo_genp_100_50.root");
TTree *tDj = (TTree*) inf4->FindObjectAny("djTree");
tDj->SetName("dj");
TFile *inf5 = new TFile("nt_dj_data100_cor.root");
TTree *tRecoData = (TTree*) inf5->FindObjectAny("ntjt");
tRecoData->SetName("data");
TFile *inf6 = new TFile("dj_HCPR-J50U-hiGoodMergedTracks_OfficialSelv2_Final0_djcalo_100_50.root");
TTree *tDjData = (TTree*) inf6->FindObjectAny("djTree");
tDjData->SetName("djdata");
tGen->AddFriend(tReco);
tGen->AddFriend(tGen2);
tGen->AddFriend(tDj);
tRecoData->AddFriend(tDjData);
setupAlias(tGen);
setupAlias(tReco);
const int nBin = 10;
double delta = 0.0; //shift
// double Bins[nBin+1] = {0,1,2,2.2,2.4,2.6,2.8,3,PI};
// double BinsMC[nBin+1] = {0+delta,1+delta,2+delta,2.2+delta,2.4+delta,2.6+delta,2.8+delta,3+delta,PI+delta};
double Bins[nBin+1];
double BinsMC[nBin+1];
for (int i=0;i<nBin+1;i++)
{
Bins[i]=-PI+2*PI/(double)nBin*i;
BinsMC[i]=-PI+2*PI/(double)nBin*i+delta;
cout <<Bins[i]<<endl;
}
const int nPtBin = 6;
double ptBins[nPtBin+1] = {0.5,1.0,1.5,4,8,20,1000};
TCanvas *c = new TCanvas("c","",600,600);
TProfile *p = new TProfile("p","",nBin,BinsMC);
TProfile *p2 = new TProfile("p2","",nBin,BinsMC);
TProfile *p3 = new TProfile("p3","",nBin,BinsMC);
TProfile *p4 = new TProfile("p4","",nBin,Bins);
TCut evtCut = "nljet>120&&abs(nljetacorr)<1.6&&aljet>50&&abs(aljetacorr)<1.6&&!maskEvt&¢<30&&abs(jdphi)>2./3.*3.14159";
tGen->Draw(Form("-gen.metOutOfConex%s:nljphi+0.0>>p",title),"weight"*evtCut);
tGen->Draw(Form("-gen2.metOutOfConex%s:nljphi+0.0>>p2",title),"weight"*evtCut);
tGen->Draw(Form("-reco.metOutOfConex%s:nljphi+0.0>>p3",title),"weight"*evtCut);
tRecoData->Draw(Form("-metOutOfConex%s:nljphi>>p4",title),"1"*evtCut);
p->SetMarkerStyle(24);
p2->SetMarkerStyle(25);
p3->SetMarkerStyle(26);
p4->SetMarkerStyle(20);
p->SetAxisRange(-80,120,"Y");
p->Draw();
p2->SetMarkerColor(2);
p2->SetLineColor(2);
p3->SetMarkerColor(4);
p3->SetLineColor(4);
p2->Draw("same");
p3->Draw("same");
p4->Draw("same");
TLine *l = new TLine(Bins[0],0,PI,0);
l->Draw();
p->SetXTitle("#phi_{Leading Jet}");
p->SetYTitle("<#slash{p}_{T}^{#parallel}> (GeV/c)");
// ====================
TLegend *leg = new TLegend(0.45,0.68,0.92,0.9);
leg->SetFillStyle(0);
leg->SetBorderSize(0);
leg->SetTextFont(63);
leg->SetTextSize(16);
leg->AddEntry("p","Jets with |#eta|<1.6","");
if (num!=-1) {
leg->AddEntry("p",Form("Tracks with %.1f<p_{T}<%.1f GeV/c",ptBins[num],ptBins[num+1]),"");
} else {
leg->AddEntry("p",Form("Tracks with %.1f<p_{T}<%.1f GeV/c",ptBins[0],ptBins[nPtBin]),"");
}
leg->AddEntry("p","#slash{p}_{T}^{#parallel} PYTHIA+HYDJET GEN Signal","pl");
leg->AddEntry("p2","#slash{p}_{T}^{#parallel} PYTHIA+HYDJET GEN S+B","pl");
leg->AddEntry("p3","#slash{p}_{T}^{#parallel} PYTHIA+HYDJET RECO","pl");
leg->AddEntry("p4","#slash{p}_{T}^{#parallel} Data RECO","pl");
leg->Draw();
//.........这里部分代码省略.........