diff --git a/ELoss/E_vs_x_proton.dat b/ELoss/E_vs_x_proton.dat index bd4ea45..19b2de2 100644 --- a/ELoss/E_vs_x_proton.dat +++ b/ELoss/E_vs_x_proton.dat @@ -1,501 +1,501 @@ Distance_cm Energy_MeV --0.0 80.0 -146.08844909581993 79.83969939879759 -291.9506729006624 79.6793987975952 -437.5865186140052 79.51909819639279 -582.9958324570482 79.35879759519038 -728.1784604328438 79.19849699398797 -873.1342483255248 79.03819639278558 -1017.8630416996045 78.87789579158317 -1162.3646858991447 78.71759519038076 -1306.6390260470469 78.55729458917835 -1450.6859070442752 78.39699398797595 -1594.5051735690733 78.23669338677355 -1738.0966700762433 78.07639278557114 -1881.4602407962884 77.91609218436874 -2024.595729734682 77.75579158316633 -2167.5029806710527 77.59549098196393 -2310.1818371584427 77.43519038076153 -2452.6321425224332 77.27488977955912 -2594.853739860392 77.11458917835671 -2736.8464720406405 76.95428857715432 -2878.6101817016897 76.79398797595191 -3020.144711251348 76.6336873747495 -3161.449902865947 76.47338677354709 -3302.525598489489 76.3130861723447 -3443.3716398328615 76.15278557114229 -3583.9878683729257 75.99248496993988 -3724.374125351719 75.83218436873747 -3864.530251775584 75.67188376753508 -4004.45608841436 75.51158316633267 -4144.151475800449 75.35128256513026 -4283.616254228 75.19098196392785 -4422.850263752025 75.03068136272545 -4561.853344187508 74.87038076152305 -4700.6253351085725 74.71008016032064 -4839.166075847519 74.54977955911824 -4977.47540549398 74.38947895791583 -5115.553162893997 74.22917835671343 -5253.399186649159 74.06887775551102 -5391.0133151156215 73.90857715430862 -5528.395386403237 73.74827655310621 -5665.545241313488 73.58797595190381 -5802.462720575961 73.4276753507014 -5939.147661723158 73.267374749499 -6075.599901852234 73.10707414829659 -6211.819277809311 72.9467735470942 -6347.805626188569 72.78647294589179 -6483.558783331217 72.62617234468938 -6619.078585324572 72.46587174348697 -6754.364868001061 72.30557114228458 -6889.417466937288 72.14527054108217 -7024.236217452975 71.98496993987976 -7158.82095461002 71.82466933867735 -7293.171513211477 71.66436873747494 -7427.287727800545 71.50406813627255 -7561.169432659598 71.34376753507014 -7694.816461809091 71.18346693386773 -7828.228649006585 71.02316633266533 -7961.405827745683 70.86286573146293 -8094.34783125504 70.70256513026052 -8227.054492497238 70.54226452905812 -8359.525644167785 70.38196392785571 -8491.76111869402 70.22166332665331 -8623.76074823409 70.0613627254509 -8755.52436467581 69.9010621242485 -8887.051799635612 69.74076152304609 -9018.34288445744 69.5804609218437 -9149.397450211682 69.42016032064129 -9280.215327694004 69.25985971943888 -9410.796347424277 69.09955911823647 -9541.140339645426 68.93925851703408 -9671.247134322346 68.77895791583167 -9801.11656114069 68.61865731462926 -9930.748449505776 68.45835671342685 -10060.142628541407 68.29805611222444 -10189.298927088703 68.13775551102205 -10318.217174194191 67.97745490981964 -10446.897201352316 67.81715430861723 -10575.338839271892 67.65685370741483 -10703.541915631118 67.49655310621243 -10831.506257819576 67.33625250501002 -10959.231692936943 67.17595190380761 -11086.718047791812 67.0156513026052 -11213.965148900439 66.85535070140281 -11340.972822485543 66.6950501002004 -11467.740894474986 66.534749498998 -11594.269190500558 66.37444889779559 -11720.557535896685 66.2141482965932 -11846.605755699196 66.05384769539079 -11972.41367464396 65.89354709418838 -12097.98111716564 65.73324649298597 -12223.307907396358 65.57294589178358 -12348.393869164422 65.41264529058117 -12473.238825992932 65.25234468937876 -12597.84260109849 65.09204408817635 -12722.205017389831 64.93174348697394 -12846.32589746647 64.77144288577155 -12970.205063617359 64.61114228456914 -13093.842337819458 64.45084168336673 -13217.237541736386 64.29054108216432 -13340.39049671699 64.13024048096193 -13463.301023793996 63.969939879759515 -13585.968943682496 63.80963927855711 -13708.394076778584 63.649338677354706 -13830.576243157908 63.4890380761523 -13952.515262574176 63.3287374749499 -14074.210954457742 63.16843687374749 -14195.663137914078 63.00813627254509 -14316.871631722335 62.84783567134268 -14437.836254825144 62.68753507014028 -14558.556828684668 62.52723446893787 -14679.03317392929 62.36693386773547 -14799.265107994592 62.20663326653306 -14919.252447982133 62.04633266533066 -15038.995010657938 61.88603206412825 -15158.492612450878 61.72573146292585 -15277.745069451132 61.56543086172344 -15396.752197408548 61.405130260521034 -15515.513811731054 61.24482965931863 -15634.029727483046 61.084529058116225 -15752.299759383717 60.92422845691382 -15870.323721805447 60.763927855711415 -15988.101428772103 60.603627254509014 -16105.632693957397 60.443326653306606 -16222.917330683165 60.283026052104205 -16339.955151917695 60.1227254509018 -16456.74597027397 59.962424849699396 -16573.28959800798 59.80212424849699 -16689.58584701694 59.641823647294586 -16805.634528837556 59.48152304609218 -16921.435454644215 59.32122244488978 -17036.988435247247 59.16092184368737 -17152.293281091068 59.00062124248497 -17267.349802252396 58.84032064128256 -17382.15780843839 58.68002004008016 -17496.717108984834 58.51971943887775 -17611.027512854223 58.35941883767535 -17725.08882863393 58.19911823647294 -17838.90086453427 58.03881763527053 -17952.463428386603 57.87851703406813 -18065.77633011362 57.718216432865724 -18178.839380254205 57.55791583166332 -18291.652386477173 57.397615230460914 -18404.215155052374 57.23731462925851 -18516.52749186086 57.077014028056105 -18628.589202392828 56.916713426853704 -18740.400091745636 56.756412825651296 -18851.959964621707 56.596112224448895 -18963.2686253265 56.43581162324649 -19074.32587776638 56.275511022044086 -19185.13152544657 56.11521042084168 -19295.68537146897 55.954909819639276 -19405.987218530066 55.79460921843687 -19516.036868918716 55.63430861723447 -19625.83412451403 55.47400801603206 -19735.37878678311 55.31370741482966 -19844.670656778882 55.15340681362725 -19953.70953513782 54.99310621242485 -20062.495222077716 54.83280561122244 -20171.02751739537 54.67250501002003 -20279.30622046431 54.51220440881763 -20387.331130232476 54.35190380761522 -20495.102045219846 54.19160320641282 -20602.61876351612 54.03130260521041 -20709.881082778276 53.87100200400801 -20816.888800228222 53.710701402805604 -20923.641712650315 53.5504008016032 -21030.13961638895 53.390100200400795 -21136.382309677567 53.229799599198394 -21242.36959159792 53.069498997995986 -21348.101258437873 52.909198396793585 -21453.577104727116 52.748897795591176 -21558.796924542676 52.588597194388775 -21663.760511506363 52.42829659318637 -21768.467658782116 52.267995991983966 -21872.918159073397 52.10769539078156 -21977.111804620483 51.94739478957916 -22081.04838719781 51.78709418837675 -22184.72769811122 51.62679358717435 -22288.14952819524 51.46649298597194 -22391.31366781029 51.30619238476954 -22494.2199068399 51.14589178356713 -22596.86803468787 50.98559118236472 -22699.25784027541 50.82529058116232 -22801.389112038298 50.66498997995991 -22903.261637923904 50.50468937875751 -23004.87520538831 50.3443887775551 -23106.2296013933 50.1840881763527 -23207.324612403394 50.023787575150294 -23308.16002438279 49.86348697394789 -23408.73562279233 49.703186372745485 -23509.05119258639 49.542885771543084 -23609.10651820979 49.382585170340676 -23708.901383594595 49.222284569138274 -23808.435575039108 49.061983967935866 -23907.708879237667 48.901683366733465 -24006.721079463146 48.74138276553106 -24105.471957530543 48.581082164328656 -24203.96129472584 48.42078156312625 -24302.188871802617 48.26048096192385 -24400.15446897871 48.10018036072144 -24497.857865932747 47.93987975951904 -24595.298841800723 47.77957915831663 -24692.477175172487 47.61927855711422 -24789.392644088228 47.45897795591182 -24886.045026034913 47.29867735470941 -24982.43409794266 47.13837675350701 -25078.559636181122 46.9780761523046 -25174.421416555786 46.8177755511022 -25270.019214304277 46.65747494989979 -25365.352804092563 46.49717434869739 -25460.421960011197 46.336873747494984 -25555.226455571436 46.17657314629258 -25649.76606370139 46.016272545090175 -25744.040556742068 45.85597194388777 -25838.049706443442 45.695671342685365 -25931.793283960396 45.535370741482964 -26025.271059848714 45.375070140280556 -26118.482807610748 45.214769539078155 -26211.428300584903 45.05446893787575 -26304.107307928756 44.894168336673346 -26396.5195977212 44.73386773547094 -26488.664937420945 44.57356713426854 -26580.54309386223 44.41326653306613 -26672.153833250402 44.25296593186372 -26763.49692115749 44.09266533066132 -26854.572122517733 43.93236472945891 -26945.379201623025 43.77206412825651 -27035.91792211835 43.6117635270541 -27126.188046997115 43.4514629258517 -27216.189338596476 43.29116232464929 -27305.92155859257 43.13086172344689 -27395.38446799574 42.97056112224448 -27484.577827145637 42.81026052104208 -27573.50139570633 42.649959919839674 -27662.154932661317 42.48965931863727 -27750.538196308495 42.329358717434864 -27838.65094425506 42.16905811623246 -27926.492933412366 42.008757515030055 -28014.06391999068 41.848456913827654 -28101.36366318383 41.688156312625246 -28188.391921999566 41.527855711422845 -28275.148451016325 41.36755511022044 -28361.63300354196 41.207254509018036 -28447.84533215614 41.04695390781563 -28533.785188704693 40.88665330661322 -28619.452324293958 40.72635270541082 -28704.846489285028 40.56605210420841 -28789.967433287915 40.40575150300601 -28874.814905155676 40.2454509018036 -28959.388652978425 40.0851503006012 -29043.68842407731 39.92484969939879 -29127.71396499837 39.76454909819639 -29211.465021506352 39.60424849699398 -29294.941338578432 39.44394789579158 -29378.142660397854 39.28364729458917 -29461.068730347488 39.12334669338677 -29543.719291003323 38.96304609218436 -29626.09408412783 38.80274549098196 -29708.19285066331 38.642444889779554 -29790.015333291147 38.48214428857715 -29871.56127577587 38.321843687374745 -29952.83041844936 38.161543086172344 -30033.822498852904 38.001242484969936 -30114.537253672657 37.840941883767535 -30194.974418732436 37.68064128256513 -30275.133728986337 37.52034068136272 -30355.014918511315 37.36004008016032 -30434.617720499646 37.19973947895791 -30513.941867251255 37.03943887775551 -30592.987090166007 36.8791382765531 -30671.753119735808 36.7188376753507 -30750.239685536668 36.55853707414829 -30828.446516220607 36.39823647294589 -30906.37333950748 36.23793587174348 -30984.01988217666 36.07763527054108 -31061.385870058624 35.91733466933867 -31138.471028026404 35.75703406813627 -31215.27507998694 35.59673346693386 -31291.79775292746 35.43643286573146 -31368.038773550114 35.27613226452905 -31443.9978634793 35.11583166332665 -31519.67474260895 34.955531062124244 -31595.069129821524 34.79523046092184 -31670.1807429786 34.634929859719435 -31745.009298911253 34.474629258517034 -31819.55451341037 34.314328657314626 -31893.816101216744 34.15402805611222 -31967.79377601106 33.993727454909816 -32041.487250403763 33.83342685370741 -32114.896235924676 33.67312625250501 -32188.02044301257 33.5128256513026 -32260.859581004494 33.3525250501002 -32333.41335812499 33.19222444889779 -32405.681481475112 33.03192384769539 -32477.663657021287 32.87162324649298 -32549.359592569577 32.71132264529058 -32620.76899687663 32.55102204408817 -32691.89157450993 32.39072144288577 -32762.72702671347 32.23042084168336 -32833.27505353806 32.07012024048096 -32903.53535382911 31.909819639278556 -32973.50762521415 31.74951903807615 -33043.19156409022 31.589218436873747 -33112.58686561101 31.428917835671342 -33181.69322367381 31.268617234468937 -33250.5103309062 31.108316633266533 -33319.037878652634 30.948016032064128 -33387.27555696062 30.787715430861724 -33455.22305456685 30.62741482965932 -33522.88005888296 30.467114228456914 -33590.246255981154 30.30681362725451 -33657.3272149316 30.146513026052105 -33724.13316652587 29.9862124248497 -33790.66815527794 29.825911823647296 -33856.93126204983 29.66561122244489 -33922.92156906973 29.505310621242486 -33988.63815996199 29.345010020040082 -34054.08011977706 29.184709418837677 -34119.246535021404 29.02440881763527 -34184.13649368736 28.864108216432864 -34248.74908528299 28.70380761523046 -34313.08340086186 28.543507014028055 -34377.13853305278 28.38320641282565 -34440.91357608941 28.222905811623246 -34504.40762583996 28.06260521042084 -34567.61977983661 27.902304609218437 -34630.54914239794 27.742004008016032 -34693.19481955004 27.581703406813627 -34755.55591384806 27.421402805611223 -34817.63152951422 27.261102204408818 -34879.420772582394 27.100801603206413 -34940.922750927115 26.94050100200401 -35002.13657429244 26.780200400801604 -35063.06135432069 26.6198997995992 -35123.69620458107 26.459599198396795 -35184.04024059814 26.29929859719439 -35244.0925798801 26.138997995991986 -35303.85234194703 25.97869739478958 -35363.3186483588 25.818396793587176 -35422.490624923266 25.65809619238477 -35481.367402246084 25.497795591182363 -35539.948110733865 25.33749498997996 -35598.23188010016 25.177194388777554 -35656.217842237376 25.01689378757515 -35713.90513124364 24.856593186372745 -35771.29288344946 24.69629258517034 -35828.38023744408 24.535991983967936 -35885.16633410166 24.37569138276553 -35941.65031660718 24.215390781563126 -35997.83133048202 24.05509018036072 -36053.708523609355 23.894789579158317 -36109.28104625917 23.734488977955913 -36164.54805555244 23.574188376753508 -36219.50871112958 23.413887775551103 -36274.16217049965 23.2535871743487 -36328.507593421265 23.093286573146294 -36382.54414216277 22.93298597194389 -36436.27098152535 22.772685370741485 -36489.68727886572 22.61238476953908 -36542.7922041185 22.452084168336675 -36595.58492981808 22.29178356713427 -36648.064631120134 22.131482965931863 -36700.23048582271 21.971182364729458 -36752.081676305344 21.810881763527053 -36803.61739000953 21.65058116232465 -36854.836814996925 21.490280561122244 -36905.739139509766 21.32997995991984 -36956.32355453395 21.169679358717435 -37006.58925381714 21.00937875751503 -37056.53543388637 20.849078156312626 -37106.16129406505 20.68877755511022 -37155.46603648939 20.528476953907816 -37204.44886612421 20.36817635270541 -37253.10899077806 20.207875751503007 -37301.44562442806 20.047575150300602 -37349.45798451609 19.887274549098198 -37397.145287884414 19.726973947895793 -37444.50675350757 19.56667334669339 -37491.541603273385 19.406372745490984 -37538.24906199386 19.24607214428858 -37584.62835741536 19.085771543086175 -37630.67872022787 18.92547094188377 -37676.399384073535 18.76517034068136 -37721.78958563464 18.604869739478957 -37766.848568175374 18.444569138276552 -37811.57557766376 18.284268537074148 -37855.96985924375 18.123967935871743 -37900.03066104483 17.96366733466934 -37943.75723418482 17.803366733466934 -37987.148832771614 17.64306613226453 -38030.20471390381 17.482765531062125 -38072.92413767024 17.32246492985972 -38115.30636714831 17.162164328657315 -38157.35067169322 17.00186372745491 -38199.056323477635 16.841563126252506 -38240.422594161806 16.6812625250501 -38281.44875834614 16.520961923847697 -38322.134093598674 16.360661322645292 -38362.47788044573 16.200360721442888 -38402.479402361125 16.040060120240483 -38442.13794575392 15.879759519038075 -38481.45280190784 15.71945891783567 -38520.4232658394 15.559158316633265 -38559.04863329251 15.39885771543086 -38597.32820185014 15.238557114228456 -38635.26127195327 15.078256513026052 -38672.84714687903 14.917955911823647 -38710.08513271719 14.757655310621242 -38746.97453834483 14.597354709418838 -38783.514677830535 14.437054108216431 -38819.70486780352 14.276753507014027 -38855.544424943895 14.116452905811622 -38891.03266855633 13.956152304609217 -38926.16892058765 13.795851703406813 -38960.952505590474 13.635551102204408 -38995.382750684956 13.475250501002003 -39029.4589873209 13.314949899799599 -39063.18054941928 13.154649298597194 -39096.546771311405 12.99434869739479 -39129.556989515084 12.834048096192385 -39162.210542907495 12.673747494989978 -39194.50677267632 12.513446893787574 -39226.445022834465 12.35314629258517 -39258.024640420204 12.192845691382765 -39289.244973820605 12.03254509018036 -39320.10537247231 11.872244488977955 -39350.60518787237 11.71194388777555 -39380.74377352361 11.551643286573146 -39410.520485213325 11.391342685370741 -39439.934681099105 11.231042084168337 -39468.98572059853 11.07074148296593 -39497.672964206075 10.910440881763526 -39525.99577417674 10.750140280561121 -39553.953514481494 10.589839679358716 -39581.54555099145 10.429539078156312 -39608.771251045844 10.269238476953907 -39635.62998312066 10.108937875751502 -39662.12303263957 9.948637274549098 -39688.252197071655 9.788336673346693 -39714.017412248264 9.628036072144289 -39739.418150987476 9.467735470941884 -39764.45387477826 9.307434869739478 -39789.12403333465 9.147134268537073 -39813.428064123975 8.986833667334668 -39837.36539186694 8.826533066132264 -39860.93542800739 8.666232464929859 -39884.13757014929 8.505931863727454 -39906.97120145806 8.34563126252505 -39929.43569002336 8.185330661322645 -39951.53038817983 8.02503006012024 -39973.254631782096 7.864729458917835 -39994.60773942981 7.70442885771543 -40015.589011638105 7.544128256513026 -40036.1977299481 7.383827655310621 -40056.43315597171 7.2235270541082155 -40076.29453036395 7.063226452905811 -40095.78107171535 6.902925851703406 -40114.89197535589 6.742625250501002 -40133.626412060774 6.582324649298597 -40151.983526646974 6.422024048096192 -40169.962436447815 6.261723446893787 -40187.562229651056 6.101422845691382 -40204.78196348348 5.9411222444889775 -40221.62066222254 5.780821643286573 -40238.07731501203 5.620521042084168 -40254.15087345511 5.460220440881763 -40269.840248953085 5.299919839679358 -40285.144309752475 5.1396192384769535 -40300.061877655855 4.979318637274549 -40314.59172434287 4.819018036072144 -40328.73256723686 4.658717434869739 -40342.483064838394 4.498416833667334 -40355.84181142934 4.338116232464929 -40368.80733102819 4.177815631262525 -40381.37807044801 4.01751503006012 -40393.55239126963 3.857214428857715 -40405.32856049203 3.6969138276553104 -40416.7047395535 3.5366132264529053 -40427.678971325135 3.3763126252505007 -40438.24916455171 3.216012024048096 -40448.41307503908 3.055711422845691 -40458.168282639024 2.8954108216432863 -40467.51216272615 2.7351102204408813 -40476.44185034229 2.5748096192384766 -40484.95419441272 2.414509018036072 -40493.04569827328 2.254208416833667 -40500.71244095311 2.0939078156312623 -40507.94997084243 1.9336072144288576 -40514.75315888312 1.7733066132264528 -40521.11599115729 1.6130060120240481 -40527.03126895743 1.4527054108216433 -40532.49016560721 1.2924048096192384 -40537.481561458924 1.1321042084168336 -40541.99104791699 0.9718036072144288 -40545.99951023971 0.8115030060120241 -40549.4815320743 0.6512024048096192 -40552.40568099562 0.4909018036072144 -40554.74660145888 0.3306012024048096 -40556.54962659048 0.1703006012024048 -40558.659591934666 0.01 +-0.0 33.0 +29.698539147985517 32.933887775551106 +59.34840915890574 32.867775551102206 +88.94958934093333 32.80166332665331 +118.50205979899215 32.73555110220441 +148.0058005607748 32.66943887775551 +177.46079078755548 32.60332665330662 +206.86700960670004 32.537214428857716 +236.22443611150226 32.47110220440882 +265.53304936106696 32.40498997995992 +294.79282838014143 32.33887775551103 +324.00375215899635 32.27276553106213 +353.1657996532586 32.20665330661323 +382.2789497837747 32.14054108216433 +411.3431814364727 32.07442885771543 +440.35847346219265 32.00831663326654 +469.3248046765606 31.94220440881764 +498.24215385982154 31.876092184368744 +527.1104997566963 31.809979959919847 +555.9298210762291 31.743867735470946 +584.7000964916286 31.67775551102205 +613.421304640123 31.611643286573152 +642.0934241227984 31.545531062124255 +670.7164335044446 31.479418837675357 +699.2903113133973 31.41330661322646 +727.8150360413819 31.34719438877756 +756.2905861433475 31.281082164328662 +784.7169400373159 31.214969939879765 +813.0940761042139 31.148857715430868 +841.4219726877116 31.08274549098197 +869.7006080940591 31.016633266533074 +897.9299605919233 30.950521042084173 +926.1100084122152 30.884408817635276 +954.2407297479318 30.81829659318638 +982.3221027539823 30.75218436873748 +1010.3541055470193 30.686072144288584 +1038.3367162052687 30.619959919839687 +1066.2699127683582 30.553847695390786 +1094.1536732371399 30.48773547094189 +1121.9879755735235 30.42162324649299 +1149.7727977002955 30.355511022044094 +1177.5081175009434 30.289398797595197 +1205.1942122319128 30.2232865731463 +1232.832893424255 30.1571743486974 +1260.4256519716414 30.091062124248502 +1287.9724232673782 30.024949899799605 +1315.4731427428615 29.958837675350708 +1342.927745867937 29.89272545090181 +1370.3361681512577 29.826613226452913 +1397.6983451406443 29.760501002004013 +1425.014212423436 29.694388777555115 +1452.2837056268577 29.628276553106218 +1479.5067604183716 29.56216432865732 +1506.6833125060366 29.496052104208424 +1533.813297638866 29.429939879759523 +1560.8966516071807 29.363827655310626 +1587.933310242973 29.29771543086173 +1614.9232094202587 29.23160320641283 +1641.8662850554354 29.165490981963934 +1668.7624731076385 29.099378757515037 +1695.6117095790994 29.033266533066136 +1722.4139305154952 28.96715430861724 +1749.1690720063136 28.901042084168342 +1775.8770701852027 28.834929859719445 +1802.5378612303277 28.768817635270548 +1829.1513813647261 28.70270541082165 +1855.7175668566638 28.63659318637275 +1882.2363540199842 28.570480961923852 +1908.7076792144705 28.504368737474955 +1935.1314788461948 28.438256513026058 +1961.507689367872 28.37214428857716 +1987.836247279214 28.306032064128264 +2014.1170891272832 28.239919839679363 +2040.3501515068401 28.173807615230466 +2066.535371060704 28.10769539078157 +2092.672684480099 28.04158316633267 +2118.7620285050066 27.975470941883774 +2144.8033399245164 27.909358717434877 +2170.7965563272287 27.843246492985976 +2196.741615485756 27.77713426853708 +2222.638454463638 27.711022044088182 +2248.487010231546 27.644909819639285 +2274.2872198110445 27.578797595190387 +2300.0390202749404 27.51268537074149 +2325.7423487476317 27.44657314629259 +2351.39714240545 27.380460921843692 +2377.0033384770154 27.314348697394795 +2402.560874243579 27.248236472945898 +2428.0696870393685 27.182124248497 +2453.5297142519357 27.1160120240481 +2478.9408933224963 27.049899799599203 +2504.303161746281 26.983787575150306 +2529.616457072875 26.91767535070141 +2554.880716906562 26.85156312625251 +2580.095878906666 26.785450901803614 +2605.261880787894 26.719338677354713 +2630.3786603206736 26.653226452905816 +2655.446155331499 26.58711422845692 +2680.4643037032665 26.52100200400802 +2705.4330433756145 26.454889779559124 +2730.352312345261 26.388777555110227 +2755.2220486663437 26.322665330661327 +2780.04219045075 26.25655310621243 +2804.812675868461 26.190440881763532 +2829.5334431478823 26.124328657314635 +2854.2044305761774 26.058216432865738 +2878.8255764996034 25.99210420841684 +2903.3968193238425 25.92599198396794 +2927.918097514331 25.859879759519043 +2952.3893495965954 25.793767535070145 +2976.810514163705 25.727655310621248 +3001.1815307104935 25.66154308617235 +3025.5023387757533 25.595430861723454 +3049.7728771086977 25.529318637274553 +3073.9930845203135 25.463206412825656 +3098.162899883695 25.39709418837676 +3122.282262134362 25.33098196392786 +3146.3511102705857 25.264869739478964 +3170.3693833537104 25.198757515030064 +3194.337020508472 25.132645290581166 +3218.253960923324 25.06653306613227 +3242.1201438507524 25.000420841683372 +3265.9355086075943 24.934308617234475 +3289.6999945753555 24.868196392785578 +3313.4135412005257 24.802084168336677 +3337.07608799489 24.73597194388778 +3360.687574535847 24.669859719438882 +3384.247940466719 24.603747494989985 +3407.7571254970603 24.537635270541088 +3431.21506940297 24.47152304609219 +3454.6217120273996 24.40541082164329 +3477.976993280454 24.339298597194393 +3501.280853139706 24.273186372745496 +3524.533231650495 24.2070741482966 +3547.7340689262305 24.1409619238477 +3570.8833051486936 24.074849699398804 +3593.9808805683388 24.008737474949903 +3617.0267355045858 23.942625250501006 +3640.020810346125 23.87651302605211 +3662.963045551209 23.810400801603212 +3685.8533816479444 23.744288577154315 +3708.6917598216746 23.678176352705417 +3731.478121534972 23.612064128256517 +3754.2124077232756 23.54595190380762 +3776.894559175513 23.479839679358722 +3799.5245167519824 23.413727454909825 +3822.1022213846345 23.347615230460928 +3844.62761407736 23.281503006012027 +3867.100635906262 23.21539078156313 +3889.521228019948 23.149278557114233 +3911.889331639798 23.083166332665336 +3934.204888060244 23.01705410821644 +3956.4678386490427 22.95094188376754 +3978.6781248475504 22.88482965931864 +4000.835688170987 22.818717434869743 +4022.940470208712 22.752605210420846 +4044.9924126244878 22.68649298597195 +4066.9914571567415 22.62038076152305 +4088.937545618831 22.554268537074154 +4110.830619899304 22.488156312625254 +4132.670621962155 22.422044088176357 +4154.457493847083 22.35593186372746 +4176.191177669747 22.289819639278562 +4197.871615622014 22.223707414829665 +4219.498749972214 22.157595190380768 +4241.072523065382 22.091482965931867 +4262.592877323503 22.02537074148297 +4284.059755245763 21.959258517034073 +4305.473099408782 21.893146292585175 +4326.832853075756 21.827034068136278 +4348.138959720929 21.76092184368738 +4369.3913622762075 21.69480961923848 +4390.590003607196 21.628697394789583 +4411.734826658197 21.562585170340686 +4432.825774452426 21.49647294589179 +4453.862790092243 21.43036072144289 +4474.84581675937 21.364248496993994 +4495.774797715111 21.298136272545094 +4516.649676300566 21.232024048096196 +4537.470395936849 21.1659118236473 +4558.236900125293 21.099799599198402 +4578.949132447662 21.033687374749505 +4599.607036566355 20.967575150300604 +4620.210556224604 20.901462925851707 +4640.75963524668 20.83535070140281 +4661.254217538082 20.769238476953912 +4681.694247085738 20.703126252505015 +4702.079667958189 20.637014028056118 +4722.410424305778 20.570901803607217 +4742.686460360833 20.50478957915832 +4762.907720437851 20.438677354709423 +4783.074148933674 20.372565130260526 +4803.185690327662 20.30645290581163 +4823.242289181865 20.24034068136273 +4843.243890183165 20.17422845691383 +4863.190438755917 20.108116232464933 +4883.081880353256 20.042004008016036 +4902.918159844812 19.97589178356714 +4922.699222183827 19.909779559118242 +4942.425012407296 19.843667334669345 +4962.095475636121 19.777555110220444 +4981.710557075248 19.711442885771547 +5001.270202013817 19.64533066132265 +5020.774355825288 19.579218436873752 +5040.22296396758 19.513106212424855 +5059.615971983196 19.446993987975958 +5078.953325499351 19.380881763527057 +5098.234970228088 19.31476953907816 +5117.460851966399 19.248657314629263 +5136.630916596335 19.182545090180366 +5155.745110085117 19.11643286573147 +5174.803378485236 19.05032064128257 +5193.80566793456 18.98420841683367 +5212.751924656419 18.918096192384773 +5231.642094959707 18.851983967935876 +5250.476125238964 18.78587174348698 +5269.253961974459 18.71975951903808 +5287.975551732269 18.65364729458918 +5306.6408413661375 18.587535070140284 +5325.249778248604 18.521422845691387 +5343.802309623175 18.45531062124249 +5362.298382373392 18.389198396793592 +5380.7379434690665 18.323086172344695 +5399.120939966323 18.256973947895794 +5417.447319007647 18.190861723446897 +5435.717027821926 18.124749498998 +5453.9300137244845 18.058637274549103 +5472.086224117112 17.992525050100205 +5490.185606488088 17.92641282565131 +5508.228108412204 17.860300601202407 +5526.213677550774 17.79418837675351 +5544.142261651646 17.728076152304613 +5562.013808549201 17.661963927855716 +5579.828266164356 17.59585170340682 +5597.585582504554 17.52973947895792 +5615.285705663746 17.46362725450902 +5632.928583822376 17.397515030060124 +5650.514165247356 17.331402805611226 +5668.04239829203 17.26529058116233 +5685.513231396143 17.199178356713432 +5702.9266133264655 17.133066132264535 +5720.28249326522 17.066953907815634 +5737.580820226112 17.000841683366737 +5754.821542965892 16.93472945891784 +5772.004610327597 16.868617234468942 +5789.1299712404825 16.802505010020045 +5806.197574719937 16.736392785571145 +5823.207369867393 16.670280561122247 +5840.159305870241 16.60416833667335 +5857.053332001721 16.538056112224453 +5873.889397620817 16.471943887775556 +5890.667452172145 16.40583166332666 +5907.387445185827 16.339719438877758 +5924.049326277364 16.27360721442886 +5940.653045147503 16.207494989979963 +5957.198551582089 16.141382765531066 +5973.685795451918 16.07527054108217 +5990.114726712581 16.00915831663327 +6006.485295404288 15.943046092184371 +6022.7974516517115 15.876933867735472 +6039.051145776818 15.810821643286575 +6055.246328576608 15.744709418837678 +6071.382950804004 15.678597194388779 +6087.4609628898315 15.612484969939882 +6103.4803153485955 15.546372745490984 +6119.4409587782675 15.480260521042085 +6135.342843860052 15.414148296593188 +6151.185921358156 15.348036072144291 +6166.9701421195405 15.281923847695392 +6182.695457073673 15.215811623246495 +6198.361817232265 15.149699398797598 +6213.969173689 15.083587174348699 +6229.517477619259 15.017474949899801 +6245.006680279835 14.951362725450904 +6260.436733008635 14.885250501002005 +6275.807587224379 14.819138276553108 +6291.1191944262855 14.753026052104211 +6306.371506193751 14.686913827655312 +6321.564474186018 14.620801603206415 +6336.698050402029 14.554689378757518 +6351.772187083139 14.488577154308619 +6366.78683627359 14.422464929859721 +6381.741949917212 14.356352705410824 +6396.637480036148 14.290240480961925 +6411.47337873047 14.224128256513028 +6426.249598177784 14.15801603206413 +6440.966090632828 14.091903807615232 +6455.6228084270615 14.025791583166335 +6470.21970396824 13.959679358717437 +6484.756729739988 13.893567134268539 +6499.2338383013575 13.827454909819641 +6513.650982286377 13.761342685370744 +6528.008114403596 13.695230460921845 +6542.305187435611 13.629118236472948 +6556.542154238595 13.563006012024049 +6570.7189677418055 13.496893787575152 +6584.835581097525 13.430781563126255 +6598.89194772431 13.364669338677356 +6612.888020945308 13.298557114228458 +6626.823753944136 13.232444889779561 +6640.699099975233 13.166332665330662 +6654.514012363323 13.100220440881765 +6668.268444502865 13.034108216432868 +6681.962349857501 12.967995991983969 +6695.595681959485 12.901883767535072 +6709.168394409115 12.835771543086175 +6722.680440874151 12.769659318637276 +6736.131775089225 12.703547094188378 +6749.522350855248 12.637434869739481 +6762.8521220388075 12.571322645290582 +6776.121042571553 12.505210420841685 +6789.329066449585 12.439098196392788 +6802.4761478882565 12.372985971943889 +6815.562241263209 12.306873747494992 +6828.587300839945 12.240761523046094 +6841.551280831695 12.174649298597195 +6854.454135513344 12.108537074148298 +6867.295819220789 12.042424849699401 +6880.076286350286 11.976312625250502 +6892.795491357805 11.910200400801605 +6905.453388758377 11.844088176352708 +6918.049933125438 11.777975951903809 +6930.585079090179 11.711863727454912 +6943.058781340893 11.645751503006013 +6955.470994622323 11.579639278557115 +6967.821673735016 11.513527054108218 +6980.110773534678 11.44741482965932 +6992.338249092873 11.381302605210422 +7004.5040555208625 11.315190380761525 +7016.608147803913 11.249078156312626 +7028.650480976439 11.182965931863729 +7040.631010125335 11.116853707414831 +7052.549690389383 11.050741482965933 +7064.406476958673 10.984629258517035 +7076.201325074046 10.918517034068138 +7087.934190026544 10.85240480961924 +7099.60502715689 10.786292585170342 +7111.21379185499 10.720180360721445 +7122.760439559452 10.654068136272546 +7134.244925757143 10.587955911823649 +7145.667206014094 10.521843687374751 +7157.02723595994 10.455731462925852 +7168.324971221456 10.389619238476955 +7179.560367437682 10.323507014028058 +7190.73338029474 10.257394789579159 +7201.843965525624 10.191282565130262 +7212.892078910052 10.125170340681365 +7223.877790915855 10.059058116232466 +7234.801460338063 9.992945891783569 +7245.66333558652 9.926833667334671 +7256.463380871922 9.860721442885772 +7267.2015600995255 9.794609218436875 +7277.877836864428 9.728496993987978 +7288.492174446746 9.662384769539079 +7299.044535806673 9.596272545090182 +7309.534883579439 9.530160320641285 +7319.963180070143 9.464048096192386 +7330.329387248463 9.397935871743488 +7340.633466743253 9.33182364729459 +7350.875379837002 9.265711422845692 +7361.055087460162 9.199599198396795 +7371.172550185347 9.133486973947896 +7381.227728221382 9.067374749498999 +7391.22058140721 9.001262525050102 +7401.151069205656 8.935150300601203 +7411.019150697023 8.869038076152306 +7420.824784572539 8.802925851703408 +7430.567929127635 8.73681362725451 +7440.248542255047 8.670701402805612 +7449.866581437753 8.604589178356715 +7459.4220037417135 8.538476953907816 +7468.914765808433 8.472364729458919 +7478.344823847322 8.406252505010022 +7487.712133627855 8.340140280561123 +7497.01665047152 8.274028056112225 +7506.258329243552 8.207915831663328 +7515.43712434444 8.14180360721443 +7524.552989701199 8.075691382765532 +7533.6058787584025 8.009579158316635 +7542.595744468962 7.943466933867736 +7551.522539284647 7.877354709418839 +7560.3862151463345 7.811242484969941 +7569.186723473977 7.745130260521043 +7577.924015156278 7.679018036072145 +7586.5980405400705 7.612905811623247 +7595.208749419369 7.546793587174349 +7603.756091024105 7.480681362725452 +7612.240014008516 7.414569138276554 +7620.66046643918 7.348456913827656 +7629.017395782684 7.282344689378759 +7637.3107488929045 7.216232464929861 +7645.540471997888 7.1501202404809625 +7653.706510686314 7.084008016032065 +7661.808809893522 7.017895791583167 +7669.847313887088 6.951783567134269 +7677.821966251913 6.885671342685372 +7685.7327098748365 6.819559118236474 +7693.579486928711 6.753446893787576 +7701.362238855949 6.687334669338678 +7709.080906351496 6.6212224448897805 +7716.735429345216 6.555110220440882 +7724.325746983651 6.488997995991984 +7731.851797611131 6.422885771543087 +7739.313518750205 6.356773547094189 +7746.710847081353 6.290661322645291 +7754.043718421948 6.224549098196394 +7761.312067704433 6.158436873747496 +7768.51582895366 6.092324649298598 +7775.65493526337 6.0262124248497 +7782.729318771744 5.960100200400802 +7789.738910635999 5.893987975951904 +7796.683641005956 5.827875751503006 +7803.563438996544 5.761763527054109 +7810.37823265917 5.695651302605211 +7817.127948951886 5.629539078156313 +7823.8125137083025 5.563426853707416 +7830.4318516051635 5.4973146292585175 +7836.9858861285 5.4312024048096195 +7843.4745395382915 5.365090180360722 +7849.897732831539 5.298977955911824 +7856.255385703643 5.232865731462926 +7862.547416508003 5.166753507014029 +7868.7737422137 5.100641282565131 +7874.9342783611555 5.034529058116233 +7881.028939015637 4.9684168336673356 +7887.057636718446 4.9023046092184375 +7893.020282435662 4.836192384769539 +7898.916785504247 4.770080160320642 +7904.747053575342 4.703967935871744 +7910.510992554552 4.637855711422846 +7916.208506538997 4.571743486973948 +7921.839497750897 4.505631262525051 +7927.403866467423 4.439519038076153 +7932.901510946536 4.373406813627255 +7938.332327348497 4.307294589178357 +7943.696209652697 4.241182364729459 +7948.993049569444 4.175070140280561 +7954.222736446275 4.108957915831664 +7959.385157168335 4.042845691382766 +7964.480196052317 3.976733466933868 +7969.507734733394 3.9106212424849702 +7974.46765204451 3.8445090180360726 +7979.359823887344 3.7783967935871745 +7984.184123094149 3.712284569138277 +7988.940419279613 3.6461723446893792 +7993.628578681748 3.580060120240481 +7998.248463990733 3.5139478957915835 +8002.799934164464 3.447835671342686 +8007.282844229422 3.381723446893788 +8011.6970450653125 3.31561122244489 +8016.042383171666 3.249498997995992 +8020.318700414417 3.1833867735470944 +8024.5258337501355 3.117274549098197 +8028.663614925306 3.0511623246492987 +8032.7318701476515 2.985050100200401 +8036.730419726044 2.918937875751503 +8040.659077675046 2.8528256513026053 +8044.5176512795015 2.7867134268537077 +8048.305940613859 2.7206012024048096 +8052.023738010081 2.654488977955912 +8055.670827466938 2.5883767535070143 +8059.246983992304 2.5222645290581163 +8062.751972868586 2.4561523046092186 +8066.185548829699 2.390040080160321 +8069.547455135898 2.323927855711423 +8072.837422530229 2.2578156312625253 +8076.055168057304 2.191703406813627 +8079.200393721412 2.1255911823647295 +8082.272784956375 2.059478957915832 +8085.272008874114 1.993366733466934 +8088.197712252063 1.9272545090180364 +8091.049519211336 1.8611422845691385 +8093.827028527408 1.7950300601202407 +8096.529810502678 1.728917835671343 +8099.157403315166 1.6628056112224452 +8101.709308739268 1.5966933867735473 +8104.184987112374 1.5305811623246495 +8106.583851395084 1.4644689378757516 +8108.905260142514 1.398356713426854 +8111.148509170924 1.332244488977956 +8113.31282167006 1.2661322645290582 +8115.397336483493 1.2000200400801606 +8117.401094269531 1.1339078156312627 +8119.323021289297 1.067795591182365 +8121.161910694649 1.001683366733467 +8122.916401498088 0.9355711422845693 +8124.584956068862 0.8694589178356715 +8126.165838325319 0.8033466933867737 +8127.657097346345 0.7372344689378758 +8129.056565906336 0.6711222444889781 +8130.361892181427 0.6050100200400803 +8131.570638455064 0.5388977955911824 +8132.6805075679595 0.47278557114228464 +8133.689802748298 0.40667334669338684 +8134.59829970906 0.34056112224448903 +8135.408837323968 0.27444889779559123 +8136.130231350632 0.20833667334669342 +8136.783265500461 0.14222444889779562 +8137.4188914140395 0.0761122244488978 +8138.289806276097 0.01 diff --git a/ELoss/PCEnergyAnalysis.py b/ELoss/PCEnergyAnalysis.py index 4e78977..ad86d04 100644 --- a/ELoss/PCEnergyAnalysis.py +++ b/ELoss/PCEnergyAnalysis.py @@ -11,9 +11,6 @@ from scipy.interpolate import interp1d import argparse import uproot import pycatima as catima -import numpy as np -import pandas as pd -from scipy.interpolate import interp1d from scipy.integrate import cumulative_trapezoid import matplotlib matplotlib.use("TkAgg") @@ -46,6 +43,9 @@ alpha_data = [2, 4.0026, 40, "alpha"] proton_data = [1, 1.0078, 20, "proton"] deuteron_data = [1, 2.014102, 30, "deuteron"] +dA = 3.2 #cm +dC = 4.2 #cm +dsx3 = 8.8 #cm particles = { "alpha": alpha_data, @@ -53,6 +53,8 @@ particles = { "deuteron": deuteron_data } +interp_cache = {} + def make_E_vs_x(z, mass_u, emax_mev, label, npoints, P_TORR, TEMP_K): # GAS SETUP R = 8.3144 @@ -149,113 +151,79 @@ def load_table(filename): data = pd.read_csv( filename, - sep='\s+', + sep=r'\s+', comment="#", header=None, skiprows=1 ) - x = data.iloc[:, 0].values - E = data.iloc[:, 1].values + x = data.iloc[:, 0].to_numpy() + E = data.iloc[:, 1].to_numpy() return x, E -def energy_loss(particle, Ei, dl): +def get_interpolators(particle): + + if particle in interp_cache: + return interp_cache[particle] + filename = f"E_vs_x_{particle}.dat" - data = pd.read_csv( - filename, - sep='\s+', - comment="#", - header=None, - skiprows=1 - ) - - x = data.iloc[:, 0].values - E = data.iloc[:, 1].values - + + x, E = load_table(filename) + E_of_x = interp1d( x, E, bounds_error=False, fill_value=0.0 ) - + x_of_E = interp1d( - E[::-1], # reverse so energy increases + E[::-1], x[::-1], bounds_error=False, fill_value="extrapolate" ) - - xi = float(x_of_E(Ei)) - xf = xi + float(dl) + interp_cache[particle] = (E_of_x, x_of_E) - Ef = float(E_of_x(xf)) + return E_of_x, x_of_E - return max(Ef, 0.0) +def energy_loss(particle, Ei, dl): + + E_of_x, x_of_E = get_interpolators(particle) + + xi = x_of_E(Ei) + + xf = xi + dl + + Ef = E_of_x(xf) + + return np.maximum(Ef, 0.0) #def energy_loss_angular(particle, Ei, theta): def energy_reconstruction(particle, Ef, dl): - filename = f"E_vs_x_{particle}.dat" - data = pd.read_csv( - filename, - sep='\s+', - comment="#", - header=None, - skiprows=1 - ) - - x = data.iloc[:, 0].values - E = data.iloc[:, 1].values - - E_of_x = interp1d( - x, - E, - bounds_error=False, - fill_value=0.0 - ) - - x_of_E = interp1d( - E[::-1], # reverse so energy increases - x[::-1], - bounds_error=False, - fill_value="extrapolate" - ) - - xf = float(x_of_E(Ef)) + + E_of_x, x_of_E = get_interpolators(particle) + + xf = x_of_E(Ef) xi = xf - dl - Ei = float(E_of_x(xi)) + Ei = E_of_x(xi) - return max(Ei, 0.0) + return np.maximum(Ei, 0.0) def energy_distance(particle, Ei, Ef): - filename = f"E_vs_x_{particle}.dat" - data = pd.read_csv( - filename, - sep='\s+', - comment="#", - header=None, - skiprows=1 - ) - - x = data.iloc[:, 0].values - E = data.iloc[:, 1].values - - x_of_E = interp1d( - E[::-1], # reverse so energy increases - x[::-1], - bounds_error=False, - fill_value="extrapolate" - ) - - xi = float(x_of_E(Ei)) - xf = float(x_of_E(Ef)) - return abs(xf - xi) + _, x_of_E = get_interpolators(particle) + + xi = x_of_E(Ei) + + xf = x_of_E(Ef) + + return np.abs(xf - xi) def resolve_particle(name): @@ -307,11 +275,15 @@ class MyInteractiveApp(cmd.Cmd): def print_params(self): """Helper method to display current state""" - print(f"Current Parameters: T={self.T}, P={self.P}") + print(f"Current Parameters: T={self.T} K, P={self.P} Torr") def initialize_file(self): """Load in default root file for anasen""" - self.file = uproot.open(f"../Armory/{self.rootFile}") + try: + self.file = uproot.open(f"../Armory/{self.rootFile}") + except: + self.file = None + print("\nATTENTION: Root file not found, continue without uproot functions or uproot file manually") #intro = "Interactive Shell Started. Type 'help' to see commands." @@ -510,6 +482,7 @@ class MyInteractiveApp(cmd.Cmd): def do_uproot_file(self, arg): """Open a specific root file for inspection""" + global rootfile args = shlex.split(arg) if len(args) > 0: filename = args[0] @@ -517,9 +490,12 @@ class MyInteractiveApp(cmd.Cmd): filename = self.rootFile try: print(f"Opening {filename}") - with uproot.open(f"../Armory/{filename}") as tempfile: - self.file = tempfile + with uproot.open(f"../Armory/{filename}") as rootfile: + self.file = rootfile except FileNotFoundError: + with uproot.open(f"{filename}") as rootfile: + self.file = rootfile + except: print("Error: file not found") def do_print_file(self, arg): @@ -535,11 +511,12 @@ class MyInteractiveApp(cmd.Cmd): """Set a specific tree from the file (default to 'tree')""" file = self.file if len(arg) > 0: - treeName = f"tree{arg}" + treeName = f"{arg}" else: treeName = "tree" try: self.tree = file[treeName] + global tree tree = self.tree print(f"Tree: {tree}") print("Branches: ", tree.keys()) @@ -583,14 +560,10 @@ class MyInteractiveApp(cmd.Cmd): while True: try: entry = input(">>> ").strip() - if entry.lower() in ["exit", "quit"]: break - if not entry: continue - - # Try eval first so expressions print naturally try: result = eval(entry, globals(), local_vars) @@ -612,6 +585,131 @@ class MyInteractiveApp(cmd.Cmd): """Start up an in-program command line to use root tools with python, look up 'uproot' for more details""" self.run_command_line() + + def do_energy_analysis(self, arg): + + args = shlex.split(arg) + + try: + particle = args[0] + except IndexError: + print("Please indicate reactant for analysis") + return + + try: + max_events = int(args[1]) + except IndexError: + max_events = None + + if self.tree is None: + self.do_set_tree("") + print(f"Using TTree: {self.tree}") + + branches = [ + "Tb", + "thetab" + ] + + if max_events: + n_events = max_events + else: + n_events = self.tree.num_entries + + print(f"Loading {n_events} events...") + + data = self.tree.arrays( + branches, + library="np", + entry_stop=max_events + ) + + Ei = data["Tb"] + + theta = np.radians(data["thetab"]) + + # Remove theta = 0 events + mask = np.sin(theta) != 0 + + Ei = Ei[mask] + theta = theta[mask] + + sin_theta = np.sin(theta) + + radii = np.array([3.2, 4.2, 6.6]) + + dA = radii[0] / sin_theta + dC = radii[1] / sin_theta + dsx3 = radii[2] / sin_theta + + print("Calculating energy losses...") + + EA = energy_loss(particle, Ei, dA) + + EC = energy_loss(particle, Ei, dC) + + Esx3 = energy_loss(particle, Ei, dsx3) + + Eprop = EA - EC + + print("Analysis complete") + + print(f"Processed events: {len(Ei)}") + + print(f"Anode average energy: {np.mean(EA):.3f} MeV") + + print(f"Cathode average energy: {np.mean(EC):.3f} MeV") + + print(f"sx3 average energy: {np.mean(Esx3):.3f} MeV") + + print(f"Proportion counter average energy difference: {np.mean(Eprop):.3f} MeV") + + print(f"Maximum proportion counter energy difference: {np.max(Eprop):.3f} MeV") + + print(f"Minimum proportion counter energy difference: {np.min(Eprop):.3f} MeV") + + output_filename = "energy_analysis.root" + + print(f"Writing new tree to {output_filename}") + + # Load ALL original branches + all_data = self.tree.arrays(library="np", entry_stop=max_events) + + # Create full-length arrays initialized to NaN + n_total = len(data["Tb"]) + + EA_full = np.full(n_total, np.nan) + EC_full = np.full(n_total, np.nan) + Esx3_full = np.full(n_total, np.nan) + Eprop_full = np.full(n_total, np.nan) + + # Put values back into valid entries + EA_full[mask] = EA + EC_full[mask] = EC + Esx3_full[mask] = Esx3 + Eprop_full[mask] = Eprop + + # Add new branches + all_data["EA"] = EA_full + all_data["EC"] = EC_full + all_data["Esx3"] = Esx3_full + all_data["Eprop"] = Eprop_full + + # Write new ROOT file + with uproot.recreate(output_filename) as fout: + + branch_types = { + name: array.dtype + for name, array in all_data.items() + } + + fout.mktree("tree", branch_types) + + fout["tree"].extend(all_data) + + print("Finished writing augmented ROOT file") + + + if __name__ == "__main__": MyInteractiveApp().cmdloop() diff --git a/ELoss/PCEnergyAnalysis.zip b/ELoss/PCEnergyAnalysis.zip new file mode 100644 index 0000000..7d45b0b Binary files /dev/null and b/ELoss/PCEnergyAnalysis.zip differ