Skip to content

Commit

Permalink
Changed RunSinPipe. Examples not updated for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjtueros committed Mar 7, 2024
1 parent 6ae02e9 commit 8d08013
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
13 changes: 10 additions & 3 deletions scripts/convert_efield2efield.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ def impz(b, a):
trun = d_input.trun
tshower = d_input.tshower
tefield = d_input.tefield



#get the list of events
events_list=tefield.get_list_of_events()

Expand Down Expand Up @@ -567,6 +568,7 @@ def impz(b, a):
out_tefield.fill()
out_tefield.write()

#TODO ask lech how to do this correctly, so that all runs get the correct sampling rate.
#now, we copy trun and change the sampling rate (filename to be changed when sim2root changes)
#f_output = d_input.ftefield.filename.replace("L0", "L1")
filename=glob.glob(args.directory+ "/run_*L0*.root")[0]
Expand All @@ -575,12 +577,17 @@ def impz(b, a):
outrun.copy_contents(trun)
if(target_sampling_rate_mhz>0):
outrun.t_bin_size = [1e3/target_sampling_rate_mhz]*len(outrun.t_bin_size)

outrun.analysis_level = trun.analysis_level+1

outrun.fill()
outrun.write()

#now, we copy trunefieldsim and change tpost (filename to be changed when sim2root changes)
#f_output = d_input.ftefield.filename.replace("L0", "L1")
filename=glob.glob(args.directory+ "/runefieldsim_*L0*.root")[0]
filename=filename.replace("L0", "L1")

#TODO ask lech how to do this correctly, so that all runs get tpost.



# =============================================
Expand Down
9 changes: 6 additions & 3 deletions scripts/convert_voltage2adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def manage_args():

if f_output == None:
f_output = f_input_file.replace('voltage','adc')
f_output = f_output.replace('L0','L1')
if noise_dir == None:
noise_trace = None

Expand Down Expand Up @@ -232,26 +233,28 @@ def manage_args():
if( input_sampling_rate_mhz != adc.sampling_rate):
voltage_trace=adc.downsample(voltage_trace,input_sampling_rate_mhz)


#-#-#- Get noise trace if requested -#-#-#
if noise_dir is not None:
noise_trace = get_noise_trace(noise_dir,
voltage_trace.shape[0],
n_samples=voltage_trace.shape[2],
rng=rng)

#-#-#- Convert voltage trace to adc trace -#-#-#
adc_trace = adc.process(voltage_trace,
noise_trace=noise_trace)

#-#-#- Save adc trace to TADC file -#-#-#
tadc.copy_contents(tvoltage)
entries = tadc.get_number_of_entries()
print("entries",entries)
tadc.trace_ch = adc_trace
print(np.shape(np.asarray(tadc.trace_ch)))
tadc.fill()
tadc.write()
logger.debug(f'ADC trace for (run,event) = {tvoltage.run_number, tvoltage.event_number} written to TADC')

tadc.analysis_level = tadc.analysis_level+1
print("al",tadc.analysis_level)
logger.info(f'Succesfully saved TADC to {f_output}')

#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
logger.info( manage_log.string_end_script() )
17 changes: 6 additions & 11 deletions sim2root/Common/RunSimPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
PRODUCEDC2Efield="../../scripts/convert_efield2efield.py"

INPUTDIR="../ZHAireSRawRoot"
EXTRA="GP300"
EXTRA="ZHAireS"

#No command line parameters for now.
"""
Expand Down Expand Up @@ -59,30 +59,25 @@
OUTPUTFILE=OUTPUTFILE[:-5]

#no noise and no chain
#cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_sampling_rate_mhz=500 --target_duration_us=4.096 --verbose=info -o " + OUTPUTFILE+"-no_rf_chain-no_noise.root --no_rf_chain --no_noise"
#cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_duration_us=4.096 --add_jitter_ns 5 --calibration_smearing_sigma 0.075 --verbose=info -o " + OUTPUTFILE+"-no_rf_chain-no_noise.root --no_rf_chain --no_noise"
#no noise
#cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_sampling_rate_mhz=500 --target_duration_us=4.096 --verbose=info -o " + OUTPUTFILE+"-no_noise.root --no_noise"
#cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_duration_us=4.096 --add_jitter_ns 5 --calibration_smearing_sigma 0.075 --verbose=info -o " + OUTPUTFILE+"-no_noise.root --no_noise"
#no chain
#cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_sampling_rate_mhz=500 --target_duration_us=4.096 --verbose=info -o " + OUTPUTFILE+"-no_rf_chain.root --no_rf_chain"
#cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_duration_us=4.096 --add_jitter_ns 5 --calibration_smearing_sigma 0.075 --verbose=info -o " + OUTPUTFILE+"-no_rf_chain.root --no_rf_chain"
#the real thing
cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_sampling_rate_mhz=500 --target_duration_us=4.096 --verbose=info -o " + OUTPUTFILE+".root"
cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_duration_us=4.096 --add_jitter_ns 5 --calibration_smearing_sigma 0.075 --verbose=info -o " + OUTPUTFILE+".root"
print("about to run:" + cmd)
p = subprocess.Popen(cmd,cwd=".",stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
stdout,stderr=p.communicate() #the communicate will make it to wait until it finishes.
#print(stdout)
print(stderr)
#cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_sampling_rate_mhz=500 --target_duration_us=4.096 --verbose=info -o " + OUTPUTFILE+"-no_rf_chain-no_noise.root --no_rf_chain --no_noise"
#cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_sampling_rate_mhz=500 --target_duration_us=4.096 --verbose=info -o " + OUTPUTFILE+"-no_noise.root --no_noise"
#cmd=PYTHONINTERPRETER+" "+PRODUCEVOLTAGE+" "+INPUTDIR+" --seed 1234 --target_sampling_rate_mhz=500 --target_duration_us=4.096 --verbose=info -o " + OUTPUTFILE+"-no_rf_chain.root --no_rf_chain"


#########################################################################################################################################################
# ADC
#####################################################################################################################################################
logging.debug(" Trying to produce ADCs")
#python /home/mjtueros/TrabajoTemporario/docker/grand/scripts/convert_voltage2adc.py ./sim_Xiaodushan_20221026_000000_RUN0_CD_GP300_0000/voltage_5388-23832_L0_0000.root
Inputfile=glob.glob(INPUTDIR+"/voltage_*L0*.root")[0]
cmd=PYTHONINTERPRETER+" "+PRODUCEADC+" "+Inputfile
cmd=PYTHONINTERPRETER+" "+PRODUCEADC+" "+INPUTDIR
print("about to run:" + cmd)
p = subprocess.Popen(cmd,cwd=".",stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
stdout,stderr=p.communicate() #the communicate will make it to wait until it finishes.
Expand Down

0 comments on commit 8d08013

Please sign in to comment.