DataMedSci / pymchelper

Python toolkit for SHIELD-HIT12A and FLUKA
http://datamedsci.github.io/pymchelper/
15 stars 7 forks source link

MCPL support #648

Closed grzanka closed 1 year ago

grzanka commented 1 year ago

Task list

reviewpad[bot] commented 1 year ago

Reviewpad Report (Reviewpad ran in dry-run mode because configuration has changed)

:scroll: Executed actions

$removeLabel("small")
$addLabel("medium")
$removeLabel("large")
grzanka commented 1 year ago

Still need to fix the structure:

(venv) PS C:\Users\Legion\workspace\pymchelper> convertmc mcpl .\tests\res\shieldhit\phasespace\NB_mcpl.bdo     
pdg: 2112.0, x: 0.02841245855746416, y: 0.005381326517123001, z: 4.0, ux: 0.008368598854519025, uy: -0.0015112242565019493, uz: 0.9999638407234828, E: 220.83161028749896
pdg: 2112.0, x: -0.016753015625251024, y: 0.032982799399799555, z: 4.0, ux: -0.0003855503288847568, uy: 0.003905925140359323, uz: 0.9999922975202068, E: 220.78200600572228
pdg: 2112.0, x: -0.03045585773897754, y: -0.0015392903504354676, z: 4.0, ux: -0.017768943962805792, uy: -0.00483371517926503, uz: 0.9998304355379529, E: 229.72058121490994
pdg: 2112.0, x: -0.23353810218223514, y: 0.46784391985896534, z: 4.0, ux: -0.2551114520775071, uy: 0.6091456431713554, uz: 0.7509059411299538, E: 118.98561705387954
pdg: 2112.0, x: 0.23005488393108486, y: -0.5736083320982837, z: 4.0, ux: 0.30757130651284637, uy: -0.6495784291684316, uz: 0.6953040743222016, E: 104.07411750473523
pdg: 2112.0, x: -0.027765238251825208, y: -0.009169230838687321, z: 4.0, ux: -0.0045242894037715075, uy: 0.003196000663551066, uz: 0.9999846580748873, E: 227.62945320865532
pdg: 2112.0, x: -0.00146986131254359, y: 0.0021216157821973467, z: 4.0, ux: 0.00022752283559986387, uy: 0.0017018660135599557, uz: 0.9999985259416292, E: 231.78859667115555
pdg: 2112.0, x: 0.03332980360156399, y: 0.005258629554694337, z: 4.0, ux: 0.021906868237701205, uy: 0.008884413960814097, uz: 0.9997205391070991, E: 232.33478828048143
pdg: 2112.0, x: 0.002918224309108038, y: -0.014254672087002162, z: 4.0, ux: 0.013585492923564788, uy: -0.008526566455317427, uz: 0.9998713577488391, E: 226.37661702172193
pdg: 2112.0, x: 0.009329617993003683, y: -0.01655540102414879, z: 4.0, ux: -0.004557773000634433, uy: 0.0039018137919602726, uz: 0.9999820011152238, E: 231.3061693987574
pdg: 2112.0, x: 0.02841245855746416, y: 0.005381326517123001, z: 4.0, ux: 0.008368598854519025, uy: -0.0015112242565019493, uz: 0.9999638407234828, E: 220.83161028749896
pdg: 2112.0, x: -0.016753015625251024, y: 0.032982799399799555, z: 4.0, ux: -0.0003855503288847568, uy: 0.003905925140359323, uz: 0.9999922975202068, E: 220.78200600572228
pdg: 2112.0, x: -0.03045585773897754, y: -0.0015392903504354676, z: 4.0, ux: -0.017768943962805792, uy: -0.00483371517926503, uz: 0.9998304355379529, E: 229.72058121490994
pdg: 2112.0, x: -0.23353810218223514, y: 0.46784391985896534, z: 4.0, ux: -0.2551114520775071, uy: 0.6091456431713554, uz: 0.7509059411299538, E: 118.98561705387954
pdg: 2112.0, x: 0.23005488393108486, y: -0.5736083320982837, z: 4.0, ux: 0.30757130651284637, uy: -0.6495784291684316, uz: 0.6953040743222016, E: 104.07411750473523
pdg: 2112.0, x: -0.027765238251825208, y: -0.009169230838687321, z: 4.0, ux: -0.0045242894037715075, uy: 0.003196000663551066, uz: 0.9999846580748873, E: 227.62945320865532
pdg: 2112.0, x: -0.00146986131254359, y: 0.0021216157821973467, z: 4.0, ux: 0.00022752283559986387, uy: 0.0017018660135599557, uz: 0.9999985259416292, E: 231.78859667115555
pdg: 2112.0, x: 0.03332980360156399, y: 0.005258629554694337, z: 4.0, ux: 0.021906868237701205, uy: 0.008884413960814097, uz: 0.9997205391070991, E: 232.33478828048143
pdg: 2112.0, x: 0.002918224309108038, y: -0.014254672087002162, z: 4.0, ux: 0.013585492923564788, uy: -0.008526566455317427, uz: 0.9998713577488391, E: 226.37661702172193
pdg: 2112.0, x: 0.009329617993003683, y: -0.01655540102414879, z: 4.0, ux: -0.004557773000634433, uy: 0.0039018137919602726, uz: 0.9999820011152238, E: 231.3061693987574
pdg: 2112.0, x: 0.02841245855746416, y: 0.005381326517123001, z: 4.0, ux: 0.008368598854519025, uy: -0.0015112242565019493, uz: 0.9999638407234828, E: 220.83161028749896
pdg: 2112.0, x: -0.016753015625251024, y: 0.032982799399799555, z: 4.0, ux: -0.0003855503288847568, uy: 0.003905925140359323, uz: 0.9999922975202068, E: 220.78200600572228
pdg: 2112.0, x: -0.03045585773897754, y: -0.0015392903504354676, z: 4.0, ux: -0.017768943962805792, uy: -0.00483371517926503, uz: 0.9998304355379529, E: 229.72058121490994
pdg: 2112.0, x: -0.23353810218223514, y: 0.46784391985896534, z: 4.0, ux: -0.2551114520775071, uy: 0.6091456431713554, uz: 0.7509059411299538, E: 118.98561705387954
pdg: 2112.0, x: 0.23005488393108486, y: -0.5736083320982837, z: 4.0, ux: 0.30757130651284637, uy: -0.6495784291684316, uz: 0.6953040743222016, E: 104.07411750473523
pdg: 2112.0, x: -0.027765238251825208, y: -0.009169230838687321, z: 4.0, ux: -0.0045242894037715075, uy: 0.003196000663551066, uz: 0.9999846580748873, E: 227.62945320865532
pdg: 2112.0, x: -0.00146986131254359, y: 0.0021216157821973467, z: 4.0, ux: 0.00022752283559986387, uy: 0.0017018660135599557, uz: 0.9999985259416292, E: 231.78859667115555
pdg: 2112.0, x: 0.03332980360156399, y: 0.005258629554694337, z: 4.0, ux: 0.021906868237701205, uy: 0.008884413960814097, uz: 0.9997205391070991, E: 232.33478828048143
pdg: 2112.0, x: 0.002918224309108038, y: -0.014254672087002162, z: 4.0, ux: 0.013585492923564788, uy: -0.008526566455317427, uz: 0.9998713577488391, E: 226.37661702172193
pdg: 2112.0, x: 0.009329617993003683, y: -0.01655540102414879, z: 4.0, ux: -0.004557773000634433, uy: 0.0039018137919602726, uz: 0.9999820011152238, E: 231.3061693987574    
pdg: 2112.0, x: -0.009268427789286311, y: -0.019544112549358218, z: 4.0, ux: -0.0046800736236272695, uy: -0.011873819652315078, uz: 0.9999185513419289, E: 227.75700590080007
pdg: 2112.0, x: 0.01965110189872477, y: -0.0059484470294552715, z: 4.0, ux: 0.011063641346092503, uy: 0.00870468943476884, uz: 0.9999009072013132, E: 224.76373908144237     
pdg: 2112.0, x: 0.001249278502080804, y: -0.008354966359701703, z: 4.0, ux: 0.00031688998304216936, uy: -0.0020841490438794387, uz: 0.9999977779492821, E: 231.7792127288987 
pdg: 2112.0, x: -0.0008117830051161366, y: -0.022163831441723514, z: 4.0, ux: 0.008660309974038742, uy: -0.013561927139437883, uz: 0.9998705282002357, E: 220.2978799669522  
pdg: 2112.0, x: 0.02396174220377775, y: 0.03235753411830211, z: 4.0, ux: 0.01230454523532541, uy: 0.013218930197766507, uz: 0.9998369157272492, E: 229.6215299891538
pdg: 2112.0, x: -0.005528735885607691, y: 0.03517167215208541, z: 4.0, ux: -0.0036526363636939685, uy: 0.007500709124628177, uz: 0.9999651981995286, E: 232.7510415852874    
pdg: 2112.0, x: -0.008303503910235505, y: -0.001772296921937754, z: 4.0, ux: 0.0017406539061439288, uy: 0.00880144397420549, uz: 0.999959751544005, E: 232.18224704971084    
pdg: 2112.0, x: 0.020459722343568663, y: 0.015035636209265818, z: 4.0, ux: 0.005402263464872512, uy: 0.004238019392616957, uz: 0.999976427092701, E: 225.50238799800252      
pdg: 2112.0, x: 0.02539066169495961, y: 0.0038357650695857314, z: 4.0, ux: 0.0144524148790347, uy: -0.001646996681138091, uz: 0.9998942019564354, E: 228.19576003791616      
pdg: 2112.0, x: -0.019219329083276934, y: 0.0028533299024403555, z: 4.0, ux: -0.010597267116947544, uy: -0.00034445552692950575, uz: 0.9999437880601298, E: 231.08336704325734
pdg: 2112.0, x: 0.04567718834403255, y: 0.023295110530366918, z: 4.0, ux: 0.019949293971612953, uy: 0.012188857166533191, uz: 0.9997266913666994, E: 230.4633665257661       
pdg: 2112.0, x: -0.026050002407379064, y: 0.008276002881973053, z: 4.0, ux: -0.004530763267700725, uy: 0.006621388596367541, uz: 0.9999678141806704, E: 224.50153432156083   
pdg: 2112.0, x: -0.02298119185768402, y: 0.015000435362255298, z: 4.0, ux: -0.0070329041269107245, uy: 0.006435395345041428, uz: 0.9999545609407933, E: 223.8490536288937    
pdg: 2112.0, x: 0.009248112120590355, y: 0.00027240719020550034, z: 4.0, ux: 0.005773513097039758, uy: 0.006977590335068262, uz: 0.999958989048868, E: 227.3196473580502     
pdg: 2112.0, x: 0.00874646306199803, y: -0.013641805946216772, z: 4.0, ux: 0.00025752873879711065, uy: -0.009601808061422154, uz: 0.9999538684163886, E: 239.84578389939992  
(venv) PS C:\Users\Legion\workspace\pymchelper> pymcpltool .\NB_mcpl_p1.mcpl
Opened MCPL file NB_mcpl_p1.mcpl:

  Basic info
    Format             : MCPL-3
    No. of particles   : 10
    Header storage     : 82 bytes
    Data storage       : 40 bytes

  Custom meta data
    Source             : "pymchelper 2.4.1+rev13"
    Number of comments : 0
    Number of blobs    : 0

  Particle data format
    User flags         : no
    Polarisation info  : no
    Fixed part. type   : no
    Fixed part. weight : yes (weight 1)
    FP precision       : single
    Endianness         : little
    Storage            : 4 bytes/particle

index     pdgcode   ekin[MeV]       x[cm]       y[cm]       z[cm]          ux          uy          uz    time[ms]
    0  1065427854        2.25 -4.9001e+10      1.2273  -6.349e+13      0.9611           0      0.2762   7.125e+11
    1  -656336089           0 -1.0249e-09    -0.84672 -5.3457e-31      0.9624           0     0.27164  2.9595e-42
    2 -1751021927   1.107e-30      -1.134  1.3376e-23      1.2569           0     0.89581     0.44444     -0.7237
    3 -1080086574  2.9595e-42     0.93749  3.5722e-09      3.6812           0           0           1  1.2671e-36
    4 -1082930044      1.1422  6.9998e+27    -0.84851           0    -0.89581 -9.0908e-17     0.44444 -4.9917e-33
    5 -1613017326  1.0279e-24  7.8996e-39      3.6987           0           0  2.9595e-42          -1     -1.6085
    6  1502425784   2.328e-38      1.7339           0        2.25           0     -1.6276 -4.2892e-37      1.7773
    7 -1075684609      1.6051      3.4648           0           0  2.9595e-42    0.055284     0.99847 -2.5491e+17
    8  1079641278      1.7874           0        2.25 -1.6791e-29    -0.79647 -8.1442e-08     0.60467  2.3829e+14
    9           0  5.7447e+12           0           0  2.9595e-42 -7.0006e-24     0.57486    -0.81825     -1.0217
grzanka commented 1 year ago

Concatenation of multiple bdo files into single MCPL file is not implemented yet, but conversion of single BDO to single MCPL could be tested. To try it i an empty directory do:

python -m venv venv
. venv/bin/activate
pip install git+https://github.com/DataMedSci/pymchelper.git@628-support-for-new-detector-in-shield-hit12a-mcpl
convertmc mcpl path_to_NB_mcpl.bdo
pip install mcpl
pymcpltool .\NB_mcpl_p1.mcpl

@nbassler would you like to test if before proceeding with concatenation ?

nbassler commented 1 year ago

page 1: no filter, 10 k page 2: proton filter, 10 k page 3: proton filter, 25 k override

(env) bassler@kepler:~/Projects/pymchelper$ pymcpltool --stats NB_mcpl_p1.mcpl
------------------------------------------------------------------------------
nparticles   : 10000
sum(weights) : 10000
------------------------------------------------------------------------------
             :            mean             rms             min             max
------------------------------------------------------------------------------
ekin   [MeV] :          199.77         70.5268     7.82424e-10         245.711
x       [cm] :        0.118766         6.08305        -111.589         130.555
y       [cm] :         0.09751         5.48947        -102.365         146.269
z       [cm] :               4               0               4               4
ux           :    -0.000538088        0.191403       -0.994108        0.991571
uy           :      0.00365777        0.187068       -0.993388        0.997862
uz           :        0.872736        0.408276       -0.996652               1
time    [ms] :               0               0               0               0
weight       :               1               0               1               1
polx         :               0               0               0               0
poly         :               0               0               0               0
polz         :               0               0               0               0
------------------------------------------------------------------------------
pdgcode      :        2112 (n)                  8839 (88.39%)
                      2212 (p)                  1158 (11.58%)
                1000020040 (alpha)                 2 ( 0.02%)
                1000010030 (T)                     1 ( 0.01%)
                     [ values ]             [ weighted counts ]
------------------------------------------------------------------------------
userflags    :           0 (0x00000000)        10000 (100.00%)
                     [ values ]             [ weighted counts ]
------------------------------------------------------------------------------
(env) bassler@kepler:~/Projects/pymchelper$ pymcpltool --stats NB_mcpl_p2.mcpl
------------------------------------------------------------------------------
nparticles   : 10000
sum(weights) : 10000
------------------------------------------------------------------------------
             :            mean             rms             min             max
------------------------------------------------------------------------------
ekin   [MeV] :         223.432         23.5902         1.48021         245.711
x       [cm] :     -0.00218875         0.24803        -7.15076         5.32751
y       [cm] :     0.000516612         0.27348        -4.85486         8.39711
z       [cm] :               4               0               4               4
ux           :    -0.000476368       0.0828518       -0.874886        0.919853
uy           :    -0.000117899       0.0855315       -0.993388         0.96495
uz           :        0.990388       0.0703668        -0.98838               1
time    [ms] :               0               0               0               0
weight       :               1               0               1               1
polx         :               0               0               0               0
poly         :               0               0               0               0
polz         :               0               0               0               0
------------------------------------------------------------------------------
pdgcode      :        2112 (n)                 10000 (100.00%)
                     [ values ]             [ weighted counts ]
------------------------------------------------------------------------------
userflags    :           0 (0x00000000)        10000 (100.00%)
                     [ values ]             [ weighted counts ]
------------------------------------------------------------------------------
(env) bassler@kepler:~/Projects/pymchelper$ pymcpltool --stats NB_mcpl_p3.mcpl
------------------------------------------------------------------------------
nparticles   : 25000
sum(weights) : 25000
------------------------------------------------------------------------------
             :            mean             rms             min             max
------------------------------------------------------------------------------
ekin   [MeV] :         223.051         24.8326         1.48021         245.711
x       [cm] :      0.00069079        0.382293        -7.15076         39.5726
y       [cm] :      0.00378688        0.384547        -6.55384         40.9435
z       [cm] :               4               0               4               4
ux           :    -0.000500529       0.0880386       -0.984036         0.97848
uy           :     0.000357538       0.0875018       -0.993388         0.96495
uz           :        0.989852       0.0691793        -0.98838               1
time    [ms] :               0               0               0               0
weight       :               1               0               1               1
polx         :               0               0               0               0
poly         :               0               0               0               0
polz         :               0               0               0               0
------------------------------------------------------------------------------
pdgcode      :        2112 (n)                 25000 (100.00%)
                     [ values ]             [ weighted counts ]
------------------------------------------------------------------------------
userflags    :           0 (0x00000000)        25000 (100.00%)
                     [ values ]             [ weighted counts ]
------------------------------------------------------------------------------
(env) bassler@kepler:~/Projects/pymchelper$ 
nbassler commented 1 year ago

also nice plots can be made:

$ pymcpltool NB_mcpl_p1.mcpl --stats --gui

image image image