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 7 of file generateStandaloneCode.py.

References join().

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