SOA Track Fix
Fix conflicts between SOA Track MR !2920 (merged). Run concurrent with Rec!2408 (merged) and Phys!925 (closed).
Merge request reports
Activity
130 struct available_states<TrackType::Ttrack> { 131 using type = state_collection<SL::FirstMeasurement, SL::LastMeasurement>; 132 }; 133 134 template <> 135 struct available_states<TrackType::Muon> { 136 using type = state_collection<SL::FirstMeasurement, SL::LastMeasurement>; 137 }; 138 139 template <> 140 struct available_states<TrackType::Calo> { 141 using type = state_collection<SL::FirstMeasurement, SL::LastMeasurement>; 142 }; 143 144 template <> 145 struct available_states<TrackType::TT> { This is to allow
v1::Track/v2::Track
toPrFittedGenericTrack
conversions (the old versions of the tracks define all those state locations). I don't think locations likeVeloR
are used by old track versions either, but I would keep it as it is for now in order to have full compatibility. As soon as we have done the necessary checks with the ThOr functors and we are sure we don't need to convert among track types any more I agree we can remove them.
126 outTrack.template field<Tag::StateCov_YQoverP>( L ).set( cov[1][4] ); 127 // tX 128 outTrack.template field<Tag::StateCov_tXtX>( L ).set( cov[2][2] ); 129 outTrack.template field<Tag::StateCov_tXtY>( L ).set( cov[2][3] ); 130 outTrack.template field<Tag::StateCov_tXQoverP>( L ).set( cov[2][4] ); 131 // tY 132 outTrack.template field<Tag::StateCov_tYtY>( L ).set( cov[3][3] ); 133 outTrack.template field<Tag::StateCov_tYQoverP>( L ).set( cov[3][4] ); 134 // q/p 135 outTrack.template field<Tag::StateCov_QoverPQoverP>( L ).set( cov[4][4] ); 136 112 outTrack.template field<Tag::StateCov>( L ).set( cov[0][0], cov[0][1], cov[0][2], cov[0][3], cov[0][4], //X 113 cov[1][1], cov[1][2], cov[1][3], cov[1][4], // Y 114 cov[2][2], cov[2][3], cov[2][4], // TX 115 cov[3][3], cov[3][4], //TY 116 cov[4][4] ); //QoverP it would be nicer if
set
would be the sole place where all this indexing has to be done, eg. it would support writing the above as:outTrack.template field<Tag::StateCov>( L ).set( cov );
instead.
That way, all that indexing only happens in one location... (but/and it forces the order of elements, which depending on your point of view could be good or bad -- but I think it would be good ;-)
38 38 meta_enum_class( StateLocation, unsigned int, Unknown = 0, ClosestToBeam, FirstMeasurement, LastMeasurement, BegRich1, 39 39 EndRich1, BegRich2, EndRich2 ) 40 40 41 constexpr unsigned int 42 operator+( unsigned int i, StateLocation s ) { 43 return i + static_cast<unsigned int>( s ); 41 /// Index associated to a StateLocation value 42 constexpr auto index( StateLocation s ) { 43 constexpr auto array = members_of<StateLocation>(); 44 for ( auto i = 0u; i < array.size(); ++i ) 45 if ( array[i] == s ) return i; 46 // we would reach this point if we pass Unknown to the function, 47 // which never happens 48 __builtin_unreachable(); there is a macro
ASSUME
defined here which in debug builds will actually check whether the assumption is correct or not -- so:ASSUME( false );
which at least in debug builds will report that an assertion failed, instead of 'undefined behavior'
Also, nicer would be:
for ( auto [ idx, i ] : LHCb::range::enumerate( members_of<StateLocation>() ) ) { if ( i == s ) return idx; } ASSUME( false );
Anyway, a lot faster would be to avoid having to loop at all:
constexpr auto index( StateLocation s ) { ASSUME( s != StateLocation::Unknown ); return s-1; }
and make sure that ends up as the correct answer 'by construction'...
I was actually wondering if the compiler could reduce it to a
switch/case
-like statement, of course, since the addition operation is not used asconstexpr
(this is why we accidentally ran into anundefined behaviour
before, which suggested these changes), the checks need to be done a runtime.
mentioned in merge request Phys!925 (closed)
mentioned in merge request Rec!2408 (merged)
- [2021-04-21 13:18] Validation started with lhcb-master-mr#2228
mentioned in issue Moore#272 (closed)