def main(): debug = True styled.HEADER('Start shapes for FF productions') styled.HEADER('\n # 0 - prepareConfig') config = analysis_shapes.prepareConfig( analysis_shapes=analysis_shapes, config_file='data/tes_config.yaml', debug=debug ) if debug: import copy config_old = copy.deepcopy(config) # Changing the analysis config to correspond to ff shapes setup config['shifts'] = ['nominal'] old_context = config['context_analysis'] # TODO: context and tags are the same new_context = 'ff_shapes_' + config['context_analysis'] dict_replace(old=old_context, new=new_context, d=config) if debug: from python_wrappers.dictdiffer import DictDiffer print DictDiffer( new_dict=config, old_dict=config_old, show_none=False, show_unchanged=False, ) # Targeted analysis class should be passed produce_shapes_variables(config=config) styled.HEADER('End')
def main(): debug = False logging.info(styled.HEADER('Start')) # styled.HEADER('Start') logging.info(styled.HEADER('# 0 - prepareConfig')) config = analysis_shapes.prepareConfig(analysis_shapes=analysis_shapes, config_file='data/tes_config.yaml', debug=debug) produce_shapes_variables(config=config) logging.info(styled.HEADER('End'))
def main(): styled.HEADER('Start MSSM shapes production') debug = False styled.HEADER('\n # 1 - prepareConfig') config = analysis_shapes_mssm.prepareConfig( analysis_shapes=analysis_shapes_mssm, config_file='data/mssm_legacy_mva_config.yaml', debug=debug) if 'yaml_conf' in config.keys() and config['yaml_conf'] is not None: config = analysis_shapes_mssm.prepareConfig( analysis_shapes=analysis_shapes_mt, config_file=config['yaml_conf'], debug=debug) produce_shapes_variables(config=config) styled.HEADER('End')
def produce_shapes_variables(config): styled.HEADER('\n # 1 - init FF shapes production') shapes = analysis_shapes(**config) styled.HEADER('\n # 2 - setup_logging') shapes.setup_logging( output_file="{}_ff_shapes.log".format(shapes._tag), level=config['log_level'], logger=shapes._logger, ) styled.HEADER('\n # 3 - era evaluation') shapes.evaluateEra() styled.HEADER('\n # 4 - import necessary estimation methods') shapes.importEstimationMethods() styled.HEADER('\n # 5 - evaluating channels (processes, variables,cattegories)') shapes.evaluateChannels() styled.HEADER('\n # 5.5 - invert isolation cuts') for key in shapes.channels.keys(): shapes.channels[key].replace_all_cuts(name='tau_iso', value='byTightIsolationMVArun2017v2DBoldDMwLT2017_2<0.5') styled.HEADER('\n # 6 - add systematics') shapes.evaluateSystematics() # return 0 styled.HEADER('\n # 7 - produce shapes') shapes.produce() styled.HEADER('\n # 8 - convert to synched shapes') shapes_dir = os.path.join('/'.join(os.path.realpath(os.path.dirname(__file__)).split('/')[:-1]), 'converted_shapes') output_file_name = convertToShapes( input_path=shapes._output_file, output_dir=os.path.join(shapes_dir, shapes._output_file[:-5]), channels=['mt'], context='_tes', ) # styled.HEADER(, t '\n # 9 - implement the nominal ploting if you want', bcolors.ENDC styled.HEADER('Output shapes:\n', output_file_name)
def main(): styled.HEADER('Start FES shapes production') debug = True styled.HEADER('\n # 1 - prepareConfig') config = analysis_shapes_et.prepareConfig( analysis_shapes=analysis_shapes_et, config_file='data/et_fes_legacy2017_config.yaml', debug=debug) if config['context_analysis'] == 'mtFes': config = analysis_shapes_mt.prepareConfig( analysis_shapes=analysis_shapes_mt, config_file='data/mt_fes_legacy_config.yaml', debug=debug) elif config['yaml_conf'] is not None: config = analysis_shapes_et.prepareConfig( analysis_shapes=analysis_shapes_mt, config_file=config['yaml_conf'], debug=debug) produce_shapes_variables(config=config) styled.HEADER('End')
def produce_shapes_variables(config): logging.info(styled.HEADER('# 1 - init ControlShapes')) shapes = analysis_shapes(**config) logging.info(styled.HEADER('# 2 - setup_logging')) handler, file_handler = shapes.setup_logging( output_file="{}_controlshapes.log".format(shapes._tag), level=config['log_level'], logger=logging.getLogger(), # shapes._logger, danger=False, add_file_handler=False, add_stream_handler=False, ) # Disabling some printouts # logging.getLogger('shape_producer').setLevel(log.INFO) # logging.getLogger('shape_producer.systematics').setLevel(log.INFO) # logging.getLogger('shape_producer.histogram').setLevel(log.INFO) logging.getLogger('shape_producer.histogram').setLevel(log.DEBUG) if handler is not None: handler.setLevel(log.INFO) # logging.getLogger('shape_producer.histogram').addHandler(handler) if file_handler is not None: file_handler.setLevel(log.DEBUG) logging.info(styled.HEADER('# 3 - era evaluation')) shapes.evaluateEra() logging.info(styled.HEADER('# 4 - import necessary estimation methods')) shapes.importEstimationMethods() logging.info(styled.HEADER('# 5 - evaluating channels (processes, variables,cattegories)')) shapes.evaluateChannels() logging.info(styled.HEADER('# 6 - add systematics')) shapes.evaluateSystematics() logging.info(styled.HEADER('# 7 - produce shapes')) shapes.produce() # TODO: close the output file properly logging.info(styled.HEADER('# 8 - convert to synched shapes')) shapes_dir = os.path.join('/'.join(os.path.realpath(os.path.dirname(__file__)).split('/')[:-1]), 'converted_shapes') output_file_name = convertToShapes( input_path=shapes._output_file, output_dir=os.path.join(shapes_dir, shapes._output_file[:-5]), channels=['mt'], variables=shapes.variables_names, context='_control', use_number_coding=False, ) # logging.info(styled.HEADER( t '\n # 9 - implement the nominal ploting if you want')) logging.info(styled.UNDERLINE(styled.HEADER('Output shapes:'))) if isinstance(output_file_name, string_types): output_file_name = [output_file_name] for o in output_file_name: logging.info(styled.BOLD(styled.HEADER(o)))