CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
generateStandaloneCode Namespace Reference

Functions

def main
 

Function Documentation

def generateStandaloneCode.main ( )

Definition at line 5 of file generateStandaloneCode.py.

References join().

5 
6 def main():
7  path_formats = join(os.environ['CMSSW_BASE'],
8  'src/CondFormats/BTauObjects')
9  path_tools = join(os.environ['CMSSW_BASE'],
10  'src/RecoBTag/PerformanceDB/test')
11 
12  # headers
13  file_h = join(path_tools, 'BTagCalibrationStandalone.h')
14  print 'Creating', file_h
15  with open(file_h, 'w') as fout:
16  for fname in ['BTagEntry.h',
17  'BTagCalibration.h',
18  'BTagCalibrationReader.h']:
19  with open(join(path_formats, 'interface', fname)) as fin:
20  for line in fin:
21  if (line.startswith('#include "CondFormats') or
22  'COND_SERIALIZABLE' in line):
23  continue
24  fout.write(line)
25  fout.write('\n\n')
26 
27  # implementation
28  file_cc = join(path_tools, 'BTagCalibrationStandalone.cc')
29  print 'Creating', file_cc
30  with open(file_cc, 'w') as fout:
31  fout.write('#include "BTagCalibrationStandalone.h"\n')
32  fout.write('#include <iostream>\n')
33  fout.write('#include <exception>\n')
34  for fname in ['BTagEntry.cc',
35  'BTagCalibration.cc',
36  'BTagCalibrationReader.cc']:
37  with open(join(path_formats, 'src', fname)) as fin:
38  err_on_line = -3
39  for line_no, line in enumerate(fin):
40  if (line.startswith('#include "CondFormats') or
41  line.startswith('#include "FWCore')):
42  continue
43  elif 'throw cms::Exception' in line:
44  line = 'std::cerr << "ERROR in BTagCalibration: "\n'
45  err_on_line = line_no
46  elif line_no == err_on_line + 2:
47  line += 'throw std::exception();\n'
48  fout.write(line)
49  fout.write('\n\n')
50 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18