Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] integrating PineAPPL #76

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include Makefile.inc

CXXFLAGS = $(PRJCXXFLAGS)
CXXFLAGS = $(PRJCXXFLAGS)
LDLIBS = ./src/libac_core.a $(PRJLDFLAGS)

VPATH=./src
Expand Down
23 changes: 14 additions & 9 deletions Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ SHELL=/bin/bash

# APPLCOMB paths
RESULTSDIR= -D RESULTS_PATH="./results/"
PINEAPPLGRID= -D PINEAPPL_PATH="../pineapplgrids/"
APPLGRIDDIR= -D APPL_PATH="../applgrids/"
DATABASEDIR= -D DB_PATH="./db/"
ALLDIR= $(RESULTSDIR) $(APPLGRIDDIR) $(DATABASEDIR)
ALLDIR= $(RESULTSDIR) $(APPLGRIDDIR) $(DATABASEDIR) $(PINEAPPLGRID)

# root
ROOTINCS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs)
ROOTINCS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs)

# APFEL
APFELINCS = $(shell apfel-config --cppflags)
APFELLIBS = $(shell apfel-config --ldflags)
APFELINCS = $(shell apfel-config --cppflags)
APFELLIBS = $(shell apfel-config --ldflags)

#LHAPDF
LHAPDFINCS = -I$(shell lhapdf-config --prefix)/include
Expand All @@ -29,7 +30,7 @@ LHAPDFLIBS = -L$(LHAPDFDIR) -lLHAPDF

# applgrid
APPLINCS = -I$(shell applgrid-config --prefix)/include
APPLCLIBS = -L$(shell applgrid-config --prefix)/lib -lAPPLgrid
APPLCLIBS = -L$(shell applgrid-config --prefix)/lib -lAPPLgrid

# libnnpdf
NNPDFINCLUDE=$(shell pkg-config nnpdf --cflags)
Expand All @@ -39,8 +40,12 @@ NNPDFLIBS=$(shell pkg-config nnpdf --libs)
GSLINCLUDE=$(shell gsl-config --cflags)
GSLLIBS=$(shell gsl-config --libs)

# additional libraries to be included
PRJLDFLAGS = $(LHAPDFLIBS) $(APPLCLIBS) $(ROOTLIBS) $(APFELLIBS) $(NNPDFLIBS) $(GSLLIBS) -lsqlite3
# pineappl
PINEAPPLINCLUDE=$(shell pkg-config pineappl_capi --cflags)
PINEAPPLLIBS=$(shell pkg-config pineappl_capi --libs)

# additional libraries to be included
PRJLDFLAGS = $(LHAPDFLIBS) $(APPLCLIBS) $(ROOTLIBS) $(APFELLIBS) $(NNPDFLIBS) $(GSLLIBS) $(PINEAPPLLIBS) -lsqlite3

# scheduling and optimization options (such as -DSSE -DSSE2 -DP4)
PRJCXXFLAGS = -Wall -O3 $(ALLDIR) $(LHAPDFINCS) $(APPLINCS) $(ROOTINCS) $(APFELINCS) $(NNPDFINCLUDE) $(GSLINCLUDE)
PRJCXXFLAGS = -Wall -O3 $(ALLDIR) $(LHAPDFINCS) $(APPLINCS) $(ROOTINCS) $(APFELINCS) $(NNPDFINCLUDE) $(GSLINCLUDE) $(PINEAPPLINCLUDE)
26 changes: 25 additions & 1 deletion db/apfelcomb.dat
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;

CREATE TABLE IF NOT EXISTS "pineappl_subgrids" (
`id` INTEGER,
`fktarget` TEXT,
`pineapplgrid` TEXT,
`mask` TEXT,
`operators` TEXT,
PRIMARY KEY(id)
);
INSERT INTO pineappl_subgrids VALUES(170,'ATLASZHIGHMASS49FB','ATLASZHIGHMASS49FB.pineappl.lz4','1 1 1 1 1 1 1 1 1 1 1 1 1',NULL);

CREATE TABLE IF NOT EXISTS "app_subgrids" (
`id` INTEGER,
`fktarget` TEXT,
Expand Down Expand Up @@ -590,6 +601,7 @@ INSERT INTO dyp_subgrids VALUES(20,'POSDYUD',NULL);
INSERT INTO dyp_subgrids VALUES(21,'POSDYUDB',NULL);
INSERT INTO dyp_subgrids VALUES(22,'POSDYUS',NULL);
INSERT INTO dyp_subgrids VALUES(23,'POSDYUSB',NULL);

CREATE TABLE IF NOT EXISTS "grids" (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
`setname` TEXT NOT NULL,
Expand All @@ -602,7 +614,7 @@ CREATE TABLE IF NOT EXISTS "grids" (
INSERT INTO grids VALUES(0,'ATLASWZRAP36PB','ATLASWZRAP36PB',' ATLAS 36PB W/Z rapidity',25,0,'APP');
INSERT INTO grids VALUES(1,'ATLASR04JETS2P76TEV','ATLASR04JETS2P76TEV','ATLAS 2.76 TeV R=0.4 inclusive jets',30,0,'APP');
INSERT INTO grids VALUES(2,'ATLASR04JETS36PB','ATLASR04JETS36PB','ATLAS 7 TeV R=0.4 inclusive jets',25,0,'APP');
INSERT INTO grids VALUES(3,'ATLASZHIGHMASS49FB','ATLASZHIGHMASS49FB','ATLAS 49FB High mass Z',20,0,'APP');
INSERT INTO grids VALUES(3,'ATLASZHIGHMASS49FB','ATLASZHIGHMASS49FB','ATLAS 49FB High mass Z',50,0,'APP');
INSERT INTO grids VALUES(4,'ATLASWPT31PB','ATLASWPT31PB_WP','ATLAS 31PB W+ pT',25,0,'APP');
INSERT INTO grids VALUES(5,'ATLASWPT31PB','ATLASWPT31PB_WM','ATLAS 31PB W- pT',35,0,'APP');
INSERT INTO grids VALUES(6,'ATLASWPT31PB','ATLASWPT31PB_WP_TOT','ATLAS 31PB W+ total',20,0,'APP');
Expand Down Expand Up @@ -894,6 +906,18 @@ INSERT INTO grids VALUES(294,'INTEGXV8','INTEGXV8','xV8 integrability',70,1,'DIS
INSERT INTO grids VALUES(295,'INTEGXV','INTEGXV','xV integrability',70,1,'DIS');
INSERT INTO grids VALUES(296,'ATLAS_TTBARTOT_13TEV_FULLLUMI','ATLAS_TTBARTOT_13TEV_FULLLUMI','ATLAS 13 TeV inclusive ttbar cross-section',30,0,'APP');

/* TODO: FIX THIS MESS */
CREATE TABLE IF NOT EXISTS "fixmegrids" (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
`setname` TEXT NOT NULL,
`name` TEXT NOT NULL UNIQUE,
`description` TEXT NOT NULL,
`nx` INTEGER NOT NULL,
`positivity` INTEGER NOT NULL,
`source` TEXT NOT NULL
);
INSERT INTO fixmegrids VALUES(0,'ATLASZHIGHMASS49FB','ATLASZHIGHMASS49FB','ATLAS 49FB High mass Z',50,0,'PINE');

DELETE FROM sqlite_sequence;
INSERT INTO sqlite_sequence VALUES('dis_subgrids',71);
INSERT INTO sqlite_sequence VALUES('dyp_subgrids',23);
Expand Down
6 changes: 3 additions & 3 deletions src/apfel_comb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int argc, char* argv[]) {

if (argc!=4)
{
cout << "Usage: "<<argv[0]<<" <source=app/dis/dyp> <database id> <theory id>"<<endl;
cout << "Usage: "<<argv[0]<<" <source=pineappl/app/dis/dyp> <database id> <theory id>"<<endl;
exit(1);
}

Expand All @@ -49,7 +49,8 @@ int main(int argc, char* argv[]) {
Splash(); QCD::qcd_param par; QCD::parse_input(iTh, par);

NNPDF::SetVerbosity(0);
NNPDF::IndexDB grid_db(databasePath()+"apfelcomb.db", "grids");
std::string gridname = (source == "pineappl") ? "fixmegrids" : "grids";
NNPDF::IndexDB grid_db(databasePath()+"apfelcomb.db", gridname);
NNPDF::IndexDB subgrid_db(databasePath()+"apfelcomb.db", source+"_subgrids");

// Read grid information
Expand Down Expand Up @@ -135,6 +136,5 @@ int main(int argc, char* argv[]) {

cout << " APPLComb Complete "<<endl;
DisplayHR();
exit(0);
}

2 changes: 1 addition & 1 deletion src/apfelcomb/fk_grids.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FKTarget
public:
FKTarget(NNPDF::IndexDB const& db, int const& targetID, int const& global_nx);
~FKTarget(){};
enum source { APP, DIS, DYP, NSR };
enum source { PINE, APP, DIS, DYP, NSR };

virtual void Splash( ostream& ) const; //!< Write table information to stream
void ReadSubGrids(NNPDF::IndexDB const& db); //!< Read information on subgrids from database
Expand Down
53 changes: 53 additions & 0 deletions src/apfelcomb/fk_pine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#pragma once

#include <stdlib.h>
#include <fstream>
#include <vector>
#include <sys/stat.h>

// NNPDF
#include "NNPDF/fkgenerator.h"
#include "NNPDF/fastkernel.h"
#include "NNPDF/nnpdfdb.h"

// PineAPPL includes
#include "pineappl_capi.h"

#include "fk_utils.h"
#include "fk_qcd.h"
#include "fk_grids.h"

using QCD::qcd_param;

namespace PINE
{
class SubGrid: public FKSubGrid
{
public:
void Compute(qcd_param const&, vector<double>&) const; //!< Compute APPLgrid results mapped to Commondata
void Combine(QCD::qcd_param const&, NNPDF::FKGenerator*) const; //!< Perform the FK combination on a subgrid
private:
friend class ::FKTarget;
SubGrid(FKTarget const& parent, NNPDF::IndexDB const& db, int const& iDB);

void Splash(ostream&) const; //!< Print metadata to stream
size_t GetNdat() const {return ndata;}; //!< Return number of datapoints in subgrid
double GetQ2max() const; //!< Return maximum scale used in a subgrid
double GetXmin() const; //!< Return minimum x-value used in this sub grid
double GetComputeXmin() const; //!< Return minimal x-value used in computation of this observable

// ***********************************************************

const string pineapplfile; //!< Path for the pineapplg file
const string readme; //!< APPLgrid README

const vector<int> maskmap; //!< Map of masked applgrid points to datapoints
const size_t ndata; //!< Number of selected datapoints

const pineappl_grid* grid; //!< PineAPPL class

static vector<int> parse_maskmap(string const&);
};

}

1 change: 1 addition & 0 deletions src/apfelcomb/fk_qcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ namespace QCD

// APFEL PDF access functions
void evolpdf(const double& x, const double& Q, double* pdf);
double flvpdf(int32_t pdgid, double x, double q2);
double alphas(const double& Q);
double beta0();

Expand Down
5 changes: 5 additions & 0 deletions src/apfelcomb/fk_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ typedef std::chrono::system_clock::duration time_span;
#define RESULTS_PATH run/
#endif

#ifndef PINEAPPL_PATH
#define PINEAPPL_PATH ./
#endif

#ifndef APPL_PATH
#define APPL_PATH ./
#endif
Expand Down Expand Up @@ -60,6 +64,7 @@ namespace Colour {
void DisplayHR();
void Splash();

std::string pineapplPath();
std::string applPath();
std::string dataPath();
std::string resultsPath();
Expand Down
2 changes: 1 addition & 1 deletion src/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CXXFLAGS = $(PRJCXXFLAGS) -I ..
LDFLAGS = $(PRJLDFLAGS)

CORELIB = ../libac_core.a
COREOBJ = fk_appl.o fk_dis.o fk_qcd.o fk_utils.o fk_grids.o fk_ftdy.o
COREOBJ = fk_pine.o fk_appl.o fk_dis.o fk_qcd.o fk_utils.o fk_grids.o fk_ftdy.o
all : $(CORELIB)

$(CORELIB) : $(COREOBJ)
Expand Down
11 changes: 8 additions & 3 deletions src/core/fk_grids.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "NNPDF/nnpdfdb.h"
#include "NNPDF/commondata.h"

#include "apfelcomb/fk_pine.h"
#include "apfelcomb/fk_appl.h"
#include "apfelcomb/fk_dis.h"
#include "apfelcomb/fk_ftdy.h"
Expand Down Expand Up @@ -61,9 +62,10 @@ void FKTarget::Combine(QCD::qcd_param const& par, NNPDF::FKGenerator* FK) const

FKTarget::source FKTarget::parse_source(string const& ss)
{
if (ss.compare("APP") == 0) return FKTarget::APP;
if (ss.compare("DIS") == 0) return FKTarget::DIS;
if (ss.compare("DYP") == 0) return FKTarget::DYP;
if (ss.compare("PINE") == 0) return FKTarget::PINE;
if (ss.compare("APP") == 0) return FKTarget::APP;
if (ss.compare("DIS") == 0) return FKTarget::DIS;
if (ss.compare("DYP") == 0) return FKTarget::DYP;
return FKTarget::NSR;
}

Expand All @@ -73,6 +75,9 @@ void FKTarget::ReadSubGrids(NNPDF::IndexDB const& db)
for (int i : subgridIDs)
switch(subgrid_source)
{
case PINE:
components.insert(pair<int, FKSubGrid*>(i, new PINE::SubGrid(*this, db, i)));
break;
case APP:
components.insert(pair<int, FKSubGrid*>(i, new APP::SubGrid(*this, db, i)));
break;
Expand Down
Loading