73 siStripClusterInfo_(consumesCollector()),
74 combinatorialTracks_token_(
114 traj = fs->
make<TTree>(
"traj",
"tree of trajectory positions");
115 #ifdef ExtendedCALIBTree
116 traj->Branch(
"timeDT", &timeDT,
"timeDT/F");
117 traj->Branch(
"timeDTErr", &timeDTErr,
"timeDTErr/F");
118 traj->Branch(
"timeDTDOF", &timeDTDOF,
"timeDTDOF/I");
119 traj->Branch(
"timeECAL", &timeECAL,
"timeECAL/F");
120 traj->Branch(
"dedx", &dedx,
"dedx/F");
121 traj->Branch(
"dedxNOM", &dedxNOM,
"dedxNOM/I");
122 traj->Branch(
"nLostHits", &nLostHits,
"nLostHits/I");
123 traj->Branch(
"chi2", &
chi2,
"chi2/F");
124 traj->Branch(
"p", &
p,
"p/F");
140 traj->Branch(
"ResX", &
ResX,
"ResX/F");
145 traj->Branch(
"nHits", &
nHits,
"nHits/I");
146 traj->Branch(
"pT", &
pT,
"pT/F");
149 traj->Branch(
"Id", &
Id,
"Id/i");
150 traj->Branch(
"run", &
run,
"run/i");
151 traj->Branch(
"event", &
event,
"event/i");
157 traj->Branch(
"PU", &
PU,
"PU/F");
173 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"beginning analyze from HitEff" << endl;
176 using namespace reco;
179 int run_nr =
e.id().run();
180 int ev_nr =
e.id().event();
181 int bunch_nr =
e.bunchCrossing();
279 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"number ckf tracks found = " << tracksCKF->size() << endl;
281 if (!tracksCKF->empty()) {
285 LogDebug(
"SiStripHitEfficiency:HitEff")
290 #ifdef ExtendedCALIBTree
293 if (
e.getByLabel(
"dedxMedianCTF", dEdxUncalibHandle)) {
297 dedx = dEdxTrackUncalib[itTrack].dEdx();
298 dedxNOM = dEdxTrackUncalib[itTrack].numberOfMeasurements();
306 if (
e.getByLabel(
"muonsWitht0Correction", muH)) {
308 if (!muonsT0.empty()) {
312 timeDTDOF = mt0.
nDof;
314 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
315 if (hasCaloEnergyInfo)
316 timeECAL = muonsT0[0].calEnergy().ecal_time;
330 it != trajTrackAssociationHandle->
end();
336 nHits = itraj->foundHits();
337 #ifdef ExtendedCALIBTree
338 nLostHits = itraj->lostHits();
339 chi2 = (itraj->chiSquared() / itraj->ndof());
340 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
342 pT =
sqrt((itraj->lastMeasurement().updatedState().globalMomentum().x() *
343 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
344 (itraj->lastMeasurement().updatedState().globalMomentum().y() *
345 itraj->lastMeasurement().updatedState().globalMomentum().y()));
350 std::vector<TrajectoryMeasurement> TMeas = itraj->measurements();
351 vector<TrajectoryMeasurement>::iterator itm;
356 double angleX = -999.;
357 double angleY = -999.;
358 double xglob, yglob, zglob;
361 bool hasMissingHits =
false;
362 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
363 auto theHit = (*itm).recHit();
365 hasMissingHits =
true;
371 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
372 auto theInHit = (*itm).recHit();
374 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"theInHit is valid = " << theInHit->isValid() << endl;
376 unsigned int iidd = theInHit->geographicalId().rawId();
378 unsigned int TKlayers =
checkLayer(iidd, tTopo);
379 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd
380 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/"
381 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
385 bool isFirstMeas = (itm == (TMeas.end() - 1));
386 bool isLastMeas = (itm == (TMeas.begin()));
399 if (TKlayers == 10 || TKlayers == 22) {
400 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"skipping original TM for TOB 6 or TEC 9" << endl;
405 std::vector<TrajectoryAtInvalidHit> TMs;
423 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" found a hit with a missing partner" << endl;
435 bool isValid = theInHit->isValid();
436 bool isLast = (itm == (TMeas.end() - 1));
437 bool isLastTOB5 =
true;
439 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9)
446 if (TKlayers == 9 &&
isValid && isLastTOB5) {
449 std::vector<BarrelDetLayer const*> barrelTOBLayers =
450 measurementTrackerHandle->geometricSearchTracker()->tobLayers();
451 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size() - 1];
454 auto tmp = layerMeasurements.measurements(*tob6, tsosTOB5, *thePropagator, *
estimator);
457 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"size of TM from propagation = " <<
tmp.size() << endl;
463 const auto& tob6Hit = tob6TM.
recHit();
465 if (tob6Hit->geographicalId().rawId() != 0) {
466 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tob6 hit actually being added to TM vector" << endl;
472 bool isLastTEC8 =
true;
481 if (TKlayers == 21 &&
isValid && isLastTEC8) {
482 std::vector<const ForwardDetLayer*> posTecLayers =
483 measurementTrackerHandle->geometricSearchTracker()->posTecLayers();
484 const DetLayer* tec9pos = posTecLayers[posTecLayers.size() - 1];
485 std::vector<const ForwardDetLayer*> negTecLayers =
486 measurementTrackerHandle->geometricSearchTracker()->negTecLayers();
487 const DetLayer* tec9neg = negTecLayers[negTecLayers.size() - 1];
493 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"there is a problem with TEC 9 extrapolation" << endl;
496 vector<TrajectoryMeasurement>
tmp;
497 if (tTopo->
tecSide(iidd) == 1) {
498 tmp = layerMeasurements.measurements(*tec9neg, tsosTEC9, *thePropagator, *
estimator);
501 if (tTopo->
tecSide(iidd) == 2) {
502 tmp = layerMeasurements.measurements(*tec9pos, tsosTEC9, *thePropagator, *
estimator);
511 const auto& tec9Hit = tec9TM.
recHit();
513 unsigned int tec9id = tec9Hit->geographicalId().rawId();
514 LogDebug(
"SiStripHitEfficiency:HitEff")
515 <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo)
516 <<
" and 0x3 = " << (tec9id & 0x3) << endl;
518 if (tec9Hit->geographicalId().rawId() != 0) {
519 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tec9 hit actually being added to TM vector" << endl;
535 for (std::vector<TrajectoryAtInvalidHit>::const_iterator TM = TMs.begin(); TM != TMs.end(); ++TM) {
537 iidd = TM->monodet_id();
538 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
543 angleX = atan(TM->localDxDz());
544 angleY = atan(TM->localDyDz());
549 xglob = TM->globalX();
550 yglob = TM->globalY();
551 zglob = TM->globalZ();
552 xErr = TM->localErrorX();
553 yErr = TM->localErrorY();
568 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Looking at layer under study" << endl;
590 if (!
input.empty()) {
591 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking clusters with size = " <<
input.size() << endl;
593 std::vector<std::vector<float> >
599 unsigned int ClusterId = DSViter->id();
600 if (ClusterId == iidd) {
601 LogDebug(
"SiStripHitEfficiency:HitEff")
602 <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
603 DetId ClusterDetId(ClusterId);
612 if (TKlayers >= 11) {
615 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
616 std::array<const float, 4>
const& parameterTrap =
618 hbedge = parameterTrap[0];
619 htedge = parameterTrap[1];
620 hapoth = parameterTrap[3];
621 uylfac = (htedge - hbedge) / (htedge + hbedge) / hapoth;
622 uxlden = 1 + yloc * uylfac;
626 if (TrajStrip == -1) {
629 TrajStrip = xloc / pitch + nstrips / 2.0;
631 if (TKlayers >= 11) {
632 float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
634 TrajStrip = TrajLocXMid / pitch + nstrips / 2.0;
651 if (TKlayers >= 11) {
655 yErr * yErr * xloc * xloc * uylfac * uylfac / uxlden / uxlden / uxlden / uxlden);
662 std::vector<float> cluster_info;
663 cluster_info.push_back(
res);
664 cluster_info.push_back(sigma);
670 VCluster_info.push_back(cluster_info);
672 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Have ID match. residual = " << VCluster_info.back()[0]
673 <<
" res sigma = " << VCluster_info.back()[1] << endl;
674 LogDebug(
"SiStripHitEfficiency:HitEff")
675 <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
676 LogDebug(
"SiStripHitEfficiency:HitEff")
678 <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
682 float FinalResSig = 1000.0;
683 float FinalCluster[7] = {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
685 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"found clusters > 0" << endl;
688 vector<vector<float> >::iterator
ires;
689 for (
ires = VCluster_info.begin();
ires != VCluster_info.end();
ires++) {
691 FinalResSig = (*ires)[1];
692 for (
unsigned int i = 0;
i <
ires->size();
i++) {
693 LogDebug(
"SiStripHitEfficiency:HitEff")
694 <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i]
695 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
696 FinalCluster[
i] = (*ires)[
i];
697 LogDebug(
"SiStripHitEfficiency:HitEff")
698 <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i]
699 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
702 LogDebug(
"SiStripHitEfficiency:HitEff")
703 <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1]
704 <<
" and FinalRes = " << FinalCluster[0] << endl;
707 FinalResSig = VCluster_info.at(0)[1];
708 for (
unsigned int i = 0;
i < VCluster_info.at(0).size();
i++) {
709 FinalCluster[
i] = VCluster_info.at(0)[
i];
713 VCluster_info.clear();
716 LogDebug(
"SiStripHitEfficiency:HitEff")
717 <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0] / FinalResSig) << endl;
718 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc)
719 <<
" abs(xloc) = " <<
abs(xloc) << endl;
720 LogDebug(
"SiStripHitEfficiency:HitEff")
721 <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5]
722 <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
723 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
725 float exclusionWidth = 0.4;
726 float TOBexclusion = 0.0;
727 float TECexRing5 = -0.89;
728 float TECexRing6 = -0.56;
729 float TECexRing7 = 0.60;
732 int ringnumber = ((iidd >> 5) & 0x7);
735 if ((TKlayers >= 5 && TKlayers < 11) ||
736 ((
subdetector == 6) && ((ringnumber >= 5) && (ringnumber <= 7)))) {
738 float highzone = 0.0;
740 float higherr = yloc + 5.0 * yErr;
741 float lowerr = yloc - 5.0 * yErr;
742 if (TKlayers >= 5 && TKlayers < 11) {
744 highzone = TOBexclusion + exclusionWidth;
745 lowzone = TOBexclusion - exclusionWidth;
746 }
else if (ringnumber == 5) {
748 highzone = TECexRing5 + exclusionWidth;
749 lowzone = TECexRing5 - exclusionWidth;
750 }
else if (ringnumber == 6) {
752 highzone = TECexRing6 + exclusionWidth;
753 lowzone = TECexRing6 - exclusionWidth;
754 }
else if (ringnumber == 7) {
756 highzone = TECexRing7 + exclusionWidth;
757 lowzone = TECexRing7 - exclusionWidth;
760 if ((highzone <= higherr) && (highzone >= lowerr))
762 if ((lowzone >= lowerr) && (lowzone <= higherr))
764 if ((higherr <= highzone) && (higherr >= lowzone))
766 if ((lowerr >= lowzone) && (lowerr <= highzone))
786 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is bad from SiStripQuality" << endl;
789 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is good from SiStripQuality" << endl;
793 for (
unsigned int ii = 0;
ii < fedErrorIds->
size();
ii++) {
794 if (iidd == (*fedErrorIds)[
ii].rawId())
802 ResX = FinalCluster[0];
804 if (FinalResSig != FinalCluster[1])
805 LogDebug(
"SiStripHitEfficiency:HitEff")
806 <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig
807 <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
816 if (commonModeDigis.
isValid() && TrajStrip >= 0 && TrajStrip <= 768) {
818 if (digiframe != commonModeDigis->end())
819 if ((
unsigned)TrajStrip / 128 < digiframe->data.
size())
820 commonMode = digiframe->data.at(TrajStrip / 128).adc();
823 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"before check good" << endl;
825 if (FinalResSig < 999.0) {
827 LogDebug(
"SiStripHitEfficiency:HitEff")
828 <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " << iidd <<
" TKlayers "
829 << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd
830 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" << ((iidd & 0x3) == 1) <<
"/"
831 << ((iidd & 0x3) == 2) << endl;
835 LogDebug(
"SiStripHitEfficiency:HitEff")
836 <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0]
837 <<
" FinalRecHit " << iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc
838 <<
" module " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/"
839 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
843 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" RPhi Error " <<
sqrt(xErr * xErr + yErr * yErr)
844 <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
846 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after good location check" << endl;
848 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after list of clusters" << endl;
850 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After layers=TKLayers if" << endl;
852 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After looping over TrajAtValidHit list" << endl;
854 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end TMeasurement loop" << endl;
856 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end of trajectories loop" << endl;
861 traj->GetDirectory()->cd();
864 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" Events Analysed " <<
events << endl;
871 double consistency = separation /
error;
877 unsigned int subid =
strip.subdetId();
878 unsigned int layer = 0;
908 unsigned int partner_iidd = 0;
909 bool found2DPartner =
false;
911 if ((iidd & 0x3) == 1)
912 partner_iidd = iidd + 1;
913 if ((iidd & 0x3) == 2)
914 partner_iidd = iidd - 1;
917 for (std::vector<TrajectoryMeasurement>::const_iterator iTM =
traj.begin(); iTM !=
traj.end(); ++iTM) {
918 if (iTM->recHit()->geographicalId().rawId() == partner_iidd) {
919 found2DPartner =
true;
922 return found2DPartner;
927 unsigned int subid =
strip.subdetId();