ATLAS Offline Software
SUSYCrossSection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef __SUSYCROSSSECTION__
6 #define __SUSYCROSSSECTION__
7 
8 // Member variables
9 #include <cstdlib>
10 #include <string>
11 #include <map>
12 
13 // For PMG centralized tool's wrapper tool handles
14 #include "AsgTools/AnaToolHandle.h"
15 
16 // Lots of function inlining!
18 
19 namespace PMGTools {
20  class IPMGCrossSectionTool;
21 }
22 
23 namespace SUSY
24 {
25 
26 unsigned int finalState(const int SUSY_Spart1_pdgId, const int SUSY_Spart2_pdgId);
27 
29 {
30 public:
31  CrossSectionDB(const std::string& txtfilename = "dev/PMGTools/PMGxsecDB_mc16.txt", bool usePathResolver = true, bool isExtended = false, bool usePMGTool = true);
32 
33  // Load all the information from a file
34  void loadFile(const std::string&);
35  // Extend the record based on information from a second file
36  void extend(const std::string&);
37 
38  // class to defined a MC process with id (or run #), name and cross-section
39  class Process
40  {
41  public:
42  Process() :
43  m_id(-1), m_name(""), m_cross_section(-1.f), m_kfactor(-1.f), m_efficiency(-1.f), m_relunc(-1.f), m_sumweight(-1.f), m_stat(-1.f) {}
44 
45  Process(int id, const std::string& name, float cross_section, float kfactor, float efficiency, float relunc, float sumweight, float stat):
47 
48  int ID() const { return m_id;}
49  const std::string& name() const { return m_name;}
50  float xsect() const { return m_cross_section;}
51  float kfactor() const { return m_kfactor;}
52  float efficiency() const { return m_efficiency;}
53  float relunc() const { return m_relunc;}
54  float sumweight() const { return m_sumweight;}
55  float stat() const { return m_stat;}
56  void sumweight(float s) { m_sumweight=s; }
57  void stat(float s) { m_stat=s; }
58  private:
59  int m_id;
60  std::string m_name;
62  float m_kfactor;
63  float m_efficiency;
64  float m_relunc;
65  float m_sumweight;
66  float m_stat;
67  };
68 
69  class Key {
71  int m_proc_id;
72  public:
73  Key(): m_sample_id(0), m_proc_id(0) {}
74  Key(int _sample_id, int _proc_id): m_sample_id(_sample_id), m_proc_id(_proc_id) {}
75  Key(int _sample_id, const std::string& name): m_sample_id(_sample_id) {
76  m_proc_id = atoi(name.c_str());
77  }
78  bool operator<(const Key & k) const {
79  return this->m_sample_id < k.m_sample_id || (this->m_sample_id == k.m_sample_id && this->m_proc_id < k.m_proc_id);
80  }
81  };
82 
83 
84  // set extended mode
85  void setExtended(bool isExtended=true){ m_extended = isExtended; };
86  void setUsePMGTool(bool usePMGTool=true){ m_usePMGTool = usePMGTool; };
87 
88 
89  // invalid ID returns a process with ID < 0
90  Process process(int id, int proc = 0) const;
91  Process process(int id, int pdgId1, int pdgId2) const { return process(id, finalState(pdgId1, pdgId2)); }
92 
93  // invalid process give < 0 result
94  float xsectTimesEff(int id, int proc = 0) const {
95  Process p = process(id, proc);
96  return p.xsect() * p.kfactor() * p.efficiency();
97  }
98  float xsectTimesEff(int id, int pdgId1, int pdgId2) const { return xsectTimesEff(id, finalState(pdgId1, pdgId2)); }
99  float rawxsect(int id, int proc = 0) const { return process(id, proc).xsect(); }
100  float rawxsect(int id, int pdgId1, int pdgId2) const { return rawxsect(id, finalState(pdgId1, pdgId2)); }
101  float kfactor(int id, int proc = 0) const { return process(id, proc).kfactor(); }
102  float kfactor(int id, int pdgId1, int pdgId2) const { return kfactor(id, finalState(pdgId1, pdgId2)); }
103  float efficiency(int id, int proc = 0) const { return process(id, proc).efficiency(); }
104  float efficiency(int id, int pdgId1, int pdgId2) const { return efficiency(id, finalState(pdgId1, pdgId2)); }
105  float rel_uncertainty(int id, int proc = 0) const { return process(id, proc).relunc(); }
106  float rel_uncertainty(int id, int pdgId1, int pdgId2) const { return rel_uncertainty(id, finalState(pdgId1, pdgId2)); }
107  float sumweight(int id, int proc = 0) const { return process(id, proc).sumweight(); }
108  float sumweight(int id, int pdgId1, int pdgId2) const { return sumweight(id, finalState(pdgId1, pdgId2)); }
109 
110  // invalid ID return "" string
111  std::string name(int id) const { return process(id, 0).name(); }
112 
113  // Allow iteration over all samples, denying modification of private data
114 private:
115  typedef std::map<Key, Process> xsDB_t; // Internal data format
118 public:
119  typedef xsDB_t::const_iterator iterator; // External iterator format
120  iterator begin() const { return m_xsectDB.begin(); }
121  iterator end() const {return m_xsectDB.end(); }
122 
123 private:
124  //PMG tool
126 
127  xsDB_t::iterator my_find( const int proc );
130 };
131 
132 }
133 
134 #endif
SUSY::CrossSectionDB::m_usePMGTool
bool m_usePMGTool
Definition: SUSYCrossSection.h:117
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SUSY::CrossSectionDB::begin
iterator begin() const
Definition: SUSYCrossSection.h:120
SUSY::CrossSectionDB::Process::m_kfactor
float m_kfactor
Definition: SUSYCrossSection.h:62
SUSY::finalState
unsigned int finalState(const int SUSY_Spart1_pdgId, const int SUSY_Spart2_pdgId)
Definition: SUSYCrossSection.cxx:227
asg::AnaToolHandle< PMGTools::IPMGCrossSectionTool >
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
SUSY::CrossSectionDB::rel_uncertainty
float rel_uncertainty(int id, int pdgId1, int pdgId2) const
Definition: SUSYCrossSection.h:106
SUSY::CrossSectionDB::Process::efficiency
float efficiency() const
Definition: SUSYCrossSection.h:52
SUSY::CrossSectionDB::end
iterator end() const
Definition: SUSYCrossSection.h:121
SUSY::CrossSectionDB::Key::Key
Key(int _sample_id, int _proc_id)
Definition: SUSYCrossSection.h:74
SUSY::CrossSectionDB::CrossSectionDB
CrossSectionDB(const std::string &txtfilename="dev/PMGTools/PMGxsecDB_mc16.txt", bool usePathResolver=true, bool isExtended=false, bool usePMGTool=true)
Definition: SUSYCrossSection.cxx:113
SUSY::CrossSectionDB::my_find
xsDB_t::iterator my_find(const int proc)
Definition: SUSYCrossSection.cxx:159
SUSY::CrossSectionDB::iterator
xsDB_t::const_iterator iterator
Definition: SUSYCrossSection.h:119
SUSY::CrossSectionDB::Process::ID
int ID() const
Definition: SUSYCrossSection.h:48
SUSY::CrossSectionDB::kfactor
float kfactor(int id, int proc=0) const
Definition: SUSYCrossSection.h:101
SUSY::CrossSectionDB::rel_uncertainty
float rel_uncertainty(int id, int proc=0) const
Definition: SUSYCrossSection.h:105
SUSY::CrossSectionDB::Process::m_name
std::string m_name
Definition: SUSYCrossSection.h:60
SUSY::CrossSectionDB::Key
Definition: SUSYCrossSection.h:69
SUSY::CrossSectionDB::kfactor
float kfactor(int id, int pdgId1, int pdgId2) const
Definition: SUSYCrossSection.h:102
SUSY::CrossSectionDB::Process::m_sumweight
float m_sumweight
Definition: SUSYCrossSection.h:65
SUSY::CrossSectionDB::Process::m_id
int m_id
Definition: SUSYCrossSection.h:59
SUSY::CrossSectionDB::Process::Process
Process(int id, const std::string &name, float cross_section, float kfactor, float efficiency, float relunc, float sumweight, float stat)
Definition: SUSYCrossSection.h:45
SUSY::CrossSectionDB::Process::xsect
float xsect() const
Definition: SUSYCrossSection.h:50
SUSY::CrossSectionDB::efficiency
float efficiency(int id, int proc=0) const
Definition: SUSYCrossSection.h:103
SUSY
Definition: SUSYCrossSection.h:24
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SUSY::CrossSectionDB::Key::m_sample_id
int m_sample_id
Definition: SUSYCrossSection.h:70
SUSY::CrossSectionDB::setUsePMGTool
void setUsePMGTool(bool usePMGTool=true)
Definition: SUSYCrossSection.h:86
SUSY::CrossSectionDB::setExtended
void setExtended(bool isExtended=true)
Definition: SUSYCrossSection.h:85
SUSY::CrossSectionDB::m_extended
bool m_extended
Definition: SUSYCrossSection.h:116
SUSY::CrossSectionDB::name
std::string name(int id) const
Definition: SUSYCrossSection.h:111
PMGTools
Tool providing sample cross-sections and k-factors etc.
Definition: AnalysisCommon/PMGTools/PMGTools/IPMGCrossSectionTool.h:15
SUSY::CrossSectionDB::Process
Definition: SUSYCrossSection.h:40
SUSY::CrossSectionDB::Process::stat
void stat(float s)
Definition: SUSYCrossSection.h:57
hist_file_dump.f
f
Definition: hist_file_dump.py:135
SUSY::CrossSectionDB::Key::Key
Key(int _sample_id, const std::string &name)
Definition: SUSYCrossSection.h:75
SUSY::CrossSectionDB::Process::name
const std::string & name() const
Definition: SUSYCrossSection.h:49
SUSY::CrossSectionDB::Process::stat
float stat() const
Definition: SUSYCrossSection.h:55
AnaToolHandle.h
SUSY::CrossSectionDB::Process::relunc
float relunc() const
Definition: SUSYCrossSection.h:53
SUSY::CrossSectionDB::Key::Key
Key()
Definition: SUSYCrossSection.h:73
SUSY::CrossSectionDB::Key::operator<
bool operator<(const Key &k) const
Definition: SUSYCrossSection.h:78
SUSY::CrossSectionDB::Process::m_cross_section
float m_cross_section
Definition: SUSYCrossSection.h:61
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
mc.proc
proc
Definition: mc.PhPy8EG_A14NNPDF23_gg4l_example.py:22
SUSY::CrossSectionDB::Process::Process
Process()
Definition: SUSYCrossSection.h:42
SUSY::CrossSectionDB::extend
void extend(const std::string &)
Definition: SUSYCrossSection.cxx:167
SUSY::CrossSectionDB::Process::m_stat
float m_stat
Definition: SUSYCrossSection.h:66
SUSY::CrossSectionDB::process
Process process(int id, int pdgId1, int pdgId2) const
Definition: SUSYCrossSection.h:91
SUSY::CrossSectionDB::Process::sumweight
void sumweight(float s)
Definition: SUSYCrossSection.h:56
SUSY::CrossSectionDB
Definition: SUSYCrossSection.h:29
SUSY::CrossSectionDB::m_xsectDB
xsDB_t m_xsectDB
Definition: SUSYCrossSection.h:128
SUSY::CrossSectionDB::sumweight
float sumweight(int id, int proc=0) const
Definition: SUSYCrossSection.h:107
SUSY::CrossSectionDB::m_cache
xsDB_t m_cache
Definition: SUSYCrossSection.h:129
SUSY::CrossSectionDB::rawxsect
float rawxsect(int id, int proc=0) const
Definition: SUSYCrossSection.h:99
SUSY::CrossSectionDB::efficiency
float efficiency(int id, int pdgId1, int pdgId2) const
Definition: SUSYCrossSection.h:104
SUSY::CrossSectionDB::sumweight
float sumweight(int id, int pdgId1, int pdgId2) const
Definition: SUSYCrossSection.h:108
SUSY::CrossSectionDB::Process::m_relunc
float m_relunc
Definition: SUSYCrossSection.h:64
SUSY::CrossSectionDB::Process::sumweight
float sumweight() const
Definition: SUSYCrossSection.h:54
IPMGCrossSectionTool.h
SUSY::CrossSectionDB::xsectTimesEff
float xsectTimesEff(int id, int pdgId1, int pdgId2) const
Definition: SUSYCrossSection.h:98
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
SUSY::CrossSectionDB::xsDB_t
std::map< Key, Process > xsDB_t
Definition: SUSYCrossSection.h:115
SUSY::CrossSectionDB::process
Process process(int id, int proc=0) const
Definition: SUSYCrossSection.cxx:206
SUSY::CrossSectionDB::Process::kfactor
float kfactor() const
Definition: SUSYCrossSection.h:51
SUSY::CrossSectionDB::xsectTimesEff
float xsectTimesEff(int id, int proc=0) const
Definition: SUSYCrossSection.h:94
fitman.k
k
Definition: fitman.py:528
SUSY::CrossSectionDB::loadFile
void loadFile(const std::string &)
Definition: SUSYCrossSection.cxx:131
SUSY::CrossSectionDB::m_pmgxs
asg::AnaToolHandle< PMGTools::IPMGCrossSectionTool > m_pmgxs
Definition: SUSYCrossSection.h:125
SUSY::CrossSectionDB::Key::m_proc_id
int m_proc_id
Definition: SUSYCrossSection.h:71
SUSY::CrossSectionDB::rawxsect
float rawxsect(int id, int pdgId1, int pdgId2) const
Definition: SUSYCrossSection.h:100
SUSY::CrossSectionDB::Process::m_efficiency
float m_efficiency
Definition: SUSYCrossSection.h:63