ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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);
128 
129 }

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)); }

◆ 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(); }

◆ 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 }

◆ 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  {
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)); }

◆ 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)); }

◆ 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)); }

◆ 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:
SUSY::CrossSectionDB::m_usePMGTool
bool m_usePMGTool
Definition: SUSYCrossSection.h:117
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
SUSY::finalState
unsigned int finalState(const int SUSY_Spart1_pdgId, const int SUSY_Spart2_pdgId)
Definition: SUSYCrossSection.cxx:227
checkFileSG.line
line
Definition: checkFileSG.py:75
SUSY::CrossSectionDB::Process::efficiency
float efficiency() const
Definition: SUSYCrossSection.h:52
asg::AnaToolHandle::retrieve
StatusCode retrieve()
initialize the tool
AthenaPoolExample_ReadWrite.Key
Key
Definition: AthenaPoolExample_ReadWrite.py:53
SUSY::CrossSectionDB::my_find
xsDB_t::iterator my_find(const int proc)
Definition: SUSYCrossSection.cxx:159
Make4DCorrelationMatrix.inFiles
list inFiles
Definition: Make4DCorrelationMatrix.py:59
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
CscCalibQuery.fullPath
string fullPath
Definition: CscCalibQuery.py:360
asg::AnaToolHandle::setTypeAndName
void setTypeAndName(const std::string &val_typeAndName)
set the value of type and name
skel.it
it
Definition: skel.GENtoEVGEN.py:396
SUSY::CrossSectionDB::Process::xsect
float xsect() const
Definition: SUSYCrossSection.h:50
PMGTools::IPMGCrossSectionTool::getXsectionUncertainty
virtual double getXsectionUncertainty(const int dsid) const =0
return the cross-section uncertainty for DSID
SUSY::CrossSectionDB::efficiency
float efficiency(int id, int proc=0) const
Definition: SUSYCrossSection.h:103
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SUSY::CrossSectionDB::setUsePMGTool
void setUsePMGTool(bool usePMGTool=true)
Definition: SUSYCrossSection.h:86
PMGTools::IPMGCrossSectionTool::readInfosFromFiles
virtual bool readInfosFromFiles(std::vector< std::string >)=0
read infos from file, store them in the structure and make a vector that keeps all of them
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::IPMGCrossSectionTool::getFilterEff
virtual double getFilterEff(const int dsid) const =0
return filter efficiency for DSID
beamspotman.stat
stat
Definition: beamspotman.py:266
SUSY::CrossSectionDB::Process::name
const std::string & name() const
Definition: SUSYCrossSection.h:49
SUSY::CrossSectionDB::Process::relunc
float relunc() const
Definition: SUSYCrossSection.h:53
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
mc.proc
proc
Definition: mc.PhPy8EG_A14NNPDF23_gg4l_example.py:22
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
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
PMGTools::IPMGCrossSectionTool::getSampleName
virtual std::string getSampleName(const int dsid) const =0
return the sample name for DSID
PMGTools::IPMGCrossSectionTool::getKfactor
virtual double getKfactor(const int dsid) const =0
return the k-factor for DSID
SUSY::CrossSectionDB::Process::sumweight
float sumweight() const
Definition: SUSYCrossSection.h:54
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::m_pmgxs
asg::AnaToolHandle< PMGTools::IPMGCrossSectionTool > m_pmgxs
Definition: SUSYCrossSection.h:125
PMGTools::IPMGCrossSectionTool::getAMIXsection
virtual double getAMIXsection(const int dsid) const =0
return the AMI cross-section for DSID