diff --git a/t25_offline_digit/mac/main1.mac b/t25_offline_digit/mac/main1.mac index 16def97..cbc4060 100644 --- a/t25_offline_digit/mac/main1.mac +++ b/t25_offline_digit/mac/main1.mac @@ -168,9 +168,9 @@ #/gate/digitizer/Singles/insert readout #/gate/digitizer/Singles/readout/setDepth 1 -#/gate/digitizer/Singles/insert blurring -#/gate/digitizer/Singles/blurring/setResolution 0.26 -#/gate/digitizer/Singles/blurring/setEnergyOfReference 511. keV +/gate/digitizer/Singles/insert blurring +/gate/digitizer/Singles/blurring/setResolution 0.26 +/gate/digitizer/Singles/blurring/setEnergyOfReference 511. keV /gate/digitizer/Singles/insert thresholder /gate/digitizer/Singles/thresholder/setThreshold 350. keV @@ -182,6 +182,8 @@ #===================================================== /gate/digitizer/Coincidences/setWindow 10. ns +/gate/digitizer/Coincidences/minSectorDifference 1 +/gate/digitizer/Coincidences/MultiplesPolicy killAll #===================================================== # P A R T I C L E S O U R C E diff --git a/t25_offline_digit/mac/main1_offline_digitizer.mac b/t25_offline_digit/mac/main1_offline_digitizer.mac index 1711f40..7a68e8b 100644 --- a/t25_offline_digit/mac/main1_offline_digitizer.mac +++ b/t25_offline_digit/mac/main1_offline_digitizer.mac @@ -7,12 +7,6 @@ /gate/digitizer/layers/insert adder -#/gate/digitizer/layers/insert readout -#/gate/digitizer/layers/readout/setDepth 1 - -#/gate/digitizer/Singles/insert adder -#/gate/digitizer/Singles/insert readout -#/gate/digitizer/Singles/readout/setDepth 1 /gate/digitizer/layers/insert blurring /gate/digitizer/layers/blurring/setResolution 0.26 @@ -26,9 +20,6 @@ # INITIALIZE is needed to recover volumeID from hits using DetectorConstruction /gate/run/initialize -#======================================================================= -# how to include a R A N D O M E N G I N E A N D S E E D for offline digitizer ??? -#============================================================================================= diff --git a/t25_offline_digit/mac/main1_offline_geom.mac b/t25_offline_digit/mac/main1_offline_geom.mac new file mode 100644 index 0000000..c41936b --- /dev/null +++ b/t25_offline_digit/mac/main1_offline_geom.mac @@ -0,0 +1,9 @@ + + +# Geometry is needed to identify layer with volumeID of hits and to perform operations with pulses +/gate/geometry/setMaterialDatabase data/GateMaterials_pet.db +/control/execute mac/PET_CylindricalPET_geom.mac + + +# INITIALIZE is needed to recover volumeID from hits using DetectorConstruction +/gate/run/initialize diff --git a/t25_offline_digit/mac/main1_offline_sorter.mac b/t25_offline_digit/mac/main1_offline_sorter.mac index 09af9cf..10d94fb 100644 --- a/t25_offline_digit/mac/main1_offline_sorter.mac +++ b/t25_offline_digit/mac/main1_offline_sorter.mac @@ -5,6 +5,10 @@ /gate/digitizer/Coincidences/setWindow 10. ns +#/gate/digitizer/Coincidences/setAcceptancePolicy4CC keepIfMultipleVolumeIDsInvolved +/gate/digitizer/Coincidences/setAcceptancePolicy4CC keepAll +#why there are more coincidences in keepAll than in keepIfMultipleVolumeIDsInvolved ? Is it possible that in the semi head BGo and LSO same volume ID ?? To be checked, + # There may be problems since by default in PET there is this minSectorDifference. # I do not know how this is read offline. diff --git a/t25_offline_digit/readme.md b/t25_offline_digit/readme.md index 78fe7da..7aa8023 100644 --- a/t25_offline_digit/readme.md +++ b/t25_offline_digit/readme.md @@ -10,21 +10,43 @@ Simple Cylindrical PET with 20 x 20 block, 5x5 crystal, LSO and BGO layer, 4 rin - Source: back to back 511 keV, half-life of 1223 sec (C11) ```shell -Gate mac/main2.mac +Gate mac/main1.mac ``` -This will generate ```output/output1.root``` with all hits only. +This will generate ```output/output1.root``` with hits, singles and coincidences - -```shell +Offline digitizer +```shell GateDigit_hits_digitizer output/output1.root output/output1-singles.root mac/main1_offline_digitizer.mac ``` -This will generate ```output/output1-singles.root``` with the singles. +This will generate ```output/output1-singles.root``` with the singles. There is an error message since there are branches not found since it is designed for CCMod data and those branches are missing here + +Offline sorter +```shell +GateDigit_singles_sorter output/output1-singles.root output/output1-coincCCMod.root mac/main1_offline_sorter.mac abs +GateDigit_singles_sorter output/output1.root output/output1-coincCCMod.root mac/main1_offline_sorter.mac abs +``` +We can generate the coincidences either from the singles of simulation stored in ```output/output1.root``` or from the offline generated singles ```output/output1-singles.root``` +This will generate ```output/output1-coincCCMod.root``` with the coincidences + +Convert CCMod coincidences into PET/SPECT coincidences format ( On branch anetxe offlineDigitizer, not yet in OpenGate) +```shell + Convert_CCMod2PETCoinc output/output1-coincCCMod.root output/output1-coinc.root mac/main1_offline_geom.mac + ``` + test with gam_gate. test_main.py + + ## Example 1.b + +Simple Cylindrical PET with 20 x 20 block, 5x5 crystal, LSO and BGO layer, 4 rings. +- No phantom. +- Physics list: emstandard_opt4 +- Digitizer: adder, readout (depth 1 or head), threshold, coinc 10 ns +- Source: back to back 511 keV, half-life of 1223 sec (C11) ```shell -GateDigit_singles_sorter output/output1-singles.root output/output1-coinc.root mac/main1_offline_sorter.mac abs +Gate mac/main1b.mac ``` -This will generate ```output/output1-coinc.root``` with the singles. +This will generate ```output/output1b.root``` with hits, singles and coincidences diff --git a/t25_offline_digit/test_main1.py b/t25_offline_digit/test_main1.py index 9cfeace..beb1b36 100755 --- a/t25_offline_digit/test_main1.py +++ b/t25_offline_digit/test_main1.py @@ -20,7 +20,7 @@ is_ok = gam.compare_root3(root_ref, root_offline, "Singles", "Singles", checked_keys, checked_keys, - tols, scalings, scalings, + tols, scalings, 'output/main1_root_singles.png') print(is_ok) @@ -28,25 +28,30 @@ # ------------------------------------------------------ # not yet possible to compare -'''print() +print() gam.warning('Compare root coinc') root_ref = 'output/output1.root' root_offline = 'output/output1-coinc.root' -checked_keys = ['time', 'energy', - 'globalPosX', 'globalPosY', 'globalPosZ'] +checked_keys = ['time1','time2', 'energy1','energy2', + 'globalPosX1','globalPosX2', 'globalPosY1','globalPosY2', 'globalPosZ1','globalPosZ2'] scalings = [1] * len(checked_keys) tols = [0.01] * len(checked_keys) -tols[0] = 0.02 # time -tols[1] = 0.001 # energy -tols[2] = 0.8 # globalPosX -tols[3] = 0.4 # globalPosY -tols[4] = 0.2 # globalPosZ +tols[0] = 0.02 # time1 +tols[1] = 0.02 +tols[2] = 0.001 # energy1 +tols[3] = 0.001 # energy2 +tols[4] = 0.8 # globalPosX1 +tols[5] = 0.8 # globalPosX2 +tols[6] = 0.8 # globalPosY1 +tols[7] = 0.8 # globalPosY2 +tols[8] = 0.2 # globalPosZ1 +tols[9] = 0.2 # globalPosZ2 print(scalings, tols) is_ok = gam.compare_root3(root_ref, root_offline, "Coincidences", "Coincidences", checked_keys, checked_keys, - tols, scalings, scalings, - 'output/main1_root_singles.png') -print(is_ok)''' + tols, scalings, + 'output/main1_root_coincidences.png') +print(is_ok)