Compare commits

...

2 commits

Author SHA1 Message Date
ava@asterix
65c3faf0cd IMPROVED AHBGOC_vertical.py AND make_verticals.py 2024-04-08 17:36:28 +02:00
ava@asterix
6a72ed3991 UPDATE AHBGOx.py 2024-04-08 17:35:06 +02:00
3 changed files with 45 additions and 29 deletions

View file

@ -75,7 +75,7 @@ def main():
for i in range(0,bin):
hist[i][0]=minV + resV*i
with fileinput.input(files=(file), encoding="utf-8") as f:
with fileinput.input(files=(file), encoding="utf-8", errors = 'ignore') as f:
T='unknown'
for line in f:
l = line.split()

View file

@ -20,7 +20,7 @@ parser.add_argument("-two", action='store_true', help = "if chosen, functions fu
parser.add_argument("-zero", action='store_true', help = "if chosen, data will be normalized to 0°C, chose only for sum") # on/off flag
parser.add_argument("-export", type=str, nargs='+', help = "filpath to store output if other then currend directory/histogramms/filename")
parser.add_argument("-nameadd", type=str, nargs='+', help = "custom nameadd to add to filename")
parser.add_argument("-tdhist", action='store_true', help = "makes 2d histogramm of B1 against B2 if AHBGOC")
#parser.add_argument("-tdhist", action='store_true', help = "makes 2d histogramm of B1 against B2 if AHBGOC")
args = parser.parse_args()
@ -47,6 +47,8 @@ if 'AHBGOD' in file:
x = 'D'
elif 'AHBGOC' in file:
x = 'C'
elif 'AHBGOS' in file:
x = 'S'
def main():
if args.Itime:
@ -77,11 +79,13 @@ def main():
trig.append(t)
nameadd = nameadd + '_' + str(t)
if args.zero: nameadd = nameadd + '_zero'
energy = 'keV'
if args.mV:
energy = 'mV'
nameadd = nameadd + '_mV'
u = [1.0]*18
if len(args.nameadd)>0:
if not args.nameadd == None:
nameadd = args.nameadd[0]
global trigchan
@ -96,10 +100,8 @@ def main():
for i in range(0,bin):
hist[i][0]=minV + resV*i
with fileinput.input(files=(file), encoding="utf-8") as f:
with fileinput.input(files=(file), encoding="utf-8", errors='ignore') as f:
T='unknown'
B1 = []
B2 = []
for line in f:
l = line.split()
if not 'EOF' in l:
@ -107,25 +109,16 @@ def main():
T = adc_to_T(int(l[8]))
elif l[0] == 'EI' and not T=='unknown':
if conditions(l,args):
if args.tdhist:
B1.append(CmV(l,ch[0])*u[0])
B2.append(CmV(l,ch[1])*u[1])
if args.hist:
for i in range(18):
x = CmV(l,ch[i])*u[i]
if args.zero:
x = x*polynom(0,*pol)/polynom(T,*pol)
if x>=minV and x<=maxV:
xx = int(x-minV/resV)
hist[xx,i+1] += 1
if args.tdhist:
frame = pd.DataFrame({"B1":B1, "B2":B2})
frame.to_csv('histograms/'+filename+nameadd+'.2dhist', sep = ' ', index = False)
if args.hist:
frame = pd.DataFrame(hist, columns = ['mV'] + name)
frame.to_csv('histograms/'+filename+nameadd+'.hist', sep = ' ', index = False)
for i in range(18):
x = CmV(l,ch[i])*u[i]
if args.zero:
x = x*polynom(0,*pol)/polynom(T,*pol)
if x>=minV and x<=maxV:
xx = int(x-minV/resV)
hist[xx,i+1] += 1
frame = pd.DataFrame(hist, columns = [energy] + name)
frame.to_csv('histograms/'+filename+nameadd+'.hist', sep = ' ', index = False)
def channels():
@ -160,13 +153,33 @@ def channels():
name[15] = "TU6"; ch[15] = 13; u[15] = 1/0.7
name[16] = "TU7"; ch[16] = 10; u[16] = 1/0.7
name[17] = "TU8"; ch[17] = 14; u[17] = 1/0.7
elif x == 'S':
name[0] = "B1a"; ch[0] = 17; thr[0] = 8; u[0] = 1/0.652
name[1] = "B2a"; ch[1] = 16; thr[1] = 8; u[1] = 1/0.668
name[2] = "TO1"; ch[2] = 0; u[2] = 1/0.7
name[3] = "TO2"; ch[3] = 3; u[3] = 1/0.7
name[4] = "TO3"; ch[4] = 5; u[4] = 1/0.7
name[5] = "B2b"; ch[5] = 6; u[5] = 1/0.7
name[6] = "TO5"; ch[6] = 9; u[6] = 1/0.7
name[7] = "TO6"; ch[7] = 11; u[7] = 1/0.7
name[8] = "TO7"; ch[8] = 12; u[8] = 1/0.7
name[9] = "B2c"; ch[9] = 15; u[9] = 1/0.7
name[10] = "TU1"; ch[10] = 1; u[10] = 1/0.7
name[11] = "TU2"; ch[11] = 2; u[11] = 1/0.7
name[12] = "TU3"; ch[12] = 4; u[12] = 1/0.7
name[13] = "B1b"; ch[13] = 7; u[13] = 1/0.7
name[14] = "TU5"; ch[14] = 8; u[14] = 1/0.7
name[15] = "TU6"; ch[15] = 13; u[15] = 1/0.7
name[16] = "TU7"; ch[16] = 10; u[16] = 1/0.7
name[17] = "B1c"; ch[17] = 14; u[17] = 1/0.7
return ch, name, thr, u
def find_Itime():
Itime = 0
lasttime = 0
with fileinput.input(files=(file), encoding="utf-8") as f:
with fileinput.input(files=(file), encoding="utf-8", errors = 'ignore') as f:
for line in f:
if line[0] == 'H':
time = int(line.split()[1])

View file

@ -41,11 +41,14 @@ pos = [7,2,5,9,13,16,12,11]
for i in range(0,8):
if args.vertical:
sub.run(["python3","AHBGOC_vertical.py", args.file, "-muon", "-trigger", "TO"+str(trigger[i]), "TU"+str(trigger[i]),"-nameadd", "_B1B2sum_vertical"+"%02d" % pos[i]])
print("python3 AHBGOC_vertical.py" + args.file + "-muon" + "-trigger"+ "TO"+str(trigger[i])+"TU"+str(trigger[i]),"-nameadd", "_B1B2sum_vertical"+"%02d" % pos[i])
if verbosity > 0:
print("python3 AHBGOC_vertical.py" + args.file + "-muon" + "-trigger"+ "TO"+str(trigger[i])+"TU"+str(trigger[i]),"-nameadd", "_B1B2sum_vertical"+"%02d" % pos[i])
if args.histfit:
print("Position: "+"%02d" % pos[i])
if verbosity > 0:
print("Position: "+"%02d" % pos[i])
sub.run(["python3","histfit_vertical.py", "histograms/"+name+"_B1B2sum_vertical"+"%02d" % pos[i]+".hist", "-e", "f"])
print('#########################################################################################')
if verbosity > 0:
print('#########################################################################################')
# elif args.hist and args.tdhist:
#print("python3","AHBGOx.py", "-hist", args.file, "-trigger", "TO"+str(trigger[i]), "TU"+str(trigger[i]), "-nameadd", "_muon_vertical"+str(pos[i])+".hist")