66 #define LOGPRINT edm::LogPrint("SiStripHitEfficiency:HitEff") 77 siStripClusterInfo_(consumesCollector()),
78 combinatorialTracks_token_(
115 traj =
fs->make<TTree>(
"traj",
"tree of trajectory positions");
116 #ifdef ExtendedCALIBTree 117 traj->Branch(
"timeDT", &timeDT,
"timeDT/F");
118 traj->Branch(
"timeDTErr", &timeDTErr,
"timeDTErr/F");
119 traj->Branch(
"timeDTDOF", &timeDTDOF,
"timeDTDOF/I");
120 traj->Branch(
"timeECAL", &timeECAL,
"timeECAL/F");
121 traj->Branch(
"dedx", &dedx,
"dedx/F");
122 traj->Branch(
"dedxNOM", &dedxNOM,
"dedxNOM/I");
123 traj->Branch(
"nLostHits", &nLostHits,
"nLostHits/I");
124 traj->Branch(
"chi2", &
chi2,
"chi2/F");
125 traj->Branch(
"p", &
p,
"p/F");
141 traj->Branch(
"ResX", &
ResX,
"ResX/F");
146 traj->Branch(
"nHits", &
nHits,
"nHits/I");
147 traj->Branch(
"pT", &
pT,
"pT/F");
150 traj->Branch(
"Id", &
Id,
"Id/i");
151 traj->Branch(
"run", &
run,
"run/i");
152 traj->Branch(
"event", &
event,
"event/i");
158 traj->Branch(
"PU", &
PU,
"PU/F");
174 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"beginning analyze from HitEff" << endl;
177 using namespace reco;
180 int run_nr =
e.id().run();
181 int ev_nr =
e.id().event();
182 int bunch_nr =
e.bunchCrossing();
196 }
else if (metaData.
isValid()) {
200 edm::LogWarning(
"SiStripHitEfficiencyWorker") <<
"could not find a source for the Luminosity and PU";
288 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"number ckf tracks found = " << tracksCKF->size() << endl;
290 if (!tracksCKF->empty()) {
294 LogDebug(
"SiStripHitEfficiency:HitEff")
299 #ifdef ExtendedCALIBTree 302 if (
e.getByLabel(
"dedxMedianCTF", dEdxUncalibHandle)) {
306 dedx = dEdxTrackUncalib[itTrack].dEdx();
307 dedxNOM = dEdxTrackUncalib[itTrack].numberOfMeasurements();
315 if (
e.getByLabel(
"muonsWitht0Correction", muH)) {
317 if (!muonsT0.empty()) {
321 timeDTDOF = mt0.
nDof;
323 bool hasCaloEnergyInfo = muonsT0[0].isEnergyValid();
324 if (hasCaloEnergyInfo)
325 timeECAL = muonsT0[0].calEnergy().ecal_time;
339 it != trajTrackAssociationHandle->
end();
345 nHits = itraj->foundHits();
346 #ifdef ExtendedCALIBTree 347 nLostHits = itraj->lostHits();
348 chi2 = (itraj->chiSquared() / itraj->ndof());
349 p = itraj->lastMeasurement().updatedState().globalMomentum().mag();
351 pT =
sqrt((itraj->lastMeasurement().updatedState().globalMomentum().x() *
352 itraj->lastMeasurement().updatedState().globalMomentum().x()) +
353 (itraj->lastMeasurement().updatedState().globalMomentum().y() *
354 itraj->lastMeasurement().updatedState().globalMomentum().y()));
359 std::vector<TrajectoryMeasurement> TMeas = itraj->measurements();
360 vector<TrajectoryMeasurement>::iterator itm;
365 double angleX = -999.;
366 double angleY = -999.;
367 double xglob, yglob, zglob;
370 bool hasMissingHits =
false;
371 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
372 auto theHit = (*itm).recHit();
374 hasMissingHits =
true;
380 for (itm = TMeas.begin(); itm != TMeas.end(); itm++) {
381 auto theInHit = (*itm).recHit();
383 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"theInHit is valid = " << theInHit->isValid() << endl;
385 unsigned int iidd = theInHit->geographicalId().rawId();
387 unsigned int TKlayers = ::checkLayer(iidd, tTopo);
388 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"TKlayer from trajectory: " << TKlayers <<
" from module = " << iidd
389 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" 390 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
394 bool isFirstMeas = (itm == (TMeas.end() - 1));
395 bool isLastMeas = (itm == (TMeas.begin()));
408 if (TKlayers == 10 || TKlayers == 22) {
409 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"skipping original TM for TOB 6 or TEC 9" << endl;
414 std::vector<TrajectoryAtInvalidHit> TMs;
422 if (::isDoubleSided(iidd, tTopo) && ((iidd & 0x3) == 0)) {
427 }
else if (::isDoubleSided(iidd, tTopo) && (!::check2DPartner(iidd, TMeas))) {
432 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" found a hit with a missing partner" << endl;
444 bool isValid = theInHit->isValid();
445 bool isLast = (itm == (TMeas.end() - 1));
446 bool isLastTOB5 =
true;
448 if (::checkLayer((++itm)->recHit()->geographicalId().rawId(), tTopo) == 9)
455 if (TKlayers == 9 &&
isValid && isLastTOB5) {
458 std::vector<BarrelDetLayer const*> barrelTOBLayers =
459 measurementTrackerHandle->geometricSearchTracker()->tobLayers();
460 const DetLayer* tob6 = barrelTOBLayers[barrelTOBLayers.size() - 1];
463 auto tmp = layerMeasurements.measurements(*tob6, tsosTOB5, *thePropagator, *
estimator);
466 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"size of TM from propagation = " <<
tmp.size() << endl;
472 const auto& tob6Hit = tob6TM.
recHit();
474 if (tob6Hit->geographicalId().rawId() != 0) {
475 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tob6 hit actually being added to TM vector" << endl;
481 bool isLastTEC8 =
true;
483 if (::checkLayer((++itm)->
recHit()->geographicalId().rawId(), tTopo) == 21)
490 if (TKlayers == 21 &&
isValid && isLastTEC8) {
491 std::vector<const ForwardDetLayer*> posTecLayers =
492 measurementTrackerHandle->geometricSearchTracker()->posTecLayers();
493 const DetLayer* tec9pos = posTecLayers[posTecLayers.size() - 1];
494 std::vector<const ForwardDetLayer*> negTecLayers =
495 measurementTrackerHandle->geometricSearchTracker()->negTecLayers();
496 const DetLayer* tec9neg = negTecLayers[negTecLayers.size() - 1];
502 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"there is a problem with TEC 9 extrapolation" << endl;
505 vector<TrajectoryMeasurement>
tmp;
506 if (tTopo->
tecSide(iidd) == 1) {
507 tmp = layerMeasurements.measurements(*tec9neg, tsosTEC9, *thePropagator, *
estimator);
510 if (tTopo->
tecSide(iidd) == 2) {
511 tmp = layerMeasurements.measurements(*tec9pos, tsosTEC9, *thePropagator, *
estimator);
520 const auto& tec9Hit = tec9TM.
recHit();
522 unsigned int tec9id = tec9Hit->geographicalId().rawId();
523 LogDebug(
"SiStripHitEfficiency:HitEff")
524 <<
"tec9id = " << tec9id <<
" is Double sided = " << ::isDoubleSided(tec9id, tTopo)
525 <<
" and 0x3 = " << (tec9id & 0x3) << endl;
527 if (tec9Hit->geographicalId().rawId() != 0) {
528 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"tec9 hit actually being added to TM vector" << endl;
531 if (::isDoubleSided(tec9id, tTopo)) {
544 for (std::vector<TrajectoryAtInvalidHit>::const_iterator TM = TMs.begin(); TM != TMs.end(); ++TM) {
546 iidd = TM->monodet_id();
547 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"setting iidd = " << iidd <<
" before checking efficiency and ";
552 angleX = atan(TM->localDxDz());
553 angleY = atan(TM->localDyDz());
558 xglob = TM->globalX();
559 yglob = TM->globalY();
560 zglob = TM->globalZ();
561 xErr = TM->localErrorX();
562 yErr = TM->localErrorY();
573 TKlayers = ::checkLayer(iidd, tTopo);
577 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Looking at layer under study" << endl;
599 if (!
input.empty()) {
600 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking clusters with size = " <<
input.size() << endl;
602 std::vector<std::vector<float> >
608 unsigned int ClusterId = DSViter->id();
609 if (ClusterId == iidd) {
610 LogDebug(
"SiStripHitEfficiency:HitEff")
611 <<
"found (ClusterId == iidd) with ClusterId = " << ClusterId <<
" and iidd = " << iidd << endl;
612 DetId ClusterDetId(ClusterId);
621 if (TKlayers >= 11) {
624 dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
625 std::array<const float, 4>
const& parameterTrap =
627 hbedge = parameterTrap[0];
628 htedge = parameterTrap[1];
629 hapoth = parameterTrap[3];
630 uylfac = (htedge - hbedge) / (htedge + hbedge) / hapoth;
631 uxlden = 1 + yloc * uylfac;
635 if (TrajStrip == -1) {
638 TrajStrip = xloc / pitch + nstrips / 2.0;
640 if (TKlayers >= 11) {
641 float TrajLocXMid = xloc / (1 + (htedge - hbedge) * yloc / (htedge + hbedge) /
643 TrajStrip = TrajLocXMid / pitch + nstrips / 2.0;
653 float sigma = ::checkConsistency(
parameters, xloc, xErr);
660 if (TKlayers >= 11) {
664 yErr * yErr * xloc * xloc * uylfac * uylfac / uxlden / uxlden / uxlden / uxlden);
671 std::vector<float> cluster_info;
672 cluster_info.push_back(
res);
673 cluster_info.push_back(sigma);
679 VCluster_info.push_back(cluster_info);
681 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Have ID match. residual = " << VCluster_info.back()[0]
682 <<
" res sigma = " << VCluster_info.back()[1] << endl;
683 LogDebug(
"SiStripHitEfficiency:HitEff")
684 <<
"trajectory measurement compatability estimate = " << (*itm).estimate() << endl;
685 LogDebug(
"SiStripHitEfficiency:HitEff")
687 <<
" trajectory position = " << xloc <<
" traj error = " << xErr << endl;
691 float FinalResSig = 1000.0;
692 float FinalCluster[7] = {1000.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0};
694 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"found clusters > 0" << endl;
697 vector<vector<float> >::iterator ires;
698 for (ires = VCluster_info.begin(); ires != VCluster_info.end(); ires++) {
699 if (
abs((*ires)[1]) <
abs(FinalResSig)) {
700 FinalResSig = (*ires)[1];
701 for (
unsigned int i = 0;
i < ires->size();
i++) {
702 LogDebug(
"SiStripHitEfficiency:HitEff")
703 <<
"filling final cluster. i = " <<
i <<
" before fill FinalCluster[i]=" << FinalCluster[
i]
704 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
705 FinalCluster[
i] = (*ires)[
i];
706 LogDebug(
"SiStripHitEfficiency:HitEff")
707 <<
"filling final cluster. i = " <<
i <<
" after fill FinalCluster[i]=" << FinalCluster[
i]
708 <<
" and (*ires)[i] =" << (*ires)[
i] << endl;
711 LogDebug(
"SiStripHitEfficiency:HitEff")
712 <<
"iresidual = " << (*ires)[0] <<
" isigma = " << (*ires)[1]
713 <<
" and FinalRes = " << FinalCluster[0] << endl;
716 FinalResSig = VCluster_info.at(0)[1];
717 for (
unsigned int i = 0;
i < VCluster_info.at(0).size();
i++) {
718 FinalCluster[
i] = VCluster_info.at(0)[
i];
721 VCluster_info.clear();
724 LogDebug(
"SiStripHitEfficiency:HitEff")
725 <<
"Final residual in X = " << FinalCluster[0] <<
"+-" << (FinalCluster[0] / FinalResSig) << endl;
726 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Checking location of trajectory: abs(yloc) = " <<
abs(yloc)
727 <<
" abs(xloc) = " <<
abs(xloc) << endl;
728 LogDebug(
"SiStripHitEfficiency:HitEff")
729 <<
"Checking location of cluster hit: yloc = " << FinalCluster[4] <<
"+-" << FinalCluster[5]
730 <<
" xloc = " << FinalCluster[2] <<
"+-" << FinalCluster[3] << endl;
731 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"Final cluster signal to noise = " << FinalCluster[6] << endl;
733 float exclusionWidth = 0.4;
734 float TOBexclusion = 0.0;
735 float TECexRing5 = -0.89;
736 float TECexRing6 = -0.56;
737 float TECexRing7 = 0.60;
740 int ringnumber = ((iidd >> 5) & 0x7);
743 if ((TKlayers >= 5 && TKlayers < 11) ||
744 ((
subdetector == 6) && ((ringnumber >= 5) && (ringnumber <= 7)))) {
746 float highzone = 0.0;
748 float higherr = yloc + 5.0 * yErr;
749 float lowerr = yloc - 5.0 * yErr;
750 if (TKlayers >= 5 && TKlayers < 11) {
752 highzone = TOBexclusion + exclusionWidth;
753 lowzone = TOBexclusion - exclusionWidth;
754 }
else if (ringnumber == 5) {
756 highzone = TECexRing5 + exclusionWidth;
757 lowzone = TECexRing5 - exclusionWidth;
758 }
else if (ringnumber == 6) {
760 highzone = TECexRing6 + exclusionWidth;
761 lowzone = TECexRing6 - exclusionWidth;
762 }
else if (ringnumber == 7) {
764 highzone = TECexRing7 + exclusionWidth;
765 lowzone = TECexRing7 - exclusionWidth;
768 if ((highzone <= higherr) && (highzone >= lowerr))
770 if ((lowzone >= lowerr) && (lowzone <= higherr))
772 if ((higherr <= highzone) && (higherr >= lowzone))
774 if ((lowerr >= lowzone) && (lowerr <= highzone))
794 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is bad from SiStripQuality" << endl;
797 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"strip is good from SiStripQuality" << endl;
801 for (
unsigned int ii = 0;
ii < fedErrorIds->
size();
ii++) {
802 if (iidd == (*fedErrorIds)[
ii].rawId())
810 ResX = FinalCluster[0];
812 if (FinalResSig != FinalCluster[1])
813 LogDebug(
"SiStripHitEfficiency:HitEff")
814 <<
"Problem with best cluster selection because FinalResSig = " << FinalResSig
815 <<
" and FinalCluster[1] = " << FinalCluster[1] << endl;
824 if (commonModeDigis.
isValid() && TrajStrip >= 0 && TrajStrip <= 768) {
826 if (digiframe != commonModeDigis->end())
827 if ((
unsigned)TrajStrip / 128 < digiframe->data.
size())
828 commonMode = digiframe->data.at(TrajStrip / 128).adc();
831 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"before check good" << endl;
833 if (FinalResSig < 999.0) {
835 LogDebug(
"SiStripHitEfficiency:HitEff")
836 <<
"hit being counted as good " << FinalCluster[0] <<
" FinalRecHit " << iidd <<
" TKlayers " 837 << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc <<
" module " << iidd
838 <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" << ((iidd & 0x3) == 1) <<
"/" 839 << ((iidd & 0x3) == 2) << endl;
843 LogDebug(
"SiStripHitEfficiency:HitEff")
844 <<
"hit being counted as bad ######### Invalid RPhi FinalResX " << FinalCluster[0]
845 <<
" FinalRecHit " << iidd <<
" TKlayers " << TKlayers <<
" xloc " << xloc <<
" yloc " << yloc
846 <<
" module " << iidd <<
" matched/stereo/rphi = " << ((iidd & 0x3) == 0) <<
"/" 847 << ((iidd & 0x3) == 1) <<
"/" << ((iidd & 0x3) == 2) << endl;
851 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" RPhi Error " <<
sqrt(xErr * xErr + yErr * yErr)
852 <<
" ErrorX " << xErr <<
" yErr " << yErr << endl;
854 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after good location check" << endl;
856 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"after list of clusters" << endl;
858 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After layers=TKLayers if" << endl;
860 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"After looping over TrajAtValidHit list" << endl;
862 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end TMeasurement loop" << endl;
864 LogDebug(
"SiStripHitEfficiency:HitEff") <<
"end of trajectories loop" << endl;
869 traj->GetDirectory()->cd();
872 LogDebug(
"SiStripHitEfficiency:HitEff") <<
" Events Analysed " <<
events << endl;
std::pair< LocalPoint, LocalError > LocalValues
static constexpr auto TEC
virtual int nstrips() const =0
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
T getParameter(std::string const &) const
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
virtual void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters <p) const
bool useAllHitsFromTracksWithMissingHits_
const edm::EDGetTokenT< std::vector< Trajectory > > trajectories_token_
T const * product() const
Class to contain the online luminosity from soft FED 1022.
std::vector< Track > TrackCollection
collection of Tracks
HitEff(const edm::ParameterSet &conf)
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
T getUntrackedParameter(std::string const &, T const &) const
void analyze(const edm::Event &e, const edm::EventSetup &c) override
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
#define DEFINE_FWK_MODULE(type)
bool getData(T &iHolder) const
const edm::ESGetToken< MeasurementTracker, CkfComponentsRecord > measurementTkToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > chi2MeasurementEstimatorToken_
Log< level::Info, false > LogInfo
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_
std::vector< LumiScalers > LumiScalersCollection
Log< level::Warning, false > LogWarning
void initEvent(const edm::EventSetup &iSetup)
collection_type::const_iterator const_iterator
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
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