particleflow icon indicating copy to clipboard operation
particleflow copied to clipboard

CLIC samples: ddsim MCParticles parent/daughter indices are not correct

Open jpata opened this issue 1 year ago • 1 comments

Using this Pythia8 card:

Random:setSeed = on
Main:numberOfEvents = 100         ! number of events to generate
Main:timesAllowErrors = 5          ! how many aborts before run stops

! 2) Settings related to output in init(), next() and stat().
Init:showChangedSettings = on      ! list changed settings
Init:showChangedParticleData = off ! list changed particle data
Next:numberCount = 100             ! print message every n events
Next:numberShowInfo = 1            ! print event information n times
Next:numberShowProcess = 1         ! print process record n times
Next:numberShowEvent = 100           ! print event record n times

Beams:idA = 11                     ! first beam, e+ = 11
Beams:idB = -11                    ! second beam, e- = -11

Beams:eCM = 380                    ! CM energy of collision

PartonLevel:ISR = on               ! initial-state radiation
PartonLevel:FSR = on               ! final-state radiation

! Hard process: ff -> Z/gamma
WeakSingleBoson:ffbar2gmZ = on

! Z to tau decays
23:onMode   = off
23:onIfAny  = 15

And running the following simulation script:

source /cvmfs/sw.hsf.org/spackages6/key4hep-stack/2023-01-15/x86_64-centos7-gcc11.2.0-opt/csapx/setup.sh

echo "Random:seed=400001" >> card.cmd

k4run pythia.py -n 1 --Dumper.Filename out.hepmc --Pythia8.PythiaInterface.pythiacard card.cmd

ddsim --compactFile $LCGEO/CLIC/compact/CLIC_o3_v14/CLIC_o3_v14.xml \
      --outputFile out_sim_edm4hep.root \
      --steeringFile clic_steer.py \
      --inputFiles out.hepmc \
      --numberOfEvents 1\
      --random.seed 400001

At the Pythia8/HEPMC level, the parent/daughter indices are correct (check particles with * or **):

 --------  PYTHIA Event Listing  (complete event)  ---------------------------------------------------------------------------------

    no         id  name            status     mothers   daughters     colours      p_x        p_y        p_z         e          m
     0         90  (system)           -11     0     0     0     0     0     0      0.000      0.000      0.000    380.000    380.000
     1         11  (e-)               -12     0     0    10     0     0     0      0.000      0.000    190.000    190.000      0.001
     2        -11  (e+)               -12     0     0    11     0     0     0      0.000      0.000   -190.000    190.000      0.001
     3         11  (e-)               -21     6     0     5     0     0     0      0.000      0.000     10.258     10.258      0.000
     4        -11  (e+)               -21     7     7     5     0     0     0      0.000      0.000   -189.587    189.587      0.000
     5         23  (Z0)               -22     3     4     8     8     0     0      0.000      0.000   -179.329    199.845     88.201
     6         11  (e-)               -41    10    10     9     3     0     0     -0.000     -0.000    190.000    190.000      0.000
     7        -11  (e+)               -42    11     0     4     4     0     0      0.000      0.000   -189.587    189.587      0.000
     8         23  (Z0)               -44     5     5    12    12     0     0     -0.272     -1.590   -179.322    199.845     88.201
     9         22  (gamma)            -43     6     0    13    13     0     0      0.272      1.590    179.734    179.742      0.000
    10         11  (e-)               -42     1     0     6     6     0     0      0.000      0.000    190.000    190.000      0.000
    11        -11  (e+)               -41     2     0    14     7     0     0     -0.000     -0.000   -190.000    190.000      0.000
    12         23  (Z0)               -44     8     8    17    18     0     0     -0.345     -1.716   -179.335    199.859     88.201
    13         22  gamma               44     9     9     0     0     0     0      0.272      1.590    179.721    179.729      0.000
    14         22  gamma               43    11     0     0     0     0     0      0.072      0.126     -0.386      0.413      0.000
    15         22  gamma               63     1     0     0     0     0     0      0.000      0.000      0.000      0.000      0.000
    16         22  gamma               63     2     0     0     0     0     0      0.000      0.000     -0.000      0.000      0.000
    17         15  (tau-)             -23    12     0    21    21     0     0    -13.056    -23.287   -171.484    173.558      1.777
    18        -15  (tau+)             -23    12     0    19    20     0     0     12.711     21.571     -7.851     26.300      1.777
  * 19        -15  (tau+)             -51    18     0    22    25     0     0     12.711     21.571     -7.851     26.300      1.777
    20         22  gamma               51    18     0     0     0     0     0      0.000      0.000      0.000      0.000      0.000
 ** 21         15  (tau-)             -52    17    17    26    28     0     0    -13.056    -23.287   -171.484    173.558      1.777
  * 22        -16  nu_taubar           91    19     0     0     0     0     0      3.521      6.005     -1.609      7.144      0.000
  * 23        111  (pi0)              -91    19     0    29    30     0     0      5.670      9.444     -4.090     11.751      0.135
  * 24        111  (pi0)              -91    19     0    31    32     0     0      1.825      3.367     -0.929      3.943      0.135
  * 25        211  pi+                 91    19     0     0     0     0     0      1.695      2.756     -1.223      3.461      0.140
 ** 26         16  nu_tau              91    21     0     0     0     0     0     -5.449     -8.875    -70.787     71.549      0.000
 ** 27         11  e-                  91    21     0     0     0     0     0     -1.761     -3.540    -22.588     22.931      0.001
 ** 28        -12  nu_ebar             91    21     0     0     0     0     0     -5.846    -10.872    -78.109     79.078      0.000
    29         22  gamma               91    23     0     0     0     0     0      5.043      8.363     -3.667     10.432      0.000
    30         22  gamma               91    23     0     0     0     0     0      0.627      1.081     -0.423      1.319      0.000
    31         22  gamma               91    24     0     0     0     0     0      1.117      2.068     -0.638      2.436      0.000
    32         22  gamma               91    24     0     0     0     0     0      0.708      1.299     -0.292      1.508      0.000
                                   Charge sum:  0.000           Momentum sum:     -0.000     -0.000     -0.000    380.000    380.000

But after ddsim, additional particles are inserted by the simulation and the indices are no longer correct:

$ root -l p8_ee_Z_Ztautau_ecm380_/out_sim_edm4hep.root 
root [5] events->Scan("MCParticles.PDG:MCParticles.daughters_begin:MCParticles.daughters_end")
***********************************************************
*    Row   * Instance * MCParticl * MCParticl * MCParticl *
***********************************************************
*        0 *        0 *        11 *         0 *         2 *
*        0 *        1 *        11 *         2 *         3 *
*        0 *        2 *        22 *         3 *         3 *
*        0 *        3 *       -11 *         3 *         5 *
*        0 *        4 *       -11 *         5 *         7 *
*        0 *        5 *        22 *         7 *         7 *
*        0 *        6 *        11 *         7 *         9 *
*        0 *        7 *       -11 *         9 *        10 *
*        0 *        8 *        22 *        10 *        10 *
*        0 *        9 *        11 *        10 *        11 *
*        0 *       10 *        22 *        11 *        12 *
*        0 *       11 *       -11 *        12 *        13 *
*        0 *       12 *        23 *        13 *        14 *
*        0 *       13 *        22 *        14 *        14 *
*        0 *       14 *        23 *        14 *        15 *
*        0 *       15 *        23 *        15 *        17 *
*        0 *       16 *        15 *        17 *        18 *
*        0 *       17 *       -15 *        18 *        20 *
*        0 *       18 *        15 *        20 *        23 * -> tau- daughters [20,23), but should be [21,22,23]. Extra photon inserted at idx=20
*        0 *       19 *       -15 *        23 *        27 * -> tau+ daughters [23,27), but should be [24,25,26,27]. Extra photon inserted at idx=20
*        0 *       20 *        22 *        27 *        27 *
*        0 *       21 *        16 *        27 *        27 *
*        0 *       22 *        11 *        27 *        31 *
*        0 *       23 *       -12 *        31 *        31 *
*        0 *       24 *       -16 *        31 *        31 *
*        0 *       25 *       111 *        31 *        33 *
*        0 *       26 *       111 *        33 *        35 *
*        0 *       27 *       211 *        35 *        38 *
*        0 *       28 *        22 *        38 *        38 *
*        0 *       29 *        22 *        38 *        38 *
*        0 *       30 *        22 *        38 *        38 *
*        0 *       31 *        22 *        38 *        38 *
*        0 *       32 *        11 *        38 *        38 *
*        0 *       33 *      2212 *        38 *        38 *
*        0 *       34 *       -11 *        38 *        38 *
*        0 *       35 *        22 *        38 *        38 *
*        0 *       36 *        22 *        38 *        38 *
*        0 *       37 *        22 *        38 *        38 *
*        0 *       38 *        22 *        38 *        38 *
***********************************************************

Need to understand if this is a ddsim issue, or something else. This does not seem to affect MLPF studies directly so far, but becomes an issue if you try to trace the exact heritage of generator-level particles (and perhaps points to some additional questions about the Key4HEP/ddsim-based setup).

jpata avatar Apr 11 '24 16:04 jpata

FYI @etiennedreyer I made the issue here so there's a bit more of a public record. I think it's ddsim not Key4HEP at this point.

jpata avatar Apr 11 '24 16:04 jpata