Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
RecoBTag
PerformanceDB
python
generateStandaloneCode.py
Go to the documentation of this file.
1
import
os
2
from
os.path
import
join
3
4
5
def
main
():
6
path_formats =
join
(os.environ[
'CMSSW_BASE'
],
7
'src/CondFormats/BTauObjects'
)
8
path_tools =
join
(os.environ[
'CMSSW_BASE'
],
9
'src/RecoBTag/PerformanceDB/test'
)
10
11
# headers
12
file_h =
join
(path_tools,
'BTagCalibrationStandalone.h'
)
13
print
'Creating'
, file_h
14
with open(file_h,
'w'
)
as
fout:
15
for
fname
in
[
'BTagEntry.h'
,
16
'BTagCalibration.h'
,
17
'BTagCalibrationReader.h'
]:
18
with open(
join
(path_formats,
'interface'
, fname))
as
fin:
19
for
line
in
fin:
20
if
(line.startswith(
'#include "CondFormats'
)
or
21
'COND_SERIALIZABLE'
in
line):
22
continue
23
fout.write(line)
24
fout.write(
'\n\n'
)
25
26
# implementation
27
file_cc =
join
(path_tools,
'BTagCalibrationStandalone.cc'
)
28
print
'Creating'
, file_cc
29
with open(file_cc,
'w'
)
as
fout:
30
fout.write(
'#include "BTagCalibrationStandalone.h"\n'
)
31
fout.write(
'#include <iostream>\n'
)
32
fout.write(
'#include <exception>\n'
)
33
for
fname
in
[
'BTagEntry.cc'
,
34
'BTagCalibration.cc'
,
35
'BTagCalibrationReader.cc'
]:
36
with open(
join
(path_formats,
'src'
, fname))
as
fin:
37
err_on_line = -3
38
for
line_no, line
in
enumerate(fin):
39
if
(line.startswith(
'#include "CondFormats'
)
or
40
line.startswith(
'#include "FWCore'
)):
41
continue
42
elif
'throw cms::Exception'
in
line:
43
line =
'std::cerr << "ERROR in BTagCalibration: "\n'
44
err_on_line = line_no
45
elif
line_no == err_on_line + 2:
46
line +=
'throw std::exception();\n'
47
fout.write(line)
48
fout.write(
'\n\n'
)
49
50
51
if
__name__ ==
'__main__'
:
52
main
()
generateStandaloneCode.main
def main
Definition:
generateStandaloneCode.py:5
join
static std::string join(char **cmd)
Definition:
RemoteFile.cc:18
main
Definition:
main.py:1
Generated for CMSSW Reference Manual by
1.8.5