69 : theService(nullptr),
70 theDTRecHitLabel(par.getParameter<
InputTag>(
"DTRecSegmentLabel")),
71 theCSCRecHitLabel(par.getParameter<
InputTag>(
"CSCRecSegmentLabel")),
72 theCSCSegmentsLabel(par.getParameter<
InputTag>(
"CSCSegmentLabel")),
73 theDT4DRecSegmentLabel(par.getParameter<
InputTag>(
"DT4DRecSegmentLabel")) {
88 auto trackerRecHitBuilderName = par.
getParameter<
string>(
"TrackerRecHitBuilder");
90 auto muonRecHitBuilderName = par.
getParameter<
string>(
"MuonRecHitBuilder");
96 category_ =
"MuonShowerInformationFiller";
98 for (
int istat = 0; istat < 4; istat++) {
151 for (
int istat = 0; istat < 4; istat++) {
194 for (chamberIdIt = dtSegments->id_begin(); chamberIdIt != dtSegments->id_end(); ++chamberIdIt) {
195 if (*chamberIdIt != chamberId)
202 if (iseg->dimension() != 4)
212 if ((*chamberId).chamber() != did.chamber())
219 if (iseg->dimension() != 3)
230 if (segments.empty())
231 return allhitscorrelated;
236 if (segments.size() == 1)
237 return allhitscorrelated;
239 for (MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator iseg = segments.begin() + 1;
240 iseg != segments.end();
246 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit1 = hits1.begin(); ihit1 != hits1.end();
248 bool usedbefore =
false;
251 GlobalPoint gp1dinsegHit = (*ihit1)->globalPosition();
253 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit2 = allhitscorrelated.begin();
254 ihit2 != allhitscorrelated.end();
258 GlobalPoint gp1dinsegHit2 = (*ihit2)->globalPosition();
260 if ((gp1dinsegHit2 - gp1dinsegHit).
mag() < 1.0)
264 allhitscorrelated.push_back(*ihit1);
268 return allhitscorrelated;
277 if (muonRecHits.empty())
284 stable_sort(muonRecHits.begin(), muonRecHits.end(),
AbsLessDTheta(refpoint));
286 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit = muonRecHits.begin();
287 ihit != muonRecHits.end() - 1;
289 if (fabs((*(ihit + 1))->globalPosition().
theta() - (*ihit)->globalPosition().theta()) < step) {
290 result.push_back(*ihit);
304 if (muonRecHits.empty())
307 stable_sort(muonRecHits.begin(), muonRecHits.end(),
LessPerp());
309 MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator seedhit =
310 min_element(muonRecHits.begin(), muonRecHits.end(),
LessPerp());
312 MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator ihigh = seedhit;
313 MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator ilow = seedhit;
316 while (ihigh != muonRecHits.end() - 1 &&
317 (fabs((*(ihigh + 1))->globalPosition().
perp() - (*ihigh)->globalPosition().perp()) < step)) {
320 while (ilow != muonRecHits.begin() &&
321 (fabs((*ilow)->globalPosition().perp() - (*(ilow - 1))->globalPosition().perp()) < step)) {
334 vector<const GeomDet*>
total;
337 LogTrace(
category_) <<
"Consider a track " << track.
p() <<
" eta: " << track.
eta() <<
" phi " << track.
phi() << endl;
347 vector<GlobalPoint> allCrossingPoints;
349 const vector<const DetLayer*>& dtlayers =
theService->detLayerGeometry()->allDTLayers();
351 for (
auto iLayer = dtlayers.begin(); iLayer != dtlayers.end(); ++iLayer) {
356 if ((fabs(xPoint.
y()) < 1000.0) && (fabs(xPoint.
z()) < 1500) &&
357 (!(xPoint.
y() == 0 && xPoint.
x() == 0 && xPoint.
z() == 0)))
358 allCrossingPoints.push_back(xPoint);
361 stable_sort(allCrossingPoints.begin(), allCrossingPoints.end(),
LessMag(innerPos));
363 vector<const GeomDet*> tempDT;
365 for (vector<GlobalPoint>::const_iterator ipos = allCrossingPoints.begin(); ipos != allCrossingPoints.end(); ++ipos) {
367 vector<const GeomDet*>::const_iterator
begin = tempDT.begin();
368 vector<const GeomDet*>::const_iterator
end = tempDT.end();
371 total.push_back(*begin);
374 allCrossingPoints.clear();
376 const vector<const DetLayer*>& csclayers =
theService->detLayerGeometry()->allCSCLayers();
377 for (
auto iLayer = csclayers.begin(); iLayer != csclayers.end(); ++iLayer) {
381 if ((fabs(xPoint.
y()) < 1000.0) && (fabs(xPoint.
z()) < 1500.0) &&
382 (!(xPoint.
y() == 0 && xPoint.
x() == 0 && xPoint.
z() == 0)))
383 allCrossingPoints.push_back(xPoint);
385 stable_sort(allCrossingPoints.begin(), allCrossingPoints.end(),
LessMag(innerPos));
387 vector<const GeomDet*> tempCSC;
388 for (vector<GlobalPoint>::const_iterator ipos = allCrossingPoints.begin(); ipos != allCrossingPoints.end(); ++ipos) {
390 vector<const GeomDet*>::const_iterator
begin = tempCSC.begin();
391 vector<const GeomDet*>::const_iterator
end = tempCSC.end();
394 total.push_back(*begin);
418 float a = p1.
x() - slope * p1.
y();
420 float n2 = (1 + slope *
slope);
421 float n1 = 2 * a *
slope;
426 if (n1 * n1 - 4 * n2 * n0 > 0) {
427 y1 = (-n1 +
sqrt(n1 * n1 - 4 * n2 * n0)) / (2 * n2);
428 y2 = (-n1 -
sqrt(n1 * n1 - 4 * n2 * n0)) / (2 * n2);
431 float x1 = p1.
x() + slope * (y1 - p1.
y());
432 float x2 = p1.
x() + slope * (y2 - p1.
y());
434 float slopeZ = dp.
z() / dp.
y();
436 float z1 = p1.
z() + slopeZ * (y1 - p1.
y());
437 float z2 = p1.
z() + slopeZ * (y2 - p1.
y());
440 if ((p2.x() * x1 > 0) && (y1 * p2.y() > 0) && (z1 * p2.z() > 0)) {
460 float diskZ = disk.position().z();
461 int endcap = diskZ > 0 ? 1 : (diskZ < 0 ? -1 : 0);
466 float slopeZ = dp.
z() / dp.
y();
467 float y1 = diskZ / slopeZ;
469 float slopeX = dp.
z() / dp.
x();
470 float x1 = diskZ / slopeX;
474 if (p2.z() * z1 > 0) {
487 if (gp.
z() < -680.0) {
490 }
else if (gp.
z() < -396.0) {
493 }
else if (gp.
z() < -126.8) {
496 }
else if (gp.
z() < 126.8) {
499 }
else if (gp.
z() < 396.0) {
502 }
else if (gp.
z() < 680.0) {
511 if (gp.
perp() > 680.0 && gp.
perp() < 755.0)
513 else if (gp.
perp() > 580.0)
515 else if (gp.
perp() > 480.0)
517 else if (gp.
perp() > 380.0)
524 float phistep =
M_PI / 6;
526 float phigp = (float)gp.
barePhi();
528 if (fabs(
deltaPhi(phigp, 0 * phistep)) < phistep)
529 sectors.push_back(1);
530 if (fabs(
deltaPhi(phigp, phistep)) < phistep)
531 sectors.push_back(2);
532 if (fabs(
deltaPhi(phigp, 2 * phistep)) < phistep)
533 sectors.push_back(3);
534 if (fabs(
deltaPhi(phigp, 3 * phistep)) < phistep) {
535 sectors.push_back(4);
537 sectors.push_back(13);
539 if (fabs(
deltaPhi(phigp, 4 * phistep)) < phistep)
540 sectors.push_back(5);
541 if (fabs(
deltaPhi(phigp, 5 * phistep)) < phistep)
542 sectors.push_back(6);
543 if (fabs(
deltaPhi(phigp, 6 * phistep)) < phistep)
544 sectors.push_back(7);
545 if (fabs(
deltaPhi(phigp, 7 * phistep)) < phistep)
546 sectors.push_back(8);
547 if (fabs(
deltaPhi(phigp, 8 * phistep)) < phistep)
548 sectors.push_back(9);
549 if (fabs(
deltaPhi(phigp, 9 * phistep)) < phistep) {
550 sectors.push_back(10);
552 sectors.push_back(14);
554 if (fabs(
deltaPhi(phigp, 10 * phistep)) < phistep)
555 sectors.push_back(11);
556 if (fabs(
deltaPhi(phigp, 11 * phistep)) < phistep)
557 sectors.push_back(12);
560 LogTrace(
category_) <<
"number of sectors to consider: " << sectors.size() << endl;
561 LogTrace(
category_) <<
"station: " << station <<
" wheels: " << minwheel <<
" " << maxwheel << endl;
563 vector<const GeomDet*>
result;
564 if (station > 4 || station < 1)
566 if (minwheel > 2 || maxwheel < -2)
569 for (vector<int>::const_iterator isector = sectors.begin(); isector != sectors.end(); ++isector) {
570 for (
int iwheel = minwheel; iwheel != maxwheel + 1; ++iwheel) {
571 DTChamberId chamberid(iwheel, station, (*isector));
572 result.push_back(
theService->trackingGeometry()->idToDet(chamberid));
576 LogTrace(
category_) <<
"number of GeomDets for this track: " << result.size() << endl;
597 if (fabs(gp.
z()) > 1000. && fabs(gp.
z()) < 1055.0) {
599 }
else if (fabs(gp.
z()) > 910.0 && fabs(gp.
z()) < 965.0) {
601 }
else if (fabs(gp.
z()) > 800.0 && fabs(gp.
z()) < 860.0) {
603 }
else if (fabs(gp.
z()) > 570.0 && fabs(gp.
z()) < 730.0) {
609 float phistep1 =
M_PI / 18.;
610 float phistep2 =
M_PI / 9.;
611 float phigp = (float)gp.
barePhi();
618 if (gp.
perp() > 100 && gp.
perp() < 270)
620 else if (gp.
perp() > 270 && gp.
perp() < 450)
622 else if (gp.
perp() > 450 && gp.
perp() < 695)
624 else if (gp.
perp() > 100 && gp.
perp() < 270)
627 }
else if (station == 2) {
628 if (gp.
perp() > 140 && gp.
perp() < 350)
630 else if (gp.
perp() > 350 && gp.
perp() < 700)
633 }
else if (station == 3) {
634 if (gp.
perp() > 160 && gp.
perp() < 350)
636 else if (gp.
perp() > 350 && gp.
perp() < 700)
639 }
else if (station == 4) {
640 if (gp.
perp() > 175 && gp.
perp() < 350)
642 else if (gp.
perp() > 350 && gp.
perp() < 700)
646 if (station > 1 && ring == 1) {
648 for (
int i = 0;
i < 18;
i++) {
649 if (fabs(
deltaPhi(phigp,
i * phistep2)) < phistep2)
650 sectors.push_back(
i + 1);
655 for (
int i = 0;
i < 36;
i++) {
656 if (fabs(
deltaPhi(phigp,
i * phistep1)) < phistep1)
657 sectors.push_back(
i + 1);
665 LogTrace(
category_) <<
"CSC number of sectors to consider: " << sectors.size() << endl;
668 vector<const GeomDet*>
result;
669 if (station > 4 || station < 1)
679 for (vector<int>::const_iterator isector = sectors.begin(); isector != sectors.end(); ++isector) {
680 for (
int ilayer = minlayer; ilayer != maxlayer + 1; ++ilayer) {
681 CSCDetId cscid(endcap, station, ring, (*isector), ilayer);
682 result.push_back(
theService->trackingGeometry()->idToDet(cscid));
702 vector<MuonRecHitContainer> muonRecHits(4);
705 vector<TransientTrackingRecHit::ConstRecHitContainer> muonCorrelatedHits(4);
712 bool dtOverlapToCheck =
false;
713 bool cscOverlapToCheck =
false;
715 for (vector<const GeomDet*>::const_iterator igd = compatibleLayers.begin(); igd != compatibleLayers.end(); igd++) {
717 DetId geoId = (*igd)->geographicalId();
728 int wheel = detid.wheel();
733 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_begin = muonCorrelatedHitsTmp.begin();
734 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_end = muonCorrelatedHitsTmp.end();
736 for (; hits_begin != hits_end; ++hits_begin) {
737 muonCorrelatedHits.at(station - 1).push_back(*hits_begin);
741 if (
abs(wheel) == 2 && station != 4 && station != 1)
742 dtOverlapToCheck =
true;
749 DTLayerId lid(detid, isuperlayer, ilayer);
752 vector<const TrackingRecHit*> subrechits = (*rechit).recHits();
753 for (vector<const TrackingRecHit*>::iterator irechit = subrechits.begin(); irechit != subrechits.end();
764 int ring = did.ring();
769 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_begin = muonCorrelatedHitsTmp.begin();
770 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_end = muonCorrelatedHitsTmp.end();
772 for (; hits_begin != hits_end; ++hits_begin) {
773 muonCorrelatedHits.at(station - 1).push_back(*hits_begin);
776 if ((station == 1 && ring == 3) && dtOverlapToCheck)
777 cscOverlapToCheck =
true;
782 if (!cscOverlapToCheck) {
793 if (temp.size() > 1) {
794 center = (temp.front()->globalPosition().perp() + temp.back()->globalPosition().perp()) / 2.;
796 center = temp.front()->globalPosition().perp();
801 muonRecHits.at(2).insert(muonRecHits.at(2).end(), tmpCSC1.begin(), tmpCSC1.end());
803 muonRecHits.at(1).insert(muonRecHits.at(1).end(), tmpCSC1.begin(), tmpCSC1.end());
831 const size_t nhit = muonRecHits[
stat].size();
834 muonRecHitsPhiBest.clear();
835 muonRecHitsPhiBest.reserve(nhit);
842 std::vector<size_t> clUppers;
843 for (
size_t ihit = 0; ihit < nhit; ++ihit) {
844 const size_t jhit = (ihit + 1) % nhit;
845 const double phi1 = muonRecHits[
stat].at(ihit)->globalPosition().barePhi();
846 const double phi2 = muonRecHits[
stat].at(jhit)->globalPosition().barePhi();
850 clUppers.push_back(ihit);
855 if (clUppers.empty()) {
857 const double refPhi = muonRecHits[
stat].at(0)->globalPosition().barePhi();
858 double dphilo = 0, dphihi = 0;
859 for (
auto&
hit : muonRecHits[
stat]) {
860 muonRecHitsPhiBest.push_back(
hit);
861 const double phi =
hit->globalPosition().barePhi();
865 dphimax =
std::abs(dphihi + dphilo);
869 size_t bestUpper = 0, bestLower = 0;
870 for (
auto icl = clUppers.begin(); icl != clUppers.end(); ++icl) {
872 const size_t upper = *icl;
874 const auto prevCl = (icl == clUppers.begin()) ? clUppers.end() : icl;
875 const size_t lower = (*(prevCl - 1) + 1) % nhit;
881 const double phi1 = muonRecHits[
stat].at(upper)->globalPosition().barePhi();
882 const double phi2 = muonRecHits[
stat].at(lower)->globalPosition().barePhi();
885 if (dphimax < dphi) {
892 if (bestUpper > bestLower) {
893 muonRecHitsPhiBest.reserve(bestUpper - bestLower + 1);
895 muonRecHits[
stat].
begin() + bestUpper + 1,
896 std::back_inserter(muonRecHitsPhiBest));
897 }
else if (bestUpper < bestLower) {
898 muonRecHitsPhiBest.reserve(bestUpper + (nhit - bestLower) + 1);
900 muonRecHits[
stat].
begin() + bestUpper + 1,
901 std::back_inserter(muonRecHitsPhiBest));
903 muonRecHits[
stat].
begin() + bestLower, muonRecHits[
stat].
end(), std::back_inserter(muonRecHitsPhiBest));
908 if (!muonRecHitsPhiBest.empty()) {
909 muonRecHits[
stat] = muonRecHitsPhiBest;
911 muonRecHits[
stat].front();
917 if (!muonCorrelatedHits.at(
stat).empty()) {
919 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator
iseed = muonCorrelatedHits.at(
stat).begin();
920 iseed != muonCorrelatedHits.at(
stat).end();
922 if (!(*iseed)->isValid())
925 muonRecHitsThetaTemp.clear();
927 if (muonRecHitsThetaTemp.size() > 1) {
928 float dtheta = fabs((
float)muonRecHitsThetaTemp.back()->globalPosition().theta() -
929 (float)muonRecHitsThetaTemp.front()->globalPosition().theta());
930 if (dtheta > dthetamax) {
932 muonRecHitsThetaBest = muonRecHitsThetaTemp;
939 if (muonRecHitsThetaBest.size() > 1 && muonRecHitsPhiBest.size() > 1)
941 muonRecHitsPhiBest.back()->globalPosition().barePhi()),
943 pow(muonRecHitsThetaBest.front()->globalPosition().theta() -
944 muonRecHitsThetaBest.back()->globalPosition().theta(),
949 LogTrace(
category_) <<
"deltaR around a track containing all the station hits, by station "
double p() const
momentum vector magnitude
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::pair< const_iterator, const_iterator > range
iterator range
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
static const double slope[3]
Global3DPoint GlobalPoint
constexpr uint32_t rawId() const
get the raw id
Geom::Theta< T > theta() const
GlobalPoint globalPosition() const
double phi() const
azimuthal angle of momentum vector
std::vector< int > nStationHits
number of all the muon RecHits per chamber crossed by a track (1D hits)
const uint16_t range(const Frame &aFrame)
static TransientTrackingRecHit::ConstRecHitContainer breakInSubRecHits(TransientTrackingRecHit::ConstRecHitPointer, int granularity)
takes a muon rechit and returns its sub-rechits given a certain granularity
C::const_iterator const_iterator
constant access iterator type
std::vector< int > nStationCorrelatedHits
number of the muon RecHits used by segments per chamber crossed by a track
double eta() const
pseudorapidity of momentum vector
Scalar radius() const
Radius of the cylinder.
static const int maxLayerId
highest layer id
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
static const int minLayerId
lowest layer id. 0 indicates a full SL
DetId geographicalId() const
The label of this GeomDet.
static const int maxSuperLayerId
highest superlayer id
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
std::vector< ConstRecHitPointer > ConstRecHitContainer
T getParameter(std::string const &) const
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
static const int minSuperLayerId
loweset super layer id. 0 indicates a full chamber
T perp() const
Magnitude of transverse component.
std::vector< float > stationShowerSizeT
the transverse size of the hit cluster
virtual const BoundDisk & specificSurface() const final
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
std::vector< MuonRecHitPointer > MuonRecHitContainer
bool isGlobalMuon() const override
Power< A, B >::type pow(const A &a, const B &b)
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
std::vector< float > stationShowerDeltaR
the radius of the cone containing the all the hits around the track
constexpr Detector det() const
get the detector field from this detid
bool isStandAloneMuon() const override