本文整理汇总了C++中TProfile类的典型用法代码示例。如果您正苦于以下问题:C++ TProfile类的具体用法?C++ TProfile怎么用?C++ TProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Plot2DHisto
void Plot2DHisto(TH2D* plothist, char xTitle[200], char yTitle[200], char savename[200], char tex[200]) {
TGaxis::SetMaxDigits(3);
TCanvas *c1 = new TCanvas("", "", 1200, 1000);
gStyle->SetPalette(1);
gStyle->SetOptStat(0);
gPad->SetFillColor(kWhite);
gPad->SetLeftMargin(0.15);
gPad->SetRightMargin(0.2);
gPad->SetTopMargin(0.1);
double yOffset=1.4;
plothist->GetYaxis()->SetTitleOffset(yOffset);
plothist->SetStats(0);
plothist->SetTitle(0);
plothist->GetYaxis()->SetTitle(yTitle);
plothist->GetXaxis()->SetTitle(xTitle);
plothist->SetMinimum(0.);
plothist->Draw("colz");
double left=0.25, top=0.935, textSize=0.04;
TLatex *latex=new TLatex();
latex->SetTextFont(42);
latex->SetNDC(kTRUE);
latex->SetTextSize(textSize);
latex->DrawLatex(left,top,tex);
char linlog_savename[200];
c1->SetLogz(false);
sprintf(linlog_savename,"%s_lin.pdf",savename);
c1->SaveAs(linlog_savename);
c1->SetLogz(true);
sprintf(linlog_savename,"%s_log.pdf",savename);
c1->SaveAs(linlog_savename);
TProfile* profileX = plothist->ProfileX("", 1, -1, "so");
TProfile* profileY = plothist->ProfileY("", 1, -1, "so");
profileX->Draw("same");
sprintf(linlog_savename,"%s_log_AddProfile.pdf",savename);
c1->SaveAs(linlog_savename);
profileX->Draw();
latex->DrawLatex(left,top,tex);
sprintf(linlog_savename,"%s_log_ProfileX.pdf",savename);
c1->SaveAs(linlog_savename);
profileY->Draw();
latex->DrawLatex(left,top,tex);
sprintf(linlog_savename,"%s_log_ProfileY.pdf",savename);
c1->SaveAs(linlog_savename);
delete c1;
delete latex;
}
示例2: rotate2DN
void rotate2DN(const char* filename,int detNum){
TFile *f = new TFile(filename);
TCanvas* cnew= new TCanvas("cnew","",800.,500.);
cnew->cd();
stringstream sss;
sss<<"Transposed-"<<filename;
TFile f1(sss.str().c_str(),"RECREATE");
for (int i=0;i<detNum;i++){
stringstream orig ;
orig<<"hNc"<<i ;
TH2D* h1=(TH2D*)f->Get(orig.str().c_str());
string gname = h1->GetTitle();
stringstream hname ;
hname<<"hN"<<i;
TH2D* Hnew = new TH2D(hname.str().c_str(),gname.c_str(),1700.,0.,1700.,8000.,0.,8000.);
for (int x=0;x<8000;x++){
for (int y=0;y<1600;y++){
int bin = h1->GetBinContent(x,y);
Hnew->Fill(y,x,bin);
}
}
cout<<"Histogram Number "<<i<<" transpose completed"<<endl;
cnew->cd();
Hnew->SetMinimum(7);
Hnew->GetYaxis()->SetRangeUser(1300,1600);
Hnew->GetYaxis()->SetTitle("Energy (keV)");
Hnew->GetXaxis()->SetTitle("Cycle Number");
Hnew->Draw("COLZ");
TCutG *cutg = new TCutG("NaIcut1",5);
cutg->SetVarX("y");
cutg->SetVarY("x");
cutg->SetPoint(0,0,1350);
cutg->SetPoint(1,1500,1350);
cutg->SetPoint(2,1500,1500);
cutg->SetPoint(3,0,1500);
cutg->SetPoint(4,0,1350);
TProfile *profx = Hnew->ProfileX(Form("profx_%d",i),1,-1,"[NaIcut1]");
profx->SetLineColor(kRed);
profx->Draw("same");
cnew->Update();
gname = gname + ".pdf";
cnew->SaveAs(gname.c_str());
}
f1.Write();
}
示例3: explore_zmass_boost
void explore_zmass_boost()
{
// Tell root not to draw everything to the screen.
gROOT->SetBatch();
// TString dyfilename = TString("/home/acarnes/h2mumu/samples/stage1/monte_carlo/bg/stage_1_dy_jetsToLL_asympt50_ALL.root");
TString dyfilename = TString("/home/acarnes/h2mumu/samples/stage1/monte_carlo/bg/stage_1_dy_ZToMuMu_asympt50_ALL.root");
TString datafilename = TString("/home/acarnes/h2mumu/samples/stage1/data_from_json/Cert_246908-251883_13TeV_PromptReco_Collisions15_JSON_v2/stage_1_doubleMuon_RunBPrompt_MINIAOD.root");
TString savedir = TString("../png/dy_vs_data/run1cuts_v2_golden_json/dyzmumu/");
// Initialize the DiMuPlottingSystems for MC and data
DiMuPlottingSystem* dpsdata = new DiMuPlottingSystem(datafilename);
DiMuPlottingSystem* dpsdy = new DiMuPlottingSystem(dyfilename);
addDiMuMassPrimeBranch(dpsdata);
dpsdata->applyRun1Cuts();
dpsdy->applyRun1Cuts();
// Get the 2D histos
TH2F* hdataZPt = ZMassVsZPtHist2D("data_zpt", "recoCandMassPrime", "(14,0,60,30,87,95)", dpsdata);
TH2F* hdyZPt = ZMassVsZPtHist2D("dy_zpt", "recoCandMass", "(14,0,60,30,87,95)", dpsdy);
//overlayTProfiles(TH2F* hdata, TH2F* hdy, TString bininfo, TString savename)
TProfile* p = overlayTProfiles(hdataZPt, hdyZPt, 90, 92, savedir+"z_mass_vs_z_pt.png");
gStyle->SetOptFit(0011);
fitTProfileCustom(p);
TCanvas* c = new TCanvas();
c->cd();
p->Draw("hist c");
p->Draw("E0 X0 same");
dpsdata->arrangeStatBox(c);
c->Draw();
c->Print("blah2.png");
// Look at RMS
c->Clear();
c->cd();
c->SetGridx(kTRUE);
c->SetGridy(kTRUE);
c->cd();
TH1F* h = dpsdata->hist1D("recoCandMass", "(100,87,95)", "");
TH1F* h2 = dpsdata->hist1D("recoCandMassPrime", "(100,87,95)", "");
h2->SetLineColor(2);
h->Draw("");
h2->Draw("same");
std::cout << "mass rms: " << h->GetRMS() << std::endl;
std::cout << "mass' rms: " << h2->GetRMS() << std::endl;
std::cout << "mass mean: " << h->GetMean() << std::endl;
std::cout << "mass' mean: " << h2->GetMean() << std::endl;
std::cout << "mass num: " << h->Integral() << std::endl;
std::cout << "mass' num: " << h2->Integral() << std::endl;
DiMuPlottingSystem* dps = new DiMuPlottingSystem();
dps->arrangeStatBox(c);
c->Draw();
c->Print("newfit.png");
}
示例4: getPlot
TProfile* getPlot(TProfile *h1, char *var, TCut cut, char *filename, char* treeName)
{
TFile *inf = new TFile(filename);
TTree *t = (TTree*)inf->FindObjectAny(treeName);
TProfile * tmp = (TProfile*)h1->Clone();
tmp->SetName("tmp");
t->Draw(Form("%s>>tmp",var),cut);
return tmp;
}
示例5: TProfile
void ElectronSimulation::plotTProfile(TTree* treeData )
{
TProfile* hprof = new TProfile("hprof", "hprof", 7, -0.5, 9.5);
for (int i = 0; i < 7; ++i)
{
char chargeValueString[100];
snprintf(chargeValueString,100,"qChargeValues[%i]:%i",i,i);
treeData->Project("+hprof",chargeValueString);
}
hprof->Draw();
}
示例6: profile
void profile()
{
TCanvas* c1 = new TCanvas("canvas","nhitac",1200,600);
c1->Divide(2,1);
c1->cd(1);
TFile *file1 = new TFile("test_nhitac_modified.root");
//TH1F *histo1 = new TH1F("nhitac1","nhitac1",60,0,300);
TProfile *profile1 = new TProfile("profile","nhitac profile",100,0,100,0,300);
TFile *file2 = new TFile("test_nhitac_unmodified.root");
//TH1F *histo2 = new TH1F("nhitac","nhitac",60,0,300);
TProfile *profile2 = new TProfile("profile2","nhitac profile2",100,0,100,0,300);
TProfile *ratio = new TProfile("ratio","nhitac ratio", 100,0,100,0,2);
//histo2->SetMarkerStyle(31);
TLegend *l1 = new TLegend(0.20, 0.60, 0.3, 0.7);
l1->SetBorderSize(0);
TTree* nhitac_modified = (TTree*)file1->Get("testnhitac");
TTree* nhitac_unmodified = (TTree*)file2->Get("testnhitac");
int testnhitac1, testnhitac2;
nhitac_modified->SetBranchAddress("nhitac",&testnhitac1);
nhitac_unmodified->SetBranchAddress("nhitac",&testnhitac2);
for(int i= 0; i < nhitac_modified->GetEntries(); i++)
{
nhitac_modified->GetEntry(i);
nhitac_unmodified->GetEntry(i);
profile1->Fill(i,testnhitac1);
profile2->Fill(i,testnhitac2);
double temp = testnhitac2;
ratio->Fill(i,testnhitac1/temp);
//histo1->Fill(testnhitac1);
//histo2->Fill(testnhitac2);
}
//histo1->SetMarkerColor(kRed);
//histo1->SetLineColor(kRed);
profile1->SetMarkerColor(kRed);
profile1->SetMarkerStyle(5);
profile2->SetMarkerColor(kBlue);
l1->AddEntry(profile1,"modified od bad channel","P");
l1->AddEntry(profile2,"old od bad channel","l");
l1->SetTextSize(0.04);
profile1->Draw("e1p");
profile1->GetXaxis()->SetTitle("event #");
profile1->GetYaxis()->SetTitle("nhitac");
profile2->Draw("same");
l1->Draw();
c1->cd(2);
ratio->GetXaxis()->SetTitle("event #");
ratio->GetYaxis()->SetTitle("new/old");
//ratio->SetMarkerStyle(5);
//ratio->SetMarkerColor(kRed);
ratio->Draw();
}
示例7: combExpr
TProfile *MillePedeTrees::CreateHistProf(const char *expX, const char *expY, const char *selection,
const char *hDef, Option_t* opt)
{
const TString combExpr(Form("%s:%s", expY, expX));
TH1 *h = this->Draw(combExpr, selection, hDef, "goff prof");
TProfile *hResult = static_cast<TProfile*>(h->Clone(Form("%sClone", h->GetName())));
if (opt) hResult->SetOption(opt);
return hResult;
}
示例8: TProfile
// Report cut flow findings to screen
void DileptonAnalyzer::reportCutFlow( TFile & outputFile ) {
// Store in a TProfile
TProfile *cutFlow = new TProfile("cutFlow","Cut flow for final set of analysis cuts",20,0.5,20.5,-9.9e9,9.9e9);
TAxis *cutFlowAxis = cutFlow->GetXaxis();
for ( unsigned int iCut = 0; iCut < cutNamesInOrder_.size(); iCut++ ) {
cutFlow->Fill( iCut+1, cutFlowMap_[cutNamesInOrder_[iCut]]);
cutFlowAxis->SetBinLabel( iCut+1, cutNamesInOrder_[iCut]);
}
outputFile.cd();
cutFlow->Write();
}
示例9: drawPtEta
void drawPtEta(char *inf){
TFile a(inf);
a.cd("ana");
TProfile *h = new TProfile("h","",100,-3,3);
TCanvas *c = new TCanvas("c","",400,400);
hi->Draw("(pt):eta>>h","evtType!=92&&evtType!=93&&(abs(eta)<2.4&&chg!=0&&abs(pdg)!=11&&abs(pdg)!=13)","prof",10000);
double nevt = hi->GetEntries("evtType!=92&&evtType!=93");
h->Sumw2();
//h->Scale(2./nevt);
h->SetXTitle("#eta");
h->SetYTitle("Average P_{T}");
h->Draw();
c->SaveAs(Form("%s-PtEta-2.4.gif",inf));
c->SaveAs(Form("%s-PtEta-2.4.C",inf));
}
示例10: ProfileY
void KVCanvas::ProfileY(TH2* hh)
{
TObject* obj = 0;
if ((obj = gROOT->FindObject(Form("%s_pfy", hh->GetName())))) obj->Delete();
TProfile* pfy = hh->ProfileY("_pfy", 1, -1, "i");
TGraphErrors* gr = gHistoManipulator->MakeGraphFrom(pfy);
pfy->Delete();
TGraph* gg = gHistoManipulator->PermuteAxis(gr);
gr->Delete();
gg->SetName(Form("%s_pfy", hh->GetName()));
gg->SetLineColor(kBlack);
gg->Draw("PEZ");
Modified();
Update();
}
示例11: _xml
// ============================================================================
StatusCode Gaudi::Utils::Histos::fromXml
( TProfile& result , const std::string& input )
{
//
result.Reset() ; // RESET old histogram
//
_Xml<TProfile> _xml ;
std::auto_ptr<TProfile> histo = _xml ( input ) ;
if ( 0 == histo.get() ) { return StatusCode::FAILURE ; } // RETURN
//
result.Reset() ;
histo->Copy ( result ) ;
//
return StatusCode::SUCCESS ;
}
示例12: plotAndProfileX
void plotAndProfileX (TH2* h2, float min, float max, bool profile) {
setStyle(h2);
gPad->SetGrid(1,1);
gStyle->SetGridColor(15);
h2->GetYaxis()->SetRangeUser(min,max);
h2->Draw();
if (profile) {
TProfile* prof = h2->ProfileX();
prof->SetMarkerColor(2);
prof->SetLineColor(2);
prof->Draw("same");
}
TLine * l = new TLine(h2->GetXaxis()->GetXmin(),0,h2->GetXaxis()->GetXmax(),0);
l->SetLineColor(3);
l->Draw();
}
示例13: printRes
void
HistoCompare::PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te )
{
myoldProfile = oldHisto;
mynewProfile = newHisto;
myte = te;
Double_t *res ;
Double_t mypv = myoldProfile->Chi2Test(mynewProfile,"WW",res);
TString title = myoldProfile->GetName();
printRes(title, mypv, myte);
return;
}
示例14: smartGausProfileXSQRTN
TH1D * smartGausProfileXSQRTN (TH2F * strip, double width){
TProfile * stripProfile = strip->ProfileX () ;
// (from FitSlices of TH2.h)
double xmin = stripProfile->GetXaxis ()->GetXmin () ;
double xmax = stripProfile->GetXaxis ()->GetXmax () ;
int profileBins = stripProfile->GetNbinsX () ;
std::string name = strip->GetName () ;
name += "_smartGaus_X" ;
TH1D * prof = new TH1D(name.c_str (),strip->GetTitle (),profileBins,xmin,xmax) ;
int cut = 0 ; // minimum number of entries per fitted bin
int nbins = strip->GetXaxis ()->GetNbins () ;
int binmin = 1 ;
int ngroup = 1 ; // bins per step
int binmax = nbins ;
// loop over the strip bins
for (int bin=binmin ; bin<=binmax ; bin += ngroup)
{
TH1D *hpy = strip->ProjectionY ("_temp",bin,bin+ngroup-1,"e") ;
if (hpy == 0) continue ;
int nentries = Int_t (hpy->GetEntries ()) ;
if (nentries == 0 || nentries < cut) {delete hpy ; continue ;}
Int_t biny = bin + ngroup/2 ;
TF1 * gaussian = new TF1 ("gaussian","gaus", hpy->GetMean () - width * hpy->GetRMS (), hpy->GetMean () + width * hpy->GetRMS ()) ;
gaussian->SetParameter (1,hpy->GetMean ()) ;
gaussian->SetParameter (2,hpy->GetRMS ()) ;
hpy->Fit ("gaussian","RQL") ;
// hpy->GetXaxis ()->SetRangeUser ( hpy->GetMean () - width * hpy->GetRMS (), hpy->GetMean () + width * hpy->GetRMS ()) ;
prof->Fill (strip->GetXaxis ()->GetBinCenter (biny), gaussian->GetParameter (1)) ;
prof->SetBinError (biny,gaussian->GetParameter (2) / sqrt(hpy->GetEntries())) ;
// prof->SetBinError (biny,gaussian->GetParError (1)) ;
delete gaussian ;
delete hpy ;
} // loop over the bins
delete stripProfile ;
return prof ;
}
示例15: show_mass_dist
void show_mass_dist()
{
TFile *file_f = new TFile("particle_mass_dist.root");
TH2F *hm = (TH2F *) file_f->Get("mass_dist");
TProfile *pm = (TProfile *) file_f->Get("mass_dist_p");
TCanvas *cm = new TCanvas("cm", "Mass", 1000, 500);
cm->Divide(2, 1);
pm->SetLineColor(4);
cm->cd(1);
hm->Draw();
cm->cd(2)->SetBorderMode(0);
pm->Draw();
}