Definition at line 8 of file generateStandaloneCode.py.
References join(), and print().
10 path_cms =
join(os.environ[
'CMSSW_BASE'],
'src')
11 path_tools =
join(path_cms,
'CondTools/BTau/test')
14 file_h =
join(path_tools,
'BTagCalibrationStandalone.h')
15 print(
'Creating', file_h)
16 with open(file_h,
'w')
as fout:
17 for fname
in [
'CondFormats/BTauObjects/interface/BTagEntry.h',
18 'CondFormats/BTauObjects/interface/BTagCalibration.h',
19 'CondTools/BTau/interface/BTagCalibrationReader.h']:
20 with open(
join(path_cms, fname))
as fin:
22 if (line.startswith(
'#include "Cond')
or
23 'COND_SERIALIZABLE' in line):
29 file_cc =
join(path_tools,
'BTagCalibrationStandalone.cpp')
30 print(
'Creating', file_cc)
31 with open(file_cc,
'w')
as fout:
32 fout.write(
'#include "BTagCalibrationStandalone.h"\n')
33 fout.write(
'#include <iostream>\n')
34 fout.write(
'#include <exception>\n')
35 for fname
in [
'CondFormats/BTauObjects/src/BTagEntry.cc',
36 'CondFormats/BTauObjects/src/BTagCalibration.cc',
37 'CondTools/BTau/src/BTagCalibrationReader.cc']:
38 with open(
join(path_cms, fname))
as fin:
40 for line_no, line
in enumerate(fin):
41 if (line.startswith(
'#include "Cond')
or
42 line.startswith(
'#include "FWCore')):
48 elif 'throw cms::Exception' in line:
49 line =
'std::cerr << "ERROR in BTagCalibration: "\n'
51 elif line_no == err_on_line + 2:
52 line +=
'throw std::exception();\n'
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)