37 return StatusCode::SUCCESS;
50 return StatusCode::FAILURE;
55 return StatusCode::FAILURE;
60 if (!NSWpadTriggerContainer.
isValid()) {
62 return StatusCode::FAILURE;
73 return StatusCode::SUCCESS;
89 int multiplet =
m_idHelperSvc -> stgcIdHelper().multilayer(
id);
91 int channelType =
m_idHelperSvc -> stgcIdHelper().channelType(
id);
96 if (channelType == sTgcIdHelper::sTgcChannelTypes::Pad) {
102 int maxPadNumberQ1 = sTgcReadoutObjectPadQ1 -> maxPadNumber(idPadQ1);
103 int maxPadNumberQ2 = sTgcReadoutObjectPadQ2 -> maxPadNumber(idPadQ2);
108 fill(
"sTgcOccupancy", sectorMon, padNumberMon);
114 fill(
"sTgcOccupancy", sectorMon, padNumberMon);
120 fill(
"sTgcOccupancy", sectorMon, padNumberMon);
125 fill(
"sTgcQuadOccupancyPad", sectorSidedMon, stationEtaSidedMon);
128 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Strip) {
129 int stripNumber =
m_idHelperSvc -> stgcIdHelper().channel(
id);
134 int maxStripNumberQ1 = sTgcReadoutObjectStripQ1 -> numberOfStrips(idStripQ1);
135 int maxStripNumberQ2 = sTgcReadoutObjectStripQ2 -> numberOfStrips(idStripQ2);
140 fill(
"sTgcOccupancy", sectorMon, stripNumberMon);
146 fill(
"sTgcOccupancy", sectorMon, stripNumberMon);
152 fill(
"sTgcOccupancy", sectorMon, stripNumberMon);
157 fill(
"sTgcQuadOccupancyStrip", sectorSidedMon, stationEtaSidedMon);
160 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Wire) {
161 int wireGroupNumber =
m_idHelperSvc -> stgcIdHelper().channel(
id);
163 const MuonGM::sTgcReadoutElement* sTgcReadoutObjectWireGroupQ3 = muonDetectorManagerObject -> getsTgcReadoutElement(idWireGroupQ3);
164 int maxWireGroupNumberQ3 = sTgcReadoutObjectWireGroupQ3 -> numberOfStrips(idWireGroupQ3);
168 fill(
"sTgcOccupancy", stationEtaMon, wireGroupNumberMon);
172 fill(
"sTgcQuadOccupancyWire", sectorSidedMon, stationEtaSidedMon);
190 int multiplet =
m_idHelperSvc -> stgcIdHelper().multilayer(
id);
192 int channelType =
m_idHelperSvc -> stgcIdHelper().channelType(
id);
196 if (channelType == sTgcIdHelper::sTgcChannelTypes::Pad) {
203 fill(
"sTgcLumiblock", padSectorGlobalMon, padLumiblockGlobalMon);
206 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Strip) {
213 fill(
"sTgcLumiblock", stripSectorGlobalMon, stripLumiblockGlobalMon);
216 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Wire) {
223 fill(
"sTgcLumiblock", wireSectorGlobalMon, wireLumiblockGlobalMon);
232 if(!meTrack)
continue;
235 if (!
status.has_value())
continue;
236 std::tuple<Identifier, const Trk::RIO_OnTrack*> rotIDtuple =
status.value();
238 Identifier rot_id = std::get<Identifier>(rotIDtuple);
241 if(!cluster)
continue;
246 int channelType =
m_idHelperSvc -> stgcIdHelper().channelType(rot_id);
247 int stEta =
m_idHelperSvc -> stgcIdHelper().stationEta(rot_id);
253 int iside = (stEta > 0) ? 1 : 0;
254 std::string
side = GeometricSectors::sTgcSide[iside];
256 if (channelType == sTgcIdHelper::sTgcChannelTypes::Pad) {
257 float padCharge = prd ->
charge();
261 short int padTiming = prd ->
time();
264 fill(
"sTgcTiming", padSectorSidedMon, padTimingMon);
268 fill(
"padTiming_quad_" +
std::to_string(std::abs(stEta)), padSectorSidedExpertMon, padTimingExpertMon);
271 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Strip) {
272 const std::vector<Identifier>& stripIds = prd->
rdoList();
273 unsigned int csize = stripIds.size();
275 std::vector<short int> stripTimesVec = prd -> stripTimes();
276 std::vector<int> stripChargesVec = prd -> stripCharges();
278 float stripClusterTimes = 0;
279 float stripClusterCharges = 0;
281 for (
unsigned int sIdx = 0; sIdx < csize; ++sIdx) {
282 stripClusterTimes += stripTimesVec.at(sIdx);
283 stripClusterCharges += stripChargesVec.at(sIdx);
286 stripClusterTimes /= stripTimesVec.size();
294 fill(
"sTgcTiming", stripClusterSectorSidedMon, stripClusterTimesMon);
295 fill(
"sTgcOverview", stripClusterSectorSidedMon, stripClusterTimesMon, stripClusterSizeMon);
299 fill(
"stripTiming_quad_" +
std::to_string(std::abs(stEta)), stripSectorSidedExpertMon, stripTimingExpertMon);
302 std::optional<Trk::ResidualPull> resPull(
m_residualPullCalculator -> residualPull(trkState -> measurementOnTrack(), trkState -> trackParameters(), Trk::ResidualPull::ResidualType::Biased));
311 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Wire) {
312 float wireGroupCharge = prd ->
charge();
316 short int wireGroupTiming = prd ->
time();
319 fill(
"sTgcTiming", wireGroupSectorSidedMon, wireGroupTimingMon);
323 fill(
"wireTiming_quad_" +
std::to_string(std::abs(stEta)), wireSectorSidedExpertMon, wireTimingExpertMon);
334 const xAOD::TrackParticle* meTP =
mu -> trackParticle(xAOD::Muon::TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle);
335 if(meTP ==
nullptr)
continue;
338 if(!meTrack)
continue;
342 if (!
status.has_value())
continue;
345 int channelType =
m_idHelperSvc -> stgcIdHelper().channelType(rot_id);
346 if (channelType != sTgcIdHelper::sTgcChannelTypes::Pad)
continue;
350 bool largeSector = rdo -> largeSector();
352 int iside = (
sideA) ? 1 : 0;
353 int isize = (largeSector) ? 1 : 0;
355 std::string
side = GeometricSectors::sTgcSide[iside];
356 std::string
size = GeometricSectors::sTgcSize[isize];
358 size_t numberOfTriggers = rdo -> getNumberOfTriggers();
359 size_t numberOfHits = rdo -> getNumberOfHits();
361 for (
size_t trigger = 0; trigger < numberOfTriggers; ++trigger) {
362 int triggerPhiIdsUnsigned = rdo -> getTriggerPhiIds().at(trigger);
363 int triggerBandIds = rdo -> getTriggerBandIds().at(trigger);
364 int triggerRelBCID = rdo -> getTriggerRelBcids().at(trigger);
365 int sourceId = rdo -> getSourceid();
374 fill(
"padTriggerShifter", phiIdsPerSideSizeMon, bandIdsPerSideSizeMon);
380 fill(
"padTriggerShifter", lbMon, relBCIDMon, sectorMon, numberOfTriggersMon);
387 fill(
"padTriggerExpert", numberOfTriggersPerSectorMon, phiIdsSidedSizedPerSectorMon, bandIdsSidedSizedPerSectorMon, lbPerSectorMon, relBCIDperSectorMon);
392 fill(
"padTriggerShifter", RelBCIDPerSectorMon, PhiIDPerSectorMon, BandIDPerSectorMon);
396 std::optional<Identifier>
status =
getPadId(rdo->getSourceid(), rdo->getHitPfebs().at(
hits), rdo->getHitTdsChannels().at(
hits));
397 if (!
status.has_value())
continue;
400 if (rot_id != pad_id)
continue;
402 int sourceIds = rdo -> getSourceid();
404 int hitRelBCID = rdo -> getHitRelBcids().at(
hits);
405 int hitpfebs = rdo -> getHitPfebs().at(
hits);
406 int hitTdsChannels = rdo->getHitTdsChannels().at(
hits);
408 std::optional<std::tuple<int, int, std::string, std::string, int>> statusPadEtaPhi =
getPadEtaPhiTuple(sourceIds, hitpfebs, hitTdsChannels);
409 if (!statusPadEtaPhi.has_value())
continue;
410 std::tuple<int, int, std::string, std::string, int> padEtaPhiTuple = statusPadEtaPhi.value();
412 int padPhi = std::get<0>(padEtaPhiTuple);
413 int padEta = std::get<1>(padEtaPhiTuple);
414 std::string sideName = std::get<2>(padEtaPhiTuple);
415 std::string sizeName = std::get<3>(padEtaPhiTuple);
416 int layer = std::get<4>(padEtaPhiTuple);
420 fill(
"padTriggerOccupancy", padPhiMon, padEtaMon);
425 fill(
"padTriggerShifter", hitRelBCIDmon, hitPfebsMon, sectorMon);
429 fill(
"padTriggerShifter", hitRelBCIDPerSectorMon, hitpfebsPerSectorMon);
442 std::array<int, 8> quadMultiplet{};
443 std::array<int, 8> layerMultiplet{};
444 std::array<float, 8> xPosMultiplet{};
445 std::array<float, 8> yPosMultiplet{};
446 std::array<float, 8> zPosMultiplet{};
449 std::array<std::array<sTGCeff, 16>, 2> effPlots;
451 const xAOD::TrackParticle* meTP =
mu -> trackParticle(xAOD::Muon::TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle);
452 if(meTP ==
nullptr)
continue;
455 if(!meTrack)
continue;
459 if (!
status.has_value())
continue;
463 int channelType =
m_idHelperSvc -> stgcIdHelper().channelType(rot_id);
464 if (channelType != sTgcIdHelper::sTgcChannelTypes::Strip)
continue;
466 int stEta =
m_idHelperSvc -> stgcIdHelper().stationEta(rot_id);
467 int iside = (stEta > 0) ? 1 : 0;
473 const Amg::Vector2D& positionsMultiplet = (trkState) -> trackParameters() -> localPosition();
474 float xPosStripInMultipletLocal = positionsMultiplet.x();
475 float yPosStripInMultipletLocal = positionsMultiplet.y();
477 Amg::Vector2D localPos(xPosStripInMultipletLocal, yPosStripInMultipletLocal);
480 sTgcReadoutObjectStrip -> surface(rot_id).localToGlobal(localPos,
Amg::Vector3D::Zero(), globalPos);
481 float xPosStripInMultiplet = globalPos.x();
482 float yPosStripInMultiplet = globalPos.y();
485 (muonDetectorManagerObject -> getsTgcReadoutElement(rot_id)) -> stripGlobalPosition(rot_id, posStripGlobal);
486 float zPosStripInMultiplet = posStripGlobal.z();
488 auto& sTGCelements = effPlots[iside][sector - 1];
490 sTGCelements.quadMultiplet.at(
layer - 1) = stEta;
491 sTGCelements.layerMultiplet.at(
layer - 1) =
layer;
492 sTGCelements.xPosMultiplet.at(
layer - 1) = xPosStripInMultiplet;
493 sTGCelements.yPosMultiplet.at(
layer - 1) = yPosStripInMultiplet;
494 sTGCelements.zPosMultiplet.at(
layer - 1) = zPosStripInMultiplet;
497 for (
unsigned int isideIndex = 0; isideIndex <= 1; ++isideIndex) {
498 for (
unsigned int sectorIndex = 1; sectorIndex <= 16; ++sectorIndex) {
499 auto& sTGCelements = effPlots[isideIndex][sectorIndex - 1];
500 bool fourOutEight = std::count_if(sTGCelements.layerMultiplet.begin(), sTGCelements.layerMultiplet.end(), [](
int i) { return i != 0; }) >= 4;
501 bool oneRefLayer = std::count_if(sTGCelements.layerMultiplet.begin(), sTGCelements.layerMultiplet.end(), [](
int i) { return i != 0; }) >= 1;
504 for (
auto layerIndex =
static_cast<std::array<int, 8>::size_type
>(1); layerIndex <= sTGCelements.layerMultiplet.size(); ++layerIndex) {
505 if (sTGCelements.layerMultiplet.at(layerIndex - 1) == 0)
continue;
507 float xPos = sTGCelements.xPosMultiplet.at(layerIndex - 1);
508 float yPos = sTGCelements.yPosMultiplet.at(layerIndex - 1);
509 float rPos = std::hypot(xPos, yPos);
511 std::string
side = GeometricSectors::sTgcSide[isideIndex];
520 fill(
"sTgcOverview", xPosStripmon, yPosStripmon, effQuestionMon);
524 else if (!fourOutEight && oneRefLayer) {
525 auto refLayerIndex =
std::distance(sTGCelements.layerMultiplet.begin(), std::find_if(sTGCelements.layerMultiplet.begin(), sTGCelements.layerMultiplet.end(), [](
int i) {return i != 0;}));
527 for (
auto layerIndex =
static_cast<std::array<int, 8>::size_type
>(1); layerIndex <= sTGCelements.layerMultiplet.size(); ++layerIndex) {
528 if (sTGCelements.layerMultiplet.at(layerIndex - 1) != 0)
continue;
529 int quad = sTGCelements.quadMultiplet.at(refLayerIndex);
531 int gap = (layerIndex <= static_cast<std::array<int, 8>::size_type>(
m_idHelperSvc->stgcIdHelper().gasGapMax())) ? layerIndex : layerIndex -
static_cast<std::array<int, 8>::size_type
>(
m_idHelperSvc->stgcIdHelper().gasGapMax());
534 const Identifier idProbe =
m_idHelperSvc -> stgcIdHelper().channelID((sectorIndex % 2 == 0) ?
"STS" :
"STL",
quad, (sectorIndex % 2 == 0) ? sectorIndex/2 : (sectorIndex + 1)/2,
multi,
gap, sTgcIdHelper::sTgcChannelTypes::Strip, 1,
isValid);
542 (muonDetectorManagerObject -> getsTgcReadoutElement(idProbe)) -> stripGlobalPosition(idProbe, posProbe);
543 float posZprobe = posProbe.z();
545 float xSlope = sTGCelements.xPosMultiplet.at(refLayerIndex)/sTGCelements.zPosMultiplet.at(refLayerIndex);
546 float ySlope = sTGCelements.yPosMultiplet.at(refLayerIndex)/sTGCelements.zPosMultiplet.at(refLayerIndex);
548 float xPos = sTGCelements.xPosMultiplet.at(refLayerIndex) + xSlope*(posZprobe - sTGCelements.zPosMultiplet.at(refLayerIndex));
549 float yPos = sTGCelements.yPosMultiplet.at(refLayerIndex) + ySlope*(posZprobe - sTGCelements.zPosMultiplet.at(refLayerIndex));
550 float rPos = std::hypot(xPos, yPos);
552 std::string
side = GeometricSectors::sTgcSide[isideIndex];
561 fill(
"sTgcOverview", xPosStripProbemon, yPosStripProbemon, effQuestionMon);
575 double recoMuonEta =
mu ->
eta();
576 double recoMuonPhi =
mu ->
phi();
578 std::string sideRecoMuon = GeometricSectors::sTgcSide[recoMuonEta > 0];
580 std::string minSideRecoMuon =
"", minSideTrigger =
"";
582 double minTriggerEta = 999., minTriggerPhi = 999.,
583 minRecoEta = 999., minRecoPhi = 999., minDeltaR = 999.;
585 auto minDeltaRtrigIt = -1;
589 bool largeSector = rdo -> largeSector();
590 std::string sideTrigger = GeometricSectors::sTgcSide[
sideA];
591 size_t numberOfTriggers = rdo -> getNumberOfTriggers();
593 for (
size_t trigger = 0; trigger < numberOfTriggers; ++trigger) {
594 int triggerPhiIdsUnsigned = rdo -> getTriggerPhiIds().at(trigger);
595 int triggerBandIds = rdo -> getTriggerBandIds().at(trigger);
596 int sourceId = rdo -> getSourceid();
601 std::optional<double>
status =
bandId2eta(triggerBandIds, largeSector,
sideA, muonDetectorManagerObject);
602 if (!
status.has_value())
continue;
603 double triggerBandIdToEta =
status.value();
609 if (sideRecoMuon == sideTrigger) {
611 minSideRecoMuon = sideRecoMuon;
612 minSideTrigger = sideTrigger;
613 minTriggerEta = triggerBandIdToEta;
614 minTriggerPhi = triggerPhiIDtoPhi;
615 minRecoEta = recoMuonEta;
616 minRecoPhi = recoMuonPhi;
618 minDeltaRtrigIt = trigger;
624 bool muonRecoTriggerMatch =
false;
626 if (minDeltaRtrigIt != -1) {
628 muonRecoTriggerMatch =
true;
633 fill(
"sTgcOverview", deltaRmon);
637 fill(
"sTgcOverview", etaRecoMuonMon, phiRecoMuonMon);
641 fill(
"sTgcOverview", etaPadTriggerMon, phiPadTriggerMon);
645 fill(
"sTgcOverview", phiRecoMuonSidedMon, phiPadTriggerSidedMon);
650 fill(
"sTgcOverview", muonRecoTriggerMatchMon, etaRecoMuonEffMon, phiRecoMuonEffMon);
654 fill(
"sTgcOverview", muonRecoTriggerMatchSidedMon, phiRecoMuonEffSidedMon);