def _setup_configfiles(self, Testboard): """ Changes config files in the already copied test directory according to test definitions from elComandante's init file. """ # Delete all root files which are already in the directory root_files = glob.glob(Testboard.testdir + '/*.root') for f in root_files: os.remove(f) # Change testboard name if Testboard.DTB and os.path.isfile(Testboard.testdir + "/tb"): self._config_file_content_substitute(Testboard.testdir + "/tb", {"id": Testboard.address}) else: self._config_file_content_substitute( Testboard.testdir + "/configParameters.dat", {"testboardName": Testboard.address}) # Get test specific config parameters (if available) params = () try: params = self.init.items("Test " + self.test.testname) except: return for par in params: file = par[0] if '.cfg' in file: section, pair = par[1].split(':') key, value = pair.split('=') config_file = BetterConfigParser() config_file.read(Testboard.testdir + "/" + file) config_file.set(section, key, value) write_file = open(Testboard.testdir + "/" + file, 'write') config_file.write(write_file) write_file.close() continue # Check for valid keys that represent config files elif "testParameters" in file or "dacParameters" in file or "configParameters" in file: pass elif "tbmParameters" in file or "tbParameters" in file: pass else: continue encoded_keys = par[1].split(",") keys = {} for key in encoded_keys: key = key.split("=", 2) if len(key) != 2: continue keys[key[0]] = key[1] if len(file) < 4 or file[-4:] != ".dat": file += ".dat" self._config_file_content_substitute( Testboard.testdir + "/" + file, keys)
def _setup_configfiles(self, Testboard): """ Changes config files in the already copied test directory according to test definitions from elComandante's init file. """ # Delete all root files which are already in the directory root_files = glob.glob(Testboard.testdir+'/*.root') for f in root_files: os.remove(f) # Change testboard name if Testboard.DTB and os.path.isfile(Testboard.testdir + "/tb"): self._config_file_content_substitute(Testboard.testdir + "/tb", {"id":Testboard.address}) else: self._config_file_content_substitute(Testboard.testdir + "/configParameters.dat", {"testboardName":Testboard.address}) # Get test specific config parameters (if available) params = () try: params = self.init.items("Test " + self.test.testname) except: return for par in params: file = par[0] if '.cfg' in file: section,pair = par[1].split(':') key,value = pair.split('=') config_file = BetterConfigParser() config_file.read(Testboard.testdir + "/" + file) config_file.set(section,key,value) write_file = open(Testboard.testdir + "/" + file, 'write') config_file.write(write_file) write_file.close() continue # Check for valid keys that represent config files elif "testParameters" in file or "dacParameters" in file or "configParameters" in file: pass elif "tbmParameters" in file or "tbParameters" in file: pass else: continue encoded_keys = par[1].split(",") keys = {} for key in encoded_keys: key = key.split("=", 2) if len(key) != 2: continue keys[key[0]] = key[1] if len(file) < 4 or file[-4:] != ".dat": file += ".dat" self._config_file_content_substitute(Testboard.testdir + "/" + file, keys)
canvas = ROOT.TCanvas("lheV_pt","lheV_pt",600,600) ROOT.gPad.SetLogy() histo.Draw() histo1.Draw('SAME') #print histo.Integral(100,300) #print histo1.Integral(100,300) histo1.SetLineColor(ROOT.kRed) canvas.Print("validation_lheV_pt.pdf","pdf") if opts.weights: weight_map = get_weights(fileList,lheBin) config.set('lheWeights', 'weights_per_bin', '%s' %weight_map) f = open('13TeVconfig/lheWeights', 'w') for section in config.sections(): if not section == 'lheWeights': config.remove_section(section) config.write(f) f.close() elif opts.apply: weight_map = eval(config.get('lheWeights', 'weights_per_bin')) if opts.apply: apply_weights(fileList,weight_map,prefix+inclusive,newpostfix) if opts.validate: do_validation(fileList,inclusive,newpostfix)
histo1.Add(h_tmp1) histo.Add(h_tmp) tfile.Close() del tree canvas = ROOT.TCanvas("lheV_pt", "lheV_pt", 600, 600) ROOT.gPad.SetLogy() histo.Draw() histo1.Draw('SAME') print histo.Integral(100, 300) print histo1.Integral(100, 300) histo1.SetLineColor(ROOT.kRed) canvas.Print("validation_lheV_pt.pdf", "pdf") if opts.weights: weight_map = get_weights(fileList, lheBin) config.set('LHEWeights', 'weights_per_bin', '%s' % weight_map) f = open('8TeVconfig/lhe_weights', 'w') for section in config.sections(): if not section == 'LHEWeights': config.remove_section(section) config.write(f) f.close() elif opts.apply: weight_map = eval(config.get('LHEWeights', 'weights_per_bin')) if opts.apply: apply_weights(fileList, weight_map, prefix + inclusive, newpostfix) if opts.validate: do_validation(fileList, inclusive, newpostfix)