ATLAS Offline Software
Loading...
Searching...
No Matches
SUSYCrossSection.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef SUSYTOOLS_SUSYCROSSSECTION_H
6#define SUSYTOOLS_SUSYCROSSSECTION_H
7
8// Member variables
9#include <cstdlib>
10#include <string>
11#include <map>
12
13// For PMG centralized tool's wrapper tool handles
15
16// Lots of function inlining!
18
19namespace PMGTools {
21}
22
23namespace SUSY
24{
25
26unsigned int finalState(const int SUSY_Spart1_pdgId, const int SUSY_Spart2_pdgId);
27
29{
30public:
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:
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;
64 float m_relunc;
66 float m_stat;
67 };
68
69 class Key {
72 public:
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
114private:
115 typedef std::map<Key, Process> xsDB_t; // Internal data format
118public:
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
123private:
124 //PMG tool
126
127 xsDB_t::iterator my_find( const int proc );
130};
131
132}
133
134#endif
Key(int sample_id, int proc_id)
Key(int sample_id, const std::string &name)
bool operator<(const Key &k) const
Process(int id, const std::string &name, float cross_section, float kfactor, float efficiency, float relunc, float sumweight, float stat)
const std::string & name() const
float kfactor(int id, int pdgId1, int pdgId2) const
xsDB_t::iterator my_find(const int proc)
xsDB_t::const_iterator iterator
CrossSectionDB(const std::string &txtfilename="dev/PMGTools/PMGxsecDB_mc16.txt", bool usePathResolver=true, bool isExtended=false, bool usePMGTool=true)
float rawxsect(int id, int pdgId1, int pdgId2) const
float rel_uncertainty(int id, int proc=0) const
float rawxsect(int id, int proc=0) const
float sumweight(int id, int proc=0) const
float kfactor(int id, int proc=0) const
void extend(const std::string &)
asg::AnaToolHandle< PMGTools::IPMGCrossSectionTool > m_pmgxs
iterator begin() const
float efficiency(int id, int proc=0) const
std::map< Key, Process > xsDB_t
float rel_uncertainty(int id, int pdgId1, int pdgId2) const
float sumweight(int id, int pdgId1, int pdgId2) const
void setUsePMGTool(bool usePMGTool=true)
void loadFile(const std::string &)
float xsectTimesEff(int id, int pdgId1, int pdgId2) const
std::string name(int id) const
void setExtended(bool isExtended=true)
Process process(int id, int pdgId1, int pdgId2) const
float xsectTimesEff(int id, int proc=0) const
float efficiency(int id, int pdgId1, int pdgId2) const
a modified tool handle that allows its owner to configure new tools from the C++ side
const std::string process
Tool providing sample cross-sections and k-factors etc.
unsigned int finalState(const int SUSY_Spart1_pdgId, const int SUSY_Spart2_pdgId)