ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SampleXsection Class Reference

#include <SampleXsection.h>

Collaboration diagram for SampleXsection:

Public Types

enum  showering {
  pythia =0, herwig =1, sherpa =2, pythia8 =4,
  herwigpp =5, sherpa21 =6, amcatnlopythia8 =7, herwigpp713 =8,
  sherpa228 =9, sherpa2210 =10, herwigpp721 =11, sherpa2212 =12,
  amcatnloherwig7 =13, unknown =14
}
 

Public Member Functions

 SampleXsection ()
 
 SampleXsection (const SampleXsection &xs)
 
 ~SampleXsection ()
 
SampleXsectionoperator= (const SampleXsection &xs)
 
bool readFromFile (const char *fName)
 
void setSample (const int dsid, const double xSect, const double kFact, const showering shower, const double xSectDw, const double xSectUp)
 
double getRawXsection (const int dsid) const
 
double getKfactor (const int dsid) const
 
double getXsection (const int dsid) const
 
double getXsectionUp (const int dsid) const
 
double getXsectionDown (const int dsid) const
 
std::pair< double, double > getXsectionDownUp (const int dsid) const
 
showering getShowering (const int dsid) const
 
std::string getShoweringString (const int dsid) const
 
int getShoweringIndex (const int dsid) const
 
void setTranslator (const std::unordered_map< std::string, std::string > &map)
 

Private Member Functions

showering applyTranslation (const showering shower) const
 
std::string showerToString (const showering shower) const
 
showering stringToShower (const std::string &name) const
 

Private Attributes

std::map< int, std::pair< double, double > > m_Xsects
 
std::map< int, std::pair< double, double > > m_Uncert
 
std::map< int, showeringm_Showering
 
std::unordered_map< std::string, std::string > m_translator
 

Detailed Description

Definition at line 19 of file SampleXsection.h.

Member Enumeration Documentation

◆ showering

Enumerator
pythia 
herwig 
sherpa 
pythia8 
herwigpp 
sherpa21 
amcatnlopythia8 
herwigpp713 
sherpa228 
sherpa2210 
herwigpp721 
sherpa2212 
amcatnloherwig7 
unknown 

Definition at line 21 of file SampleXsection.h.

21  {
22  pythia=0,
23  herwig=1,
24  sherpa=2,
25  pythia8=4,
26  herwigpp=5,
27  sherpa21=6,
29  herwigpp713=8,
30  sherpa228=9,
31  sherpa2210=10,
32  herwigpp721=11,
33  sherpa2212=12,
34  amcatnloherwig7=13,
35  unknown=14
36  };

Constructor & Destructor Documentation

◆ SampleXsection() [1/2]

SampleXsection::SampleXsection ( )
inline

Definition at line 38 of file SampleXsection.h.

38 : m_Xsects() {}

◆ SampleXsection() [2/2]

SampleXsection::SampleXsection ( const SampleXsection xs)
inline

Definition at line 39 of file SampleXsection.h.

39 : m_Xsects(xs.m_Xsects) {}

◆ ~SampleXsection()

SampleXsection::~SampleXsection ( )
inline

Definition at line 40 of file SampleXsection.h.

40 {}

Member Function Documentation

◆ applyTranslation()

SampleXsection::showering SampleXsection::applyTranslation ( const showering  shower) const
private

Definition at line 183 of file SampleXsection.cxx.

183  {
184  const std::string& stringName = showerToString(shower);
185 
186  // check the map
187  auto itr = m_translator.find(stringName);
188  if (itr == m_translator.end()) {
189  return shower;
190  } else {
191  // need to apply the translation
192  return stringToShower(itr->second);
193  }
194 }

◆ getKfactor()

double SampleXsection::getKfactor ( const int  dsid) const

Definition at line 95 of file SampleXsection.cxx.

95  {
96  map<int, pair<double, double> >::const_iterator it = m_Xsects.find(dsid);
97  if (it != m_Xsects.end()) return it->second.second;
98 
99  return -1;
100 }

◆ getRawXsection()

double SampleXsection::getRawXsection ( const int  dsid) const

Definition at line 88 of file SampleXsection.cxx.

88  {
89  map<int, pair<double, double> >::const_iterator it = m_Xsects.find(dsid);
90  if (it != m_Xsects.end()) return it->second.first;
91 
92  return -1;
93 }

◆ getShowering()

SampleXsection::showering SampleXsection::getShowering ( const int  dsid) const

Definition at line 131 of file SampleXsection.cxx.

131  {
132  map<int, showering >::const_iterator it = m_Showering.find(dsid);
133  if (it != m_Showering.end()) {
134 
135  showering shower = it->second;
136  // apply the translation of set
137  shower = applyTranslation(shower);
138 
139  return shower;
140  }
141 
142  return unknown;
143 }

◆ getShoweringIndex()

int SampleXsection::getShoweringIndex ( const int  dsid) const

Definition at line 150 of file SampleXsection.cxx.

150  {
151  // S.Korn: labelling taken from here:
152  // https://twiki.cern.ch/twiki/bin/view/AtlasProtected/BTagRecommendationsRelease22
153 
154  showering shower = getShowering(dsid);
155 
156  if (shower == showering::pythia) return 0;
157  else if (shower == showering::herwigpp || shower == showering::herwig) // use the herwig++ maps for the few fortran
158  // herwig samples we may have
159  return 1;
160  else if (shower == showering::pythia8) return 2;
161  else if (shower == showering::sherpa) return 3;
162  else if (shower == showering::sherpa21) return 4;
163  else if (shower == showering::amcatnlopythia8) return 5;
164  else if (shower == showering::herwigpp713) return 6;
165  else if (shower == showering::sherpa228) return 7;
166  else if (shower == showering::sherpa2210) return 8;
167  else if (shower == showering::herwigpp721) return 9;
168  else if (shower == showering::sherpa2212) return 10;
169  else if (shower == showering::amcatnloherwig7) return 11;
170  else {
171  std::cout <<
172  "==========================================================================================================================================="
173  << std::endl;
174  std::cout << "ERROR:TopDataPreparation: The DSID " << dsid <<
175  " does not have a showering algorithm defined!!! This is needed for MC/MC SF!!! ---> EXIT." << std::endl;
176  std::cout << "\t" << std::endl;
177  exit(1);
178  }
179 
180  return 0;
181 }

◆ getShoweringString()

std::string SampleXsection::getShoweringString ( const int  dsid) const

Definition at line 145 of file SampleXsection.cxx.

146 {
148 }

◆ getXsection()

double SampleXsection::getXsection ( const int  dsid) const

Definition at line 102 of file SampleXsection.cxx.

102  {
103  map<int, pair<double, double> >::const_iterator it = m_Xsects.find(dsid);
104  if (it != m_Xsects.end()) return (it->second.first) * (it->second.second);
105 
106  return -1;
107 }

◆ getXsectionDown()

double SampleXsection::getXsectionDown ( const int  dsid) const

Definition at line 109 of file SampleXsection.cxx.

109  {
110  map<int, pair<double, double> >::const_iterator it = m_Uncert.find(dsid);
111  if (it != m_Uncert.end()) return it->second.first;
112 
113  return -1;
114 }

◆ getXsectionDownUp()

pair< double, double > SampleXsection::getXsectionDownUp ( const int  dsid) const

Definition at line 123 of file SampleXsection.cxx.

123  {
124  map<int, pair<double, double> >::const_iterator it = m_Uncert.find(dsid);
125  if (it != m_Uncert.end()) return it->second;
126 
127  pair<double, double> temp = pair<double, double>(-1, -1);
128  return temp;
129 }

◆ getXsectionUp()

double SampleXsection::getXsectionUp ( const int  dsid) const

Definition at line 116 of file SampleXsection.cxx.

116  {
117  map<int, pair<double, double> >::const_iterator it = m_Uncert.find(dsid);
118  if (it != m_Uncert.end()) return it->second.second;
119 
120  return -1;
121 }

◆ operator=()

SampleXsection & SampleXsection::operator= ( const SampleXsection xs)

Definition at line 15 of file SampleXsection.cxx.

15  {
16  if (this != &xs) {
17  m_Xsects = xs.m_Xsects;
18  m_Uncert = xs.m_Uncert;
19  }
20  return *this;
21 }

◆ readFromFile()

bool SampleXsection::readFromFile ( const char *  fName)

Definition at line 23 of file SampleXsection.cxx.

23  {
24  ifstream in(fName);
25 
26  if (!in) return false;
27 
28  for (; !in.eof(); ) {
29  string line;
30  if (!getline(in, line)) break;
31  if (!line.empty() && line[0] != '#') {
32  istringstream istr(line);
33  int dsid = -1;
34  double xSect, kFact, xSectDw, xSectUp;
35  string s_shower, s_xSectDw, s_xSectUp;
36  showering shower;
37  istr >> dsid >> xSect >> kFact >> s_shower >> s_xSectDw >> s_xSectUp;
38  if (!s_shower.empty() && s_shower[0] != '#') {
39  shower = stringToShower(s_shower);
40  if (shower == showering::unknown) {
41  cerr <<
42  "ERROR!! TopDataPreparation::SampleXsection::readFromFile: unknown showering (which is needed for btagging SF!!!) : "
43  << s_shower << " for DSID= " << dsid << endl;
44  }
45 
46  if (!s_xSectDw.empty() && s_xSectDw[0] != '#') {
47  xSectDw = atof(s_xSectDw.c_str());
48  if (!s_xSectUp.empty()) {
49  xSectUp = atof(s_xSectUp.c_str());
50  } else {
51  cerr << "ERROR!! SampleXsection::readFromFile: xSectDw of " << dsid << " is defined ( " << s_xSectDw <<
52  " ), but not xSectUp" << endl;
53  xSectUp = -1.;
54  }
55  } else {
56  xSectDw = -1.;
57  xSectUp = -1.;
58  }
59  }// !s_showering.empty()
60  else {
61  xSectDw = -1.;
62  xSectUp = -1.;
63  shower = unknown;
64  }
65  setSample(dsid, xSect, kFact, shower, xSectDw, xSectUp);
66  }
67  }
68 
69  in.close();
70  return true;
71 }

◆ setSample()

void SampleXsection::setSample ( const int  dsid,
const double  xSect,
const double  kFact,
const showering  shower,
const double  xSectDw,
const double  xSectUp 
)

Definition at line 73 of file SampleXsection.cxx.

74  {
75  if (dsid < 0) return;
76 
77  map<int, pair<double, double> >::const_iterator it = m_Xsects.find(dsid);
78  if (it != m_Xsects.end()) {
79  cerr << "ERROR!! SampleXsection::setSample: duplicate entry ! DSID= " << dsid << endl;
80  //cerr << "ERROR!! SampleXsection::setSample: xSect=" << xSect << "\told xSect=" <<
81  // it->second.first <<endl;
82  }
83  m_Xsects[dsid] = pair<double, double>(xSect, kFact);
84  m_Uncert[dsid] = pair<double, double>(xSectDw, xSectUp);
85  m_Showering[dsid] = shower;
86 }

◆ setTranslator()

void SampleXsection::setTranslator ( const std::unordered_map< std::string, std::string > &  map)
inline

Definition at line 57 of file SampleXsection.h.

57 {m_translator = map;}

◆ showerToString()

std::string SampleXsection::showerToString ( const showering  shower) const
private

Definition at line 196 of file SampleXsection.cxx.

196  {
197  if (shower == showering::pythia) return "pythia";
198  else if (shower == showering::herwig) return "herwig";
199  else if (shower == showering::herwigpp) return "herwig";
200  else if (shower == showering::sherpa) return "sherpa";
201  else if (shower == showering::sherpa21) return "sherpa21";
202  else if (shower == showering::pythia8) return "pythia8";
203  else if (shower == showering::amcatnlopythia8) return "amcatnlopythia8";
204  else if (shower == showering::herwigpp713) return "herwigpp713";
205  else if (shower == showering::sherpa228) return "sherpa228";
206  else if (shower == showering::sherpa2210) return "sherpa2210";
207  else if (shower == showering::herwigpp721) return "herwigpp721";
208  else if (shower == showering::sherpa2212) return "sherpa2212";
209  else if (shower == showering::amcatnloherwig7) return "amcatnloherwig7";
210 
211  return "";
212 }

◆ stringToShower()

SampleXsection::showering SampleXsection::stringToShower ( const std::string &  name) const
private

Definition at line 214 of file SampleXsection.cxx.

214  {
215  if (name == "pythia") return showering::pythia;
216  else if (name == "herwig") return showering::herwig;
217  else if (name == "sherpa") return showering::sherpa;
218  else if (name == "sherpa21") return showering::sherpa21;
219  else if (name == "pythia8") return showering::pythia8;
220  else if (name == "herwigpp") return showering::herwigpp;
221  else if (name == "amcatnlopythia8") return showering::amcatnlopythia8;
222  else if (name == "herwigpp713") return showering::herwigpp713;
223  else if (name == "sherpa228") return showering::sherpa228;
224  else if (name == "sherpa2210") return showering::sherpa2210;
225  else if (name == "herwigpp721") return showering::herwigpp721;
226  else if (name == "sherpa2212") return showering::sherpa2212;
227  else if (name == "amcatnloherwig7") return showering::amcatnloherwig7;
228 
229  return showering::unknown;
230 }

Member Data Documentation

◆ m_Showering

std::map<int, showering > SampleXsection::m_Showering
private

Definition at line 62 of file SampleXsection.h.

◆ m_translator

std::unordered_map<std::string, std::string> SampleXsection::m_translator
private

Definition at line 63 of file SampleXsection.h.

◆ m_Uncert

std::map<int, std::pair<double, double> > SampleXsection::m_Uncert
private

Definition at line 61 of file SampleXsection.h.

◆ m_Xsects

std::map<int, std::pair<double, double> > SampleXsection::m_Xsects
private

Definition at line 60 of file SampleXsection.h.


The documentation for this class was generated from the following files:
SampleXsection::sherpa2212
@ sherpa2212
Definition: SampleXsection.h:33
SampleXsection::amcatnlopythia8
@ amcatnlopythia8
Definition: SampleXsection.h:28
temp
Definition: JetEventDict.h:21
SampleXsection::m_Showering
std::map< int, showering > m_Showering
Definition: SampleXsection.h:62
SampleXsection::sherpa
@ sherpa
Definition: SampleXsection.h:24
checkFileSG.line
line
Definition: checkFileSG.py:75
SampleXsection::herwig
@ herwig
Definition: SampleXsection.h:23
SampleXsection::amcatnloherwig7
@ amcatnloherwig7
Definition: SampleXsection.h:34
rootconvert.fName
string fName
Definition: rootconvert.py:5
SampleXsection::setSample
void setSample(const int dsid, const double xSect, const double kFact, const showering shower, const double xSectDw, const double xSectUp)
Definition: SampleXsection.cxx:73
skel.it
it
Definition: skel.GENtoEVGEN.py:423
SampleXsection::showering
showering
Definition: SampleXsection.h:21
SampleXsection::sherpa2210
@ sherpa2210
Definition: SampleXsection.h:31
SampleXsection::herwigpp
@ herwigpp
Definition: SampleXsection.h:26
SampleXsection::m_Uncert
std::map< int, std::pair< double, double > > m_Uncert
Definition: SampleXsection.h:61
Generate_dsid_ranseed.dsid
dsid
Definition: Generate_dsid_ranseed.py:6
SampleXsection::herwigpp713
@ herwigpp713
Definition: SampleXsection.h:29
SampleXsection::herwigpp721
@ herwigpp721
Definition: SampleXsection.h:32
SampleXsection::pythia
@ pythia
Definition: SampleXsection.h:22
SampleXsection::m_translator
std::unordered_map< std::string, std::string > m_translator
Definition: SampleXsection.h:63
SampleXsection::getShowering
showering getShowering(const int dsid) const
Definition: SampleXsection.cxx:131
SampleXsection::sherpa21
@ sherpa21
Definition: SampleXsection.h:27
calibdata.exit
exit
Definition: calibdata.py:236
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition: Control/CxxUtils/Root/StringUtils.cxx:91
SampleXsection::sherpa228
@ sherpa228
Definition: SampleXsection.h:30
SampleXsection::m_Xsects
std::map< int, std::pair< double, double > > m_Xsects
Definition: SampleXsection.h:60
Muon::nsw::unknown
@ unknown
Definition: NSWTriggerElink.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SampleXsection::pythia8
@ pythia8
Definition: SampleXsection.h:25
SampleXsection::unknown
@ unknown
Definition: SampleXsection.h:35
SampleXsection::applyTranslation
showering applyTranslation(const showering shower) const
Definition: SampleXsection.cxx:183
SampleXsection::stringToShower
showering stringToShower(const std::string &name) const
Definition: SampleXsection.cxx:214
SampleXsection::showerToString
std::string showerToString(const showering shower) const
Definition: SampleXsection.cxx:196