ATLAS Offline Software
Loading...
Searching...
No Matches
SUSY::CrossSectionDB Class Reference

#include <SUSYCrossSection.h>

Collaboration diagram for SUSY::CrossSectionDB:

Classes

class  Key
class  Process

Public Types

typedef xsDB_t::const_iterator iterator

Public Member Functions

 CrossSectionDB (const std::string &txtfilename="dev/PMGTools/PMGxsecDB_mc16.txt", bool usePathResolver=true, bool isExtended=false, bool usePMGTool=true)
void loadFile (const std::string &)
void extend (const std::string &)
void setExtended (bool isExtended=true)
void setUsePMGTool (bool usePMGTool=true)
Process process (int id, int proc=0) const
Process process (int id, int pdgId1, int pdgId2) const
float xsectTimesEff (int id, int proc=0) const
float xsectTimesEff (int id, int pdgId1, int pdgId2) const
float rawxsect (int id, int proc=0) const
float rawxsect (int id, int pdgId1, int pdgId2) const
float kfactor (int id, int proc=0) const
float kfactor (int id, int pdgId1, int pdgId2) const
float efficiency (int id, int proc=0) const
float efficiency (int id, int pdgId1, int pdgId2) const
float rel_uncertainty (int id, int proc=0) const
float rel_uncertainty (int id, int pdgId1, int pdgId2) const
float sumweight (int id, int proc=0) const
float sumweight (int id, int pdgId1, int pdgId2) const
std::string name (int id) const
iterator begin () const
iterator end () const

Private Types

typedef std::map< Key, ProcessxsDB_t

Private Member Functions

xsDB_t::iterator my_find (const int proc)

Private Attributes

bool m_extended
bool m_usePMGTool
asg::AnaToolHandle< PMGTools::IPMGCrossSectionToolm_pmgxs
xsDB_t m_xsectDB
xsDB_t m_cache

Detailed Description

Definition at line 28 of file SUSYCrossSection.h.

Member Typedef Documentation

◆ iterator

typedef xsDB_t::const_iterator SUSY::CrossSectionDB::iterator

Definition at line 119 of file SUSYCrossSection.h.

◆ xsDB_t

typedef std::map<Key, Process> SUSY::CrossSectionDB::xsDB_t
private

Definition at line 115 of file SUSYCrossSection.h.

Constructor & Destructor Documentation

◆ CrossSectionDB()

SUSY::CrossSectionDB::CrossSectionDB ( const std::string & txtfilename = "dev/PMGTools/PMGxsecDB_mc16.txt",
bool usePathResolver = true,
bool isExtended = false,
bool usePMGTool = true )

Definition at line 113 of file SUSYCrossSection.cxx.

114 : m_pmgxs("")
115{
116 setExtended(isExtended);
117 setUsePMGTool(usePMGTool);
118
119 // configuring the PMG tool...
120 m_pmgxs.setTypeAndName("PMGTools::PMGCrossSectionTool/PMGCrossSectionTool");
121 m_pmgxs.retrieve().ignore(); // Ignore the status code
122 std::vector<std::string> inFiles={};
123 std::string fullPath = usePathResolver ? PathResolverFindCalibFile(txtfilename) : txtfilename;
124 std::ifstream in(fullPath.c_str());
125 if (!in) return;
126 inFiles.push_back(fullPath);
127 m_pmgxs->readInfosFromFiles( inFiles );
128
129}
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
asg::AnaToolHandle< PMGTools::IPMGCrossSectionTool > m_pmgxs
void setUsePMGTool(bool usePMGTool=true)
void setExtended(bool isExtended=true)

Member Function Documentation

◆ begin()

iterator SUSY::CrossSectionDB::begin ( ) const
inline

Definition at line 120 of file SUSYCrossSection.h.

120{ return m_xsectDB.begin(); }

◆ efficiency() [1/2]

float SUSY::CrossSectionDB::efficiency ( int id,
int pdgId1,
int pdgId2 ) const
inline

Definition at line 104 of file SUSYCrossSection.h.

104{ return efficiency(id, finalState(pdgId1, pdgId2)); }
float efficiency(int id, int proc=0) const
unsigned int finalState(const int SUSY_Spart1_pdgId, const int SUSY_Spart2_pdgId)

◆ efficiency() [2/2]

float SUSY::CrossSectionDB::efficiency ( int id,
int proc = 0 ) const
inline

Definition at line 103 of file SUSYCrossSection.h.

103{ return process(id, proc).efficiency(); }
const std::string process

◆ end()

iterator SUSY::CrossSectionDB::end ( ) const
inline

Definition at line 121 of file SUSYCrossSection.h.

121{return m_xsectDB.end(); }

◆ extend()

void SUSY::CrossSectionDB::extend ( const std::string & txtfilename)

Definition at line 167 of file SUSYCrossSection.cxx.

167 {
168 // Just like the above function, but with more functionality
169 std::string line;
170
171 std::ifstream in(txtfilename.c_str());
172 if (!in) return;
173 while ( getline(in, line) )
174 {
175 // skip leading blanks (in case there are some in front of a comment)
176 if ( !line.empty() ){
177 while ( line[0] == ' ' ) line.erase(0, 1);
178 }
179 // skip lines that do not start with a number, they are comments
180 if ( !line.empty() && isdigit(line[0]) ){
181 std::stringstream is(line);
182 int id;
183 std::string name;
184 float xsect, kfactor, efficiency, relunc;
185 float sumweight = -1, stat = -1;
186 is >> id;
187 auto my_it = my_find( id );
188 if (my_it==m_xsectDB.end()){
189 is >> name >> xsect >> kfactor >> efficiency >> relunc;
190 if (m_extended == true){
191 is >> sumweight >> stat;
192 }
193 m_xsectDB[Key(id, name)] = Process(id, name, xsect, kfactor, efficiency, relunc, sumweight, stat);
194 } else {
195 // Now we have extended records
196 if (!m_extended) m_extended=true;
197 is >> sumweight >> stat;
198 my_it->second.sumweight(sumweight);
199 my_it->second.stat(stat);
200 }
201 }
202 }
203
204}
xsDB_t::iterator my_find(const int proc)
float sumweight(int id, int proc=0) const
float kfactor(int id, int proc=0) const
std::string name(int id) const

◆ kfactor() [1/2]

float SUSY::CrossSectionDB::kfactor ( int id,
int pdgId1,
int pdgId2 ) const
inline

Definition at line 102 of file SUSYCrossSection.h.

102{ return kfactor(id, finalState(pdgId1, pdgId2)); }

◆ kfactor() [2/2]

float SUSY::CrossSectionDB::kfactor ( int id,
int proc = 0 ) const
inline

Definition at line 101 of file SUSYCrossSection.h.

101{ return process(id, proc).kfactor(); }

◆ loadFile()

void SUSY::CrossSectionDB::loadFile ( const std::string & txtfilename)

Definition at line 131 of file SUSYCrossSection.cxx.

131 {
132
133 std::string line;
134
135 std::ifstream in(txtfilename.c_str());
136 if (!in) return;
137 while ( getline(in, line) ){
138 // skip leading blanks (in case there are some in front of a comment)
139 if ( !line.empty() ){
140 while ( line[0] == ' ' ) line.erase(0, 1);
141 }
142 // skip lines that do not start with a number, they are comments
143 if ( !line.empty() && isdigit(line[0]) ){
144 std::stringstream is(line);
145 int id;
146 std::string name;
147 float xsect, kfactor, efficiency, relunc;
148 float sumweight = -1, stat = -1;
149 is >> id >> name >> xsect >> kfactor >> efficiency >> relunc;
150 if (m_extended == true){
151 is >> sumweight >> stat;
152 }
153 m_xsectDB[Key(id, name)] = Process(id, name, xsect, kfactor, efficiency, relunc, sumweight, stat);
154 }
155 }
156}

◆ my_find()

SUSY::CrossSectionDB::xsDB_t::iterator SUSY::CrossSectionDB::my_find ( const int proc)
private

Definition at line 159 of file SUSYCrossSection.cxx.

159 {
160 for (SUSY::CrossSectionDB::xsDB_t::iterator it = m_xsectDB.begin(); it!=m_xsectDB.end();++it){
161 if (it->second.ID()==proc) return it;
162 }
163 return m_xsectDB.end();
164}

◆ name()

std::string SUSY::CrossSectionDB::name ( int id) const
inline

Definition at line 111 of file SUSYCrossSection.h.

111{ return process(id, 0).name(); }

◆ process() [1/2]

Process SUSY::CrossSectionDB::process ( int id,
int pdgId1,
int pdgId2 ) const
inline

Definition at line 91 of file SUSYCrossSection.h.

91{ return process(id, finalState(pdgId1, pdgId2)); }

◆ process() [2/2]

SUSY::CrossSectionDB::Process SUSY::CrossSectionDB::process ( int id,
int proc = 0 ) const

Definition at line 206 of file SUSYCrossSection.cxx.

207{
208 // for background x-sections, use the PMG tool
209 if(proc==0 && m_usePMGTool) {
210 return Process( id, m_pmgxs->getSampleName(id), m_pmgxs->getAMIXsection(id), m_pmgxs->getKfactor(id), m_pmgxs->getFilterEff(id), m_pmgxs->getXsectionUncertainty(id), -1, -1 );
211 } else {
212 const Key k(id, proc);
213 xsDB_t::const_iterator pos = m_cache.find(k);
214 if (pos != m_cache.end()) {
215 return pos->second;
216 } else {
217 pos = m_xsectDB.find(k);
218 if (pos != m_xsectDB.end()) {
219 return pos->second;
220 }
221 }
222 }
223 return Process();
224}

◆ rawxsect() [1/2]

float SUSY::CrossSectionDB::rawxsect ( int id,
int pdgId1,
int pdgId2 ) const
inline

Definition at line 100 of file SUSYCrossSection.h.

100{ return rawxsect(id, finalState(pdgId1, pdgId2)); }
float rawxsect(int id, int proc=0) const

◆ rawxsect() [2/2]

float SUSY::CrossSectionDB::rawxsect ( int id,
int proc = 0 ) const
inline

Definition at line 99 of file SUSYCrossSection.h.

99{ return process(id, proc).xsect(); }

◆ rel_uncertainty() [1/2]

float SUSY::CrossSectionDB::rel_uncertainty ( int id,
int pdgId1,
int pdgId2 ) const
inline

Definition at line 106 of file SUSYCrossSection.h.

106{ return rel_uncertainty(id, finalState(pdgId1, pdgId2)); }
float rel_uncertainty(int id, int proc=0) const

◆ rel_uncertainty() [2/2]

float SUSY::CrossSectionDB::rel_uncertainty ( int id,
int proc = 0 ) const
inline

Definition at line 105 of file SUSYCrossSection.h.

105{ return process(id, proc).relunc(); }

◆ setExtended()

void SUSY::CrossSectionDB::setExtended ( bool isExtended = true)
inline

Definition at line 85 of file SUSYCrossSection.h.

85{ m_extended = isExtended; };

◆ setUsePMGTool()

void SUSY::CrossSectionDB::setUsePMGTool ( bool usePMGTool = true)
inline

Definition at line 86 of file SUSYCrossSection.h.

86{ m_usePMGTool = usePMGTool; };

◆ sumweight() [1/2]

float SUSY::CrossSectionDB::sumweight ( int id,
int pdgId1,
int pdgId2 ) const
inline

Definition at line 108 of file SUSYCrossSection.h.

108{ return sumweight(id, finalState(pdgId1, pdgId2)); }

◆ sumweight() [2/2]

float SUSY::CrossSectionDB::sumweight ( int id,
int proc = 0 ) const
inline

Definition at line 107 of file SUSYCrossSection.h.

107{ return process(id, proc).sumweight(); }

◆ xsectTimesEff() [1/2]

float SUSY::CrossSectionDB::xsectTimesEff ( int id,
int pdgId1,
int pdgId2 ) const
inline

Definition at line 98 of file SUSYCrossSection.h.

98{ return xsectTimesEff(id, finalState(pdgId1, pdgId2)); }
float xsectTimesEff(int id, int proc=0) const

◆ xsectTimesEff() [2/2]

float SUSY::CrossSectionDB::xsectTimesEff ( int id,
int proc = 0 ) const
inline

Definition at line 94 of file SUSYCrossSection.h.

94 {
95 Process p = process(id, proc);
96 return p.xsect() * p.kfactor() * p.efficiency();
97 }

Member Data Documentation

◆ m_cache

xsDB_t SUSY::CrossSectionDB::m_cache
private

Definition at line 129 of file SUSYCrossSection.h.

◆ m_extended

bool SUSY::CrossSectionDB::m_extended
private

Definition at line 116 of file SUSYCrossSection.h.

◆ m_pmgxs

asg::AnaToolHandle<PMGTools::IPMGCrossSectionTool> SUSY::CrossSectionDB::m_pmgxs
private

Definition at line 125 of file SUSYCrossSection.h.

◆ m_usePMGTool

bool SUSY::CrossSectionDB::m_usePMGTool
private

Definition at line 117 of file SUSYCrossSection.h.

◆ m_xsectDB

xsDB_t SUSY::CrossSectionDB::m_xsectDB
private

Definition at line 128 of file SUSYCrossSection.h.


The documentation for this class was generated from the following files: