168 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"beginning analyze from HitEff" << endl;
171 using namespace reco;
174 int run_nr = e.
id().
run();
184 if (lumiScalers->begin() != lumiScalers->end()) {
185 instLumi = lumiScalers->begin()->instantLumi();
186 PU = lumiScalers->begin()->pileup();
221 es.get<
TkStripCPERecord>().
get(
"StripCPEfromTrackAngle", parameterestimator);
290 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"number ckf tracks found = " << tracksCKF->size() << endl;
292 if (!tracksCKF->empty()) {
296 LogDebug(
"SiStripHitEfficiency:HitEff")
301 #ifdef ExtendedCALIBTree 304 if (e.
getByLabel(
"dedxMedianCTF", dEdxUncalibHandle)) {
308 dedx = dEdxTrackUncalib[itTrack].dEdx();
309 dedxNOM = dEdxTrackUncalib[itTrack].numberOfMeasurements();
317 if (e.
getByLabel(
"muonsWitht0Correction", muH)) {
319 if (!muonsT0.empty()) {
323 timeDTDOF = mt0.
nDof;
325 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
326 if (hasCaloEnergyInfo)
327 timeECAL = muonsT0[0].calEnergy().ecal_time;
341 it != trajTrackAssociationHandle->
end();
347 nHits = itraj->foundHits();
348 #ifdef ExtendedCALIBTree 349 nLostHits = itraj->lostHits();
350 chi2 = (itraj->chiSquared() / itraj->ndof());
351 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
353 pT =
sqrt((itraj->lastMeasurement().updatedState().globalMomentum().x() *
354 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
355 (itraj->lastMeasurement().updatedState().globalMomentum().y() *
356 itraj->lastMeasurement().updatedState().globalMomentum().y()));
361 std::vector<TrajectoryMeasurement> TMeas = itraj->measurements();
362 vector<TrajectoryMeasurement>::iterator itm;
367 double angleX = -999.;
368 double angleY = -999.;
369 double xglob, yglob, zglob;
372 bool hasMissingHits =
false;
373 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
374 auto theHit = (*itm).recHit();
376 hasMissingHits =
true;
382 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
383 auto theInHit = (*itm).recHit();
385 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"theInHit is valid = " << theInHit->isValid() << endl;
387 unsigned int iidd = theInHit->geographicalId().rawId();
389 unsigned int TKlayers =
checkLayer(iidd, tTopo);
390 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd
391 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" 392 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
396 bool isFirstMeas = (itm == (TMeas.end() - 1));
397 bool isLastMeas = (itm == (TMeas.begin()));
410 if (TKlayers == 10 || TKlayers == 22) {
411 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"skipping original TM for TOB 6 or TEC 9" << endl;
416 std::vector<TrajectoryAtInvalidHit> TMs;
434 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" found a hit with a missing partner" << endl;
446 bool isValid = theInHit->isValid();
447 bool isLast = (itm == (TMeas.end() - 1));
448 bool isLastTOB5 =
true;
450 if (
checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9)
457 if (TKlayers == 9 && isValid && isLastTOB5) {
460 std::vector<BarrelDetLayer const*> barrelTOBLayers =
461 measurementTrackerHandle->geometricSearchTracker()->tobLayers();
462 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size() - 1];
467 vector<TrajectoryMeasurement>
tmp =
468 theLayerMeasurements->
measurements(*tob6, tsosTOB5, *thePropagator, *estimator);
471 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"size of TM from propagation = " << tmp.size() << endl;
477 const auto& tob6Hit = tob6TM.
recHit();
479 if (tob6Hit->geographicalId().rawId() != 0) {
480 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tob6 hit actually being added to TM vector" << endl;
486 bool isLastTEC8 =
true;
495 if (TKlayers == 21 && isValid && isLastTEC8) {
496 std::vector<const ForwardDetLayer*> posTecLayers =
497 measurementTrackerHandle->geometricSearchTracker()->posTecLayers();
498 const DetLayer* tec9pos = posTecLayers[posTecLayers.size() - 1];
499 std::vector<const ForwardDetLayer*> negTecLayers =
500 measurementTrackerHandle->geometricSearchTracker()->negTecLayers();
501 const DetLayer* tec9neg = negTecLayers[negTecLayers.size() - 1];
510 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"there is a problem with TEC 9 extrapolation" << endl;
513 vector<TrajectoryMeasurement>
tmp;
514 if (tTopo->
tecSide(iidd) == 1) {
515 tmp = theLayerMeasurements->
measurements(*tec9neg, tsosTEC9, *thePropagator, *estimator);
518 if (tTopo->
tecSide(iidd) == 2) {
519 tmp = theLayerMeasurements->
measurements(*tec9pos, tsosTEC9, *thePropagator, *estimator);
528 const auto& tec9Hit = tec9TM.
recHit();
530 unsigned int tec9id = tec9Hit->geographicalId().rawId();
531 LogDebug(
"SiStripHitEfficiency:HitEff")
532 <<
"tec9id = " << tec9id <<
" is Double sided = " <<
isDoubleSided(tec9id, tTopo)
533 <<
" and 0x3 = " << (tec9id & 0x3) << endl;
535 if (tec9Hit->geographicalId().rawId() != 0) {
536 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tec9 hit actually being added to TM vector" << endl;
552 for (std::vector<TrajectoryAtInvalidHit>::const_iterator TM = TMs.begin(); TM != TMs.end(); ++TM) {
554 iidd = TM->monodet_id();
555 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
560 angleX = atan(TM->localDxDz());
561 angleY = atan(TM->localDyDz());
566 xglob = TM->globalX();
567 yglob = TM->globalY();
568 zglob = TM->globalZ();
569 xErr = TM->localErrorX();
570 yErr = TM->localErrorY();
585 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Looking at layer under study" << endl;
607 if (!input.
empty()) {
608 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking clusters with size = " << input.
size() << endl;
610 std::vector<std::vector<float> >
616 unsigned int ClusterId = DSViter->id();
617 if (ClusterId == iidd) {
618 LogDebug(
"SiStripHitEfficiency:HitEff")
619 <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
620 DetId ClusterDetId(ClusterId);
629 if (TKlayers >= 11) {
632 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
633 std::array<const float, 4>
const& parameterTrap =
635 hbedge = parameterTrap[0];
636 htedge = parameterTrap[1];
637 hapoth = parameterTrap[3];
638 uylfac = (htedge - hbedge) / (htedge + hbedge) / hapoth;
639 uxlden = 1 + yloc * uylfac;
643 if (TrajStrip == -1) {
646 TrajStrip = xloc / pitch + nstrips / 2.0;
648 if (TKlayers >= 11) {
649 float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
651 TrajStrip = TrajLocXMid / pitch + nstrips / 2.0;
660 float res = (parameters.first.x() - xloc);
668 if (TKlayers >= 11) {
669 res = parameters.first.x() - xloc / uxlden;
671 sqrt(parameters.second.xx() + xErr * xErr / uxlden / uxlden +
672 yErr * yErr * xloc * xloc * uylfac * uylfac / uxlden / uxlden / uxlden / uxlden);
679 std::vector<float> cluster_info;
680 cluster_info.push_back(res);
681 cluster_info.push_back(sigma);
682 cluster_info.push_back(parameters.first.x());
683 cluster_info.push_back(
sqrt(parameters.second.xx()));
684 cluster_info.push_back(parameters.first.y());
685 cluster_info.push_back(
sqrt(parameters.second.yy()));
686 cluster_info.push_back(clusterInfo.signalOverNoise());
688 VCluster_info.push_back(cluster_info);
690 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Have ID match. residual = " << VCluster_info.back()[0]
691 <<
" res sigma = " << VCluster_info.back()[1] << endl;
692 LogDebug(
"SiStripHitEfficiency:HitEff")
693 <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
694 LogDebug(
"SiStripHitEfficiency:HitEff")
695 <<
"hit position = " << parameters.first.x() <<
" hit error = " <<
sqrt(parameters.second.xx())
696 <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
700 float FinalResSig = 1000.0;
701 float FinalCluster[7] = {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
703 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"found clusters > 0" << endl;
706 vector<vector<float> >::iterator
ires;
707 for (ires = VCluster_info.begin(); ires != VCluster_info.end(); ires++) {
708 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
709 FinalResSig = (*ires)[1];
710 for (
unsigned int i = 0;
i < ires->size();
i++) {
711 LogDebug(
"SiStripHitEfficiency:HitEff")
712 <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i]
713 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
714 FinalCluster[
i] = (*ires)[
i];
715 LogDebug(
"SiStripHitEfficiency:HitEff")
716 <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i]
717 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
720 LogDebug(
"SiStripHitEfficiency:HitEff")
721 <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1]
722 <<
" and FinalRes = " << FinalCluster[0] << endl;
725 FinalResSig = VCluster_info.at(0)[1];
726 for (
unsigned int i = 0;
i < VCluster_info.at(0).size();
i++) {
727 FinalCluster[
i] = VCluster_info.at(0)[
i];
731 VCluster_info.clear();
734 LogDebug(
"SiStripHitEfficiency:HitEff")
735 <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0] / FinalResSig) << endl;
736 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc)
737 <<
" abs(xloc) = " <<
abs(xloc) << endl;
738 LogDebug(
"SiStripHitEfficiency:HitEff")
739 <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5]
740 <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
741 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
743 float exclusionWidth = 0.4;
744 float TOBexclusion = 0.0;
745 float TECexRing5 = -0.89;
746 float TECexRing6 = -0.56;
747 float TECexRing7 = 0.60;
750 int ringnumber = ((iidd >> 5) & 0x7);
753 if ((TKlayers >= 5 && TKlayers < 11) ||
754 ((subdetector == 6) && ((ringnumber >= 5) && (ringnumber <= 7)))) {
756 float highzone = 0.0;
758 float higherr = yloc + 5.0 * yErr;
759 float lowerr = yloc - 5.0 * yErr;
760 if (TKlayers >= 5 && TKlayers < 11) {
762 highzone = TOBexclusion + exclusionWidth;
763 lowzone = TOBexclusion - exclusionWidth;
764 }
else if (ringnumber == 5) {
766 highzone = TECexRing5 + exclusionWidth;
767 lowzone = TECexRing5 - exclusionWidth;
768 }
else if (ringnumber == 6) {
770 highzone = TECexRing6 + exclusionWidth;
771 lowzone = TECexRing6 - exclusionWidth;
772 }
else if (ringnumber == 7) {
774 highzone = TECexRing7 + exclusionWidth;
775 lowzone = TECexRing7 - exclusionWidth;
778 if ((highzone <= higherr) && (highzone >= lowerr))
780 if ((lowzone >= lowerr) && (lowzone <= higherr))
782 if ((higherr <= highzone) && (higherr >= lowzone))
784 if ((lowerr >= lowzone) && (lowerr <= highzone))
804 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is bad from SiStripQuality" << endl;
807 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is good from SiStripQuality" << endl;
811 for (
unsigned int ii = 0;
ii < fedErrorIds->
size();
ii++) {
812 if (iidd == (*fedErrorIds)[
ii].rawId())
820 ResX = FinalCluster[0];
822 if (FinalResSig != FinalCluster[1])
823 LogDebug(
"SiStripHitEfficiency:HitEff")
824 <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig
825 <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
834 if (commonModeDigis.
isValid() && TrajStrip >= 0 && TrajStrip <= 768) {
836 if (digiframe != commonModeDigis->end())
837 if ((
unsigned)TrajStrip / 128 < digiframe->data.
size())
838 commonMode = digiframe->data.at(TrajStrip / 128).adc();
841 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"before check good" << endl;
843 if (FinalResSig < 999.0) {
845 LogDebug(
"SiStripHitEfficiency:HitEff")
846 <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " << iidd <<
" TKlayers " 847 << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd
848 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" << ((iidd & 0x3) == 1) <<
"/" 849 << ((iidd & 0x3) == 2) << endl;
853 LogDebug(
"SiStripHitEfficiency:HitEff")
854 <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0]
855 <<
" FinalRecHit " << iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc
856 <<
" module " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" 857 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
861 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" RPhi Error " <<
sqrt(xErr * xErr + yErr * yErr)
862 <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
864 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after good location check" << endl;
866 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after list of clusters" << endl;
868 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After layers=TKLayers if" << endl;
870 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After looping over TrajAtValidHit list" << endl;
872 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end TMeasurement loop" << endl;
874 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end of trajectories loop" << endl;
std::pair< LocalPoint, LocalError > LocalValues
EventNumber_t event() const
static constexpr auto TEC
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
bool check2DPartner(unsigned int iidd, const std::vector< TrajectoryMeasurement > &traj)
const_iterator end(bool update=false) const
ConstRecHitPointer const & recHit() const
virtual const std::array< const float, 4 > parameters() const
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
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
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.
std::vector< Muon > MuonCollection
collection of Muon objects
const edm::EDGetTokenT< MeasurementTrackerEvent > trackerEvent_token_
static std::string const input
virtual float width() const =0
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool isDoubleSided(unsigned int iidd, const TrackerTopology *tTopo) const
short getBadApvs(const uint32_t &detid) const
const edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusters_token_
const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_
const edm::EDGetTokenT< DetIdCollection > digis_token_
int nDof
number of muon stations used
Abs< T >::type abs(const T &t)
unsigned int trajHitValid
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
size_type size() const
Return the number of contained DetSets.
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
double checkConsistency(const StripClusterParameterEstimator::LocalValues ¶meters, double xx, double xerr)
T const * product() const
virtual int nstrips() const =0
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_
const_iterator begin() const
first iterator over the map (read only)
collection_type::const_iterator const_iterator
const edm::EDGetTokenT< LumiScalersCollection > scalerToken_
T const * product() const
const edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > commonModeToken_
const_iterator begin(bool update=false) const
unsigned int tecSide(const DetId &id) const