Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:37

0001 #! /bin/env python
0002 
0003 from argparse import ArgumentParser
0004 from RecoBTag.CTagging.helpers import get_vars
0005 import os
0006 import FWCore.ParameterSet.Config as cms
0007 import hashlib
0008 from pdb import set_trace
0009 
0010 parser = ArgumentParser('''This script produces the CMSSW configuration to provide to the Charm Tagging discriminators.
0011 WARNING: It automatically overwrites the official CMSSW file in the proper location! Use git commands to restore previous settings. ''')
0012 parser.add_argument('CvsLXML', help='XML Weight file of the Charm vs Light training')
0013 parser.add_argument('CvsBXML', help='XML Weight file of the Charm vs B training')
0014 args = parser.parse_args()
0015 
0016 if not os.path.isfile(args.CvsLXML):
0017    raise ValueError('File %s does not exists!' % args.CvsLXML)
0018 if not os.path.isfile(args.CvsBXML):
0019    raise ValueError('File %s does not exists!' % args.CvsBXML)
0020 
0021 with open(args.CvsLXML) as CvsLXML:
0022    sha1_CvsLXML = hashlib.sha1(CvsLXML.read()).hexdigest()
0023 
0024 with open(args.CvsBXML) as CvsBXML:
0025    sha1_CvsBXML = hashlib.sha1(CvsBXML.read()).hexdigest()
0026 
0027 CvsLXML_vpset = cms.VPSet(
0028    *get_vars(args.CvsLXML, False) #False: do not mimick FileInPath functionalities and take the bare path as the file path
0029     )
0030 CvsBXML_vpset = cms.VPSet(
0031    *get_vars(args.CvsBXML, False)
0032     )
0033 
0034 with open('%s/src/RecoBTag/CTagging/python/training_settings.py' % os.environ['CMSSW_BASE'], 'w') as output:
0035    output.write('import FWCore.ParameterSet.Config as cms\n')
0036    output.write('''
0037 ## IMPORTANT!
0038 ## This file was automatically generated by RecoBTag/CTagging/test/dump_training_vars_cfg.py
0039 ## with input xml files:
0040 ##    - C vs L: %s sha1 checksum: %s
0041 ##    - C vs B: %s sha1 checksum: %s 
0042 
0043 ''' % (args.CvsLXML, sha1_CvsLXML, args.CvsBXML, sha1_CvsBXML))
0044    output.write('c_vs_l_vars_vpset = %s\n' % CvsLXML_vpset.__repr__())
0045    output.write('\n\n')
0046    output.write('c_vs_b_vars_vpset = %s\n' % CvsBXML_vpset.__repr__())
0047    
0048