20 :
AthMonitorAlgorithm(
name, pSvcLocator ), m_afpSiHitContainerKey(
"AFPSiHitContainer" ), m_afpToFHitContainerKey(
"AFPToFHitContainer" ), m_afpTrackContainerKey(
"AFPTrackContainer" ) {
48 if ( !afpSiHitContainer.
isValid() ) {
50 return StatusCode::SUCCESS;
55 if ( !afpTrackContainer.
isValid() ) {
57 return StatusCode::SUCCESS;
62 if ( !afpToFHitContainer.
isValid() ) {
64 return StatusCode::SUCCESS;
94 std::vector<std::pair<int, int>> fsp[ 2 ][ 2 ] = {};
95 std::vector<std::pair<int, int>> fsp_full[ 4 ][ 2 ] = {};
98 if ( hitsItr->stationID() != 0 && hitsItr->stationID() != 3 )
continue;
99 int side = hitsItr->stationID() / 2;
100 if ( hitsItr->pixelLayerID() >= 0 && hitsItr->pixelLayerID() < 4 )
102 int plane_full = hitsItr->pixelLayerID();
103 fsp_full[ plane_full ][
side ].emplace_back( hitsItr->pixelRowIDChip(), hitsItr->pixelColIDChip() );
106 if ( hitsItr->pixelLayerID() != 0 && hitsItr->pixelLayerID() != 2 )
continue;
107 int plane = hitsItr->pixelLayerID() / 2;
109 fsp[ plane ][
side ].emplace_back( hitsItr->pixelRowIDChip(), hitsItr->pixelColIDChip() );
112 int numToFHitsTrain[ 4 ][ 2 ] = {};
113 bool ToFHasHit =
false;
116 int side = hitsItr->stationID() / 2;
117 float bar = hitsItr->trainID() + hitsItr->barInTrainID() / 4.0;
121 for (
auto& coord2 : fsp[ 1 ][
side ] ) {
122 match |= std::abs( coord2.first -
coord.first ) < 3 && std::abs( coord2.second -
coord.second ) < 2;
128 fsp0_columns_tight[
side ] =
coord.second;
130 fill(
"AFPToFSiTTool", lqbar_tight[
side ], fsp0_rows_tight[
side ] );
131 fill(
"AFPToFSiTTool", lqbar_tight[
side ], fsp0_columns_tight[
side ] );
133 lqbar_tight[
side ] = -0.5;
135 fill(
"AFPToFSiTTool", lqbar_tight[
side ], fsp0_rows_tight[
side ] );
136 fill(
"AFPToFSiTTool", lqbar_tight[
side ], fsp0_columns_tight[
side ] );
140 for (
int j = 0; j < 4; j++)
141 for (
auto&
coord : fsp_full[ j ][
side ] )
149 fill(
"AFPToFSiTTool", lqbar[
side ], fs_rows_full[
side ] );
152 for (
int j = 0; j < 4; j++)
157 fs_columns[
side ] = -5;
158 for (
int k = -10;
k < -1; ++
k )
161 fs_rows_full[
side ] =
k;
168 ++numToFHitsTrain[ hitsItr->trainID() ][
side ];
174 for (
auto side : { 0, 1 } ) {
175 bool wasMatch =
false;
179 for (
auto& coord2 : fsp[ 1 ][
side ] ) {
180 match |= std::abs( coord2.first -
coord.first ) < 3 && std::abs( coord2.second -
coord.second ) < 2;
183 for (
int itrain = 0; itrain < 4; ++itrain ) {
184 trainHits[
side ] = itrain + numToFHitsTrain[ itrain ][
side ] / 5.0;
186 fsp0_columns_tight[
side ] =
coord.second;
188 fill(
"AFPToFSiTTool", trainHits[
side ], fsp0_rows_tight[
side ] );
189 fill(
"AFPToFSiTTool", trainHits[
side ], fsp0_columns_tight[
side ] );
191 if ( numToFHitsTrain[ 0 ][
side ] > 4 || numToFHitsTrain[ 1 ][
side ] > 4
192 || numToFHitsTrain[ 2 ][
side ] > 4 || numToFHitsTrain[ 3 ][
side ] > 4 ) {
193 trainHits[
side ] = -1;
195 fsp0_columns_tight[
side ] =
coord.second;
197 fill(
"AFPToFSiTTool", trainHits[
side ], fsp0_rows_tight[
side ] );
198 fill(
"AFPToFSiTTool", trainHits[
side ], fsp0_columns_tight[
side ] );
208 lqbar_tight[
side ] = -1;
210 fsp0_columns_tight[
side ] =
coord.second;
212 fill(
"AFPToFSiTTool", lqbar_tight[
side ], fsp0_rows_tight[
side ] );
213 fill(
"AFPToFSiTTool", lqbar_tight[
side ], fsp0_columns_tight[
side ] );
216 for (
int j = 0; j < 4; j++)
217 for (
auto&
coord : fsp_full[ j ][
side ] )
227 fsp0Hits[
side ] = fsp[ 0 ][
side ].size();
228 fill(
"AFPToFSiTTool", tofHits[
side ], fsp0Hits[
side ] );
251 bool bar_hit[2][5] = {};
252 bool channel_present[2][16] = {};
253 bool multihit[2] = {};
255 std::size_t track_count[2] = {};
259 const auto side = tracksItr->stationID() == 3;
262 if (tracksItr->stationID() != 0 && tracksItr->stationID() != 3)
265 const auto xLocal = tracksItr->xLocal();
266 for (
uint8_t train = 0; train < 4; ++train) {
270 track_train[
side] = train;
276 const auto side = hitsItr->stationID() == 3;
277 const auto train = hitsItr->trainID();
278 const auto bar = hitsItr->barInTrainID();
282 if (hitsItr->stationID() != 0 && hitsItr->stationID() != 3)
286 if (train == track_train[
side])
289 multihit[
side] =
true;
295 if (track_count[
side] != 1)
continue;
297 if (multihit[
side])
continue;
299 tof_eff_OFF_trains[
side] = track_train[
side];
303 fill(
"AFPToFSiTTool", tof_eff_OFF_passed[
side], tof_eff_OFF_bars[
side], tof_eff_OFF_trains[
side] );
307 return StatusCode::SUCCESS;