170 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"beginning analyze from HitEff" << endl;
173 using namespace reco;
176 int run_nr =
e.id().run();
177 int ev_nr =
e.id().event();
178 int bunch_nr =
e.bunchCrossing();
292 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"number ckf tracks found = " << tracksCKF->size() << endl;
294 if (!tracksCKF->empty()) {
298 LogDebug(
"SiStripHitEfficiency:HitEff")
303 #ifdef ExtendedCALIBTree
306 if (
e.getByLabel(
"dedxMedianCTF", dEdxUncalibHandle)) {
310 dedx = dEdxTrackUncalib[itTrack].dEdx();
311 dedxNOM = dEdxTrackUncalib[itTrack].numberOfMeasurements();
319 if (
e.getByLabel(
"muonsWitht0Correction", muH)) {
321 if (!muonsT0.empty()) {
325 timeDTDOF = mt0.
nDof;
327 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
328 if (hasCaloEnergyInfo)
329 timeECAL = muonsT0[0].calEnergy().ecal_time;
343 it != trajTrackAssociationHandle->
end();
349 nHits = itraj->foundHits();
350 #ifdef ExtendedCALIBTree
351 nLostHits = itraj->lostHits();
352 chi2 = (itraj->chiSquared() / itraj->ndof());
353 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
355 pT =
sqrt((itraj->lastMeasurement().updatedState().globalMomentum().x() *
356 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
357 (itraj->lastMeasurement().updatedState().globalMomentum().y() *
358 itraj->lastMeasurement().updatedState().globalMomentum().y()));
363 std::vector<TrajectoryMeasurement> TMeas = itraj->measurements();
364 vector<TrajectoryMeasurement>::iterator itm;
369 double angleX = -999.;
370 double angleY = -999.;
371 double xglob, yglob, zglob;
374 bool hasMissingHits =
false;
375 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
376 auto theHit = (*itm).recHit();
378 hasMissingHits =
true;
384 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
385 auto theInHit = (*itm).recHit();
387 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"theInHit is valid = " << theInHit->isValid() << endl;
389 unsigned int iidd = theInHit->geographicalId().rawId();
391 unsigned int TKlayers =
checkLayer(iidd, tTopo);
392 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd
393 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/"
394 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
398 bool isFirstMeas = (itm == (TMeas.end() - 1));
399 bool isLastMeas = (itm == (TMeas.begin()));
412 if (TKlayers == 10 || TKlayers == 22) {
413 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"skipping original TM for TOB 6 or TEC 9" << endl;
418 std::vector<TrajectoryAtInvalidHit> TMs;
436 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" found a hit with a missing partner" << endl;
448 bool isValid = theInHit->isValid();
449 bool isLast = (itm == (TMeas.end() - 1));
450 bool isLastTOB5 =
true;
452 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9)
459 if (TKlayers == 9 && isValid && isLastTOB5) {
462 std::vector<BarrelDetLayer const*> barrelTOBLayers =
463 measurementTrackerHandle->geometricSearchTracker()->tobLayers();
464 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size() - 1];
469 vector<TrajectoryMeasurement>
tmp =
473 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"size of TM from propagation = " <<
tmp.size() << endl;
479 const auto& tob6Hit = tob6TM.
recHit();
481 if (tob6Hit->geographicalId().rawId() != 0) {
482 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tob6 hit actually being added to TM vector" << endl;
488 bool isLastTEC8 =
true;
497 if (TKlayers == 21 && isValid && isLastTEC8) {
498 std::vector<const ForwardDetLayer*> posTecLayers =
499 measurementTrackerHandle->geometricSearchTracker()->posTecLayers();
500 const DetLayer* tec9pos = posTecLayers[posTecLayers.size() - 1];
501 std::vector<const ForwardDetLayer*> negTecLayers =
502 measurementTrackerHandle->geometricSearchTracker()->negTecLayers();
503 const DetLayer* tec9neg = negTecLayers[negTecLayers.size() - 1];
512 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"there is a problem with TEC 9 extrapolation" << endl;
515 vector<TrajectoryMeasurement>
tmp;
516 if (tTopo->
tecSide(iidd) == 1) {
520 if (tTopo->
tecSide(iidd) == 2) {
530 const auto& tec9Hit = tec9TM.
recHit();
532 unsigned int tec9id = tec9Hit->geographicalId().rawId();
533 LogDebug(
"SiStripHitEfficiency:HitEff")
534 <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo)
535 <<
" and 0x3 = " << (tec9id & 0x3) << endl;
537 if (tec9Hit->geographicalId().rawId() != 0) {
538 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tec9 hit actually being added to TM vector" << endl;
554 for (std::vector<TrajectoryAtInvalidHit>::const_iterator TM = TMs.begin(); TM != TMs.end(); ++TM) {
556 iidd = TM->monodet_id();
557 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
562 angleX = atan(TM->localDxDz());
563 angleY = atan(TM->localDyDz());
568 xglob = TM->globalX();
569 yglob = TM->globalY();
570 zglob = TM->globalZ();
571 xErr = TM->localErrorX();
572 yErr = TM->localErrorY();
587 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Looking at layer under study" << endl;
609 if (!
input.empty()) {
610 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking clusters with size = " <<
input.size() << endl;
612 std::vector<std::vector<float> >
618 unsigned int ClusterId = DSViter->id();
619 if (ClusterId == iidd) {
620 LogDebug(
"SiStripHitEfficiency:HitEff")
621 <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
622 DetId ClusterDetId(ClusterId);
631 if (TKlayers >= 11) {
634 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
635 std::array<const float, 4>
const& parameterTrap =
637 hbedge = parameterTrap[0];
638 htedge = parameterTrap[1];
639 hapoth = parameterTrap[3];
640 uylfac = (htedge - hbedge) / (htedge + hbedge) / hapoth;
641 uxlden = 1 + yloc * uylfac;
645 if (TrajStrip == -1) {
648 TrajStrip = xloc / pitch + nstrips / 2.0;
650 if (TKlayers >= 11) {
651 float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
653 TrajStrip = TrajLocXMid / pitch + nstrips / 2.0;
670 if (TKlayers >= 11) {
674 yErr * yErr * xloc * xloc * uylfac * uylfac / uxlden / uxlden / uxlden / uxlden);
681 std::vector<float> cluster_info;
682 cluster_info.push_back(
res);
683 cluster_info.push_back(sigma);
689 VCluster_info.push_back(cluster_info);
691 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Have ID match. residual = " << VCluster_info.back()[0]
692 <<
" res sigma = " << VCluster_info.back()[1] << endl;
693 LogDebug(
"SiStripHitEfficiency:HitEff")
694 <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
695 LogDebug(
"SiStripHitEfficiency:HitEff")
697 <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
701 float FinalResSig = 1000.0;
702 float FinalCluster[7] = {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
704 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"found clusters > 0" << endl;
707 vector<vector<float> >::iterator
ires;
708 for (
ires = VCluster_info.begin();
ires != VCluster_info.end();
ires++) {
710 FinalResSig = (*ires)[1];
711 for (
unsigned int i = 0;
i <
ires->size();
i++) {
712 LogDebug(
"SiStripHitEfficiency:HitEff")
713 <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i]
714 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
715 FinalCluster[
i] = (*ires)[
i];
716 LogDebug(
"SiStripHitEfficiency:HitEff")
717 <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i]
718 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
721 LogDebug(
"SiStripHitEfficiency:HitEff")
722 <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1]
723 <<
" and FinalRes = " << FinalCluster[0] << endl;
726 FinalResSig = VCluster_info.at(0)[1];
727 for (
unsigned int i = 0;
i < VCluster_info.at(0).size();
i++) {
728 FinalCluster[
i] = VCluster_info.at(0)[
i];
732 VCluster_info.clear();
735 LogDebug(
"SiStripHitEfficiency:HitEff")
736 <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0] / FinalResSig) << endl;
737 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc)
738 <<
" abs(xloc) = " <<
abs(xloc) << endl;
739 LogDebug(
"SiStripHitEfficiency:HitEff")
740 <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5]
741 <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
742 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
744 float exclusionWidth = 0.4;
745 float TOBexclusion = 0.0;
746 float TECexRing5 = -0.89;
747 float TECexRing6 = -0.56;
748 float TECexRing7 = 0.60;
751 int ringnumber = ((iidd >> 5) & 0x7);
754 if ((TKlayers >= 5 && TKlayers < 11) ||
755 ((
subdetector == 6) && ((ringnumber >= 5) && (ringnumber <= 7)))) {
757 float highzone = 0.0;
759 float higherr = yloc + 5.0 * yErr;
760 float lowerr = yloc - 5.0 * yErr;
761 if (TKlayers >= 5 && TKlayers < 11) {
763 highzone = TOBexclusion + exclusionWidth;
764 lowzone = TOBexclusion - exclusionWidth;
765 }
else if (ringnumber == 5) {
767 highzone = TECexRing5 + exclusionWidth;
768 lowzone = TECexRing5 - exclusionWidth;
769 }
else if (ringnumber == 6) {
771 highzone = TECexRing6 + exclusionWidth;
772 lowzone = TECexRing6 - exclusionWidth;
773 }
else if (ringnumber == 7) {
775 highzone = TECexRing7 + exclusionWidth;
776 lowzone = TECexRing7 - exclusionWidth;
779 if ((highzone <= higherr) && (highzone >= lowerr))
781 if ((lowzone >= lowerr) && (lowzone <= higherr))
783 if ((higherr <= highzone) && (higherr >= lowzone))
785 if ((lowerr >= lowzone) && (lowerr <= highzone))
805 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is bad from SiStripQuality" << endl;
808 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is good from SiStripQuality" << endl;
812 for (
unsigned int ii = 0;
ii < fedErrorIds->
size();
ii++) {
813 if (iidd == (*fedErrorIds)[
ii].rawId())
821 ResX = FinalCluster[0];
823 if (FinalResSig != FinalCluster[1])
824 LogDebug(
"SiStripHitEfficiency:HitEff")
825 <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig
826 <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
835 if (commonModeDigis.
isValid() && TrajStrip >= 0 && TrajStrip <= 768) {
837 if (digiframe != commonModeDigis->end())
838 if ((
unsigned)TrajStrip / 128 < digiframe->data.
size())
839 commonMode = digiframe->data.at(TrajStrip / 128).adc();
842 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"before check good" << endl;
844 if (FinalResSig < 999.0) {
846 LogDebug(
"SiStripHitEfficiency:HitEff")
847 <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " << iidd <<
" TKlayers "
848 << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd
849 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" << ((iidd & 0x3) == 1) <<
"/"
850 << ((iidd & 0x3) == 2) << endl;
854 LogDebug(
"SiStripHitEfficiency:HitEff")
855 <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0]
856 <<
" FinalRecHit " << iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc
857 <<
" module " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/"
858 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
862 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" RPhi Error " <<
sqrt(xErr * xErr + yErr * yErr)
863 <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
865 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after good location check" << endl;
867 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after list of clusters" << endl;
869 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After layers=TKLayers if" << endl;
871 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After looping over TrajAtValidHit list" << endl;
873 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end TMeasurement loop" << endl;
875 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end of trajectories loop" << endl;