impy-project / chromo

Hadronic Interaction Model interface in PYthon
Other
30 stars 7 forks source link

Unified treatment of beam particles #170

Closed jncots closed 1 year ago

jncots commented 1 year ago

Fixes #101.

The patch prepend to event 2 beam particles if the generator doesn't contain them, or refill 2 first entry if generator doesn't produce correct one (case of nuclei for DpmJet). These 2 beam particles are calculated from EventKinematics and take into account reference frames of generator and EventKinematics to provide correct px, py, pz, en values. 2 beam particles have status == 4.

The event entries for beam particles are calculated only once for EventKinematics object and then applied for each event generated for this EventKinematics. Therefore, the beam particles event entries are kept in EventKinematics as one of the attribute.

For the particles which have mothers = [-1, -1] and some other similar combinations ([0, -1], [1, -1], [1, 1]), the mothers are reset to [0,1], so all such particles are daughters of beam particles. Phojet193 has mothers of the kind [6, 4]. I don't know what it means, but when such event are stored, pyhepmc produces error. I swapped number to [4, 6] to fix this. Svg graphs after these fixes have a single origin vertex where beam particles meet.

jncots commented 1 year ago

BeamData class contains beam particles in the format of EventData. Each event kinematics contains an instance of BeamData ready to apply to the event produced by generator. It is done because of efficiency considerations, otherwise one should create a new BeamData for each new event. However, it is still needed to create a new BeamData in case of CompositeTarget.

Initially implementation used EventData, but there is a circular dependence + there is a need for ref_frame attribute. However, if there is an idea how to use EventData instead of BeamData I will change it back.

Some tests were changed to reflect changes in MCEvent class.

jncots commented 1 year ago

It seems that all tests pass. It is a part of #165 issue. Together with #167 it is a part of release #164.

jncots commented 1 year ago

@HDembinski, thanks for comments, the implementation became much simpler. Now it is consist of one additional method for EventKinematics: get_beam_data and 2 methods in EventData. I needed an inverse boost, so I added 1 parameter for apply_boost and used SimpleNamespace to have en, pz attributes.

jncots commented 1 year ago

There have been introduced couple of changes.

jncots commented 1 year ago

Following the discussion in #164

jncots commented 1 year ago

I noticed 2 following problems with Phojet and Dpmjet.

C in SUBROUTINE DT_LT2LAB

C This

      DO i = NPOint(4) , NHKk
         IF ( (ABS(ISThkk(i)).EQ.1) .OR. (ISThkk(i).EQ.1000) .OR. 
     &        (ISThkk(i).EQ.1001) ) THEN
            CALL DT_LTNUC(PHKk(3,i),PHKk(4,i),pz,pe,-3)
            PHKk(3,i) = pz
            PHKk(4,i) = pe
         END IF
      END DO

C should be changed to

      DO i = 1 , NHKk
            CALL DT_LTNUC(PHKk(3,i),PHKk(4,i),pz,pe,-3)
            PHKk(3,i) = pz
            PHKk(4,i) = pe
      END DO

@afedynitch, could you change it?

afedynitch commented 1 year ago

Cool! Did you try the proposed source code? It may need to be behind a flag, maybe. Need to have a deeper look

jncots commented 1 year ago

Cool! Did you try the proposed source code? It may need to be behind a flag, maybe. Need to have a deeper look

Yes, I tried it. It works good.

I also tried to fix the energy using only chromo:

self._lib.dtflg1.iframe = 2
self._frame = EventFrame.CENTER_OF_MASS

but I've seen events where the energy of decayed particle (rho+ if I remember it correctly) is larger than the sum of its products.

jncots commented 1 year ago

The issues noticed by @afedynitch have been resolved.

Problems with Phojet (removed history) and Dpmjet (Lorentz boost only for final particles) should be resolved.

One strage behaviour of EposLHC is noticed in connection with test_final_state: it produce different particles from run to run for the same seed. Because of that it is not possible to define known_issues to pass the test.

afedynitch commented 1 year ago

EposLHC is noticed in connection with test_final_state: it produce different particles from run to run for the same seed.

Does it mean that it doesn't conserve the random number sequence? It would be strange because it runs in CORSIKA 7.

HDembinski commented 1 year ago

Does it mean that it doesn't conserve the random number sequence? It would be strange because it runs in CORSIKA 7.

I worked on the rng instrumentation in EPOS-LHC. It is confusing because they use several seeds. Maybe some of them are not properly initialized. I believe it is rather a bug in our RNG handling than in EPOS-LHC itself.