175 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"beginning analyze from HitEff" << endl;
178 using namespace reco;
181 int run_nr =
e.id().run();
182 int ev_nr =
e.id().event();
183 int bunch_nr =
e.bunchCrossing();
197 }
else if (metaData.
isValid()) {
201 edm::LogWarning(
"SiStripHitEfficiencyWorker") <<
"could not find a source for the Luminosity and PU";
289 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"number ckf tracks found = " << tracksCKF->size() << endl;
291 if (!tracksCKF->empty()) {
295 LogDebug(
"SiStripHitEfficiency:HitEff")
300 #ifdef ExtendedCALIBTree 303 if (
e.getByLabel(
"dedxMedianCTF", dEdxUncalibHandle)) {
307 dedx = dEdxTrackUncalib[itTrack].dEdx();
308 dedxNOM = dEdxTrackUncalib[itTrack].numberOfMeasurements();
316 if (
e.getByLabel(
"muonsWitht0Correction", muH)) {
318 if (!muonsT0.empty()) {
322 timeDTDOF = mt0.
nDof;
324 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
325 if (hasCaloEnergyInfo)
326 timeECAL = muonsT0[0].calEnergy().ecal_time;
340 it != trajTrackAssociationHandle->
end();
346 nHits = itraj->foundHits();
347 #ifdef ExtendedCALIBTree 348 nLostHits = itraj->lostHits();
349 chi2 = (itraj->chiSquared() / itraj->ndof());
350 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
352 pT =
sqrt((itraj->lastMeasurement().updatedState().globalMomentum().x() *
353 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
354 (itraj->lastMeasurement().updatedState().globalMomentum().y() *
355 itraj->lastMeasurement().updatedState().globalMomentum().y()));
360 std::vector<TrajectoryMeasurement> TMeas = itraj->measurements();
361 vector<TrajectoryMeasurement>::iterator itm;
366 double angleX = -999.;
367 double angleY = -999.;
368 double xglob, yglob, zglob;
371 bool hasMissingHits =
false;
372 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
373 auto theHit = (*itm).recHit();
375 hasMissingHits =
true;
381 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
382 auto theInHit = (*itm).recHit();
384 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"theInHit is valid = " << theInHit->isValid() << endl;
386 unsigned int iidd = theInHit->geographicalId().rawId();
388 unsigned int TKlayers = ::checkLayer(iidd, tTopo);
389 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd
390 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" 391 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
395 bool isFirstMeas = (itm == (TMeas.end() - 1));
396 bool isLastMeas = (itm == (TMeas.begin()));
409 if (TKlayers == 10 || TKlayers == 22) {
410 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"skipping original TM for TOB 6 or TEC 9" << endl;
415 std::vector<TrajectoryAtInvalidHit> TMs;
423 if (::isDoubleSided(iidd, tTopo) && ((iidd & 0x3) == 0)) {
428 }
else if (::isDoubleSided(iidd, tTopo) && (!::check2DPartner(iidd, TMeas))) {
433 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" found a hit with a missing partner" << endl;
445 bool isValid = theInHit->isValid();
446 bool isLast = (itm == (TMeas.end() - 1));
447 bool isLastTOB5 =
true;
449 if (::checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9)
456 if (TKlayers == 9 &&
isValid && isLastTOB5) {
459 std::vector<BarrelDetLayer const*> barrelTOBLayers =
460 measurementTrackerHandle->geometricSearchTracker()->tobLayers();
461 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size() - 1];
464 auto tmp = layerMeasurements.measurements(*tob6, tsosTOB5, *thePropagator, *
estimator);
467 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"size of TM from propagation = " <<
tmp.size() << endl;
473 const auto& tob6Hit = tob6TM.
recHit();
475 if (tob6Hit->geographicalId().rawId() != 0) {
476 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tob6 hit actually being added to TM vector" << endl;
482 bool isLastTEC8 =
true;
484 if (::checkLayer((++itm)->
recHit()->geographicalId().rawId(), tTopo) == 21)
491 if (TKlayers == 21 &&
isValid && isLastTEC8) {
492 std::vector<const ForwardDetLayer*> posTecLayers =
493 measurementTrackerHandle->geometricSearchTracker()->posTecLayers();
494 const DetLayer* tec9pos = posTecLayers[posTecLayers.size() - 1];
495 std::vector<const ForwardDetLayer*> negTecLayers =
496 measurementTrackerHandle->geometricSearchTracker()->negTecLayers();
497 const DetLayer* tec9neg = negTecLayers[negTecLayers.size() - 1];
503 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"there is a problem with TEC 9 extrapolation" << endl;
506 vector<TrajectoryMeasurement>
tmp;
507 if (tTopo->
tecSide(iidd) == 1) {
508 tmp = layerMeasurements.measurements(*tec9neg, tsosTEC9, *thePropagator, *
estimator);
511 if (tTopo->
tecSide(iidd) == 2) {
512 tmp = layerMeasurements.measurements(*tec9pos, tsosTEC9, *thePropagator, *
estimator);
521 const auto& tec9Hit = tec9TM.
recHit();
523 unsigned int tec9id = tec9Hit->geographicalId().rawId();
524 LogDebug(
"SiStripHitEfficiency:HitEff")
525 <<
"tec9id = " << tec9id <<
" is Double sided = " << ::isDoubleSided(tec9id, tTopo)
526 <<
" and 0x3 = " << (tec9id & 0x3) << endl;
528 if (tec9Hit->geographicalId().rawId() != 0) {
529 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tec9 hit actually being added to TM vector" << endl;
532 if (::isDoubleSided(tec9id, tTopo)) {
545 for (std::vector<TrajectoryAtInvalidHit>::const_iterator TM = TMs.begin(); TM != TMs.end(); ++TM) {
547 iidd = TM->monodet_id();
548 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
553 angleX = atan(TM->localDxDz());
554 angleY = atan(TM->localDyDz());
559 xglob = TM->globalX();
560 yglob = TM->globalY();
561 zglob = TM->globalZ();
562 xErr = TM->localErrorX();
563 yErr = TM->localErrorY();
574 TKlayers = ::checkLayer(iidd, tTopo);
578 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Looking at layer under study" << endl;
600 if (!
input.empty()) {
601 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking clusters with size = " <<
input.size() << endl;
603 std::vector<std::vector<float> >
609 unsigned int ClusterId = DSViter->id();
610 if (ClusterId == iidd) {
611 LogDebug(
"SiStripHitEfficiency:HitEff")
612 <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
613 DetId ClusterDetId(ClusterId);
622 if (TKlayers >= 11) {
625 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
626 std::array<const float, 4>
const& parameterTrap =
628 hbedge = parameterTrap[0];
629 htedge = parameterTrap[1];
630 hapoth = parameterTrap[3];
631 uylfac = (htedge - hbedge) / (htedge + hbedge) / hapoth;
632 uxlden = 1 + yloc * uylfac;
636 if (TrajStrip == -1) {
639 TrajStrip = xloc / pitch + nstrips / 2.0;
641 if (TKlayers >= 11) {
642 float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
644 TrajStrip = TrajLocXMid / pitch + nstrips / 2.0;
654 float sigma = ::checkConsistency(
parameters, xloc, xErr);
661 if (TKlayers >= 11) {
665 yErr * yErr * xloc * xloc * uylfac * uylfac / uxlden / uxlden / uxlden / uxlden);
672 std::vector<float> cluster_info;
673 cluster_info.push_back(
res);
674 cluster_info.push_back(sigma);
680 VCluster_info.push_back(cluster_info);
682 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Have ID match. residual = " << VCluster_info.back()[0]
683 <<
" res sigma = " << VCluster_info.back()[1] << endl;
684 LogDebug(
"SiStripHitEfficiency:HitEff")
685 <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
686 LogDebug(
"SiStripHitEfficiency:HitEff")
688 <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
692 float FinalResSig = 1000.0;
693 float FinalCluster[7] = {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
695 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"found clusters > 0" << endl;
698 vector<vector<float> >::iterator ires;
699 for (ires = VCluster_info.begin(); ires != VCluster_info.end(); ires++) {
700 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
701 FinalResSig = (*ires)[1];
702 for (
unsigned int i = 0;
i < ires->size();
i++) {
703 LogDebug(
"SiStripHitEfficiency:HitEff")
704 <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i]
705 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
706 FinalCluster[
i] = (*ires)[
i];
707 LogDebug(
"SiStripHitEfficiency:HitEff")
708 <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i]
709 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
712 LogDebug(
"SiStripHitEfficiency:HitEff")
713 <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1]
714 <<
" and FinalRes = " << FinalCluster[0] << endl;
717 FinalResSig = VCluster_info.at(0)[1];
718 for (
unsigned int i = 0;
i < VCluster_info.at(0).size();
i++) {
719 FinalCluster[
i] = VCluster_info.at(0)[
i];
722 VCluster_info.clear();
725 LogDebug(
"SiStripHitEfficiency:HitEff")
726 <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0] / FinalResSig) << endl;
727 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc)
728 <<
" abs(xloc) = " <<
abs(xloc) << endl;
729 LogDebug(
"SiStripHitEfficiency:HitEff")
730 <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5]
731 <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
732 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
734 float exclusionWidth = 0.4;
735 float TOBexclusion = 0.0;
736 float TECexRing5 = -0.89;
737 float TECexRing6 = -0.56;
738 float TECexRing7 = 0.60;
741 int ringnumber = ((iidd >> 5) & 0x7);
744 if ((TKlayers >= 5 && TKlayers < 11) ||
745 ((
subdetector == 6) && ((ringnumber >= 5) && (ringnumber <= 7)))) {
747 float highzone = 0.0;
749 float higherr = yloc + 5.0 * yErr;
750 float lowerr = yloc - 5.0 * yErr;
751 if (TKlayers >= 5 && TKlayers < 11) {
753 highzone = TOBexclusion + exclusionWidth;
754 lowzone = TOBexclusion - exclusionWidth;
755 }
else if (ringnumber == 5) {
757 highzone = TECexRing5 + exclusionWidth;
758 lowzone = TECexRing5 - exclusionWidth;
759 }
else if (ringnumber == 6) {
761 highzone = TECexRing6 + exclusionWidth;
762 lowzone = TECexRing6 - exclusionWidth;
763 }
else if (ringnumber == 7) {
765 highzone = TECexRing7 + exclusionWidth;
766 lowzone = TECexRing7 - exclusionWidth;
769 if ((highzone <= higherr) && (highzone >= lowerr))
771 if ((lowzone >= lowerr) && (lowzone <= higherr))
773 if ((higherr <= highzone) && (higherr >= lowzone))
775 if ((lowerr >= lowzone) && (lowerr <= highzone))
795 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is bad from SiStripQuality" << endl;
798 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is good from SiStripQuality" << endl;
802 for (
unsigned int ii = 0;
ii < fedErrorIds->
size();
ii++) {
803 if (iidd == (*fedErrorIds)[
ii].rawId())
811 ResX = FinalCluster[0];
813 if (FinalResSig != FinalCluster[1])
814 LogDebug(
"SiStripHitEfficiency:HitEff")
815 <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig
816 <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
825 if (commonModeDigis.
isValid() && TrajStrip >= 0 && TrajStrip <= 768) {
827 if (digiframe != commonModeDigis->end())
828 if ((
unsigned)TrajStrip / 128 < digiframe->data.
size())
829 commonMode = digiframe->data.at(TrajStrip / 128).adc();
832 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"before check good" << endl;
834 if (FinalResSig < 999.0) {
836 LogDebug(
"SiStripHitEfficiency:HitEff")
837 <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " << iidd <<
" TKlayers " 838 << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd
839 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" << ((iidd & 0x3) == 1) <<
"/" 840 << ((iidd & 0x3) == 2) << endl;
844 LogDebug(
"SiStripHitEfficiency:HitEff")
845 <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0]
846 <<
" FinalRecHit " << iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc
847 <<
" module " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" 848 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
852 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" RPhi Error " <<
sqrt(xErr * xErr + yErr * yErr)
853 <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
855 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after good location check" << endl;
857 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after list of clusters" << endl;
859 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After layers=TKLayers if" << endl;
861 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After looping over TrajAtValidHit list" << endl;
863 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end TMeasurement loop" << endl;
865 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end of trajectories loop" << endl;
std::pair< LocalPoint, LocalError > LocalValues
static constexpr auto TEC
virtual int nstrips() const =0
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
const edm::EDGetTokenT< OnlineLuminosityRecord > metaDataToken_
void setCluster(const SiStripCluster &cluster, int detId)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
friend struct const_iterator
bool useAllHitsFromTracksWithMissingHits_
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
T const * product() const
std::vector< Track > TrackCollection
collection of Tracks
SiStripClusterInfo siStripClusterInfo_
data_type const * const_iterator
float instLumi() const
Return the luminosity for the current nibble.
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > siStripQualityToken_
key_type key() const
Accessor for product key.
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_
const_iterator end() const
last iterator over the map (read only)
float signalOverNoise() const
size_type size() const
Return the number of contained DetSets.
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
unsigned int tecSide(const DetId &id) const
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
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
Abs< T >::type abs(const T &t)
unsigned int trajHitValid
const edm::ESGetToken< MeasurementTracker, CkfComponentsRecord > measurementTkToken_
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > chi2MeasurementEstimatorToken_
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const Plane & surface() const
The nominal surface of the GeomDet.
const edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecord > cpeToken_
virtual const std::array< const float, 4 > parameters() const
unsigned int trackMultiplicityCut_
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
unsigned int SiStripQualBad
const_iterator begin() const
first iterator over the map (read only)
const edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackAsso_token_
Log< level::Warning, false > LogWarning
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_
float avgPileUp() const
Return the average pileup for th current nibble.
ConstRecHitPointer const & recHit() const
short getBadApvs(uint32_t detid) const
const Bounds & bounds() const