Skip to content
Snippets Groups Projects

Add ParticleID::isQuark method

Merged Alex Pearce requested to merge apearce-add-particleid-isquark into master

Adds method ParticleID::isQuark that returns true if the absolute ID of the particle is less than 11. Also updates a test to print the value of this property, and adds a reference file for that test.

These changes represent my proposal for fixing LHCBPS-1718. (I'll create a separate MR in Analysis for Phys/DaVinciMCTools if this is approved.)

/cc @gcorti @gligorov (as cc'd in the issue) and @ibelyaev (as the author of the test)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • @apearce
    Hi Alex,

    1. The current method evaluates to true for invalid particle ID (0).. I think it is not good - at least it is not very logical. for invalid ID, it is better to return false for "isQuark"-method.
    2. To be more consistent, I woudd also sugest to modify the method hasQuarks : : return isQuark() || ( .... ) ;
    3. I have some worries about magic appearence of 11.. Does 10 corresponds to quark? Would it be better to code isQuark in terms of only 6 quarks?
    const unnsigned  int ia = abspid() ;
    return up == ia || down == ia || .... || top == ia ;  
  • Author Contributor

    Thanks a lot for the feedback @ibelyaev! On your points:

    1. Agreed.
    2. This is something I wondered about in LHCBPS-1718. I can't decide if it makes sense for a method called hasQuarks, plural, to return true for a single quark. Maybe it does, and if so, then we don't need the additional method, as the modified hasQuarks would be sufficient on its own.
    3. The PDG MC numbering scheme document has this to say:

    Quarks and leptons are numbered consecutively starting from 1 and 11 respectively

    To me, that says any ID in the range 1–10, inclusive, is considered a quark ID. Currently, the listings use IDs 7 and 8 for 'b prime' and 't prime' quarks. But still, maybe we want to be more specific than the PDG.

  • @apearce Hi Alex, for me hasQuarks is more "has at least one quark" than "has two or more quarks". but I am happy with all decisions.

  • independently on you final decision on (2), I think it is worth to add this new isQuark method.

  • @apearce if 10 is allowed ID for quark, we could have some problem: there are many places in the code that relies on the fact that the quark id fits into single decimal digit..- and we have inherited this from PDG scheme, that meand that PDG scheme is not self-consistent. It is a pity, but we can do nothing here.

  • Author Contributor

    It's a method in our codebase, so we're free to use a different definition, as long as the expected behaviour is clearly documented.

    Maybe then it's safer to only allow IDs in the set {1, 2, 3, 4, 5, 6}?

  • Author Contributor

    Possible alternative implementation:

    bool LHCb::ParticleID::isQuark() const
    {
      const auto fundamental = 0 < fundamentalID();
      const auto has_any_quark = (
          hasUp() || hasDown() ||
          hasCharm() || hasStrange() ||
          hasTop() || hasBottom()
      );
      return fundamental && has_any_quark;
    }
  • hasXQuark are not very cheap :-) what about more explicit

    const unsigned  int ia = abspid() ;
    return up == ia || down == ia || ...  || top == ia ;
  • or even trivial: return m_pid && abspid() <= 6 ;

  • @apearce anyhow, whatever are the implementation details - as soon as the issue with ParticleID(0) is solved - it is fine for me.

    P.S. Since, as you pointed, we do have b' and t' in our table, probably better to use return m_pid && abspid() <= 8 ;

  • @apearce sorry for spamming.. Since you are touching the package, I suggest you add two more items for Quark enum: e.g. b_prime and t_prime or bottom_prime/top_prime - as you want :-) and please update the printout methods for these enums.

  • Author Contributor

    OK yes, I'll do this then:

    return 1 <= abspid() && abspid() <= 8;

    and I'll add the other quarks to enum Quark and update the print methods.

  • @apearce thank you!

  • Author Contributor

    Or I suppose I could hide the magic numbers a little more:

    return LHCb::ParticleID::up <= abspid() && abspid <= LHCb::ParticleID::top_prime;
    Edited by Alex Pearce
  • good idea. for some enums in lhcb I've see another rather attractive pattern: enum XXX { a , b , c , d , ... , x , y , z , first = a , last = z } ; in this case one can be a bit more safe with respect to (highly unprobable) furtehr extensions return last => absid() && first <= absid() ;

  • Alex Pearce added 2 commits

    added 2 commits

    • 44bab493 - Add missing b' and t' quarks.
    • 10f80897 - Use explicit Quark enum values for less magic.

    Compare with previous version

  • Author Contributor

    Nice. I've pushed commits with that, and with the modified isQuark.

  • @apearce Very good! Thank you very much!

  • @gcorti @gligorov Any further comments?

  • No further comments. The solution implemented seems very reasonable

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading