ATLAS Offline Software
PDFScaleFactorCalculator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #ifndef PDFSCALEFACTORCALCULATOR
6 #define PDFSCALEFACTORCALCULATOR
7 
8 #include <memory>
9 #include <iostream>
10 #include <string>
11 #include <unordered_map>
12 
13 // Framework include(s):
14 #include "AsgTools/AsgTool.h"
15 
16 // save diagnostic state
17 #pragma GCC diagnostic push
18 // turn off the sily warnings in Boost.
19 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
20 #include "LHAPDF/LHAPDF.h"
21 // turn back on the warnings
22 #pragma GCC diagnostic pop
23 #include "LHAPDF/PDFSet.h"
24 
25 #include "TopEvent/Event.h"
26 
27 namespace top {
28  class TopConfig;
29 
37  class PDFScaleFactorCalculator final: public asg::AsgTool {
38  public:
39  explicit PDFScaleFactorCalculator(const std::string& name);
40 
42 
43  // Delete Standard constructors
47 
51 
52  int numberInSet(const std::string& name) const {
53  const LHAPDF::PDFSet set(name);
54 
55  return set.size();
56  }
57 
64  void printAvailablePDFs() const {
65  ATH_MSG_INFO("List of available PDFs:");
66  for (const std::string& pdfname : LHAPDF::availablePDFSets())
67  msg(MSG::Level::INFO) << " " << pdfname << "\n";
68  msg(MSG::Level::INFO) << std::endl;
69  }
70 
71  private:
72  std::shared_ptr<top::TopConfig> m_config;
73 
74  std::vector< std::string > m_pdf_names;
75  std::string m_base_pdf_name;
77 
78  // Small helper class to hold the information we need
79  class PDFSet {
80  public:
81  PDFSet() {;};
82 
83  explicit PDFSet(const std::string& name) {
84  LHAPDF::mkPDFs(name, pdf_members);
85  unsigned int n_members = pdf_members.size();
86  event_weights.resize(n_members);
87  sum_of_event_weights.resize(n_members);
88  };
89 
90  std::vector< std::unique_ptr<const LHAPDF::PDF> > pdf_members = {};
91 
92  std::vector< float > event_weights = {};
93 
94  std::vector< float > sum_of_event_weights = {};
95  };
96 
97  std::unordered_map< std::string, PDFSet > m_pdf_sets;
98  };
99 }
100 
101 #endif
top::PDFScaleFactorCalculator::m_basepdf
LHAPDF::PDF * m_basepdf
Definition: PDFScaleFactorCalculator.h:76
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
Powheg_tt_mtop_common.PDF
PDF
Definition: Powheg_tt_mtop_common.py:110
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
top::PDFScaleFactorCalculator::PDFScaleFactorCalculator
PDFScaleFactorCalculator(PDFScaleFactorCalculator &&rhs)=delete
top::PDFScaleFactorCalculator::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: PDFScaleFactorCalculator.cxx:21
top::PDFScaleFactorCalculator::m_config
std::shared_ptr< top::TopConfig > m_config
Definition: PDFScaleFactorCalculator.h:72
top::PDFScaleFactorCalculator::execute
StatusCode execute()
Definition: PDFScaleFactorCalculator.cxx:42
top::PDFScaleFactorCalculator::PDFSet::PDFSet
PDFSet()
Definition: PDFScaleFactorCalculator.h:81
top::PDFScaleFactorCalculator::PDFSet
Definition: PDFScaleFactorCalculator.h:79
top::PDFScaleFactorCalculator::operator=
PDFScaleFactorCalculator & operator=(const PDFScaleFactorCalculator &rhs)=delete
top::PDFScaleFactorCalculator::PDFSet::PDFSet
PDFSet(const std::string &name)
Definition: PDFScaleFactorCalculator.h:83
top::PDFScaleFactorCalculator::m_pdf_sets
std::unordered_map< std::string, PDFSet > m_pdf_sets
Definition: PDFScaleFactorCalculator.h:97
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
top::PDFScaleFactorCalculator::PDFSet::sum_of_event_weights
std::vector< float > sum_of_event_weights
Definition: PDFScaleFactorCalculator.h:94
top::PDFScaleFactorCalculator::finalize
StatusCode finalize()
Definition: PDFScaleFactorCalculator.cxx:113
Event.h
top::PDFScaleFactorCalculator::printAvailablePDFs
void printAvailablePDFs() const
Print a list of the available PDFs to the screen.
Definition: PDFScaleFactorCalculator.h:64
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
top::PDFScaleFactorCalculator::m_pdf_names
std::vector< std::string > m_pdf_names
Definition: PDFScaleFactorCalculator.h:74
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
top::PDFScaleFactorCalculator::m_base_pdf_name
std::string m_base_pdf_name
Definition: PDFScaleFactorCalculator.h:75
top::PDFScaleFactorCalculator::numberInSet
int numberInSet(const std::string &name) const
Definition: PDFScaleFactorCalculator.h:52
top::PDFScaleFactorCalculator::PDFSet::event_weights
std::vector< float > event_weights
Definition: PDFScaleFactorCalculator.h:92
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:16
top::PDFScaleFactorCalculator::PDFScaleFactorCalculator
PDFScaleFactorCalculator(const std::string &name)
Definition: PDFScaleFactorCalculator.cxx:15
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
top::PDFScaleFactorCalculator::~PDFScaleFactorCalculator
virtual ~PDFScaleFactorCalculator()
Definition: PDFScaleFactorCalculator.h:41
top::PDFScaleFactorCalculator::PDFScaleFactorCalculator
PDFScaleFactorCalculator(const PDFScaleFactorCalculator &rhs)=delete
AsgTool.h
top::PDFScaleFactorCalculator::PDFSet::pdf_members
std::vector< std::unique_ptr< const LHAPDF::PDF > > pdf_members
Definition: PDFScaleFactorCalculator.h:90
top::PDFScaleFactorCalculator
For testing PDF reweighting with LHAPDF6.
Definition: PDFScaleFactorCalculator.h:37