@@ -560,28 +560,52 @@ inline void buildFT0FV0Words(TFT0 const& ft0, TFV0A const& fv0a,
560560 constexpr int kFV0Offset = 208 ;
561561
562562 auto ampsA = ft0.amplitudeA ();
563- const int nA = std::min<int >(ampsA.size (), 96 );
564- for (int i = 0 ; i < nA; ++i) {
565- const auto a = ampsA[i];
566- setBit (thr1, kFT0AOffset + i, a >= thr1_FT0A);
567- setBit (thr2, kFT0AOffset + i, a >= thr2_FT0A);
568- }
563+ auto chanA = ft0.channelA ();
564+ const int nA = std::min<int >(ampsA.size (), chanA.size ());
565+
566+ for (int i = 0 ; i < nA; ++i) {
567+ const auto a = ampsA[i];
568+ const int c = chanA[i];
569+
570+ if (c < 0 || c >= 96 ) {
571+ continue ;
572+ }
573+
574+ setBit (thr1, kFT0AOffset + c, a >= thr1_FT0A);
575+ setBit (thr2, kFT0AOffset + c, a >= thr2_FT0A);
576+ }
569577
570578 auto ampsC = ft0.amplitudeC ();
571- const int nC = std::min< int >(ampsC. size (), 112 );
572- for ( int i = 0 ; i < nC; ++i) {
573- const auto a = ampsC[i];
574- setBit (thr1, kFT0COffset + i, a >= thr1_FT0C);
575- setBit (thr2, kFT0COffset + i, a >= thr2_FT0C) ;
576- }
579+ auto chanC = ft0. channelC ( );
580+ const int nC = std::min< int >(ampsC. size (), chanC. size ());
581+
582+ for ( int i = 0 ; i < nC; ++i) {
583+ const auto a = ampsC[i] ;
584+ const int c = chanC[i]; // physical FT0C channel id
577585
586+ if (c < 0 || c >= 112 ) {
587+ continue ;
588+ }
589+
590+ setBit (thr1, kFT0COffset + c, a >= thr1_FT0C);
591+ setBit (thr2, kFT0COffset + c, a >= thr2_FT0C);
592+ }
593+
578594 auto ampsV = fv0a.amplitude ();
579- const int nV = std::min<int >(ampsV.size (), 48 );
580- for (int i = 0 ; i < nV; ++i) {
581- const auto a = ampsV[i];
582- setBit (thr1, kFV0Offset + i, a >= thr1_FV0A);
583- setBit (thr2, kFV0Offset + i, a >= thr2_FV0A);
584- }
595+ auto chanV = fv0a.channel ();
596+ const int nV = std::min<int >(ampsV.size (), chanV.size ());
597+
598+ for (int i = 0 ; i < nV; ++i) {
599+ const auto a = ampsV[i];
600+ const int c = chanV[i];
601+
602+ if (c < 0 || c >= 48 ) {
603+ continue ;
604+ }
605+
606+ setBit (thr1, kFV0Offset + c, a >= thr1_FV0A);
607+ setBit (thr2, kFV0Offset + c, a >= thr2_FV0A);
608+ }
585609}
586610
587611// -----------------------------------------------------------------------------
0 commit comments