66 numberOfEventsPerLumiblockFront = eventInfo->lumiBlock();
67 numberOfEventsPerLumiblockMiddle = eventInfo->lumiBlock();
68 numberOfEventsPerLumiblockEnd = eventInfo->lumiBlock();
71 const unsigned int bcid = eventInfo->bcid();
72 const unsigned int run_number = eventInfo->runNumber();
75 ATH_MSG_ERROR(
"Unable to retrieve BunchCrossing conditions object (SiT)" );
79 int bx_diff = int(run_number) >= 521800 ? 2 : 1;
81 enum { FRONT, MIDDLE, END, NPOS } position = NPOS;
85 fill(
"AFPSiLayerTool", bcidAll);
90 fill(
"AFPSiLayerTool", bcidFront);
91 fill(
"AFPSiLayerTool", numberOfEventsPerLumiblockFront);
99 fill(
"AFPSiLayerTool", bcidMiddle);
100 fill(
"AFPSiLayerTool", numberOfEventsPerLumiblockMiddle);
106 fill(
"AFPSiLayerTool", bcidEnd);
107 fill(
"AFPSiLayerTool", numberOfEventsPerLumiblockEnd);
147 lb = eventInfo->lumiBlock();
148 lbEvents = eventInfo->lumiBlock();
151 if (muPerBX == 0.0) {
152 ATH_MSG_DEBUG(
"AverageInteractionsPerCrossing is 0, forcing to 1.0");
155 fill(
"AFPSiLayerTool",
lb, muPerBX);
156 fill(
"AFPSiLayerTool", lbEvents);
160 if(! afpHitContainer.
isValid())
163 return StatusCode::SUCCESS;
168 nSiHits = afpHitContainer->size();
169 fill(
"AFPSiLayerTool",
lb, nSiHits);
171 int eventsInStations[4] = {};
172 int numberOfHitsPerPlane[4][4] = {};
176 lb = eventInfo->lumiBlock();
177 lbHits = eventInfo->lumiBlock();
178 lbEventsStations = eventInfo->lumiBlock();
179 lbEventsStationsAll = eventInfo->lumiBlock();
180 pixelRowIDChip = hitsItr->pixelRowIDChip();
181 pixelColIDChip = hitsItr->pixelColIDChip();
185 if (hitsItr->stationID()<4 && hitsItr->stationID()>=0 && hitsItr->pixelLayerID()<4 && hitsItr->pixelLayerID()>=0)
187 ++eventsInStations[hitsItr->stationID()];
194 planeHits = hitsItr->pixelLayerID();
197 ++numberOfHitsPerPlane[hitsItr->stationID()][hitsItr->pixelLayerID()];
198 numberOfHitsPerStation = hitsItr->stationID();
199 fill(
"AFPSiLayerTool", numberOfHitsPerStation);
201 fill(
"AFPSiLayerTool", lbHits);
203 else ATH_MSG_WARNING(
"Unrecognised station index: " << hitsItr->stationID());
211 lbhitsPerPlaneProfile = eventInfo->lumiBlock();
212 for(
int i_station = 0; i_station < 4; i_station++)
213 for(
int j_layer = 0; j_layer < 4; j_layer++)
215 hitsPerPlaneProfile = numberOfHitsPerPlane[i_station][j_layer]/muPerBX;
217 if (muPerBX != 0.0) {
218 hitsPerPlaneEventsMu = numberOfHitsPerPlane[i_station][j_layer] / muPerBX;
220 hitPerPlaneEventMuIndex = reorganizePlanes(i_station, j_layer);
221 fill(
"AFPSiLayerTool", hitPerPlaneEventMuIndex, hitsPerPlaneEventsMu);
224 bool noEventsInStations =
true;
225 for(
int i=0; i<4; i++)
227 if(eventsInStations[i]>0) {
230 eventsPerStation = i * 4;
231 fill(
"AFPSiLayerTool", eventsPerStation);
233 fill(
"AFPSiLayerTool", eventsPerStation);
235 fill(
"AFPSiLayerTool", eventsPerStation);
237 fill(
"AFPSiLayerTool", eventsPerStation);
239 noEventsInStations =
false;
242 if(!noEventsInStations)
244 fill(
"AFPSiLayerTool", lbEventsStationsAll);
252 unsigned int totalTracksAll[4] = {};
253 unsigned int totalTracksFront[4] = {};
254 unsigned int totalTracksMiddle[4] = {};
255 unsigned int totalTracksEnd[4] = {};
257 for (
const auto& track :
fast.tracks())
259 trackX = track.x * 1.0;
260 trackY = track.y * 1.0;
263 if (position == FRONT)
265 ++totalTracksFront[track.station];
266 ++totalTracksAll[track.station];
268 else if (position == MIDDLE)
270 ++totalTracksMiddle[track.station];
271 ++totalTracksAll[track.station];
273 else if (position == END)
275 ++totalTracksEnd[track.station];
276 ++totalTracksAll[track.station];
290 lbTracksAll = eventInfo->lumiBlock();
291 lbTracksFront = eventInfo->lumiBlock();
292 lbTracksMiddle = eventInfo->lumiBlock();
293 lbTracksEnd = eventInfo->lumiBlock();
295 for(
int i = 0; i < 4; i++)
297 Total_tracks_All_profile = totalTracksAll[i] / muPerBX;
299 totalTracksAll[i] = 0;
301 Total_tracks_Front_profile = totalTracksFront[i] / muPerBX;
302 if (position == FRONT)
304 totalTracksFront[i] = 0;
306 Total_tracks_Middle_profile = totalTracksMiddle[i] / muPerBX;
307 if (position == MIDDLE)
309 totalTracksMiddle[i] = 0;
311 Total_tracks_End_profile = totalTracksEnd[i] / muPerBX;
314 totalTracksEnd[i] = 0;
318 unsigned int totalClustersAll[4][4] = {};
319 unsigned int totalClustersFront[4][4] = {};
320 unsigned int totalClustersMiddle[4][4] = {};
321 unsigned int totalClustersEnd[4][4] = {};
333 lbClustersPerPlanesAll = eventInfo->lumiBlock();
334 lbClustersPerPlanesFront = eventInfo->lumiBlock();
335 lbClustersPerPlanesMiddle = eventInfo->lumiBlock();
336 lbClustersPerPlanesEnd = eventInfo->lumiBlock();
338 for(
const auto& cluster :
fast.clusters())
340 clusterX = cluster.x * 1.0;
341 clusterY = cluster.y * 1.0;
343 if (cluster.station == 0 || cluster.station == 1)
345 clustersInPlanes = reorganizePlanes(cluster.station, cluster.layer);
349 clustersInPlanes = (cluster.station*4)+cluster.layer;
351 fill(
"AFPSiLayerTool", clustersInPlanes);
353 clusterToT = cluster.sumToT;
356 if (position == FRONT)
358 ++totalClustersFront[cluster.station][cluster.layer];
359 ++totalClustersAll[cluster.station][cluster.layer];
361 else if (position == MIDDLE)
363 ++totalClustersMiddle[cluster.station][cluster.layer];
364 ++totalClustersAll[cluster.station][cluster.layer];
366 else if (position == END)
368 ++totalClustersEnd[cluster.station][cluster.layer];
369 ++totalClustersAll[cluster.station][cluster.layer];
373 for(
int i_station = 0; i_station < 4; i_station++)
374 for(
int j_layer = 0; j_layer < 4; j_layer++)
376 clustersPerPlaneAllPP = totalClustersAll[i_station][j_layer] / muPerBX;
378 totalClustersAll[i_station][j_layer] = 0;
380 clustersPerPlaneFrontPP = totalClustersFront[i_station][j_layer] / muPerBX;
381 if (position == FRONT)
383 totalClustersFront[i_station][j_layer] = 0;
385 clustersPerPlaneMiddlePP = totalClustersMiddle[i_station][j_layer] / muPerBX;
386 if (position == MIDDLE)
388 totalClustersMiddle[i_station][j_layer] = 0;
390 clustersPerPlaneEndPP = totalClustersEnd[i_station][j_layer] / muPerBX;
393 totalClustersEnd[i_station][j_layer] = 0;
423 int min_hits[4] = {2, 3, 3, 3};
428 std::vector<std::vector<int>> nclusters_planes(numStations, std::vector<int>(numPlanes, 0));
429 for (
const auto& cluster :
fast.clusters()) {
430 ++nclusters_planes[cluster.station][cluster.layer];
434 std::vector<std::vector<int>> nclusters_other_planes(numStations, std::vector<int>(numPlanes, 0));
435 for (
int iStation = 0; iStation < numStations; ++iStation) {
436 for (
int iPlane = 0; iPlane < numPlanes; ++iPlane) {
437 for (
int ip = 0; ip < numPlanes; ++ip) {
438 if (iPlane != ip && nclusters_planes[iStation][ip] > 0) {
439 ++nclusters_other_planes[iStation][iPlane];
446 std::array<std::set<int>, 4> precomputed_tag_planes = {
447 std::set<int>{1, 2, 3},
448 std::set<int>{0, 1, 2, 3},
449 std::set<int>{0, 1, 2, 3},
450 std::set<int>{0, 1, 2, 3}
454 using ClusterType = std::decay_t<
decltype(*
fast.clusters().begin())>;
455 std::vector<std::vector<std::vector<ClusterType>>> clusters_by_station_layer(numStations,
456 std::vector<std::vector<ClusterType>>(numPlanes));
458 for (
const auto& cluster :
fast.clusters()) {
459 clusters_by_station_layer[cluster.station][cluster.layer].push_back(cluster);
462 for (
int iStation = 0; iStation < numStations; ++iStation) {
463 for (
int iPlane = 0; iPlane < numPlanes; ++iPlane) {
465 if (nclusters_other_planes[iStation][iPlane] < min_hits[iStation]) {
continue;}
467 std::set<int> tag_planes = precomputed_tag_planes[iStation];
468 tag_planes.erase(iPlane);
470 std::vector<int> v_tag_planes(tag_planes.begin(), tag_planes.end());
471 int seed = v_tag_planes[0];
474 for (
const auto& cluster : clusters_by_station_layer[iStation][seed]) {
475 int found_in_other_tag_planes = 0;
478 for (
size_t i = 1; i < v_tag_planes.size(); ++i) {
479 int tag_plane = v_tag_planes[i];
482 for (
const auto& clusterTag : clusters_by_station_layer[iStation][tag_plane]) {
483 if (std::fabs(cluster.x - clusterTag.x) < 2.0 && std::fabs(cluster.y - clusterTag.y) < 2.0) {
485 ++found_in_other_tag_planes;
494 if (found_in_other_tag_planes ==
static_cast<int>(v_tag_planes.size()) - 1) {
495 sit_plane_eff_triedX = cluster.x;
496 sit_plane_eff_triedY = cluster.y;
499 for (
const auto& clusterTag : clusters_by_station_layer[iStation][iPlane]) {
500 if (std::fabs(cluster.x - clusterTag.x) < 2.0 && std::fabs(cluster.y - clusterTag.y) < 2.0) {
501 sit_plane_eff_passed =
true;
507 sit_plane_eff_passed, sit_plane_eff_triedY, sit_plane_eff_triedX);
508 sit_plane_eff_passed =
false;
513 return StatusCode::SUCCESS;