Changeset View
Changeset View
Standalone View
Standalone View
scripts/countTotalBF.py
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
#!/usr/bin/env python | |||||
import os,sys | |||||
import argparse | |||||
parser = argparse.ArgumentParser( | |||||
description='Guide mark calculation') | |||||
parser.add_argument('-decfile', default='DECAY.DEC') | |||||
parser.add_argument('-particle', default='') | |||||
args = parser.parse_args() | |||||
decFiles = open( args.decfile ) | |||||
inDecay = False | |||||
bfSum = 0.0 | |||||
nDecays = 0 | |||||
for line in decFiles: | |||||
if (inDecay == False) and (line.find('Decay') != -1): | |||||
ss = line.split(' ') | |||||
if ( ss[len(ss)-1].strip() == args.particle ): | |||||
inDecay = True | |||||
print(line) | |||||
continue | |||||
if (inDecay == True) and (line.find('Enddecay') != -1): | |||||
inDecay = False | |||||
break | |||||
if inDecay == True: | |||||
if line[0] == '#' or len(line)<2: # This is comment, skip | |||||
continue | |||||
print(line.strip()) | |||||
bfSum += float(line.strip().split(' ')[0]) | |||||
nDecays += 1 | |||||
print('Counted ',nDecays,' decays with total BF = ',bfSum) | |||||
print('Missing to 1 is ',1-bfSum) | |||||
decFiles.close() | |||||