From 0271fb57bf0323cc5b4525e5cc704cb250ef732f Mon Sep 17 00:00:00 2001 From: vrm7fj Date: Fri, 20 Sep 2024 18:32:26 -0400 Subject: [PATCH] Implementing TOT Digitization in LDMX Hcal --- .DS_Store | Bin 10244 -> 8196 bytes Plotting/plotting_TOT_ADC.py | 116 ----------------------------------- PythonScript/electronGun.py | 64 ------------------- 3 files changed, 180 deletions(-) delete mode 100644 Plotting/plotting_TOT_ADC.py delete mode 100644 PythonScript/electronGun.py diff --git a/.DS_Store b/.DS_Store index 1990da23e60776f941501c4b8e5c3b18822b2d06..5c279a4713ceb576407aa85590e48ba834af398e 100644 GIT binary patch delta 97 zcmZn(XmOBWU|?W$DortDU;r^WfEYvza8E20o2aMAD7P_SH$S7?W*z|%md!uKo-+$F l1EqmLf*VMdrS{LVa?UnP)(5u%@Aay-wh&9}vwm;px(5&{4K literal 10244 zcmeHM-EI>{6h4#K^*RYC7a+t1(h6=Wkp^#^@FQ-FajGJb{$K=B`3ZJx9Fz5~Wp6OZ z3i2f_eTF^)y{!5IeFX0N0^D=eerINDW@p!Jghb$C#+o_n-S6zo`Ocg(o-q-L>VC^3 za*4=6Wx2eBCZq6kuBkE?-#HH{pik7LfI2t)aHr{~(DsI9z%pPNunbrRECZhd16Z@U zIEzZ!)-qrjunbHY;QZjCvaG~%qNGe6Xyg_EGKbr;;2Qe?spH1763dB_QWfu1y9W`g zig=45lscZf42P`5a-yVCC!y3y#6636hazO}&~qi6L`6y4S_UiwX$E-jUZ5&=?hP91 z`}eSkCmc-IP*?w!1y@9Q+MyoMd(>7t{VDP{19_aT)0RTgO}u+Z5$Y=1XA~uM#Ti3) z0lFbh6I#%VQ2Baj=)5v?9I8iWgz)r?)w;P zgPte#*g|n!v#>~C!?FfE+@_J_WY5rmmlGN}`X+NkurC|e91Z(TU(T98nti`Jj7p_9 zVs1W{|Dxa&oJHqBeK#D{qeiqptTqPs_}lF;^qc=)H=1|4?a}t~iR)nyHM&82AQif; zHX!%!c7s+ps)qYPYbbT=>VZ>qirdSl$7ApE#)|7*@(xzqu~#aUR@{r_^1(sTIeG5F z)mz(pelG}_b`%k>HgrsVpSHi?YHIk?`XKPbpu-BN4n3iLIoUHOh`_rO#1s%5H!$5d z>07GPW|D3J$0pE=GNd|iQx`7sF}XOz`bjP6))$&v3-mouJaM%nIz4cOj&^|d;rs}n zEc|OM{13FZr|_TJ#cQ4i7nj$ii_0Z^*;p%mfQwUx`5mvm6ZZPkiNNkQ$m)f)T0Fm< zmur8m(|3Pz4$Z)|4u$LQ{(qmw6kNiXp2K;&aAJT-g<2A{#l%y%2S6zLYi>>4ud7UU|jTq_wkybdKoArB2+AHbu5Bd6An{%5;DhBm!<{<1 zI7M^#a27Owvam~ajRm@c(fGi&Ambk`$zC`w&pp%}tK|`UX&JB#SOzQumVu*TU|x0O zE<$e3{{R1I24j1%3|Iy}2?HWmtJkXNnolpX3ZJ#RsE<&&Fm9rxR6)ZKzAumC@r94$ zzl`sdSaQMhN-QTzN_E_q>X7O*|D*pIaM&ZB)Sf+KADqJI`(L~NxBGuSMVH5TpVj{V EAIp6<*Z=?k diff --git a/Plotting/plotting_TOT_ADC.py b/Plotting/plotting_TOT_ADC.py deleted file mode 100644 index 20f96d371..000000000 --- a/Plotting/plotting_TOT_ADC.py +++ /dev/null @@ -1,116 +0,0 @@ -# plot CHARGE vs ADC/TOT using Voltage_ADC_TOT.txt -import numpy as np -import matplotlib.pyplot as plt -from matplotlib.ticker import AutoMinorLocator - -plt.rc('font', family='sans-serif') - -# Load the data from the text file -data = np.loadtxt('Voltage_ADC_TOT.txt') - -# Apply the masks to filter the data -maskADC = (data[:, 0] < 60000) & (data[:, 1] != 0) -maskTOT = (data[:, 0] < 60000) & (data[:, 2] != 0) - -filtered_data_ADC = data[maskADC] -filtered_data_TOT = data[maskTOT] - - -# IF YOU ARE CHANGING THE CAPACITANCE IN hcal_hardcoded_conditions CHANGE IT HERE AS WELL!! -capacitance = 13/5.1 - -# Extract the columns -x_adc = capacitance * filtered_data_ADC[:, 0] * 1e-3 # pC -y_adc = filtered_data_ADC[:, 1] - -x_tot = capacitance * filtered_data_TOT[:, 0] * 1e-3 # pC -y_tot = filtered_data_TOT[:, 2] - -# Create a figure -fig, ax1 = plt.subplots(figsize=(12, 7), dpi=300) - -# Plot the ADC data points -ax1.plot(x_adc, y_adc, '.', color='darkviolet', label='ADC') - -# Plot the TOT data points -ax1.plot(x_tot, y_tot, '.', color='deeppink', label='TOT') - -ax1.set_xlabel('Charge [pC]') -ax1.set_ylabel('adc_count / tot_count') -ax1.grid(True, linestyle = '--', alpha = 0.3) -ax1.legend(loc='upper right', bbox_to_anchor=(1,0.9), frameon = False) -#ax1.legend(loc='upper right') -ax1.set_xticks(range(0,50,5)) -ax1.set_yticks(range(0, 1200, 100)) - - -# Plot multiple x-axes -x = np.arange(0,120,1) - -# Functions for conversions -def pC2MIP(xpc): - return xpc * (15 / 13.0) - -def pC2MeV(ypc): - return ypc * (15 * 4.66 / 13.0) - -def pC2PE(zpc): - return zpc * (15 * 68 / 13.0) - -# 2nd x-axis -ax2 = ax1.twiny() -xlim_ax1 = ax1.get_xlim() -ax2.set_xlim(pC2MIP(xlim_ax1[0]), pC2MIP(xlim_ax1[1])) -ticks_ax2 = pC2MIP(np.array(ax1.get_xticks())) -ax2.set_xticks(ticks_ax2) -rounded_labels_ax2 = [round(tick) for tick in ticks_ax2] -ax2.set_xticklabels(rounded_labels_ax2) -ax2.set_xlabel('Number of MIPs') -ax2.spines['top'].set_color('crimson') -ax2.xaxis.label.set_color('crimson') -ax2.xaxis.set_label_coords(0.5, 1.07) -ax2.tick_params(axis = 'x', colors = 'crimson', direction = 'out', length = 5) -#ax2.set_xticks(range(int(pC2MIP(0)), int(pC2MIP(120)), 100)) - -# 3rd x-axis -ax3 = ax1.twiny() -ax3.set_xlim(pC2MeV(xlim_ax1[0]), pC2MeV(xlim_ax1[1])) -ticks_ax3 = pC2MeV(np.array(ax1.get_xticks())) -ax3.set_xticks(ticks_ax3) -ax3.set_xlabel('Energy [MeV]') -ax3.spines['top'].set_color('royalblue') -ax3.xaxis.label.set_color('royalblue') -ax3.xaxis.set_label_coords(0.5, 0.91) -ax3.xaxis.label.set_color('royalblue') -ax3.tick_params(axis = 'x', colors = 'royalblue', direction = 'in', length = 5, pad = -20 ) - -# 4th x-axis -ax4 = ax1.twiny() -ax4.set_xlim(pC2PE(xlim_ax1[0]), pC2PE(xlim_ax1[1])) -ticks_ax4 = pC2PE(np.array(ax1.get_xticks())) -ax4.set_xticks(ticks_ax4) -ax4.xaxis.set_label_coords(0.5, 0.07) -ax4.set_xlabel('Number of Photoelectrons') -ax4.spines['top'].set_position(('axes', 1)) # Position it on the primary x-axis -ax4.xaxis.set_ticks_position('bottom') -#ax4.xaxis.set_label_position('bottom') -ax4.spines['bottom'].set_position(('outward', 0)) -ax4.spines['bottom'].set_color('black') -ax4.xaxis.label.set_color('darkmagenta') -ax4.tick_params(axis='x', colors='darkmagenta', direction='in', length = 5, pad = -15) - -# Some modifications -ax1.spines["right"].set_visible(False) -ax1.spines["left"].set_visible(False) -ax1.spines["top"].set_visible(False) -ax2.spines["right"].set_visible(False) -ax2.spines["left"].set_visible(False) -ax2.spines["top"].set_visible(False) -ax3.spines["right"].set_visible(False) -ax3.spines["left"].set_visible(False) -ax3.spines["top"].set_visible(False) -ax4.spines["right"].set_visible(False) -ax4.spines["left"].set_visible(False) -ax4.spines["top"].set_visible(False) - -plt.show() diff --git a/PythonScript/electronGun.py b/PythonScript/electronGun.py deleted file mode 100644 index 6a658a932..000000000 --- a/PythonScript/electronGun.py +++ /dev/null @@ -1,64 +0,0 @@ -from LDMX.Framework import ldmxcfg -p=ldmxcfg.Process("electron") -p.libraries.append("libSimCore.so") -p.libraries.append("libHcal.so") -p.libraries.append("libEcal.so") - -import argparse, sys -parser = argparse.ArgumentParser(f'ldmx fire {sys.argv[0]}') -parser.add_argument('energy',type=float) -parser.add_argument('nevents',default=100,type=int) -arg = parser.parse_args() - -#nevents = 1000 # number of events -energy = arg.energy -nevents = arg.nevents - -from LDMX.SimCore import simulator -from LDMX.SimCore import generators -sim = simulator.simulator("single_electron") -sim.setDetector( 'ldmx-det-v12' , True ) -sim.description = "HCal electron" -sim.beamSpotSmear = [20., 80., 0.] #mm -#sim.beamSpotSmear = [100., 100., 0.] #mm -particle_gun = generators.gun( "single_electron_upstream_hcal") -particle_gun.particle = 'e-' -#position = 870. -position = 690.6 # back hcal -#position = 240.4 # ecal face -#position = 0.0 -particle_gun.position = [ 0., 0., position ] # mm -particle_gun.direction = [ 0., 0., 1.] -particle_gun.energy = energy -myGen = particle_gun -print(myGen) -sim.generators.append(myGen) - -#p.outputFiles=['data/ngun_%.2fmm_%.2f_gev.root'%(position,energy)] -p.maxEvents = nevents -#p.outputFiles = ["eGun2_" + str(p.maxEvents) + "_smear_" + str(sim.beamSpotSmear[0]) - #+ ", " + str(sim.beamSpotSmear[1]) + "_events_zpos_" + str(position) +".root"] - -p.outputFiles = ["eGun2_" + str(p.maxEvents) + ".root"] -p.run = 11 -p.sequence=[sim] - -import LDMX.Ecal.digi as ecal_digi -import LDMX.Hcal.digi as hcal_digi - -from LDMX.Ecal import EcalGeometry -geom = EcalGeometry.EcalGeometryProvider.getInstance() - -from LDMX.Hcal import HcalGeometry -geom = HcalGeometry.HcalGeometryProvider.getInstance() - -import LDMX.Hcal.hcal_hardcoded_conditions -digit = hcal_digi.HcalDigiProducer() -recon = hcal_digi.HcalRecProducer() - -import LDMX.Ecal.ecal_hardcoded_conditions -p.sequence.extend([ - ecal_digi.EcalDigiProducer(), - ecal_digi.EcalRecProducer(), - digit,recon -])