Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
CondFormats
BTauObjects
src
BTagCalibration.cc
Go to the documentation of this file.
1
#include <fstream>
2
#include <sstream>
3
4
#include "
CondFormats/BTauObjects/interface/BTagCalibration.h
"
5
#include "
FWCore/Utilities/interface/Exception.h
"
6
7
8
BTagCalibration::BTagCalibration
(
const
std::string
&taggr):
9
tagger_(taggr)
10
{}
11
12
BTagCalibration::BTagCalibration
(
const
std::string
&taggr,
13
const
std::string
&
filename
):
14
tagger_(taggr)
15
{
16
std::ifstream ifs(filename);
17
readCSV
(ifs);
18
ifs.close();
19
}
20
21
void
BTagCalibration::addEntry
(
const
BTagEntry
&entry)
22
{
23
data_
[
token
(entry.
params
)].push_back(entry);
24
}
25
26
const
std::vector<BTagEntry>&
BTagCalibration::getEntries
(
27
const
BTagEntry::Parameters
&par)
const
28
{
29
std::string
tok
=
token
(par);
30
if
(!
data_
.count(tok)) {
31
throw
cms::Exception
(
"BTagCalibration"
)
32
<<
"(OperatingPoint, measurementType, sysType) not available: "
33
<<
tok
;
34
}
35
return
data_
.at(tok);
36
}
37
38
void
BTagCalibration::readCSV
(
const
std::string
&
s
)
39
{
40
std::stringstream buff(s);
41
readCSV
(buff);
42
}
43
44
void
BTagCalibration::readCSV
(std::istream &
s
)
45
{
46
std::string
line
;
47
48
// firstline might be the header
49
getline(s,line);
50
if
(line.find(
"OperatingPoint"
) == std::string::npos) {
51
addEntry
(
BTagEntry
(line));
52
}
53
54
while
(getline(s,line)) {
55
line =
BTagEntry::trimStr
(line);
56
if
(line.empty()) {
// skip empty lines
57
continue
;
58
}
59
addEntry
(
BTagEntry
(line));
60
}
61
}
62
63
void
BTagCalibration::makeCSV
(std::ostream &
s
)
const
64
{
65
s <<
tagger_
<<
";"
<<
BTagEntry::makeCSVHeader
();
66
for
(
std::map
<
std::string
, std::vector<BTagEntry> >::const_iterator
i
67
=
data_
.cbegin();
i
!=
data_
.cend(); ++
i
) {
68
const
std::vector<BTagEntry> &vec =
i
->second;
69
for
(std::vector<BTagEntry>::const_iterator
j
70
= vec.cbegin();
j
!= vec.cend(); ++
j
) {
71
s <<
j
->makeCSVLine();
72
}
73
}
74
}
75
76
std::string
BTagCalibration::makeCSV
()
const
77
{
78
std::stringstream buff;
79
makeCSV
(buff);
80
return
buff.str();
81
}
82
83
std::string
BTagCalibration::token
(
const
BTagEntry::Parameters
&par)
84
{
85
std::stringstream buff;
86
buff << par.
operatingPoint
<<
", "
87
<< par.
measurementType
<<
", "
88
<< par.
sysType
;
89
return
buff.str();
90
}
BTagEntry::Parameters::sysType
std::string sysType
Definition:
BTagEntry.h:41
i
int i
Definition:
DBlmapReader.cc:9
BTagEntry::trimStr
static std::string trimStr(std::string str)
Definition:
BTagEntry.cc:251
Exception
Definition:
hltDiff.cc:318
BTagEntry::makeCSVHeader
static std::string makeCSVHeader()
Definition:
BTagEntry.cc:218
BTagEntry
Definition:
BTagEntry.h:24
BTagCalibration::readCSV
void readCSV(std::istream &s)
Definition:
BTagCalibration.cc:44
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:255
BTagEntry::Parameters
Definition:
BTagEntry.h:38
BTagCalibration::getEntries
const std::vector< BTagEntry > & getEntries(const BTagEntry::Parameters &par) const
Definition:
BTagCalibration.cc:26
geometryCSVtoXML.line
tuple line
Definition:
geometryCSVtoXML.py:15
python.multivaluedict.map
def map
Definition:
multivaluedict.py:125
BTagEntry::Parameters::operatingPoint
OperatingPoint operatingPoint
Definition:
BTagEntry.h:39
j
int j
Definition:
DBlmapReader.cc:9
BTagCalibration::makeCSV
std::string makeCSV() const
Definition:
BTagCalibration.cc:76
BTagCalibration::BTagCalibration
BTagCalibration()
Definition:
BTagCalibration.h:30
Exception.h
BTagEntry::params
Parameters params
Definition:
BTagEntry.h:79
alignCSCRings.s
list s
Definition:
alignCSCRings.py:91
BTagCalibration::addEntry
void addEntry(const BTagEntry &entry)
Definition:
BTagCalibration.cc:21
lut2db_cfg.filename
tuple filename
Definition:
lut2db_cfg.py:20
BTagCalibration::readCSV
void readCSV(const std::string &s)
Definition:
BTagCalibration.cc:38
BTagCalibration::tagger_
std::string tagger_
Definition:
BTagCalibration.h:48
BTagEntry::Parameters::measurementType
std::string measurementType
Definition:
BTagEntry.h:40
BTagCalibration.h
BTagCalibration::token
static std::string token(const BTagEntry::Parameters &par)
Definition:
BTagCalibration.cc:83
BTagCalibration::data_
std::map< std::string, std::vector< BTagEntry > > data_
Definition:
BTagCalibration.h:49
results_mgr.tok
tuple tok
Definition:
results_mgr.py:63
Generated for CMSSW Reference Manual by
1.8.5