404 LogDebug(
"SiStripHitEfficiencyWorker") <<
"beginning analyze from HitEff";
420 }
else if (metaData.
isValid()) {
424 edm::LogWarning(
"SiStripHitEfficiencyWorker") <<
"could not find a source for the Luminosity and PU";
452 for (
const auto& fedErr : *fedErrorIds) {
476 LogDebug(
"SiStripHitEfficiencyWorker") <<
"number ckf tracks found = " << tracksCKF->size();
486 if (!tracksCKF->empty()) {
490 LogDebug(
"SiStripHitEfficiencyWorker")
496 for (
const auto& trajTrack : *trajTrackAssociationHandle) {
500 auto TMeas = trajTrack.key->measurements();
510 bool hasMissingHits{
false};
511 int previous_layer{999};
512 std::vector<unsigned int> missedLayers;
514 for (
const auto& itm : TMeas) {
515 auto theHit = itm.recHit();
516 unsigned int iidd = theHit->geographicalId().rawId();
517 int layer = ::checkLayer(iidd, tTopo);
518 int missedLayer =
layer + 1;
519 int diffPreviousLayer = (
layer - previous_layer);
522 if (diffPreviousLayer == -2 && missedLayer > k_LayersStart && missedLayer < k_LayersAtTOBEnd) {
524 hasMissingHits =
true;
527 else if (diffPreviousLayer == -2 && (missedLayer > k_LayersAtTOBEnd + 1 && missedLayer <= k_LayersAtTIDEnd)) {
529 hasMissingHits =
true;
532 else if (diffPreviousLayer == -2 && missedLayer > k_LayersAtTIDEnd && missedLayer <= k_LayersAtTECEnd) {
534 hasMissingHits =
true;
538 if ((
layer > k_LayersStart &&
layer <= k_LayersAtTIBEnd) && (previous_layer == 12)) {
540 hasMissingHits =
true;
544 if ((
layer > k_LayersAtTIBEnd &&
layer <= k_LayersAtTOBEnd) && (previous_layer == 15)) {
546 hasMissingHits =
true;
550 hasMissingHits =
true;
553 missedLayers.push_back(
layer);
554 previous_layer =
layer;
559 unsigned int prev_TKlayers = 0;
560 for (
auto itm = TMeas.cbegin(); itm != TMeas.cend(); ++itm) {
561 const auto theInHit = (*itm).recHit();
566 LogDebug(
"SiStripHitEfficiencyWorker") <<
"theInHit is valid = " << theInHit->isValid();
568 unsigned int iidd = theInHit->geographicalId().rawId();
570 unsigned int TKlayers = ::checkLayer(iidd, tTopo);
576 LogDebug(
"SiStripHitEfficiencyWorker") <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd
577 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" 578 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2);
582 bool isFirstMeas = (itm == (TMeas.end() - 1));
583 bool isLastMeas = (itm == (TMeas.begin()));
596 if (TKlayers == bounds::k_LayersAtTOBEnd || TKlayers == bounds::k_LayersAtTECEnd) {
597 LogDebug(
"SiStripHitEfficiencyWorker") <<
"skipping original TM for TOB 6 or TEC 9";
601 std::vector<TrajectoryAtInvalidHit> TMs;
609 if (::isDoubleSided(iidd, tTopo) && ((iidd & 0x3) == 0)) {
612 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator, 1);
613 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator, 2);
614 }
else if (::isDoubleSided(iidd, tTopo) && (!::check2DPartner(iidd, TMeas))) {
617 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator, 1);
618 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator, 2);
619 LogDebug(
"SiStripHitEfficiencyWorker") <<
" found a hit with a missing partner";
622 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator);
625 bool missingHitAdded{
false};
626 std::vector<TrajectoryMeasurement> tmpTmeas;
627 unsigned int misLayer = TKlayers + 1;
630 if (
int(TKlayers) -
int(prev_TKlayers) == -2) {
631 const DetLayer* detlayer = itm->layer();
634 std::vector<DetLayer::DetWithState> compatDets = detlayer->
compatibleDets(tsos, prop, chi2Estimator);
636 if (misLayer > k_LayersAtTIDEnd && misLayer < k_LayersAtTECEnd) {
637 std::vector<ForwardDetLayer const*> negTECLayers = measTracker.geometricSearchTracker()->negTecLayers();
638 std::vector<ForwardDetLayer const*> posTECLayers = measTracker.geometricSearchTracker()->posTecLayers();
639 const DetLayer* tecLayerneg = negTECLayers[misLayer - k_LayersAtTIDEnd - 1];
640 const DetLayer* tecLayerpos = posTECLayers[misLayer - k_LayersAtTIDEnd - 1];
641 if (tTopo->tecSide(iidd) == 1) {
642 tmpTmeas = layerMeasurements.measurements(*tecLayerneg, tsos, prop, chi2Estimator);
643 }
else if (tTopo->tecSide(iidd) == 2) {
644 tmpTmeas = layerMeasurements.measurements(*tecLayerpos, tsos, prop, chi2Estimator);
648 else if (misLayer == (k_LayersAtTIDEnd - 1) ||
649 misLayer == k_LayersAtTIDEnd) {
650 std::vector<ForwardDetLayer const*> negTIDLayers = measTracker.geometricSearchTracker()->negTidLayers();
651 std::vector<ForwardDetLayer const*> posTIDLayers = measTracker.geometricSearchTracker()->posTidLayers();
652 const DetLayer* tidLayerneg = negTIDLayers[misLayer - k_LayersAtTOBEnd - 1];
653 const DetLayer* tidLayerpos = posTIDLayers[misLayer - k_LayersAtTOBEnd - 1];
655 if (tTopo->tidSide(iidd) == 1) {
656 tmpTmeas = layerMeasurements.measurements(*tidLayerneg, tsos, prop, chi2Estimator);
657 }
else if (tTopo->tidSide(iidd) == 2) {
658 tmpTmeas = layerMeasurements.measurements(*tidLayerpos, tsos, prop, chi2Estimator);
662 if (misLayer > k_LayersStart && misLayer < k_LayersAtTOBEnd) {
664 std::vector<BarrelDetLayer const*> barrelTIBLayers = measTracker.geometricSearchTracker()->tibLayers();
665 std::vector<BarrelDetLayer const*> barrelTOBLayers = measTracker.geometricSearchTracker()->tobLayers();
667 if (misLayer > k_LayersStart && misLayer <= k_LayersAtTIBEnd) {
668 const DetLayer* tibLayer = barrelTIBLayers[misLayer - k_LayersStart - 1];
669 tmpTmeas = layerMeasurements.measurements(*tibLayer, tsos, prop, chi2Estimator);
670 }
else if (misLayer > k_LayersAtTIBEnd && misLayer < k_LayersAtTOBEnd) {
671 const DetLayer* tobLayer = barrelTOBLayers[misLayer - k_LayersAtTIBEnd - 1];
672 tmpTmeas = layerMeasurements.measurements(*tobLayer, tsos, prop, chi2Estimator);
676 if ((
int(TKlayers) > k_LayersStart &&
int(TKlayers) <= k_LayersAtTIBEnd) &&
int(prev_TKlayers) == 12) {
677 const DetLayer* detlayer = itm->layer();
680 std::vector<DetLayer::DetWithState> compatDets = detlayer->
compatibleDets(tsos, prop, chi2Estimator);
681 std::vector<ForwardDetLayer const*> negTIDLayers = measTracker.geometricSearchTracker()->negTidLayers();
682 std::vector<ForwardDetLayer const*> posTIDLayers = measTracker.geometricSearchTracker()->posTidLayers();
684 const DetLayer* tidLayerneg = negTIDLayers[k_LayersStart];
685 const DetLayer* tidLayerpos = posTIDLayers[k_LayersStart];
686 if (tTopo->tidSide(iidd) == 1) {
687 tmpTmeas = layerMeasurements.measurements(*tidLayerneg, tsos, prop, chi2Estimator);
688 }
else if (tTopo->tidSide(iidd) == 2) {
689 tmpTmeas = layerMeasurements.measurements(*tidLayerpos, tsos, prop, chi2Estimator);
693 if ((
int(TKlayers) > k_LayersAtTIBEnd &&
int(TKlayers) <= k_LayersAtTOBEnd) &&
int(prev_TKlayers) == 15) {
694 const DetLayer* detlayer = itm->layer();
697 std::vector<DetLayer::DetWithState> compatDets = detlayer->
compatibleDets(tsos, prop, chi2Estimator);
699 std::vector<ForwardDetLayer const*> negTECLayers = measTracker.geometricSearchTracker()->negTecLayers();
700 std::vector<ForwardDetLayer const*> posTECLayers = measTracker.geometricSearchTracker()->posTecLayers();
702 const DetLayer* tecLayerneg = negTECLayers[k_LayersStart];
703 const DetLayer* tecLayerpos = posTECLayers[k_LayersStart];
704 if (tTopo->tecSide(iidd) == 1) {
705 tmpTmeas = layerMeasurements.measurements(*tecLayerneg, tsos, prop, chi2Estimator);
706 }
else if (tTopo->tecSide(iidd) == 2) {
707 tmpTmeas = layerMeasurements.measurements(*tecLayerpos, tsos, prop, chi2Estimator);
711 if (!tmpTmeas.empty()) {
713 unsigned int iidd_tmp = TM_tmp.
recHit()->geographicalId().rawId();
715 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" hit actually being added to TM vector";
718 if (::isDoubleSided(iidd_tmp, tTopo)) {
723 missingHitAdded =
true;
729 prev_TKlayers = TKlayers;
734 bool hitsWithBias =
false;
735 for (
auto ilayer : missedLayers) {
736 if (ilayer < TKlayers)
749 const auto nextId = (itm + 1 != TMeas.end()) ? (itm + 1)->recHit()->geographicalId() :
DetId{};
751 if (TKlayers == 9 && theInHit->isValid() && !((!nextId.null()) && (::checkLayer(nextId.rawId(), tTopo) == 9))) {
754 const DetLayer* tob6 = measTracker.geometricSearchTracker()->tobLayers().back();
757 const auto tmp = theLayerMeasurements.measurements(*tob6, tsosTOB5, prop, chi2Estimator);
760 LogDebug(
"SiStripHitEfficiencyWorker") <<
"size of TM from propagation = " <<
tmp.size();
765 const auto& tob6TM =
tmp.back();
766 const auto& tob6Hit = tob6TM.recHit();
767 if (tob6Hit->geographicalId().rawId() != 0) {
768 LogDebug(
"SiStripHitEfficiencyWorker") <<
"tob6 hit actually being added to TM vector";
769 TMs.emplace_back(tob6TM, tTopo, tkgeom,
propagator);
775 if (TKlayers == 21 && theInHit->isValid() &&
776 !((!nextId.null()) && (::checkLayer(nextId.rawId(), tTopo) == 21))) {
777 const DetLayer* tec9pos = measTracker.geometricSearchTracker()->posTecLayers().back();
778 const DetLayer* tec9neg = measTracker.geometricSearchTracker()->negTecLayers().back();
785 LogDebug(
"SiStripHitEfficiencyWorker") <<
"there is a problem with TEC 9 extrapolation";
788 std::vector<TrajectoryMeasurement>
tmp;
789 if (tTopo->tecSide(iidd) == 1) {
790 tmp = theLayerMeasurements.measurements(*tec9neg, tsosTEC9, prop, chi2Estimator);
793 if (tTopo->tecSide(iidd) == 2) {
794 tmp = theLayerMeasurements.measurements(*tec9pos, tsosTEC9, prop, chi2Estimator);
802 const auto& tec9TM =
tmp.back();
803 const auto& tec9Hit = tec9TM.recHit();
805 const unsigned int tec9id = tec9Hit->geographicalId().rawId();
806 LogDebug(
"SiStripHitEfficiencyWorker")
807 <<
"tec9id = " << tec9id <<
" is Double sided = " << ::isDoubleSided(tec9id, tTopo)
808 <<
" and 0x3 = " << (tec9id & 0x3);
810 if (tec9Hit->geographicalId().rawId() != 0) {
811 LogDebug(
"SiStripHitEfficiencyWorker") <<
"tec9 hit actually being added to TM vector";
814 if (::isDoubleSided(tec9id, tTopo)) {
815 TMs.emplace_back(tec9TM, tTopo, tkgeom,
propagator, 1);
816 TMs.emplace_back(tec9TM, tTopo, tkgeom,
propagator, 2);
818 TMs.emplace_back(tec9TM, tTopo, tkgeom,
propagator);
823 for (
const auto& tm : TMs) {
837 LogDebug(
"SiStripHitEfficiencyWorker") <<
"After looping over TrajAtValidHit list";
839 LogDebug(
"SiStripHitEfficiencyWorker") <<
"end TMeasurement loop";
841 LogDebug(
"SiStripHitEfficiencyWorker") <<
"end of trajectories loop";
const edm::ESGetToken< MeasurementTracker, CkfComponentsRecord > measTrackerToken_
MonitorElement * h_nTracksVsPU
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
MonitorElement * h_instLumi
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
std::vector< int > missHitPerLayer
const edm::EDGetTokenT< DetIdCollection > digis_token_
float instLumi() const
Return the luminosity for the current nibble.
std::unordered_map< uint32_t, int > fedErrorCounts
std::unique_ptr< TkHistoMap > FEDErrorOccupancy
const edm::EDGetTokenT< MeasurementTrackerEvent > trackerEvent_token_
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
void fillForTraj(const TrajectoryAtInvalidHit &tm, const TrackerTopology *tTopo, const TrackerGeometry *tkgeom, const StripClusterParameterEstimator &stripCPE, const SiStripQuality &stripQuality, const DetIdCollection &fedErrorIds, const edm::Handle< edm::DetSetVector< SiStripRawDigi >> &commonModeDigis, const edmNew::DetSetVector< SiStripCluster > &theClusters, int bunchCrossing, float instLumi, float PU, bool highPurity)
const edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecord > stripCPEToken_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
const edm::EDGetTokenT< OnlineLuminosityRecord > metaDataToken_
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > chi2EstimatorToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
unsigned int trackMultiplicityCut_
bool useAllHitsFromTracksWithMissingHits_
dqm::reco::MonitorElement * EventStats
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
SiStripHitEffData calibData_
const edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAsso_token_
MonitorElement * h_nTracks
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
const edm::EDGetTokenT< LumiScalersCollection > scalerToken_
std::vector< unsigned int > hitRecoveryCounters
const edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > commonModeToken_
Log< level::Warning, false > LogWarning
float avgPileUp() const
Return the average pileup for th current nibble.
ConstRecHitPointer const & recHit() const
bool doMissingHitsRecovery_