Skip to content

xAOD::TrackParticle , numberOfParameters() Fix for ATR-24933

To access the parameters at measurement (usually first/last, not the defining ...)

we use

float TrackParticle_v1::parameterPX(unsigned int index) const {
    static const Accessor< std::vector<float>  > acc( "parameterPX" );
    return acc(*this).at(index);
  }

where the index is found by

xAOD::ParameterPosition TrackParticle_v1::parameterPosition(unsigned int index) const
  {
    static const Accessor< std::vector<uint8_t>  > acc( "parameterPosition" );
    return static_cast<xAOD::ParameterPosition>(acc(*this).at(index));
  }
 bool TrackParticle_v1::indexOfParameterAtPosition(unsigned int& index, ParameterPosition position) const
  {
    size_t maxParameters = numberOfParameters();
    bool foundParameters=false;
    for (size_t i=0; i<maxParameters; ++i){
      if (parameterPosition(i)==position){
        foundParameters=true;
        index=i;
        break;
      }
    }
    return foundParameters;
  }

In this MR efffectively we make

static const Accessor< std::vector<uint8_t>  > acc( "parameterPosition" );
maxParameters = acc(*this).size();

We make the maxParameters to be the size of the vector that we iterate over in reality ...

static_cast<xAOD::ParameterPosition>(acc(*this).at(index));

The change is

size_t TrackParticle_v1::numberOfParameters() const{
 -   ///@todo - Can we do this in a better way? Not great to force retrieval of one specific parameter - any would do.
 -  static const Accessor< std::vector<float>  > acc( "parameterX" );
 +   /// number of parameters should be the size of positions we need for them
 +   static const Accessor< std::vector<uint8_t>  > acc( "parameterPosition" );

Actually in some sense the Curvillinear parameters (x,y,z, px,py,pz) are always six. What we want the index , max is the number of how many positions we have kept "curvillinear" parameters for.

Edited by Christos Anastopoulos

Merge request reports