我有一个对有经验的用户来说可能天真的问题,但我有点卡住了。我试图让ApplGrid代码正常工作(https://applgrid.hepforge.org/index.htm),所以我希望运行提供的示例。
据我所知,依赖项是ROOT(root.cern.ch)和LHAPDF库(lhapdf.hepforge.org/index.html),它们在我的机器上运行良好。 上述示例是为了使用旧版本的LHAPDF而构建的,因此我不得不更改调用方法的名称。 当我尝试制作时,我得到关于该函数的未定义引用的错误,但如果我隔离该指令并执行
g++ extract.cxx `lhapdf-config --cflags --ldflags`
它就像一个魅力。
config命令的输出为:
-I / home / matteo / software / gcc-4.7 / lhapdf / install / include -I / home / matteo / software / gcc-4.7 / boost / install / include -L / home / matteo / software / gcc- 4.7 / lhapdf / install / lib -lLHAPDF
如果我删除" LHAPDF相关命令"从原来的cxx文件我可以运行" make"没有任何问题。
作为最后的测试,我试图找出" applgrid相关代码"并尝试编译:
g++ extract_2.cxx `applgrid-config --cxxflags --ldfflags`
但是我得到了一个未定义的引用错误。
config命令的输出为:
-I / home / matteo / software / gcc-4.7 / applgrid / install / include -pthread -m64 -I / home / matteo / software / gcc-4.7 / root / install / include -L / home / matteo / software / gcc-4.7 / applgrid / install / lib -lfAPPLgrid -lAPPLgrid -m64 -L / home / matteo / software / gcc-4.7 / root / install / lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d - lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -L / home / matteo / software / gcc-4.7 / hoppet / install / lib -lhoppet_v1
makefile的内容如下:
CXX = g++
F77 = gfortran
FFLAGS += -O3 -fPIC
CXXFLAGS += -O3 -fPIC
# root
ROOTINCS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --glibs)
ROOTARCH = $(findstring -m64, $(ROOTINCS) )
#LHAPDF
LHAPDFINCS = $(shell lhapdf-config --cflags)
LHAPDFDIR = $(shell lhapdf-config --libdir)
LHAPDFLIBS = $(shell lhapdf-config --libs)
# applgrid
APPLCXXFLAGS = $(shell applgrid-config --cxxflags)
APPLCLIBS = $(shell applgrid-config --ldcflags)
APPLFLIBS = $(shell applgrid-config --ldflags)
# hoppet
HOPPETLIBS = $(shell hoppet-config --libs)
# get the fotran runtime library for linking fortran
FRTLLIB = $(shell gfortran $(CXXFLAGS) -print-file-name=libgfortran.a)
FRTLIB = -L$(subst /libgfortran.a, ,$(FRTLLIB) ) -lgfortran
# now set up the compile and link flags and libs
CXXFLAGS += $(ROOTARCH) $(ROOTINCS) $(APPLCXXFLAGS) $(LHAPDFINCS)
LDFLAGS += $(ROOTARCH)
FFLAGS += $(ROOTARCH)
CLIBS += $(ROOTLIBS) $(LHAPDFLIBS) $(HOPPETLIBS) $(APPLCLIBS)
FLIBS += $(ROOTLIBS) $(LHAPDFLIBS) $(HOPPETLIBS) $(APPLFLIBS) $(APPLCLIBS) $(FRTLIB)
install : all
all : stand fnlo fstand getdata
stand: stand.o
$(CXX) $(LDFLAGS) -o $@ $< $(CLIBS)
fstand: fstand.o fmain.o
$(CXX) $(LDFLAGS) -o $@ fstand.o fmain.o $(FLIBS)
% : %.o
$(CXX) $(LDFLAGS) -o $@ $< $(CLIBS)
fnlo: fnmain.o
$(CXX) $(LDFLAGS) -o $@ $< $(CLIBS)
.SUFFIXES : .cxx .o .f .c
.f.o :
$(F77) $(FFLAGS) -c $<
.cxx.o:
$(CXX) $(CXXFLAGS) -c $<
#########################################################
# just type make getdata and it will download all
# the required data for these examples
#########################################################
.PRECIOUS : fnlodata appldata
getdata : getfnlodata getappldata
getfnlodata: fnl0004.tab
fnl0004.tab:
@ echo "\n************************\ndownloading fastnlo data\n************************\n"
(curl http://fastnlo.hepforge.org/code/src/fnl0004.tab.gz | gunzip > fnl0004.tab )
getappldata: atlas-incljets-arxiv-1009.5908v2
atlas-incljets-arxiv-1009.5908v2:
@ echo "\n*************************************\n downloading atlas inclusive jet data\n***********************************\n"
(curl http://www.hepforge.org/archive/applgrid/atlas-incljets-arxiv-1009.5908v2.tgz | tar -xzf - )
clean:
rm -rf ./.libs ./.obj *.lo *.o *.la stand fnlo fstand *~
而目录中的其他文件如下:
fmain.cxx
extern "C" void fstand_();
int main() {
fstand_();
return 0
fnmain.cxx
#include <iostream>
#include <stdio.h>
#include "appl_grid/fastnlo.h"
#include "TFile.h"
#include "TH1D.h"
// lhapdf routines
#include "LHAPDF/LHAPDF.h"
extern "C" void evolvepdf_(const double& , const double& , double* );
extern "C" double alphaspdf_(const double& Q);
int main(int argc, char** argv) {
if ( argc<2 ) {
std::cerr << "usage: fnlo fastnlogrid.tab" << std::endl;
return -1;
}
std::cout << "set up lhapdf..." << std::endl;
const std::string _pdfname = "cteq6mE.LHgrid";
int iset = 0;
LHAPDF::initPDFSet( _pdfname, iset );
// don't need to hard code, can use a runtime parameter...
std::string gridname = argv[1];
// std::string gridname = "fnt1007midp.tab";
// std::string gridname = "fnt1008midp.tab";
// std::string gridname = "fnt2004.tab";
// std::string gridname = "fnl2004.tab";
fastnlo f( gridname );
std::vector<appl::grid*> g = f.grids();
// g.push_back( new appl::grid("atlas-incljets04-eta1.root") );
/// histograms and file for seeing the results
std::vector<TH1D*> hc(g.size());
std::string foutname = "appl.root";
TFile fout( foutname.c_str(),"recreate");
for ( int i=0 ; i<g.size() ; i++ ) {
// trim the grids (not actually needed, done in
// the fastnlo constructor
g[i]->trim();
char hname[64];
sprintf(hname, "hist%02d", i);
/// optionally print out the grid documentation
std::cout << "\n" << g[i]->getDocumentation() << std::endl;
/// perform the convolution
hc[i] = g[i]->convolute( evolvepdf_, alphaspdf_ );
hc[i]->SetName(hname);
hc[i]->SetDirectory(&fout);
hc[i]->Write();
/// print out the results
for ( int j=1 ; j<=hc[i]->GetNbinsX() ; j++ ) {
std::cout << "xsec(" << j-1 << ")=" << hc[i]->GetBinContent(j) << std::endl;
}
}
std::cout << "writing file " << foutname << std::endl;
fout.Close();
return 0;
}
}
fstand.f
C----------------------------------------------------------
C dummy routines that call the pdf and alphas routines
C this example, they just call the lhapdf routine
C for apdf fit, call your own routines
C----------------------------------------------------------
double precision function fnalphas(Q)
double precision Q
double precision alphaspdf
fnalphas = alphaspdf(Q)
return
end
subroutine fnpdf(x, Q, xf)
double precision x, Q
double precision xf(13)
call evolvePDF(x, Q, xf)
return
end
C----------------------------------------------------------
stand.cxx
#include <iostream>
#include <string>
#include <vector>
#include "appl_grid/appl_grid.h"
#include "appl_grid/appl_timer.h"
#include "TH1D.h"
#include "TPad.h"
// lhapdf routines
#include "LHAPDF/LHAPDF.h"
extern "C" void evolvepdf_(const double& , const double& , double* );
extern "C" double alphaspdf_(const double& Q);
int main(int argc, char** argv) {
// use a default atlas inclusive grid
std::string gridname = "atlas-incljets04-eta1.root";
if ( argc>1 ) gridname = argv[1];
std::cout << "reading grid " << gridname << std::endl;
// get name of grid from user and create from grid file
appl::grid g(gridname);
g.trim(); // trim away uneeded memory
/// print the grid documentation
std::cout << g.getDocumentation() << std::endl;
// initialise lhapdf
std::cout << "setting up lhapdf" << std::endl;
// const std::string _pdfname = "cteq6mE.LHgrid";
const std::string _pdfname = "CT10.LHgrid";
int iset = 0;
LHAPDF::initPDFSet( _pdfname, iset );
// initpdfset_(_pdfname.c_str());
// initpdf_( iset );
// do the convolution into a vector
std::cout << "doing standalone convolution" << std::endl;
// struct timeval atimer = appl_timer_start();
std::vector<double> xsec = g.vconvolute( evolvepdf_, alphaspdf_ );
// double atime = appl_timer_stop(atimer);
// std::cout << "time " << atime << " ms" << std::endl;
for ( int i=0 ; i<xsec.size() ; i++ ) std::cout << "xsec[" << i << "]\t= " << xsec[i] << std::endl;
// do the convolution into a TH1D
// atimer = appl_timer_start();
TH1D* hxsec = g.convolute( evolvepdf_, alphaspdf_ );
// atime = appl_timer_stop(atimer);
// std::cout << "time " << atime << " ms" << std::endl;
hxsec->SetLineColor(kRed);
hxsec->SetMarkerColor(kRed);
hxsec->SetMarkerStyle(20);
hxsec->DrawCopy();
gPad->SetLogy(true);
gPad->Print("xsec.pdf");
return 0;
}
待机full.cxx
#include <iostream>
#include <string>
#include <vector>
#include "appl_grid/appl_grid.h"
#include "appl_grid/appl_timer.h"
#include "TH1D.h"
#include "TPad.h"
// lhapdf routines
#include "LHAPDF/LHAPDF.h"
extern "C" void evolvepdf_(const double& , const double& , double* );
extern "C" double alphaspdf_(const double& Q);
int main(int argc, char** argv) {
// use a default atlas inclusive grid
std::string gridname = "atlas-incljets04-eta1.root";
if ( argc>1 ) gridname = argv[1];
std::cout << "reading grid " << gridname << std::endl;
// get name of grid from user and create from grid file
appl::grid g(gridname);
g.trim(); // trim away uneeded memory
std::cout << "setting up lhapdf" << std::endl;
// initialise lhapdf
// const std::string _pdfname = "cteq6mE.LHgrid";
const std::string _pdfname = "CT10.LHgrid";
int iset = 0;
LHAPDF::initPDFSet( _pdfname, iset );
// initpdfset_(_pdfname.c_str());
// initpdf_( iset );
// do the convolution into a vector
std::cout << "doing standalone convolution" << std::endl;
std::cout << g.getDocumentation() << std::endl;
struct timeval atimer = appl_timer_start();
std::vector<double> xsec = g.vconvolute( evolvepdf_, alphaspdf_ );
double atime = appl_timer_stop(atimer);
const int Nsubproc = g.subProcesses();
std::cout << "time : " << atime << " ms\tNsubproc : " << Nsubproc << std::endl;
std::vector<std::vector<double> > xsb(Nsubproc);
for ( int i=0 ; i<Nsubproc ; i++ ) {
xsb[i] = g.vconvolute( i, evolvepdf_, alphaspdf_ );
}
// print results
for ( int i=0 ; i<xsec.size() ; i++ ) {
std::cout << "xsec(" << i << ")=" << xsec[i] << std::endl;
}
for ( int i=0 ; i<Nsubproc ; i++ ) {
std::cout << "subproc: " << i << std::endl;
for ( int j=0 ; j<xsec.size() ; j++ ) {
std::cout << "xsec(" << i << ")=" << xsb[i][j] << std::endl;
}
}
TH1D* hxsec = g.convolute( evolvepdf_, alphaspdf_ );
std::vector<TH1D*> hxsb(Nsubproc);
for ( int i=0 ; i<Nsubproc ; i++ ) {
hxsb[i] = g.convolute( i, evolvepdf_, alphaspdf_ );
}
hxsec->SetLineColor(kRed);
hxsec->SetMarkerColor(kRed);
hxsec->SetMarkerStyle(20);
hxsec->SetMinimum(0.000001);
hxsec->DrawCopy();
gPad->SetLogy(true);
for ( int i=0 ; i<Nsubproc ; i++ ) {
hxsb[i]->SetLineColor(kRed+i%5);
hxsb[i]->SetMarkerColor(kRed+i%5);
hxsb[i]->SetLineStyle(1+i%5);
hxsb[i]->SetMarkerStyle(20+i%5);
hxsb[i]->DrawCopy("same");
}
gPad->Print("xsec.pdf");
double escale = 7e3/8e3;
TH1D* hxsec8 = g.convolute( escale, evolvepdf_, alphaspdf_ );
escale = 7e3/2.76e3;
TH1D* hxsec276 = g.convolute( escale, evolvepdf_, alphaspdf_ );
hxsec->DrawCopy();
hxsec8->SetLineColor(kRed+1);
hxsec8->SetLineStyle(2);
hxsec8->DrawCopy("same");
gPad->Print("xsec8.pdf");
hxsec276->SetLineColor(kRed+2);
hxsec276->SetLineStyle(3);
hxsec276->DrawCopy("same");
gPad->Print("xsec276.pdf");
// or get into a histogram
// TH1D* hxsec = g.convolute( evolvepdf_, alphaspdf_ );
// hxsec->SetName("xsec");
return 0;
}
待机save.cxx
#include <iostream>
#include <string>
#include <vector>
#include "appl_grid/appl_grid.h"
#include "appl_grid/appl_timer.h"
#include "TH1D.h"
#include "TPad.h"
// lhapdf routines
#include "LHAPDF/LHAPDF.h"
extern "C" void evolvepdf_(const double& , const double& , double* );
extern "C" double alphaspdf_(const double& Q);
int main(int argc, char** argv) {
// use a default atlas inclusive grid
std::string gridname = "atlas-incljets04-eta1.root";
if ( argc>1 ) gridname = argv[1];
std::cout << "reading grid " << gridname << std::endl;
// get name of grid from user and create from grid file
appl::grid g(gridname);
g.trim(); // trim away uneeded memory
/// print the grid documentation
std::cout << g.getDocumentation() << std::endl;
// initialise lhapdf
std::cout << "setting up lhapdf" << std::endl;
// const string _pdfname = "cteq6mE.LHgrid";
const string _pdfname = "CT10.LHgrid";
int iset = 0;
LHAPDF::initPDFSet( _pdfname, iset );
// initpdfset_(_pdfname.c_str());
// initpdf_( iset );
// do the convolution into a vector
std::cout << "doing standalone convolution" << std::endl;
// struct timeval atimer = appl_timer_start();
std::vector<double> xsec = g.vconvolute( evolvepdf_, alphaspdf_ );
// double atime = appl_timer_stop(atimer);
// std::cout << "time " << atime << " ms" << std::endl;
for ( int i=0 ; i<xsec.size() ; i++ ) std::cout << "xsec[" << i << "]\t= " << xsec[i] << std::endl;
// do the convolution into a TH1D
// atimer = appl_timer_start();
TH1D* hxsec = g.convolute( evolvepdf_, alphaspdf_ );
// atime = appl_timer_stop(atimer);
// std::cout << "time " << atime << " ms" << std::endl;
hxsec->SetLineColor(kRed);
hxsec->SetMarkerColor(kRed);
hxsec->SetMarkerStyle(20);
hxsec->DrawCopy();
gPad->SetLogy(true);
gPad->Print("xsec.pdf");
return 0;
}
待机tutorial.cxx
#include <iostream>
#include <string>
#include <vector>
#include "appl_grid/appl_grid.h"
#include "appl_grid/appl_timer.h"
#include "TH1D.h"
#include "TLatex.h"
#include "TFile.h"
#include "TH2D.h"
#include "TStyle.h"
#include "TCanvas.h"
#include "TPad.h"
#include "TStyle.h"
#include "TColor.h"
#include "TPaveStats.h"
// lhapdf routines
#include "LHAPDF/LHAPDF.h"
extern "C" void evolvepdf_(const double& x, const double& Q, double* xf);
extern "C" double alphaspdf_(const double& Q);
void setpalette()
{
const Int_t NRGBs = 7;
const Int_t NCont = 98;
Double_t stops[NRGBs] = { 0.00, 0.20, 0.40, 0.60, 0.70, 0.90, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.00, 0.60, 0.90, 1.00, 0.50 };
Double_t green[NRGBs] = { 0.00, 0.00, 0.40, 0.95, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.00, 1.00, 1.00, 0.10, 0.00, 0.00, 0.00 };
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
gStyle->SetNumberContours(NCont);
}
TH2D* smooth(TH2D* h) {
int Nnbins = 10;
TH2D* hi = new TH2D("h2","",
h->GetXaxis()->GetNbins()*Nnbins,
h->GetXaxis()->GetBinLowEdge(1),
h->GetXaxis()->GetBinLowEdge(h->GetXaxis()->GetNbins()+1),
h->GetYaxis()->GetNbins()*Nnbins,
h->GetYaxis()->GetBinLowEdge(1),
h->GetYaxis()->GetBinLowEdge(h->GetYaxis()->GetNbins()+1) );
hi->GetXaxis()->SetTitle( h->GetXaxis()->GetTitle() );
hi->GetYaxis()->SetTitle( h->GetYaxis()->GetTitle() );
hi->GetYaxis()->SetTitleOffset(1.1);
for ( int i=1 ; i<=h->GetXaxis()->GetNbins() ; i++ ) {
for ( int j=1 ; j<=h->GetYaxis()->GetNbins() ; j++ ) {
double z1 = h->GetBinContent(i,j);
double z2 = h->GetBinContent(i+1,j);
double z3 = h->GetBinContent(i,j+1);
double z4 = h->GetBinContent(i+1,j+1);
if ( z2==0 ) z2 = z1;
if ( z3==0 ) z3 = z1;
if ( z4==0 ) z4 = z3;
for ( int ii=0 ; ii<Nnbins ; ii++ ) {
double fx = 1.0*ii/Nnbins;
for ( int jj=0 ; jj<Nnbins ; jj++ ) {
double fy = 1.0*jj/Nnbins;
double z = ( (z4-z3-z2+z1)*fx + z3 - z1 )*fy + (z2-z1)*fx + z1;
// std::cout << (i-1)*Nnbins+ii+1 << " " << (j-1)*Nnbins+jj+1 << "\t z : " << z << "\tz1-4: " << z1 << " " << z2 << " " << z3 << " " << z4 << std::endl;
hi->SetBinContent( (i-1)*Nnbins+ii+1, (j-1)*Nnbins+jj+1, z);
// hi->SetBinContent( (i-1)*Nnbins+ii+1, (j-1)*Nnbins+jj+1, h->GetBinContent(i,j) );
}
}
}
}
return hi;
}
int main(int argc, char** argv) {
gStyle->SetOptStat(0);
setpalette();
// use a default atlas inclusive grid
std::string gridname = "atlas-incljets-arxiv-1009.5908v2/r04/atlas-incljets-eta1.root";
if ( argc>1 ) gridname = argv[1];
std::cout << "reading grid " << gridname << std::endl;
appl::grid g(gridname);
// g.trim(); // trim away uneeded memory
/// print the grid documentation
std::cout << g.getDocumentation() << std::endl;
// initialise lhapdf
std::cout << "setting up lhapdf" << std::endl;
// const std::string _pdfname = "cteq6mE.LHgrid";
const std::string _pdfname = "CT10.LHgrid";
int iset = 0;
LHAPDF::initPDFSet( _pdfname, iset );
// initpdfset_(_pdfname.c_str());
// initpdf_( iset );
/// ----------------- example 1 --------------------
if ( true ) {
// do the convolution into a vector
std::cout << "example 1: standalone convolution" << std::endl;
struct timeval atimer = appl_timer_start();
std::vector<double> xsec = g.vconvolute( evolvepdf_, alphaspdf_ );
double atime = appl_timer_stop(atimer);
std::cout << "time : " << atime << " ms" << std::endl;
for ( int i=0 ; i<xsec.size() ; i++ ) std::cout << "xsec[" << i << "]\t= " << xsec[i] << std::endl;
TH1D* hxsec = g.convolute( evolvepdf_, alphaspdf_ );
hxsec->SetTitle("");
hxsec->DrawCopy();
gPad->SetLogy(true);
gPad->Print("example-1.pdf");
}
/// ----------------- example 2 (corrections) --------------------
if ( false ) {
std::cout << "example 2: multiplicative corrections" << std::endl;
std::cout << g.getApplyCorrections() << std::endl;
g.setApplyCorrections(false);
TH1D* huncor = g.convolute( evolvepdf_, alphaspdf_ );
g.setApplyCorrections(true);
TH1D* hcor = g.convolute( evolvepdf_, alphaspdf_ );
huncor->SetLineStyle(2);
huncor->SetTitle("");
huncor->DrawCopy();
hcor->DrawCopy("same");
gPad->Print("example-2.pdf");
}
/// ----------------- example 3 (cms scaling) --------------------
if ( false ) {
std::cout << "example 3: centre-of-mass energy scaling " << std::endl;
TH1D* h7 = g.convolute( evolvepdf_, alphaspdf_ );
double Escale = 7/2.46;
TH1D* h246 = g.convolute( Escale, evolvepdf_, alphaspdf_ );
std::cout << "cms scale " << g.getCMSScale() << std::endl;
h7->SetTitle("");
h7->SetMinimum(0.001);
gStyle->SetOptStat(0);
h7->DrawCopy();
h246->SetLineColor(kRed);
h246->DrawCopy("same");
gPad->SetLogy(true);
gPad->Print("example-3.pdf");
}
/// ------------------ example 4 (scale variation) -----------------
if ( false ) {
std::cout << "example 4: scale variation " << std::endl;
int nloops = 1; // loop order
int Nbins = 30;
TH2D* hscale = new TH2D("scale", "", Nbins, 0.45, 2.05, Nbins, 0.45, 2.05 );
struct timeval atimer = appl_timer_start();
for ( int i=1 ; i<=hscale->GetNbinsX() ; i++ ) {
double fscale = hscale->GetXaxis()->GetBinCenter(i);
for ( int j=1 ; j<=hscale->GetNbinsY() ; j++ ) {
double rscale = hscale->GetYaxis()->GetBinCenter(j);
std::vector<double> xs = g.vconvolute( evolvepdf_, alphaspdf_, nloops, rscale, fscale );
double total = 0;
for ( int k=xs.size() ; k-- ; ) total += xs[k];
hscale->Fill( fscale, rscale, total );
}
}
double atime = appl_timer_stop(atimer);
std::cout << "time " << atime << " ms" << std::endl;
/// plot ....
gStyle->SetPalette(52);
gStyle->SetPadRightMargin(0.17);
TCanvas* tc = new TCanvas( "","", 650, 600 );
hscale->GetXaxis()->SetTitle("factorisation scale factor");
hscale->GetYaxis()->SetTitle("renormalisation scale factor");
hscale->GetYaxis()->SetTitleOffset(1.1);
TH2D* _hscale = smooth(hscale);
_hscale->DrawCopy("colz");
gPad->Print("example-4.png");
TFile fs("scale.root","recreate");
fs.cd();
hscale->Write();
fs.Write();
fs.Close();
}
/// ------------------ example 5 (subprocesses) -----------------
if ( false ) {
std::cout << "example 4: subprocess contributions " << std::endl;
std::vector<double> xsec = g.vconvolute( evolvepdf_, alphaspdf_);
std::vector<TH1D*> xsec_sub(g.subProcesses());
for ( int i=0 ; i<g.subProcesses() ; i++ ) {
xsec_sub[i] = g.convolute_subproc( i, evolvepdf_, alphaspdf_);
for ( int j=0 ; j<xsec_sub[i]->GetNbinsX() ; j++ ) {
xsec_sub[i]->SetBinContent( j+1, xsec_sub[i]->GetBinContent(j+1)/xsec[j] );
}
}
/// plot ...
int col[7] = { kRed, kBlue, kMagenta, kCyan, kGreen, kBlack, kViolet };
xsec_sub[0]->SetMaximum(0.6);
xsec_sub[0]->SetMinimum(0);
xsec_sub[0]->GetXaxis()->SetTitle("P_{T} [GeV]");
xsec_sub[0]->GetYaxis()->SetTitle("subprocess fraction");
xsec_sub[0]->SetTitle("");
xsec_sub[0]->DrawCopy();
for ( int i=0 ; i<g.subProcesses() ; i++ ) {
xsec_sub[i]->SetLineColor(col[i]);
xsec_sub[i]->DrawCopy("same");
TLatex* tl = new TLatex(0,0,"");
tl->SetTextColor(col[i]);
tl->SetTextSize(0.04);
char label[64];
sprintf(label, "subprocess %d", i);
tl->DrawLatex(430, 0.55-0.035*i, label );
}
gPad->SetLogy(false);
gPad->Print("example-5.pdf");
}
/// -------------------- example 6 (pdf sets) -----------------------
if ( false ) {
// const std::string _pdfname = "cteq6mE.LHgrid";
const std::string _pdfname = "CT10.LHgrid";
int iset = 0;
LHAPDF::initPDFSet( _pdfname, iset );
std::vector<double> _xs = g.vconvolute( evolvepdf_, alphaspdf_ );
int Nset = LHAPDF::numberPDF();
std::vector<TH1D*> xs(Nset);
for ( int i=0 ; i<Nset ; i++ ) {
struct timeval atimer = appl_timer_start();
LHAPDF::initPDFSet( _pdfname, i );
double atime = appl_timer_stop(atimer);
std::cout << "set " << i << "\tinitPDF time " << atime << " ms" << std::endl;
atimer = appl_timer_start();
xs[i] = g.convolute( evolvepdf_, alphaspdf_ );
atime = appl_timer_stop(atimer);
std::cout << "convolution time " << atime << " ms" << std::endl;
for ( int j=_xs.size() ; j-- ; ) xs[i]->SetBinContent( j+1, xs[i]->GetBinContent(j+1)/_xs[j]);
}
xs[0]->SetMaximum(1.1);
xs[0]->SetMinimum(0.9);
gPad->SetLogy(false);
gPad->SetLogx(true);
xs[0]->DrawCopy("l");
for ( int i=0 ; i<Nset ; i++ ) xs[i]->DrawCopy("lsame");
gPad->Print("example-6.pdf");
gPad->SetLogx(false);
}
/// ------------------- example 7 (timers) ---------------------
if ( false ) {
gStyle->SetOptStat(2220);
std::cout << "example 7 : timings" << std::endl;
TH1D* htrim = new TH1D("htrim", "", 100, 38, 45);
// TH1D* htrim2 = new TH1D("htrim2", "", 100, 37, 45);
TH1D* huntrim = new TH1D("huntrim", "", 100, 38, 45);
g.trim();
std::cout << "grid size : " << g.size() << std::endl;
for ( int i=400 ; i-- ; ) {
struct timeval atimer = appl_timer_start();
std::vector<double> xsec = g.vconvolute( evolvepdf_, alphaspdf_ );
double atime = appl_timer_stop( atimer );
htrim->Fill(atime);
}
g.untrim();
std::cout << "grid size : " << g.size() << std::endl;
for ( int i=400 ; i-- ; ) {
struct timeval atimer = appl_timer_start();
std::vector<double> xsec = g.vconvolute( evolvepdf_, alphaspdf_ );
double atime = appl_timer_stop( atimer );
huntrim->Fill(atime);
}
if ( huntrim->GetMaximum()<htrim->GetMaximum() ) huntrim->SetMaximum(1.1*htrim->GetMaximum());
else htrim->SetMaximum(1.1*huntrim->GetMaximum());
huntrim->SetLineStyle(2);
huntrim->SetLineColor(kRed);
htrim->GetXaxis()->SetTitle("time [ms]");
huntrim->GetXaxis()->SetTitle("time [ms]");
huntrim->Draw();
htrim->Draw("same");
// htrim2->DrawCopy("same");
huntrim->Draw("same");
htrim->Draw("sames+");
huntrim->Draw("sames+");
gPad->Update();
TPaveStats* tp1 = (TPaveStats*)htrim->GetListOfFunctions()->FindObject("stats");
TPaveStats* tp2 = (TPaveStats*)huntrim->GetListOfFunctions()->FindObject("stats");
std::cout << tp1 << " " << tp2 << std::endl;
tp2->SetTextColor(kRed);
tp1->SetY1NDC(0.93-0.15);
tp1->SetY2NDC(0.93);
tp2->SetY1NDC(0.93-0.16-0.15);
tp2->SetY2NDC(0.93-0.16);
tp1->Draw();
tp2->Draw();
gPad->Update();
gPad->Print("example-7.pdf");
}
return 0;
}
任何帮助将不胜感激,谢谢。