202 combinatorialTracks_token_(
208 digisCol_token_(consumes(conf.getParameter<
edm::
InputTag>(
"siStripDigis"))),
209 digisVec_token_(consumes(conf.getParameter<
edm::
InputTag>(
"siStripDigis"))),
219 tkDetMapToken_(esConsumes<edm::Transition::BeginRun>()),
221 layers_(conf.getParameter<
int>(
"Layer")),
222 DEBUG_(conf.getUntrackedParameter<
bool>(
"Debug",
false)),
223 addLumi_(conf.getUntrackedParameter<
bool>(
"addLumi",
false)),
224 addCommonMode_(conf.getUntrackedParameter<
bool>(
"addCommonMode",
false)),
225 cutOnTracks_(conf.getParameter<
bool>(
"cutOnTracks")),
226 trackMultiplicityCut_(conf.getParameter<
unsigned int>(
"trackMultiplicity")),
227 useFirstMeas_(conf.getParameter<
bool>(
"useFirstMeas")),
228 useLastMeas_(conf.getParameter<
bool>(
"useLastMeas")),
229 useAllHitsFromTracksWithMissingHits_(conf.getParameter<
bool>(
"useAllHitsFromTracksWithMissingHits")),
230 doMissingHitsRecovery_(conf.getParameter<
bool>(
"doMissingHitsRecovery")),
231 clusterMatchingMethod_(conf.getParameter<
int>(
"ClusterMatchingMethod")),
232 resXSig_(conf.getParameter<
double>(
"ResXSig")),
233 clusterTracjDist_(conf.getParameter<
double>(
"ClusterTrajDist")),
234 stripsApvEdge_(conf.getParameter<
double>(
"StripsApvEdge")),
235 useOnlyHighPurityTracks_(conf.getParameter<
bool>(
"UseOnlyHighPurityTracks")),
236 bunchX_(conf.getUntrackedParameter<
int>(
"BunchCrossing", 0)),
237 showRings_(conf.getUntrackedParameter<
bool>(
"ShowRings",
false)),
238 showTOB6TEC9_(conf.getUntrackedParameter<
bool>(
"ShowTOB6TEC9",
false)) {
239 hitRecoveryCounters.resize(k_END_OF_LAYERS, 0);
240 hitTotalCounters.resize(k_END_OF_LAYERS, 0);
241 missHitPerLayer.resize(k_END_OF_LAYERS, 0);
244 nTEClayers_ = (showRings_ ? 7 : 9);
247 if (!badModulesFile.empty()) {
248 std::ifstream badModules_file(badModulesFile);
249 uint32_t badmodule_detid;
250 int mods, fiber1, fiber2, fiber3;
251 if (badModules_file.is_open()) {
253 while (getline(badModules_file,
line)) {
254 if (badModules_file.eof())
256 std::stringstream
ss(
line);
257 ss >> badmodule_detid >>
mods >> fiber1 >> fiber2 >> fiber3;
258 if (badmodule_detid != 0 &&
mods == 1 && (fiber1 == 1 || fiber2 == 1 || fiber3 == 1))
259 badModules_.insert(badmodule_detid);
261 badModules_file.close();
264 if (!badModules_.empty())
265 LogDebug(
"SiStripHitEfficiencyWorker") <<
"Remove additionnal bad modules from the analysis: ";
266 for (
const auto badMod : badModules_) {
267 LogDebug(
"SiStripHitEfficiencyWorker") <<
" " << badMod;
275 h_bx = booker.
book1D(
"bx",
"bx", 3600, 0, 3600);
277 h_PU = booker.
book1D(
"PU",
"PU", 200, 0, 200);
278 h_nTracks = booker.
book1D(
"ntracks",
"n.tracks;n. tracks;n.events", 500, -0.5, 499.5);
288 booker.
book1D(
"goodlayer_found",
"goodlayer_found", 35, 0., 35.));
290 booker.
book1D(
"alllayer_found",
"alllayer_found", 35, 0., 35.));
294 "layer_found",
"layer_found", bounds::k_END_OF_LAYERS, 0., static_cast<float>(bounds::k_END_OF_LAYERS)),
296 "layer_total",
"layer_total", bounds::k_END_OF_LAYERS, 0., static_cast<float>(bounds::k_END_OF_LAYERS)));
303 auto ihres = booker.
book1D(Form(
"resol_layer_%i",
layer), lyrName, 125, -125., 125.);
310 booker.
book1D(Form(
"layerfound_vsLumi_layer_%i",
layer), lyrName, 100, 0, 25000)));
315 booker.
book1D(Form(
"layerfound_vsPU_layer_%i",
layer), lyrName, 45, 0, 90)));
320 booker.
book1D(Form(
"layerfound_vsCM_layer_%i",
layer), lyrName, 20, 0, 400)));
326 booker.
book1D(Form(
"totalVsBx_layer%i",
layer), Form(
"layer %i (%s)",
layer, lyrName.c_str()), 3565, 0, 3565),
327 booker.
book1D(Form(
"foundVsBx_layer%i",
layer), Form(
"layer %i (%s)",
layer, lyrName.c_str()), 3565, 0, 3565)));
331 if (
layer <= bounds::k_LayersAtTOBEnd) {
332 const bool isTIB =
layer <= bounds::k_LayersAtTIBEnd;
333 const auto partition = (isTIB ?
"TIB" :
"TOB");
334 const auto yMax = (isTIB ? 100 : 120);
337 Form(
"%s%i: Map of missing hits",
partition, (isTIB ?
layer :
layer - bounds::k_LayersAtTIBEnd));
342 ::replaceInString(
name,
":",
"");
346 ihhotcold->setBinLabel(1,
"360", 1);
347 ihhotcold->setBinLabel(50,
"180", 1);
348 ihhotcold->setBinLabel(100,
"0", 1);
349 ihhotcold->setAxisTitle(
"Global Z [cm]", 2);
350 ihhotcold->setOption(
"colz");
353 const bool isTID =
layer <= bounds::k_LayersAtTIDEnd;
355 (isTID ? std::vector<std::string>{
"TIDplus",
"TIDminus"} : std::vector<std::string>{
"TECplus",
"TECminus"});
356 const auto axMax = (isTID ? 100 : 120);
360 ::replaceInString(forTitle,
"minus",
"-");
361 ::replaceInString(forTitle,
"plus",
"+");
365 const auto&
name = Form(
"%s %i Map of Missing Hits",
367 (isTID ?
layer - bounds::k_LayersAtTOBEnd :
layer - bounds::k_LayersAtTIDEnd));
368 const auto& tit = Form(
"%s%i: Map of Missing Hits",
370 (isTID ?
layer - bounds::k_LayersAtTOBEnd :
layer - bounds::k_LayersAtTIDEnd));
372 auto ihhotcold = booker.
book2D(
name, tit, 100, -axMax, axMax, 100, -axMax, axMax);
374 ihhotcold->setBinLabel(1,
"+Y", 1);
375 ihhotcold->setBinLabel(50,
"0", 1);
376 ihhotcold->setBinLabel(100,
"-Y", 1);
377 ihhotcold->setAxisTitle(
"Global X", 2);
378 ihhotcold->setBinLabel(1,
"-X", 2);
379 ihhotcold->setBinLabel(50,
"0", 2);
380 ihhotcold->setBinLabel(100,
"+X", 2);
381 ihhotcold->setOption(
"colz");
393 EffTkMap(std::make_unique<TkHistoMap>(tkDetMap, booker, tkDetMapFolder,
"perModule_total", 0,
false,
true),
394 std::make_unique<TkHistoMap>(tkDetMap, booker, tkDetMapFolder,
"perModule_found", 0,
false,
true));
400 std::make_unique<TkHistoMap>(tkDetMap, booker, FEDErrorMapFolder,
"perModule_FEDErrors", 0,
false,
true);
408 LogDebug(
"SiStripHitEfficiencyWorker") <<
"beginning analyze from HitEff";
424 }
else if (metaData.
isValid()) {
428 edm::LogWarning(
"SiStripHitEfficiencyWorker") <<
"could not find a source for the Luminosity and PU";
460 if (not fedErrorIdsCol_h.isValid() and not fedErrorIdsVec_h.isValid()) {
462 <<
"no valid product for SiStrip DetIds with FED errors (see parameter \"siStripDigis\"), " 463 "neither for new format (DetIdVector) nor old format (DetIdCollection)";
465 auto const& fedErrorIds = fedErrorIdsVec_h.isValid() ? *fedErrorIdsVec_h : fedErrorIdsCol_h->as_vector();
468 for (
const auto& fedErr : fedErrorIds) {
492 LogDebug(
"SiStripHitEfficiencyWorker") <<
"number ckf tracks found = " << tracksCKF->size();
502 if (!tracksCKF->empty()) {
506 LogDebug(
"SiStripHitEfficiencyWorker")
512 for (
const auto& trajTrack : *trajTrackAssociationHandle) {
516 auto TMeas = trajTrack.key->measurements();
526 bool hasMissingHits{
false};
527 int previous_layer{999};
528 std::vector<unsigned int> missedLayers;
530 for (
const auto& itm : TMeas) {
531 auto theHit = itm.recHit();
532 unsigned int iidd = theHit->geographicalId().rawId();
533 int layer = ::checkLayer(iidd, tTopo);
534 int missedLayer =
layer + 1;
535 int previousMissedLayer = (
layer + 2);
536 int diffPreviousLayer = (
layer - previous_layer);
539 if (diffPreviousLayer == -2 && missedLayer > k_LayersStart && missedLayer < k_LayersAtTOBEnd) {
541 hasMissingHits =
true;
544 else if (diffPreviousLayer == -2 && (missedLayer > k_LayersAtTOBEnd + 1 && missedLayer <= k_LayersAtTIDEnd)) {
546 hasMissingHits =
true;
549 else if (diffPreviousLayer == -2 && missedLayer > k_LayersAtTIDEnd && missedLayer <= k_LayersAtTECEnd) {
551 hasMissingHits =
true;
555 if ((
layer > k_LayersStart &&
layer <= k_LayersAtTIBEnd) && (previous_layer == 12)) {
557 hasMissingHits =
true;
561 if ((
layer > k_LayersAtTIBEnd &&
layer <= k_LayersAtTOBEnd) && (previous_layer == 15)) {
563 hasMissingHits =
true;
569 if (diffPreviousLayer == -3 && missedLayer > k_LayersStart && missedLayer < k_LayersAtTOBEnd &&
570 previousMissedLayer > k_LayersStart && previousMissedLayer < k_LayersAtTOBEnd) {
573 hasMissingHits =
true;
577 else if (diffPreviousLayer == -3 && missedLayer > k_LayersAtTIDEnd && missedLayer <= k_LayersAtTECEnd &&
578 previousMissedLayer > k_LayersAtTIDEnd && previousMissedLayer <= k_LayersAtTECEnd) {
581 hasMissingHits =
true;
585 hasMissingHits =
true;
588 missedLayers.push_back(
layer);
589 previous_layer =
layer;
594 unsigned int prev_TKlayers = 0;
595 for (
auto itm = TMeas.cbegin(); itm != TMeas.cend(); ++itm) {
596 const auto theInHit = (*itm).recHit();
601 LogDebug(
"SiStripHitEfficiencyWorker") <<
"theInHit is valid = " << theInHit->isValid();
603 unsigned int iidd = theInHit->geographicalId().rawId();
605 unsigned int TKlayers = ::checkLayer(iidd, tTopo);
607 bool foundConsMissingHits{
false};
613 LogDebug(
"SiStripHitEfficiencyWorker") <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd
614 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" 615 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2);
619 bool isFirstMeas = (itm == (TMeas.end() - 1));
620 bool isLastMeas = (itm == (TMeas.begin()));
633 if (TKlayers == bounds::k_LayersAtTOBEnd || TKlayers == bounds::k_LayersAtTECEnd) {
634 LogDebug(
"SiStripHitEfficiencyWorker") <<
"skipping original TM for TOB 6 or TEC 9";
638 std::vector<TrajectoryAtInvalidHit> TMs;
646 if (::isDoubleSided(iidd, tTopo) && ((iidd & 0x3) == 0)) {
649 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator, 1);
650 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator, 2);
651 }
else if (::isDoubleSided(iidd, tTopo) && (!::check2DPartner(iidd, TMeas))) {
654 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator, 1);
655 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator, 2);
656 LogDebug(
"SiStripHitEfficiencyWorker") <<
" found a hit with a missing partner";
659 TMs.emplace_back(*itm, tTopo, tkgeom,
propagator);
662 bool missingHitAdded{
false};
663 std::vector<TrajectoryMeasurement> tmpTmeas, prev_tmpTmeas;
664 unsigned int misLayer = TKlayers + 1;
665 unsigned int previousMisLayer = TKlayers + 2;
668 if (
int(TKlayers) -
int(prev_TKlayers) == -2) {
669 const DetLayer* detlayer = itm->layer();
672 std::vector<DetLayer::DetWithState> compatDets = detlayer->
compatibleDets(tsos, prop, chi2Estimator);
674 if (misLayer > k_LayersAtTIDEnd && misLayer < k_LayersAtTECEnd) {
675 std::vector<ForwardDetLayer const*> negTECLayers = measTracker.geometricSearchTracker()->negTecLayers();
676 std::vector<ForwardDetLayer const*> posTECLayers = measTracker.geometricSearchTracker()->posTecLayers();
677 const DetLayer* tecLayerneg = negTECLayers[misLayer - k_LayersAtTIDEnd - 1];
678 const DetLayer* tecLayerpos = posTECLayers[misLayer - k_LayersAtTIDEnd - 1];
679 if (tTopo->tecSide(iidd) == 1) {
680 tmpTmeas = layerMeasurements.measurements(*tecLayerneg, tsos, prop, chi2Estimator);
681 }
else if (tTopo->tecSide(iidd) == 2) {
682 tmpTmeas = layerMeasurements.measurements(*tecLayerpos, tsos, prop, chi2Estimator);
686 else if (misLayer == (k_LayersAtTIDEnd - 1) ||
687 misLayer == k_LayersAtTIDEnd) {
688 std::vector<ForwardDetLayer const*> negTIDLayers = measTracker.geometricSearchTracker()->negTidLayers();
689 std::vector<ForwardDetLayer const*> posTIDLayers = measTracker.geometricSearchTracker()->posTidLayers();
690 const DetLayer* tidLayerneg = negTIDLayers[misLayer - k_LayersAtTOBEnd - 1];
691 const DetLayer* tidLayerpos = posTIDLayers[misLayer - k_LayersAtTOBEnd - 1];
693 if (tTopo->tidSide(iidd) == 1) {
694 tmpTmeas = layerMeasurements.measurements(*tidLayerneg, tsos, prop, chi2Estimator);
695 }
else if (tTopo->tidSide(iidd) == 2) {
696 tmpTmeas = layerMeasurements.measurements(*tidLayerpos, tsos, prop, chi2Estimator);
700 if (misLayer > k_LayersStart && misLayer < k_LayersAtTOBEnd) {
702 std::vector<BarrelDetLayer const*> barrelTIBLayers = measTracker.geometricSearchTracker()->tibLayers();
703 std::vector<BarrelDetLayer const*> barrelTOBLayers = measTracker.geometricSearchTracker()->tobLayers();
705 if (misLayer > k_LayersStart && misLayer <= k_LayersAtTIBEnd) {
706 const DetLayer* tibLayer = barrelTIBLayers[misLayer - k_LayersStart - 1];
707 tmpTmeas = layerMeasurements.measurements(*tibLayer, tsos, prop, chi2Estimator);
708 }
else if (misLayer > k_LayersAtTIBEnd && misLayer < k_LayersAtTOBEnd) {
709 const DetLayer* tobLayer = barrelTOBLayers[misLayer - k_LayersAtTIBEnd - 1];
710 tmpTmeas = layerMeasurements.measurements(*tobLayer, tsos, prop, chi2Estimator);
714 if ((
int(TKlayers) > k_LayersStart &&
int(TKlayers) <= k_LayersAtTIBEnd) &&
int(prev_TKlayers) == 12) {
715 const DetLayer* detlayer = itm->layer();
718 std::vector<DetLayer::DetWithState> compatDets = detlayer->
compatibleDets(tsos, prop, chi2Estimator);
719 std::vector<ForwardDetLayer const*> negTIDLayers = measTracker.geometricSearchTracker()->negTidLayers();
720 std::vector<ForwardDetLayer const*> posTIDLayers = measTracker.geometricSearchTracker()->posTidLayers();
722 const DetLayer* tidLayerneg = negTIDLayers[k_LayersStart];
723 const DetLayer* tidLayerpos = posTIDLayers[k_LayersStart];
724 if (tTopo->tidSide(iidd) == 1) {
725 tmpTmeas = layerMeasurements.measurements(*tidLayerneg, tsos, prop, chi2Estimator);
726 }
else if (tTopo->tidSide(iidd) == 2) {
727 tmpTmeas = layerMeasurements.measurements(*tidLayerpos, tsos, prop, chi2Estimator);
731 if ((
int(TKlayers) > k_LayersAtTIBEnd &&
int(TKlayers) <= k_LayersAtTOBEnd) &&
int(prev_TKlayers) == 15) {
732 const DetLayer* detlayer = itm->layer();
735 std::vector<DetLayer::DetWithState> compatDets = detlayer->
compatibleDets(tsos, prop, chi2Estimator);
737 std::vector<ForwardDetLayer const*> negTECLayers = measTracker.geometricSearchTracker()->negTecLayers();
738 std::vector<ForwardDetLayer const*> posTECLayers = measTracker.geometricSearchTracker()->posTecLayers();
740 const DetLayer* tecLayerneg = negTECLayers[k_LayersStart];
741 const DetLayer* tecLayerpos = posTECLayers[k_LayersStart];
742 if (tTopo->tecSide(iidd) == 1) {
743 tmpTmeas = layerMeasurements.measurements(*tecLayerneg, tsos, prop, chi2Estimator);
744 }
else if (tTopo->tecSide(iidd) == 2) {
745 tmpTmeas = layerMeasurements.measurements(*tecLayerpos, tsos, prop, chi2Estimator);
750 if (
int(TKlayers) -
int(prev_TKlayers) == -3) {
751 foundConsMissingHits =
true;
752 const DetLayer* detlayer = itm->layer();
755 std::vector<DetLayer::DetWithState> compatDets = detlayer->
compatibleDets(tsos, prop, chi2Estimator);
757 if (misLayer > k_LayersStart && misLayer <= k_LayersAtTOBEnd && previousMisLayer > k_LayersStart &&
758 previousMisLayer <= k_LayersAtTOBEnd) {
759 std::vector<BarrelDetLayer const*> barrelTIBLayers = measTracker.geometricSearchTracker()->tibLayers();
760 std::vector<BarrelDetLayer const*> barrelTOBLayers = measTracker.geometricSearchTracker()->tobLayers();
761 if (misLayer > k_LayersStart && misLayer < k_LayersAtTIBEnd) {
762 const DetLayer* tibLayer = barrelTIBLayers[misLayer - k_LayersStart - 1];
763 const DetLayer* prevTibLayer = barrelTIBLayers[previousMisLayer - k_LayersStart - 1];
765 tmpTmeas = layerMeasurements.measurements(*tibLayer, tsos, prop, chi2Estimator);
766 prev_tmpTmeas = layerMeasurements.measurements(*prevTibLayer, tsos, prop, chi2Estimator);
767 }
else if (misLayer > k_LayersAtTIBEnd && misLayer < k_LayersAtTOBEnd) {
768 const DetLayer* tobLayer = barrelTOBLayers[misLayer - k_LayersAtTIBEnd - 1];
769 const DetLayer* prevTobLayer = barrelTOBLayers[previousMisLayer - k_LayersAtTIBEnd - 1];
770 tmpTmeas = layerMeasurements.measurements(*tobLayer, tsos, prop, chi2Estimator);
771 prev_tmpTmeas = layerMeasurements.measurements(*prevTobLayer, tsos, prop, chi2Estimator);
773 }
else if (misLayer > k_LayersAtTIDEnd && misLayer < k_LayersAtTECEnd &&
774 previousMisLayer > k_LayersAtTIDEnd && previousMisLayer < k_LayersAtTECEnd) {
775 std::vector<ForwardDetLayer const*> negTECLayers = measTracker.geometricSearchTracker()->negTecLayers();
776 std::vector<ForwardDetLayer const*> posTECLayers = measTracker.geometricSearchTracker()->posTecLayers();
778 const DetLayer* tecLayerneg = negTECLayers[misLayer - k_LayersAtTIDEnd - 1];
779 const DetLayer* prevTecLayerneg = negTECLayers[previousMisLayer - k_LayersAtTIDEnd - 1];
781 const DetLayer* tecLayerpos = posTECLayers[misLayer - k_LayersAtTIDEnd - 1];
782 const DetLayer* prevTecLayerpos = posTECLayers[previousMisLayer - k_LayersAtTIDEnd - 1];
784 if (tTopo->tecSide(iidd) == 1) {
785 tmpTmeas = layerMeasurements.measurements(*tecLayerneg, tsos, prop, chi2Estimator);
786 prev_tmpTmeas = layerMeasurements.measurements(*prevTecLayerneg, tsos, prop, chi2Estimator);
787 }
else if (tTopo->tecSide(iidd) == 2) {
788 tmpTmeas = layerMeasurements.measurements(*tecLayerpos, tsos, prop, chi2Estimator);
789 prev_tmpTmeas = layerMeasurements.measurements(*prevTecLayerpos, tsos, prop, chi2Estimator);
793 if (!tmpTmeas.empty() && !foundConsMissingHits) {
795 unsigned int iidd_tmp = TM_tmp.
recHit()->geographicalId().rawId();
797 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" hit actually being added to TM vector";
800 if (::isDoubleSided(iidd_tmp, tTopo)) {
805 missingHitAdded =
true;
810 if (!tmpTmeas.empty() && !prev_tmpTmeas.empty() &&
811 foundConsMissingHits) {
815 unsigned int modIdInner = TM_tmp1.
recHit()->geographicalId().rawId();
816 unsigned int modIdOuter = TM_tmp2.recHit()->geographicalId().rawId();
817 bool innerModInactive =
false, outerModInactive =
false;
818 for (
const auto& tm : tmpTmeas) {
819 unsigned int tmModId = tm.recHit()->geographicalId().rawId();
820 if (tmModId == modIdInner && tm.recHit()->getType() == 2) {
821 innerModInactive =
true;
825 for (
const auto& tm : prev_tmpTmeas) {
826 unsigned int tmModId = tm.recHit()->geographicalId().rawId();
827 if (tmModId == modIdOuter && tm.recHit()->getType() == 2) {
828 outerModInactive =
true;
833 if (outerModInactive) {
834 if (modIdInner != 0) {
835 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" hit actually being added to TM vector";
838 if (::isDoubleSided(modIdInner, tTopo)) {
843 missingHitAdded =
true;
847 if (innerModInactive) {
848 if (modIdOuter != 0) {
849 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" hit actually being added to TM vector";
852 if (::isDoubleSided(modIdOuter, tTopo)) {
857 missingHitAdded =
true;
864 prev_TKlayers = TKlayers;
869 bool hitsWithBias =
false;
870 for (
auto ilayer : missedLayers) {
871 if (ilayer < TKlayers)
884 const auto nextId = (itm + 1 != TMeas.end()) ? (itm + 1)->recHit()->geographicalId() :
DetId{};
886 if (TKlayers == 9 && theInHit->isValid() && !((!nextId.null()) && (::checkLayer(nextId.rawId(), tTopo) == 9))) {
889 const DetLayer* tob6 = measTracker.geometricSearchTracker()->tobLayers().back();
892 const auto tmp = theLayerMeasurements.measurements(*tob6, tsosTOB5, prop, chi2Estimator);
895 LogDebug(
"SiStripHitEfficiencyWorker") <<
"size of TM from propagation = " <<
tmp.size();
900 const auto& tob6TM =
tmp.back();
901 const auto& tob6Hit = tob6TM.recHit();
902 if (tob6Hit->geographicalId().rawId() != 0) {
903 LogDebug(
"SiStripHitEfficiencyWorker") <<
"tob6 hit actually being added to TM vector";
904 TMs.emplace_back(tob6TM, tTopo, tkgeom,
propagator);
910 if (TKlayers == 21 && theInHit->isValid() &&
911 !((!nextId.null()) && (::checkLayer(nextId.rawId(), tTopo) == 21))) {
912 const DetLayer* tec9pos = measTracker.geometricSearchTracker()->posTecLayers().back();
913 const DetLayer* tec9neg = measTracker.geometricSearchTracker()->negTecLayers().back();
920 LogDebug(
"SiStripHitEfficiencyWorker") <<
"there is a problem with TEC 9 extrapolation";
923 std::vector<TrajectoryMeasurement>
tmp;
924 if (tTopo->tecSide(iidd) == 1) {
925 tmp = theLayerMeasurements.measurements(*tec9neg, tsosTEC9, prop, chi2Estimator);
928 if (tTopo->tecSide(iidd) == 2) {
929 tmp = theLayerMeasurements.measurements(*tec9pos, tsosTEC9, prop, chi2Estimator);
937 const auto& tec9TM =
tmp.back();
938 const auto& tec9Hit = tec9TM.recHit();
940 const unsigned int tec9id = tec9Hit->geographicalId().rawId();
941 LogDebug(
"SiStripHitEfficiencyWorker")
942 <<
"tec9id = " << tec9id <<
" is Double sided = " << ::isDoubleSided(tec9id, tTopo)
943 <<
" and 0x3 = " << (tec9id & 0x3);
945 if (tec9Hit->geographicalId().rawId() != 0) {
946 LogDebug(
"SiStripHitEfficiencyWorker") <<
"tec9 hit actually being added to TM vector";
949 if (::isDoubleSided(tec9id, tTopo)) {
950 TMs.emplace_back(tec9TM, tTopo, tkgeom,
propagator, 1);
951 TMs.emplace_back(tec9TM, tTopo, tkgeom,
propagator, 2);
953 TMs.emplace_back(tec9TM, tTopo, tkgeom,
propagator);
958 for (
const auto& tm : TMs) {
972 LogDebug(
"SiStripHitEfficiencyWorker") <<
"After looping over TrajAtValidHit list";
974 LogDebug(
"SiStripHitEfficiencyWorker") <<
"end TMeasurement loop";
976 LogDebug(
"SiStripHitEfficiencyWorker") <<
"end of trajectories loop";
994 LogDebug(
"SiStripHitEfficiencyWorker") <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
996 const auto xloc = tm.
localX();
997 const auto yloc = tm.
localY();
1005 const auto TKlayers = ::checkLayer(iidd, tTopo);
1007 const bool withinAcceptance =
1008 tm.
withinAcceptance() && (!::isInBondingExclusionZone(iidd, TKlayers, yloc, yErr, tTopo));
1012 (
layers_ == bounds::k_LayersStart))) {
1013 LogDebug(
"SiStripHitEfficiencyWorker") <<
"Looking at layer under study";
1014 unsigned int ModIsBad = 2;
1015 unsigned int SiStripQualBad = 0;
1016 float commonMode = -100;
1020 if (!theClusters.
empty()) {
1021 LogDebug(
"SiStripHitEfficiencyWorker") <<
"Checking clusters with size = " << theClusters.
size();
1022 std::vector<::ClusterInfo> VCluster_info;
1023 const auto idsv = theClusters.
find(iidd);
1024 if (idsv != theClusters.
end()) {
1026 LogDebug(
"SiStripHitEfficiencyWorker")
1027 <<
"found (ClusterId == iidd) with ClusterId = " << idsv->id() <<
" and iidd = " << iidd;
1036 if (TKlayers > bounds::k_LayersAtTOBEnd) {
1037 const BoundPlane& plane = stripdet->surface();
1039 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
1040 std::array<const float, 4>
const& parameterTrap = (*trapezoidalBounds).
parameters();
1041 hbedge = parameterTrap[0];
1042 htedge = parameterTrap[1];
1043 hapoth = parameterTrap[3];
1044 uylfac = (htedge - hbedge) / (htedge + hbedge) / hapoth;
1045 uxlden = 1 + yloc * uylfac;
1049 if (TrajStrip == -1) {
1051 float pitch = stripdet->surface().bounds().width() / nstrips;
1052 TrajStrip = xloc / pitch + nstrips / 2.0;
1054 if (TKlayers > bounds::k_LayersAtTOBEnd) {
1055 const float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
1057 TrajStrip = TrajLocXMid / pitch + nstrips / 2.0;
1062 for (
const auto& clus : *idsv) {
1065 float sigma = ::checkConsistency(
parameters, xloc, xErr);
1072 if (TKlayers > bounds::k_LayersAtTOBEnd) {
1075 yErr * yErr * xloc * xloc * uylfac * uylfac / uxlden / uxlden / uxlden / uxlden);
1078 VCluster_info.emplace_back(
res, sigma,
parameters.first.x());
1080 LogDebug(
"SiStripHitEfficiencyWorker") <<
"Have ID match. residual = " <<
res <<
" res sigma = " << sigma;
1083 LogDebug(
"SiStripHitEfficiencyWorker")
1085 <<
" trajectory position = " << xloc <<
" traj error = " << xErr;
1088 ::ClusterInfo finalCluster{1000.0, 1000.0, 0.0};
1089 if (!VCluster_info.empty()) {
1090 LogDebug(
"SiStripHitEfficiencyWorker") <<
"found clusters > 0";
1091 if (VCluster_info.size() > 1) {
1093 for (
const auto&
res : VCluster_info) {
1097 LogDebug(
"SiStripHitEfficiencyWorker")
1098 <<
"iresidual = " <<
res.xResidual <<
" isigma = " <<
res.xResidualPull
1099 <<
" and FinalRes = " << finalCluster.xResidual;
1102 finalCluster = VCluster_info[0];
1104 VCluster_info.clear();
1107 LogDebug(
"SiStripHitEfficiencyWorker") <<
"Final residual in X = " << finalCluster.xResidual <<
"+-" 1108 << (finalCluster.xResidual / finalCluster.xResidualPull);
1109 LogDebug(
"SiStripHitEfficiencyWorker")
1110 <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc) <<
" abs(xloc) = " <<
abs(xloc);
1118 LogDebug(
"SiStripHitEfficiencyWorker") <<
"strip is bad from SiStripQuality";
1121 LogDebug(
"SiStripHitEfficiencyWorker") <<
"strip is good from SiStripQuality";
1125 for (
unsigned int ii = 0;
ii < fedErrorIds.size();
ii++) {
1126 if (iidd == fedErrorIds[
ii].
rawId())
1132 if (commonModeDigis.isValid() && TrajStrip >= 0 && TrajStrip <= 768) {
1133 const auto digiframe = commonModeDigis->find(iidd);
1134 if (digiframe != commonModeDigis->end())
1139 LogDebug(
"SiStripHitEfficiencyWorker") <<
"before check good";
1141 if (finalCluster.xResidualPull < 999.0) {
1143 LogDebug(
"SiStripHitEfficiencyWorker")
1144 <<
"hit being counted as good " << finalCluster.xResidual <<
" FinalRecHit " << iidd <<
" TKlayers " 1145 << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd
1146 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" << ((iidd & 0x3) == 1) <<
"/" 1147 << ((iidd & 0x3) == 2);
1150 LogDebug(
"SiStripHitEfficiencyWorker")
1151 <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << finalCluster.xResidual
1152 <<
" FinalRecHit " << iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc
1153 <<
" module " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" << ((iidd & 0x3) == 1)
1154 <<
"/" << ((iidd & 0x3) == 2);
1156 LogDebug(
"SiStripHitEfficiencyWorker")
1157 <<
" RPhi Error " <<
sqrt(xErr * xErr + yErr * yErr) <<
" ErrorX " << xErr <<
" yErr " << yErr;
1160 LogDebug(
"SiStripHitEfficiencyWorker")
1161 <<
"To avoid them staying unused: ModIsBad=" << ModIsBad <<
", SiStripQualBad=" << SiStripQualBad
1162 <<
", commonMode=" << commonMode <<
", highPurity=" <<
highPurity 1163 <<
", withinAcceptance=" << withinAcceptance;
1165 unsigned int layer = TKlayers;
1167 if (
layer <= bounds::k_LayersAtTIDEnd) {
1168 layer = bounds::k_LayersAtTOBEnd +
1171 layer = bounds::k_LayersAtTIDEnd + tTopo->
tecRing(iidd);
1174 unsigned int layerWithSide =
layer;
1175 if (
layer > bounds::k_LayersAtTOBEnd &&
layer <= bounds::k_LayersAtTIDEnd) {
1178 layerWithSide =
layer + 3;
1179 }
else if (
layer > bounds::k_LayersAtTIDEnd) {
1182 layerWithSide =
layer + 3;
1183 }
else if (
side == 2) {
1188 if ((
bunchX_ > 0 &&
bunchX_ != bunchCrossing) || (!withinAcceptance) ||
1190 (!
showTOB6TEC9_ && (TKlayers == bounds::k_LayersAtTOBEnd || TKlayers == bounds::k_LayersAtTECEnd)) ||
1194 const bool badquality = (SiStripQualBad == 1);
1199 bool badflag =
false;
1204 if (ModIsBad == 1 || finalCluster.xResidualPull >
resXSig_)
1212 if (finalCluster.xResidualPull ==
1222 double stripTrajMid = xloc / Pitch + nstrips / 2.0;
1223 double stripCluster = finalCluster.xLocal / Pitch + nstrips / 2.0;
1226 if (stripdet &&
layer > bounds::k_LayersAtTOBEnd) {
1228 std::array<const float, 4>
const&
parameters = trapezoidalBounds.parameters();
1232 const float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
1234 stripTrajMid = TrajLocXMid / Pitch + nstrips / 2.0;
1238 LogDebug(
"SiStripHitEfficiencyWorker")
1239 <<
"layer " <<
layer <<
" vector index " <<
layer - 1 <<
" before filling h_resolution" << std::endl;
1246 if (finalCluster.xResidualPull == 1000.0) {
1247 LogDebug(
"SiStripHitEfficiencyWorker") <<
"Marking bad for resxsig=1000";
1253 LogDebug(
"SiStripHitEfficiencyWorker") <<
"Marking bad for cluster-to-traj distance";
1263 LogDebug(
"SiStripHitEfficiencyWorker") <<
"Too close to the edge: " << stripInAPV;
1267 LogDebug(
"SiStripHitEfficiencyWorker") <<
"Marking bad for tapv!=capv";
1274 LogDebug(
"SiStripHitEfficiencyWorker")
1275 <<
"Filling measurement for " << iidd <<
" in layer " <<
layer <<
" histograms with bx=" << bunchCrossing
1276 <<
", lumi=" <<
instLumi <<
", PU=" <<
PU <<
"; bad flag=" << badflag;
1280 if (
layer > bounds::k_LayersStart &&
layer <= bounds::k_LayersAtTIBEnd) {
1284 }
else if (
layer > bounds::k_LayersAtTIBEnd &&
layer <= bounds::k_LayersAtTOBEnd) {
1288 }
else if (
layer > bounds::k_LayersAtTOBEnd &&
layer <= bounds::k_LayersAtTIDEnd) {
1296 }
else if (
layer > bounds::k_LayersAtTIDEnd) {
1307 LogDebug(
"SiStripHitEfficiencyWorker")
1308 <<
"layer " <<
layer <<
" vector index " <<
layer - 1 <<
" before filling h_layer_vsSmthg" << std::endl;
1349 LogDebug(
"SiStripHitEfficiencyWorker") <<
"after good location check";
1351 LogDebug(
"SiStripHitEfficiencyWorker") <<
"after list of clusters";
1353 LogDebug(
"SiStripHitEfficiencyWorker") <<
"After layers=TKLayers if with TKlayers=" << TKlayers
1360 desc.add<
bool>(
"UseOnlyHighPurityTracks",
true);
1361 desc.add<
bool>(
"cutOnTracks",
false);
1362 desc.add<
bool>(
"doMissingHitsRecovery",
false);
1363 desc.add<
bool>(
"useAllHitsFromTracksWithMissingHits",
false);
1364 desc.add<
bool>(
"useFirstMeas",
false);
1365 desc.add<
bool>(
"useLastMeas",
false);
1366 desc.add<
double>(
"ClusterTrajDist", 64.0);
1367 desc.add<
double>(
"ResXSig", -1);
1368 desc.add<
double>(
"StripsApvEdge", 10.0);
1377 desc.add<
int>(
"ClusterMatchingMethod", 0);
1378 desc.add<
int>(
"Layer", 0);
1379 desc.add<
unsigned int>(
"trackMultiplicity", 100);
1380 desc.addUntracked<
bool>(
"Debug",
false);
1381 desc.addUntracked<
bool>(
"ShowRings",
false);
1382 desc.addUntracked<
bool>(
"ShowTOB6TEC9",
false);
1383 desc.addUntracked<
bool>(
"addCommonMode",
false);
1384 desc.addUntracked<
bool>(
"addLumi",
true);
1385 desc.addUntracked<
int>(
"BunchCrossing", 0);
std::pair< LocalPoint, LocalError > LocalValues
const edm::ESGetToken< MeasurementTracker, CkfComponentsRecord > measTrackerToken_
const edm::EDGetTokenT< DetIdVector > digisVec_token_
MonitorElement * h_nTracksVsPU
virtual int nstrips() const =0
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void fill(double x, bool found, float weight=1.)
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
std::vector< EffME1 > h_layer_vsPU
std::vector< MonitorElement * > h_resolution
MonitorElement * h_instLumi
bool useOnlyHighPurityTracks_
virtual void setCurrentFolder(std::string const &fullpath)
EffME1(MonitorElement *total, MonitorElement *found)
std::vector< EffME1 > h_layer_vsBx
void fillForTraj(const TrajectoryAtInvalidHit &tm, const TrackerTopology *tTopo, const TrackerGeometry *tkgeom, const StripClusterParameterEstimator &stripCPE, const SiStripQuality &stripQuality, const DetIdVector &fedErrorIds, const edm::Handle< edm::DetSetVector< SiStripRawDigi >> &commonModeDigis, const edmNew::DetSetVector< SiStripCluster > &theClusters, int bunchCrossing, float instLumi, float PU, bool highPurity)
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
std::vector< MonitorElement * > h_hotcold
virtual void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters <p) const
void bookHistograms(DQMStore::IBooker &booker, const edm::Run &run, const edm::EventSetup &setup) override
unsigned int tidSide(const DetId &id) const
Class to contain the online luminosity from soft FED 1022.
std::vector< Track > TrackCollection
collection of Tracks
unsigned int monodet_id() const
std::vector< EffME1 > h_layer_vsCM
ALPAKA_FN_ACC int side(int ieta, int iphi)
std::vector< int > missHitPerLayer
float instLumi() const
Return the luminosity for the current nibble.
std::unordered_map< uint32_t, int > fedErrorCounts
unsigned int tecRing(const DetId &id) const
ring id
std::unique_ptr< TkHistoMap > FEDErrorOccupancy
const edm::EDGetTokenT< MeasurementTrackerEvent > trackerEvent_token_
const_iterator end(bool update=false) const
~SiStripHitEfficiencyWorker() override=default
const edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
std::unique_ptr< TkHistoMap > hTotal
const edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecord > stripCPEToken_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
const edm::EDGetTokenT< OnlineLuminosityRecord > metaDataToken_
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > chi2EstimatorToken_
double localErrorX() const
unsigned int tecSide(const DetId &id) const
EffTkMap(std::unique_ptr< TkHistoMap > &&total, std::unique_ptr< TkHistoMap > &&found)
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
unsigned int clusterMatchingMethod_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
Abs< T >::type abs(const T &t)
unsigned int trackMultiplicityCut_
#define DEFINE_FWK_MODULE(type)
bool useAllHitsFromTracksWithMissingHits_
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::set< uint32_t > badModules_
dqm::reco::MonitorElement * EventStats
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
SiStripHitEfficiencyWorker(const edm::ParameterSet &conf)
void analyze(const edm::Event &e, const edm::EventSetup &c) override
std::vector< DetId > DetIdVector
std::vector< unsigned int > hitTotalCounters
SiStripHitEffData calibData_
const Plane & surface() const
The nominal surface of the GeomDet.
const edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAsso_token_
Constants and enumerated types for FED/FEC systems.
double localErrorY() const
virtual const std::array< const float, 4 > parameters() const
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
const edm::EDGetTokenT< DetIdCollection > digisCol_token_
std::unique_ptr< TkHistoMap > hFound
MonitorElement * h_nTracks
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
const_iterator find(id_type i, bool update=false) const
static const uint16_t STRIPS_PER_APV
const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > stripQualityToken_
const edm::EDGetTokenT< LumiScalersCollection > scalerToken_
std::vector< unsigned int > hitRecoveryCounters
unsigned int tidRing(const DetId &id) const
std::vector< LumiScalers > LumiScalersCollection
void fill(uint32_t id, bool found, float weight=1.)
const edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > commonModeToken_
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
virtual float width() const =0
std::vector< EffME1 > h_layer_vsLumi
MonitorElement * book2I(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
float avgPileUp() const
Return the average pileup for th current nibble.
ConstRecHitPointer const & recHit() const
bool doMissingHitsRecovery_
bool withinAcceptance() const
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
short getBadApvs(uint32_t detid) const
const Bounds & bounds() const