37 return StatusCode::SUCCESS;
50 return StatusCode::FAILURE;
55 return StatusCode::FAILURE;
60 if (!NSWpadTriggerContainer.
isValid()) {
62 return StatusCode::FAILURE;
75 return StatusCode::SUCCESS;
92 int multiplet =
m_idHelperSvc -> stgcIdHelper().multilayer(
id);
94 int channelType =
m_idHelperSvc -> stgcIdHelper().channelType(
id);
102 std::string
side = GeometricSectors::sTgcSide[iside];
103 std::string channelName =
"";
105 if (channelType == sTgcIdHelper::sTgcChannelTypes::Pad) {
112 int maxPadNumberQ1 = sTgcReadoutObjectPadQ1 -> maxPadNumber(idPadQ1);
113 int maxPadNumberQ2 = sTgcReadoutObjectPadQ2 -> maxPadNumber(idPadQ2);
115 if (stationEtaAbs == 2) padNumber = padNumber + maxPadNumberQ1;
116 else if (stationEtaAbs == 3) padNumber = padNumber + maxPadNumberQ1 + maxPadNumberQ2;
120 fill(
"Occupancy", sectorMon, padNumberMon);
123 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Strip) {
124 channelName =
"strip";
125 int stripNumber =
m_idHelperSvc -> stgcIdHelper().channel(
id);
130 int maxStripNumberQ1 = sTgcReadoutObjectStripQ1 -> numberOfStrips(idStripQ1);
131 int maxStripNumberQ2 = sTgcReadoutObjectStripQ2 -> numberOfStrips(idStripQ2);
133 if (stationEtaAbs == 2) stripNumber = stripNumber + maxStripNumberQ1 + 1;
134 else if (stationEtaAbs == 3) stripNumber = stripNumber + maxStripNumberQ1 + maxStripNumberQ2 + 1;
138 fill(
"Occupancy", sectorMon, stripNumberMon);
141 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Wire) {
142 channelName =
"wire";
143 int wireGroupNumber =
m_idHelperSvc -> stgcIdHelper().channel(
id);
145 const MuonGM::sTgcReadoutElement* sTgcReadoutObjectWireGroupQ3 = muonDetectorManagerObject -> getsTgcReadoutElement(idWireGroupQ3);
146 int maxWireGroupNumberQ3 = sTgcReadoutObjectWireGroupQ3 -> numberOfStrips(idWireGroupQ3);
149 auto wireGroupNumberMon =
Monitored::Scalar<int>(
"wireGroupNumber_layer_" + layerStr, wireGroupNumber + (sector - 1)*maxWireGroupNumberQ3);
150 fill(
"Occupancy", stationEtaMon, wireGroupNumberMon);
155 fill(
"OccupancyShifter", layerMon, quadMon);
159 fill(
"Overview", sectorMon, febMon);
181 int channelType =
m_idHelperSvc->stgcIdHelper().channelType(
id);
182 int multiplet =
m_idHelperSvc->stgcIdHelper().multilayer(
id);
191 std::string
side = GeometricSectors::sTgcSide[iside];
192 std::string channelName =
"";
195 if (channelType == sTgcIdHelper::sTgcChannelTypes::Pad) channelName =
"pad";
196 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Strip) channelName =
"strip";
197 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Wire) channelName =
"wire";
202 fill(
"LBShifterGroup", lbMon, febMon);
212 if(!meTrack)
continue;
215 if (!
status.has_value())
continue;
216 std::tuple<Identifier, const Trk::RIO_OnTrack*> rotIDtuple =
status.value();
218 Identifier rot_id = std::get<Identifier>(rotIDtuple);
221 if(!cluster)
continue;
226 int channelType =
m_idHelperSvc -> stgcIdHelper().channelType(rot_id);
227 int stEta =
m_idHelperSvc -> stgcIdHelper().stationEta(rot_id);
233 int iside = (stEta > 0) ? 1 : 0;
234 std::string
side = GeometricSectors::sTgcSide[iside];
235 std::string channelName =
"";
239 if (channelType == sTgcIdHelper::sTgcChannelTypes::Pad) {
240 float padCharge = prd ->
charge();
244 short int padTiming = prd ->
time();
247 fill(
"sTgcTiming", padSectorSidedMon, padTimingMon);
251 fill(
"padTiming_quad_" +
std::to_string(std::abs(stEta)), padSectorSidedExpertMon, padTimingExpertMon);
257 fill(
"sTgcTiming", timeMon, febMon);
260 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Strip) {
261 channelName =
"strip";
262 const std::vector<Identifier>& stripIds = prd->
rdoList();
263 unsigned int csize = stripIds.size();
265 std::vector<short int> stripTimesVec = prd -> stripTimes();
266 std::vector<int> stripChargesVec = prd -> stripCharges();
268 float stripClusterTimes = 0;
269 float stripClusterCharges = 0;
271 for (
unsigned int sIdx = 0; sIdx < csize; ++sIdx) {
272 stripClusterTimes += stripTimesVec.at(sIdx);
273 stripClusterCharges += stripChargesVec.at(sIdx);
276 stripClusterTimes /= stripTimesVec.size();
284 fill(
"sTgcTiming", stripClusterSectorSidedMon, stripClusterTimesMon);
285 fill(
"padTriggerShifter", stripClusterSectorSidedMon, stripClusterSizeMon);
291 fill(
"sTgcTiming", timeMon, febMon);
296 fill(
"stripTiming_quad_" +
std::to_string(std::abs(stEta)), stripSectorSidedExpertMon, stripTimingExpertMon);
299 std::optional<Trk::ResidualPull> resPull(
m_residualPullCalculator -> residualPull(trkState -> measurementOnTrack(), trkState -> trackParameters(), Trk::ResidualPull::ResidualType::Biased));
308 else if (channelType == sTgcIdHelper::sTgcChannelTypes::Wire) {
309 float wireGroupCharge = prd ->
charge();
313 short int wireGroupTiming = prd ->
time();
316 fill(
"sTgcTiming", wireGroupSectorSidedMon, wireGroupTimingMon);
320 fill(
"wireTiming_quad_" +
std::to_string(std::abs(stEta)), wireSectorSidedExpertMon, wireTimingExpertMon);
326 fill(
"sTgcTiming", timeMon, febMon);
337 bool largeSector = rdo -> largeSector();
339 int iside = (
sideA) ? 1 : 0;
340 int isize = (largeSector) ? 1 : 0;
342 std::string
side = GeometricSectors::sTgcSide[iside];
343 std::string
size = GeometricSectors::sTgcSize[isize];
345 size_t numberOfTriggers = rdo -> getNumberOfTriggers();
346 size_t numberOfHits = rdo -> getNumberOfHits();
348 for (
size_t trigger = 0; trigger < numberOfTriggers; ++trigger) {
349 int triggerPhiIdsUnsigned = rdo -> getTriggerPhiIds().at(trigger);
350 int triggerBandIds = rdo -> getTriggerBandIds().at(trigger);
351 int triggerRelBCID = rdo -> getTriggerRelBcids().at(trigger);
352 int sourceId = rdo -> getSourceid();
361 fill(
"padTriggerShifter", phiIdsPerSideSizeMon, bandIdsPerSideSizeMon);
367 fill(
"padTriggerShifter", lbMon, relBCIDMon, sectorMon, numberOfTriggersMon);
374 fill(
"padTriggerExpert", numberOfTriggersPerSectorMon, phiIdsSidedSizedPerSectorMon, bandIdsSidedSizedPerSectorMon, lbPerSectorMon, relBCIDperSectorMon);
379 fill(
"padTriggerShifter", RelBCIDPerSectorMon, PhiIDPerSectorMon, BandIDPerSectorMon);
383 std::optional<Identifier>
status =
getPadId(rdo->getSourceid(), rdo->getHitPfebs().at(
hits), rdo->getHitTdsChannels().at(
hits));
384 if (!
status.has_value())
continue;
391 const xAOD::TrackParticle* meTP =
mu -> trackParticle(xAOD::Muon::TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle);
392 if(meTP ==
nullptr)
continue;
395 if(!meTrack)
continue;
399 if (!
status.has_value())
continue;
402 int channelType =
m_idHelperSvc -> stgcIdHelper().channelType(rot_id);
403 if (channelType != sTgcIdHelper::sTgcChannelTypes::Pad)
continue;
406 if (rot_id != pad_id)
continue;
408 int sourceIds = rdo -> getSourceid();
410 int hitRelBCID = rdo -> getHitRelBcids().at(
hits);
411 int hitpfebs = rdo -> getHitPfebs().at(
hits);
412 int hitTdsChannels = rdo->getHitTdsChannels().at(
hits);
414 std::optional<std::tuple<int, int, std::string, std::string, int>> statusPadEtaPhi =
getPadEtaPhiTuple(sourceIds, hitpfebs, hitTdsChannels);
415 if (!statusPadEtaPhi.has_value())
continue;
416 std::tuple<int, int, std::string, std::string, int> padEtaPhiTuple = statusPadEtaPhi.value();
418 int padPhi = std::get<0>(padEtaPhiTuple);
419 int padEta = std::get<1>(padEtaPhiTuple);
420 std::string sideName = std::get<2>(padEtaPhiTuple);
421 std::string sizeName = std::get<3>(padEtaPhiTuple);
422 int layer = std::get<4>(padEtaPhiTuple);
426 fill(
"padTriggerOccupancy", padPhiMon, padEtaMon);
431 fill(
"padTriggerShifter", hitRelBCIDmon, hitPfebsMon, sectorMon);
435 fill(
"padTriggerShifter", hitRelBCIDPerSectorMon, hitpfebsPerSectorMon);
450 std::array<int, 8> quadMultiplet{};
451 std::array<int, 8> layerMultiplet{};
452 std::array<float, 8> xPosMultiplet{};
453 std::array<float, 8> yPosMultiplet{};
454 std::array<float, 8> zPosMultiplet{};
457 std::array<std::array<sTGCeff, 16>, 2> effPlots;
459 const xAOD::TrackParticle* meTP =
mu -> trackParticle(xAOD::Muon::TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle);
460 if(meTP ==
nullptr)
continue;
463 if(!meTrack)
continue;
467 if (!
status.has_value())
continue;
471 int channelType =
m_idHelperSvc -> stgcIdHelper().channelType(rot_id);
472 if (channelType != sTgcIdHelper::sTgcChannelTypes::Strip)
continue;
474 int stEta =
m_idHelperSvc -> stgcIdHelper().stationEta(rot_id);
475 int iside = (stEta > 0) ? 1 : 0;
481 const Amg::Vector2D& positionsMultiplet = (trkState) -> trackParameters() -> localPosition();
482 float xPosStripInMultipletLocal = positionsMultiplet.x();
483 float yPosStripInMultipletLocal = positionsMultiplet.y();
485 Amg::Vector2D localPos(xPosStripInMultipletLocal, yPosStripInMultipletLocal);
488 sTgcReadoutObjectStrip -> surface(rot_id).localToGlobal(localPos,
Amg::Vector3D::Zero(), globalPos);
489 float xPosStripInMultiplet = globalPos.x();
490 float yPosStripInMultiplet = globalPos.y();
493 (muonDetectorManagerObject -> getsTgcReadoutElement(rot_id)) -> stripGlobalPosition(rot_id, posStripGlobal);
494 float zPosStripInMultiplet = posStripGlobal.z();
496 auto& sTGCelements = effPlots[iside][sector - 1];
498 sTGCelements.quadMultiplet.at(
layer - 1) = stEta;
499 sTGCelements.layerMultiplet.at(
layer - 1) =
layer;
500 sTGCelements.xPosMultiplet.at(
layer - 1) = xPosStripInMultiplet;
501 sTGCelements.yPosMultiplet.at(
layer - 1) = yPosStripInMultiplet;
502 sTGCelements.zPosMultiplet.at(
layer - 1) = zPosStripInMultiplet;
505 for (
unsigned int isideIndex = 0; isideIndex <= 1; ++isideIndex) {
506 for (
unsigned int sectorIndex = 1; sectorIndex <= 16; ++sectorIndex) {
507 auto& sTGCelements = effPlots[isideIndex][sectorIndex - 1];
508 bool fourOutEight = std::count_if(sTGCelements.layerMultiplet.begin(), sTGCelements.layerMultiplet.end(), [](
int i) { return i != 0; }) >= 4;
509 bool oneRefLayer = std::count_if(sTGCelements.layerMultiplet.begin(), sTGCelements.layerMultiplet.end(), [](
int i) { return i != 0; }) >= 1;
512 for (
auto layerIndex =
static_cast<std::array<int, 8>::size_type
>(1); layerIndex <= sTGCelements.layerMultiplet.size(); ++layerIndex) {
513 if (sTGCelements.layerMultiplet.at(layerIndex - 1) == 0)
continue;
515 float xPos = sTGCelements.xPosMultiplet.at(layerIndex - 1);
516 float yPos = sTGCelements.yPosMultiplet.at(layerIndex - 1);
517 float rPos = std::hypot(xPos, yPos);
519 std::string
side = GeometricSectors::sTgcSide[isideIndex];
528 fill(
"padTriggerShifter", xPosStripmon, yPosStripmon, effQuestionMon);
532 else if (!fourOutEight && oneRefLayer) {
533 auto refLayerIndex =
std::distance(sTGCelements.layerMultiplet.begin(), std::find_if(sTGCelements.layerMultiplet.begin(), sTGCelements.layerMultiplet.end(), [](
int i) {return i != 0;}));
535 for (
auto layerIndex =
static_cast<std::array<int, 8>::size_type
>(1); layerIndex <= sTGCelements.layerMultiplet.size(); ++layerIndex) {
536 if (sTGCelements.layerMultiplet.at(layerIndex - 1) != 0)
continue;
537 int quad = sTGCelements.quadMultiplet.at(refLayerIndex);
539 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());
542 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);
550 (muonDetectorManagerObject -> getsTgcReadoutElement(idProbe)) -> stripGlobalPosition(idProbe, posProbe);
551 float posZprobe = posProbe.z();
553 float xSlope = sTGCelements.xPosMultiplet.at(refLayerIndex)/sTGCelements.zPosMultiplet.at(refLayerIndex);
554 float ySlope = sTGCelements.yPosMultiplet.at(refLayerIndex)/sTGCelements.zPosMultiplet.at(refLayerIndex);
556 float xPos = sTGCelements.xPosMultiplet.at(refLayerIndex) + xSlope*(posZprobe - sTGCelements.zPosMultiplet.at(refLayerIndex));
557 float yPos = sTGCelements.yPosMultiplet.at(refLayerIndex) + ySlope*(posZprobe - sTGCelements.zPosMultiplet.at(refLayerIndex));
558 float rPos = std::hypot(xPos, yPos);
560 std::string
side = GeometricSectors::sTgcSide[isideIndex];
569 fill(
"padTriggerShifter", xPosStripProbemon, yPosStripProbemon, effQuestionMon);
585 double recoMuonEta =
mu ->
eta();
586 double recoMuonPhi =
mu ->
phi();
588 std::string sideRecoMuon = GeometricSectors::sTgcSide[recoMuonEta > 0];
590 std::string minSideRecoMuon =
"", minSideTrigger =
"";
592 double minTriggerEta = 999., minTriggerPhi = 999.,
593 minRecoEta = 999., minRecoPhi = 999., minDeltaR = 999.;
595 auto minDeltaRtrigIt = -1;
599 bool largeSector = rdo -> largeSector();
600 std::string sideTrigger = GeometricSectors::sTgcSide[
sideA];
601 size_t numberOfTriggers = rdo -> getNumberOfTriggers();
603 for (
size_t trigger = 0; trigger < numberOfTriggers; ++trigger) {
604 int triggerPhiIdsUnsigned = rdo -> getTriggerPhiIds().at(trigger);
605 int triggerBandIds = rdo -> getTriggerBandIds().at(trigger);
606 int sourceId = rdo -> getSourceid();
611 std::optional<double>
status =
bandId2eta(triggerBandIds, largeSector,
sideA, muonDetectorManagerObject);
612 if (!
status.has_value())
continue;
613 double triggerBandIdToEta =
status.value();
619 if (sideRecoMuon == sideTrigger) {
621 minSideRecoMuon = sideRecoMuon;
622 minSideTrigger = sideTrigger;
623 minTriggerEta = triggerBandIdToEta;
624 minTriggerPhi = triggerPhiIDtoPhi;
625 minRecoEta = recoMuonEta;
626 minRecoPhi = recoMuonPhi;
628 minDeltaRtrigIt = trigger;
634 bool muonRecoTriggerMatch =
false;
636 if (minDeltaRtrigIt != -1) {
638 muonRecoTriggerMatch =
true;
643 fill(
"Overview", deltaRmon);
647 fill(
"Overview", etaRecoMuonMon, phiRecoMuonMon);
651 fill(
"Overview", etaPadTriggerMon, phiPadTriggerMon);
655 fill(
"Overview", phiRecoMuonSidedMon, phiPadTriggerSidedMon);
660 fill(
"Overview", muonRecoTriggerMatchMon, etaRecoMuonEffMon, phiRecoMuonEffMon);