Page MenuHomeHEPForge

No OneTemporary

Index: nnlo-bridge/trunk/src/fastnlo_utils.cxx
===================================================================
--- nnlo-bridge/trunk/src/fastnlo_utils.cxx (revision 1611)
+++ nnlo-bridge/trunk/src/fastnlo_utils.cxx (revision 1612)
@@ -1,294 +1,292 @@
//
// @file fastnlo_utils.cxx
//
//
// @author M.Sutton
//
// Copyright (C) 2016 M.Sutton (sutt@cern.ch)
//
// $Id: fastnlo_utils.cxx, v0.0 Mon 25 Apr 2016 15:03:20 CEST sutt $
#include "amconfig.h"
#ifdef HAVE_FASTNLO
#include <iostream>
// applgrid headers ...
// Temporary to use APPLGRID lumipdf function. To be replaced either in NNLO Bridge or in fastNLO.
#include "appl_grid/appl_grid.h"
#include "appl_grid/appl_pdf.h"
#include "appl_grid/lumi_pdf.h"
/// fastnlo headers ...
#include "fastnlo_utils.h"
//#include "fastnlotk/fastNLOCreate.h"
//#include "fastnlotk/read_steer.h"
//#include "fastnlotk/speaker.h"
#include "nnlo_common.h"
#include "nnlo_utils.h"
//-----------------------------------------------------------------------------
//
// --- --- --- fnloUtils --- --- --
//
//-----------------------------------------------------------------------------
//
// --- fastNLO specific functions
//
// _____________________________________________________________________ //
fastNLO::GeneratorConstants fnloUtils::GetNNLOJET_GenConsts() {
//!< Get NNLOJET specific generator constants for this interface
fastNLO::GeneratorConstants gc;
gc.Name = "NNLOJET"; //!< Name and version of generator
gc.References.push_back("JHEP 1607 (2016) 133 [arXiv:1605.04295]"); //!< References for generator
gc.References.push_back("Phys. Rev. Lett. 117, 042001 (2016) [arXiv:1606.03991]"); //!< References for generator
gc.UnitsOfCoefficients = 15;
return gc;
}
// _____________________________________________________________________ //
fastNLO::ProcessConstants fnloUtils::GetNNLOJET_ProcConstsPP(int LOord, const std::vector<std::vector<int> >& partLiCos) {
//!< Get default process constants for pp processes
fastNLO::ProcessConstants pc;
pc.LeadingOrder = LOord; // Order in alpha_s of leading order process
pc.NPDF = 2; // No. of PDFs involved
pc.NPDFDim = 2; // 2: full-matrix (then we don't need 'asymmetric processes
int nprocs = partLiCos.size();
pc.IPDFdef1 = 0; // Flag 1 to define PDF linear combinations
pc.IPDFdef2 = 0; // Flag 2 to define PDF linear combinations
pc.IPDFdef3LO = nprocs; // No. of subprocesses
pc.IPDFdef3NLO = nprocs;
pc.IPDFdef3NNLO = nprocs;
pc.NSubProcessesLO = nprocs; //No. of LO subprocesses
pc.NSubProcessesNLO = nprocs;
pc.NSubProcessesNNLO= nprocs;
// parton combinations in two different formats
pc.PDFCoeffLO = VectorToPairs(partLiCos);//!< PDF Linear combinations
pc.PDFCoeffNLO = pc.PDFCoeffLO;
pc.PDFCoeffNNLO = pc.PDFCoeffLO;
pc.PDFLiCoInLO = partLiCos; //!< PDF Linear combinations
pc.PDFLiCoInNLO = pc.PDFLiCoInLO;
pc.PDFLiCoInNNLO = pc.PDFLiCoInLO;
//AsymmetricProcesses = ; // empty
pc.Name = "Name of process not set and only specified in NNLOJET runcard.";
pc.References.push_back("Please see NNLOJET manual for more reference."); // references for processes
return pc;
}
// _____________________________________________________________________ //
fastNLO::ProcessConstants fnloUtils::GetNNLOJET_ProcConstsDIS() {
//!< Get default process constants for pp processes
fastNLO::ProcessConstants gc;
std::cout<<"[fnloUtils::GetNNLOJET_GenConstsDIS()] Not yet implemented."<<std::endl;
exit(4);
return gc;
}
// _____________________________________________________________________ //
// Temporary pointer to APPLGRID lumi function for fastNLO
const lumi_pdf *fnlopdf;
//-----------------------------------------------------------------------------
//
// --- --- --- fastNLO_nnlo --- --- --
//
//-----------------------------------------------------------------------------
// _____________________________________________________________________ //
void nnlo::init_fastnlo( const int& id, const std::string& gridname, int nbins, double lo, double hi ) {
//!<
//!< initialize fastNLO tables
//!<
std::cout << std::endl;
std::cout << "[nnlo::init_fastnlo] fastNLO initialisation" << std::endl;
// --- Set fastNLO verbosity level
say::SetGlobalVerbosity(say::DEBUG);
// ---- Set parton lumi mappings
// For the time being use Mark's APPLgrid trunk update to map colour dependent channels to subprocesses
// LO for testing; use the one created in APPLgrid booking if it exists
std::cout<<"[nnlo::init_fastnlo] DB set parton lumi mappings. This currently requires that an applgrid has been initialized first."<<std::endl;
fnlopdf = dynamic_cast<const lumi_pdf*>( appl::appl_pdf::getpdf("ZJ-LO.config") );
// Create new mapping
if ( fnlopdf == 0 ) {
lumi_pdf* _fnlopdf = new lumi_pdf("ZJ-LO.config");
_fnlopdf->removeDuplicates();
fnlopdf = _fnlopdf;
};
std::vector<std::vector<int> > PartonCombinationsLO = fnlopdf->vectorise();
// printout parton combinations
for ( unsigned int ip=0; ip<PartonCombinationsLO.size(); ip++ ) {
std::cout << "LO parton combinations: ip = " << ip << ", PartonCombinationsLO = " << PartonCombinationsLO[ip] << std::endl;
}
// --- get NNLOJET specific generator constants
// fastNLO::GeneratorConstants gc = fnloUtils::GetNNLOJET_GenConsts();
// --- build process specific 'processConstants'
// fastNLO::ProcessConstants pc = fnloUtils::GetNNLOJET_ProcConstsPP(inppar_.njets,PartonCombinationsLO);
// --- initalisation starts here
// filename of steering files
std::cout << "[nnlo::init_fastnlo] fastNLO initialisation" << std::endl;
// Derive naming from NNLOJETS histogram name passed via gridname
std::string basename = gridname.substr(0,gridname.find_last_of("."));
std::string steeringNameSpace = basename;
std::cout << "[nnlo::init_fastnlo] Steering name space set to: " << steeringNameSpace << std::endl;
std::cout << "[nnlo::init_fastnlo] Book fastNLO interpolation grid." << std::endl;
std::cout << "[nnlo::init_fastnlo] Set parameters that are passed from NNLOJETS to fastNLO!" << std::endl;
// Values passed here will overwrite a possible value in the steering
// Pass process info
// LO & copy for now
int leading_order = inppar_.njets;
std::cout << "[nnlo::init_fastnlo] Setting steering parameter 'LeadingOrder' to " << leading_order << std::endl;
ADD_NS("LeadingOrder", leading_order, steeringNameSpace);
int nprocs = PartonCombinationsLO.size();
std::cout << "[nnlo::init_fastnlo] Setting steering parameters 'iPDFdef3' and 'NSubProcesses' to " << nprocs << std::endl;
ADD_NS("IPDFdef3LO",nprocs,steeringNameSpace);
ADD_NS("IPDFdef3NLO",nprocs,steeringNameSpace);
ADD_NS("IPDFdef3NNLO",nprocs,steeringNameSpace);
ADD_NS("NSubProcessesLO",nprocs,steeringNameSpace);
ADD_NS("NSubProcessesNLO",nprocs,steeringNameSpace);
ADD_NS("NSubProcessesNNLO",nprocs,steeringNameSpace);
std::cout << "[nnlo::init_fastnlo] Setting steering parameters 'PartonCombinations' " << std::endl;
std::vector<std::string> Tmp(PartonCombinationsLO.size());
ADDTABLE_NS("PartonCombinationsLO",Tmp,PartonCombinationsLO,steeringNameSpace);
ADDTABLE_NS("PartonCombinationsNLO",Tmp,PartonCombinationsLO,steeringNameSpace);
ADDTABLE_NS("PartonCombinationsNNLO",Tmp,PartonCombinationsLO,steeringNameSpace);
// --- Define vector with binning for FastNLO
std::vector<double> binning(nbins+1);
double binwidth = (hi-lo)/nbins;
double flo = lo;
for (int i=0; i<=nbins; i++) {
binning[i] = flo;
flo += binwidth;
}
std::cout << "[nnlo::init_fastnlo] Setting steering parameters 'SingleDifferentialBinning' " << std::endl;
ADDARRAY_NS("SingleDifferentialBinning", binning, steeringNameSpace);
// --- steering file
std::string steerfile = "fastNLObase.str";
std::cout << "[nnlo::init_fastnlo] Initializing fastNLOCreate with steering file '"<<steerfile<<"' and SteeringNamespace '"<<steeringNameSpace<<"'." << std::endl;
// --- Create table
fnloUtils::ftable[id] = new fastNLOCreate(steerfile,steeringNameSpace, true);
//fnloUtils::ftable[id] = new fastNLOCreate(steerfile,gc,pc);
if ( fnloUtils::ftable[id]->GetIsWarmup() ) {
std::cout << "[nnlo::init_fastnlo] fastNLO warmup file initialised." << std::endl;
} else {
std::cout << "[nnlo::init_fastnlo] fastNLO interpolation grid booked." << std::endl;
fnloUtils::ftable[id]->fastNLOTable::SetNcontrib(1);
fnloUtils::ftablename[id] = basename+".tab";
}
- fnloUtils::ftablename[id] = gridname+".tab"; // keep name for final writing
-
std::cout << "[nnlo::init_fastnlo] fastNLO initialized. " << std::endl;
}
// _____________________________________________________________________ //
void nnlo::fill_fastnlo( const int& id,
const double& x1, const double& x2, const double& Q2,
const double& obs,
const double* wt ) {
//!<
//!< Fill fastNLO table
//!<
// std::cout << "[nnlo::fill_fastnlo] Fill fastNLO table for id="<<id<<"\tx1="<<x1<<"\tx2="<<x2<<"\tQ2="<<Q2<<"\tQ="<<sqrt(Q2)<<"\tObs="<<obs<<"\twt0="<<wt[0]<<std::endl;
//! --- Set fastNLO verbosity level
say::SetGlobalVerbosity(say::WARNING);
int leading_order = inppar_.njets; // should be replaced by fastNLO getter
int iorder = ndimcurrent_.norder;
// int nv = ndimcurrent_.nv;
int iproc = currentprocess_.iproc;
int iprocess = fnlopdf->decideSubProcess( iproc );
// std::cout << "iorder = " << iorder << ", nv = " << nv << ", iproc = " << iproc << ", iprocess = " << iprocess << std::endl;
fnloUtils::ftable[id]->SetOrderOfAlphasOfCalculation(leading_order+iorder);
// --- pass variables to fastNLO
fnloUtils::ftable[id]->fEvent.SetProcessId(iprocess);
fnloUtils::ftable[id]->fEvent.SetWeight(wt[0]);
fnloUtils::ftable[id]->fEvent.SetX1(x1);
fnloUtils::ftable[id]->fEvent.SetX2(x2);
fnloUtils::ftable[id]->fScenario.SetObservable0(obs);
fnloUtils::ftable[id]->fScenario.SetObsScale1(sqrt(Q2));
// --- fill event within fastNLO
fnloUtils::ftable[id]->Fill();
//fnloUtils::ftable[id]->fEvent.Reset(); // needed?
}
// _____________________________________________________________________ //
void nnlo::fill_ref_fastnlo( const int& id, const double& obs, const double* wt ) {
// Do nothing for the moment
}
// _____________________________________________________________________ //
void nnlo::term_fastnlo( const int& id, int nweights ) {
//!<
//!< Terminate fastNLO: Write table to disk
//!<
std::cout << "[nnlo::term()] Write fastNLO table ..." << std::endl;
//! --- Set fastNLO verbosity level
say::SetGlobalVerbosity(say::DEBUG);
// --- set number of events
//unsigned long long int nEvents = nweights;
fnloUtils::ftable[id]->SetNumberOfEvents(nweights);
// --- write table
if (fnloUtils::ftable[id]->GetIsWarmup()) {
std::cout << "[nnlo::term()] fastNLO warmup run finished ..." << std::endl;
fnloUtils::ftable[id]->WriteTable();
} else {
std::cout << "[nnlo::term()] fastNLO run finished, writing table '" << fnloUtils::ftablename[id] << "'." << std::endl;
fnloUtils::ftable[id]->WriteTable(fnloUtils::ftablename[id]);
}
}
#endif

File Metadata

Mime Type
text/x-diff
Expires
Sat, Dec 21, 4:05 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4023380
Default Alt Text
(11 KB)

Event Timeline