172 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"beginning analyze from HitEff" << endl;
175 using namespace reco;
178 int run_nr = e.
id().
run();
188 if (lumiScalers->begin() != lumiScalers->end()) {
189 instLumi = lumiScalers->begin()->instantLumi();
190 PU = lumiScalers->begin()->pileup();
278 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"number ckf tracks found = " << tracksCKF->size() << endl;
280 if (!tracksCKF->empty()) {
284 LogDebug(
"SiStripHitEfficiency:HitEff")
289 #ifdef ExtendedCALIBTree
292 if (e.
getByLabel(
"dedxMedianCTF", dEdxUncalibHandle)) {
296 dedx = dEdxTrackUncalib[itTrack].dEdx();
297 dedxNOM = dEdxTrackUncalib[itTrack].numberOfMeasurements();
305 if (e.
getByLabel(
"muonsWitht0Correction", muH)) {
307 if (!muonsT0.empty()) {
311 timeDTDOF = mt0.
nDof;
313 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
314 if (hasCaloEnergyInfo)
315 timeECAL = muonsT0[0].calEnergy().ecal_time;
329 it != trajTrackAssociationHandle->end();
335 nHits = itraj->foundHits();
336 #ifdef ExtendedCALIBTree
337 nLostHits = itraj->lostHits();
338 chi2 = (itraj->chiSquared() / itraj->ndof());
339 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
341 pT =
sqrt((itraj->lastMeasurement().updatedState().globalMomentum().x() *
342 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
343 (itraj->lastMeasurement().updatedState().globalMomentum().y() *
344 itraj->lastMeasurement().updatedState().globalMomentum().y()));
347 highPurity = itrack->quality(reco::TrackBase::TrackQuality::highPurity);
349 std::vector<TrajectoryMeasurement> TMeas = itraj->measurements();
350 vector<TrajectoryMeasurement>::iterator itm;
355 double angleX = -999.;
356 double angleY = -999.;
357 double xglob, yglob, zglob;
360 bool hasMissingHits =
false;
361 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
362 auto theHit = (*itm).recHit();
364 hasMissingHits =
true;
370 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
371 auto theInHit = (*itm).recHit();
373 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"theInHit is valid = " << theInHit->isValid() << endl;
375 unsigned int iidd = theInHit->geographicalId().rawId();
377 unsigned int TKlayers =
checkLayer(iidd, tTopo);
378 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd
379 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/"
380 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
384 bool isFirstMeas = (itm == (TMeas.end() - 1));
385 bool isLastMeas = (itm == (TMeas.begin()));
398 if (TKlayers == 10 || TKlayers == 22) {
399 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"skipping original TM for TOB 6 or TEC 9" << endl;
404 std::vector<TrajectoryAtInvalidHit> TMs;
422 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" found a hit with a missing partner" << endl;
434 bool isValid = theInHit->isValid();
435 bool isLast = (itm == (TMeas.end() - 1));
436 bool isLastTOB5 =
true;
438 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9)
445 if (TKlayers == 9 && isValid && isLastTOB5) {
448 std::vector<BarrelDetLayer const*> barrelTOBLayers =
449 measurementTrackerHandle->geometricSearchTracker()->tobLayers();
450 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size() - 1];
451 const LayerMeasurements layerMeasurements{*measurementTrackerHandle, *measurementTrackerEvent};
453 auto tmp = layerMeasurements.measurements(*tob6, tsosTOB5, *thePropagator, *
estimator);
456 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"size of TM from propagation = " <<
tmp.size() << endl;
462 const auto& tob6Hit = tob6TM.
recHit();
464 if (tob6Hit->geographicalId().rawId() != 0) {
465 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tob6 hit actually being added to TM vector" << endl;
471 bool isLastTEC8 =
true;
473 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 21)
480 if (TKlayers == 21 && isValid && isLastTEC8) {
481 std::vector<const ForwardDetLayer*> posTecLayers =
482 measurementTrackerHandle->geometricSearchTracker()->posTecLayers();
483 const DetLayer* tec9pos = posTecLayers[posTecLayers.size() - 1];
484 std::vector<const ForwardDetLayer*> negTecLayers =
485 measurementTrackerHandle->geometricSearchTracker()->negTecLayers();
486 const DetLayer* tec9neg = negTecLayers[negTecLayers.size() - 1];
487 const LayerMeasurements layerMeasurements{*measurementTrackerHandle, *measurementTrackerEvent};
492 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"there is a problem with TEC 9 extrapolation" << endl;
495 vector<TrajectoryMeasurement>
tmp;
496 if (tTopo->
tecSide(iidd) == 1) {
497 tmp = layerMeasurements.measurements(*tec9neg, tsosTEC9, *thePropagator, *
estimator);
500 if (tTopo->
tecSide(iidd) == 2) {
501 tmp = layerMeasurements.measurements(*tec9pos, tsosTEC9, *thePropagator, *
estimator);
510 const auto& tec9Hit = tec9TM.
recHit();
512 unsigned int tec9id = tec9Hit->geographicalId().rawId();
513 LogDebug(
"SiStripHitEfficiency:HitEff")
514 <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo)
515 <<
" and 0x3 = " << (tec9id & 0x3) << endl;
517 if (tec9Hit->geographicalId().rawId() != 0) {
518 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tec9 hit actually being added to TM vector" << endl;
534 for (std::vector<TrajectoryAtInvalidHit>::const_iterator TM = TMs.begin(); TM != TMs.end(); ++TM) {
536 iidd = TM->monodet_id();
537 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
542 angleX = atan(TM->localDxDz());
543 angleY = atan(TM->localDyDz());
548 xglob = TM->globalX();
549 yglob = TM->globalY();
550 zglob = TM->globalZ();
551 xErr = TM->localErrorX();
552 yErr = TM->localErrorY();
567 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Looking at layer under study" << endl;
589 if (!
input.empty()) {
590 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking clusters with size = " <<
input.size() << endl;
592 std::vector<std::vector<float> >
598 unsigned int ClusterId = DSViter->id();
599 if (ClusterId == iidd) {
600 LogDebug(
"SiStripHitEfficiency:HitEff")
601 <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
602 DetId ClusterDetId(ClusterId);
611 if (TKlayers >= 11) {
614 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
615 std::array<const float, 4>
const& parameterTrap =
617 hbedge = parameterTrap[0];
618 htedge = parameterTrap[1];
619 hapoth = parameterTrap[3];
620 uylfac = (htedge - hbedge) / (htedge + hbedge) / hapoth;
621 uxlden = 1 + yloc * uylfac;
625 if (TrajStrip == -1) {
628 TrajStrip = xloc / pitch + nstrips / 2.0;
630 if (TKlayers >= 11) {
631 float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
633 TrajStrip = TrajLocXMid / pitch + nstrips / 2.0;
642 float res = (parameters.first.x() - xloc);
650 if (TKlayers >= 11) {
651 res = parameters.first.x() - xloc / uxlden;
653 sqrt(parameters.second.xx() + xErr * xErr / uxlden / uxlden +
654 yErr * yErr * xloc * xloc * uylfac * uylfac / uxlden / uxlden / uxlden / uxlden);
661 std::vector<float> cluster_info;
662 cluster_info.push_back(res);
663 cluster_info.push_back(sigma);
664 cluster_info.push_back(parameters.first.x());
665 cluster_info.push_back(
sqrt(parameters.second.xx()));
666 cluster_info.push_back(parameters.first.y());
667 cluster_info.push_back(
sqrt(parameters.second.yy()));
669 VCluster_info.push_back(cluster_info);
671 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Have ID match. residual = " << VCluster_info.back()[0]
672 <<
" res sigma = " << VCluster_info.back()[1] << endl;
673 LogDebug(
"SiStripHitEfficiency:HitEff")
674 <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
675 LogDebug(
"SiStripHitEfficiency:HitEff")
676 <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx())
677 <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
681 float FinalResSig = 1000.0;
682 float FinalCluster[7] = {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
684 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"found clusters > 0" << endl;
687 vector<vector<float> >::iterator
ires;
688 for (ires = VCluster_info.begin(); ires != VCluster_info.end(); ires++) {
689 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
690 FinalResSig = (*ires)[1];
691 for (
unsigned int i = 0;
i < ires->size();
i++) {
692 LogDebug(
"SiStripHitEfficiency:HitEff")
693 <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i]
694 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
695 FinalCluster[
i] = (*ires)[
i];
696 LogDebug(
"SiStripHitEfficiency:HitEff")
697 <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i]
698 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
701 LogDebug(
"SiStripHitEfficiency:HitEff")
702 <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1]
703 <<
" and FinalRes = " << FinalCluster[0] << endl;
706 FinalResSig = VCluster_info.at(0)[1];
707 for (
unsigned int i = 0;
i < VCluster_info.at(0).size();
i++) {
708 FinalCluster[
i] = VCluster_info.at(0)[
i];
712 VCluster_info.clear();
715 LogDebug(
"SiStripHitEfficiency:HitEff")
716 <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0] / FinalResSig) << endl;
717 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc)
718 <<
" abs(xloc) = " <<
abs(xloc) << endl;
719 LogDebug(
"SiStripHitEfficiency:HitEff")
720 <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5]
721 <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
722 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
724 float exclusionWidth = 0.4;
725 float TOBexclusion = 0.0;
726 float TECexRing5 = -0.89;
727 float TECexRing6 = -0.56;
728 float TECexRing7 = 0.60;
731 int ringnumber = ((iidd >> 5) & 0x7);
734 if ((TKlayers >= 5 && TKlayers < 11) ||
735 ((subdetector == 6) && ((ringnumber >= 5) && (ringnumber <= 7)))) {
737 float highzone = 0.0;
739 float higherr = yloc + 5.0 * yErr;
740 float lowerr = yloc - 5.0 * yErr;
741 if (TKlayers >= 5 && TKlayers < 11) {
743 highzone = TOBexclusion + exclusionWidth;
744 lowzone = TOBexclusion - exclusionWidth;
745 }
else if (ringnumber == 5) {
747 highzone = TECexRing5 + exclusionWidth;
748 lowzone = TECexRing5 - exclusionWidth;
749 }
else if (ringnumber == 6) {
751 highzone = TECexRing6 + exclusionWidth;
752 lowzone = TECexRing6 - exclusionWidth;
753 }
else if (ringnumber == 7) {
755 highzone = TECexRing7 + exclusionWidth;
756 lowzone = TECexRing7 - exclusionWidth;
759 if ((highzone <= higherr) && (highzone >= lowerr))
761 if ((lowzone >= lowerr) && (lowzone <= higherr))
763 if ((higherr <= highzone) && (higherr >= lowzone))
765 if ((lowerr >= lowzone) && (lowerr <= highzone))
783 if (SiStripQuality_->getBadApvs(iidd) != 0) {
785 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is bad from SiStripQuality" << endl;
788 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is good from SiStripQuality" << endl;
792 for (
unsigned int ii = 0;
ii < fedErrorIds->size();
ii++) {
793 if (iidd == (*fedErrorIds)[
ii].rawId())
801 ResX = FinalCluster[0];
803 if (FinalResSig != FinalCluster[1])
804 LogDebug(
"SiStripHitEfficiency:HitEff")
805 <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig
806 <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
815 if (commonModeDigis.isValid() && TrajStrip >= 0 && TrajStrip <= 768) {
817 if (digiframe != commonModeDigis->
end())
818 if ((
unsigned)TrajStrip / 128 < digiframe->data.
size())
819 commonMode = digiframe->data.at(TrajStrip / 128).adc();
822 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"before check good" << endl;
824 if (FinalResSig < 999.0) {
826 LogDebug(
"SiStripHitEfficiency:HitEff")
827 <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " << iidd <<
" TKlayers "
828 << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd
829 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" << ((iidd & 0x3) == 1) <<
"/"
830 << ((iidd & 0x3) == 2) << endl;
834 LogDebug(
"SiStripHitEfficiency:HitEff")
835 <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0]
836 <<
" FinalRecHit " << iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc
837 <<
" module " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/"
838 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
842 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" RPhi Error " <<
sqrt(xErr * xErr + yErr * yErr)
843 <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
845 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after good location check" << endl;
847 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after list of clusters" << endl;
849 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After layers=TKLayers if" << endl;
851 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After looping over TrajAtValidHit list" << endl;
853 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end TMeasurement loop" << endl;
855 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end of trajectories loop" << endl;
std::pair< LocalPoint, LocalError > LocalValues
EventNumber_t event() const
static constexpr auto TEC
virtual int nstrips() const =0
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
bool check2DPartner(unsigned int iidd, const std::vector< TrajectoryMeasurement > &traj)
void setCluster(const SiStripCluster &cluster, int detId)
ConstRecHitPointer const & recHit() const
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
virtual const std::array< const float, 4 > parameters() const
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool useAllHitsFromTracksWithMissingHits_
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
std::vector< Track > TrackCollection
collection of Tracks
int bunchCrossing() const
const Bounds & bounds() const
SiStripClusterInfo siStripClusterInfo_
data_type const * const_iterator
key_type key() const
Accessor for product key.
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
const Plane & surface() const
The nominal surface of the GeomDet.
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > siStripQualityToken_
std::vector< Muon > MuonCollection
collection of Muon objects
const edm::EDGetTokenT< MeasurementTrackerEvent > trackerEvent_token_
static std::string const input
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
float signalOverNoise() const
bool isDoubleSided(unsigned int iidd, const TrackerTopology *tTopo) const
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
const edm::EDGetTokenT< DetIdCollection > digis_token_
int nDof
number of muon stations used
Abs< T >::type abs(const T &t)
unsigned int trajHitValid
const edm::ESGetToken< MeasurementTracker, CkfComponentsRecord > measurementTkToken_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
iterator end()
Return the off-the-end iterator.
size_type size() const
Return the number of contained DetSets.
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > chi2MeasurementEstimatorToken_
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
double checkConsistency(const StripClusterParameterEstimator::LocalValues ¶meters, double xx, double xerr)
T const * product() const
const edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecord > cpeToken_
unsigned int trackMultiplicityCut_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
unsigned int checkLayer(unsigned int iidd, const TrackerTopology *tTopo)
unsigned int SiStripQualBad
const edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAsso_token_
void initEvent(const edm::EventSetup &iSetup)
collection_type::const_iterator const_iterator
const edm::EDGetTokenT< LumiScalersCollection > scalerToken_
virtual float width() const =0
const edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > commonModeToken_
tuple AnalyticalPropagator
unsigned int tecSide(const DetId &id) const