#!/bin/bash
##export fname=scurves_PC_inj_run16
#export fname=data_s_curves_run50
#export fname=data_s_curves_run75
#export fname=data_s_curves_run78
#export fname=data_s_curves_run79
#export fname=data_s_curves_run81
#export fname=data_s_curves_run82
#export fname=data_s_curves_run83
#export fname=data_s_curves_run90
#export fname=data_s_curves_run91
export fname=data_s_curves_run104
#export fname=data_s_curves_run105
#export fname=$@ #standard input
#export fname_o=gain-900V_$fname.txt
#export fname_o=gain-1000V-diffFit_$fname-ASIC_C-th150.txt
#export fname_o=gain-1000V-halfMax11000_$fname.txt
#export fname_o=gain-1000V-mean_$fname.txt
#export fname_o=gain-1000V-sfit-ASIC_D-th170-it0.txt
#export fname_o=gain-1000V-sfit-ASIC_C-th120_th180-it0.txt
#export fname_o=gain-1000V-sfit-T2_ASIC_C-th220-it0.txt
#export fname_o=gain-1000V-sfit-T2_ASIC_D-th130-it0.txt
#export fname_o=gain-1000V-sfit-T2_ASIC_C-th240-it1.txt
#export fname_o=gain-1000V-sfit-T2_ASIC_D-th200-it1.txt
#export fname_o=gain-1000V-sfit-T1_ASIC_C-th170-it1.txt
#export fname_o=gain-1000V-sfit-T1_ASIC_C-th180_th150-ch17-it3.txt
#export fname_o=gain-1000V-sfit-T1_ASIC_C-th200-it3.txt
export fname_o=gain-run_104-T1_ASIC_D-it1.txt


#for j in `seq 0 127`; do echo "0"; done > ${fname_o} #ASIC_C only/and ASIC_D
for j in `seq 0 191`; do echo "0"; done > ${fname_o} #only ASIC_D

#cd ${fname}_C
#grep OUT_TABLE gain-output.dat > gain-output-extract.dat
#cat tmp2.dat |awk '{print($3)}' >> ../${fname_o} #dacHalf
#cat tmp2.dat |awk '{print($4)}' >> ../${fname_o} #differential
#cat gain-output-extract.dat |awk '{print($6)}' >> ../${fname_o} #scurve_fit
#cd ../
cd ${fname}_D
grep OUT_TABLE gain-output.dat > gain-output-extract.dat
#cat tmp2.dat |awk '{print($3)}' >> ../${fname_o} #dacHalf
#cat tmp2.dat |awk '{print($5)}' >> ../${fname_o} #differential
cat gain-output-extract.dat |awk '{print($6)}' >> ../${fname_o} #scurve_fit
cd ../

for j in `seq 0 127`; do echo "0"; done >> ./${fname_o} #ASIC_D only/and ASIC_C
#for j in `seq 0 191`; do echo "0"; done >> ./${fname_o} #only ASIC_C
