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 category_ =
"MuonShowerInformationFiller";
90 for (
int istat = 0; istat < 4; istat++) {
143 for (
int istat = 0; istat < 4; istat++) {
186 for (chamberIdIt = dtSegments->id_begin(); chamberIdIt != dtSegments->id_end(); ++chamberIdIt) {
187 if (*chamberIdIt != chamberId)
194 if (iseg->dimension() != 4)
204 if ((*chamberId).chamber() != did.chamber())
211 if (iseg->dimension() != 3)
222 if (segments.empty())
223 return allhitscorrelated;
228 if (segments.size() == 1)
229 return allhitscorrelated;
231 for (MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator iseg = segments.begin() + 1;
232 iseg != segments.end();
238 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit1 = hits1.begin(); ihit1 != hits1.end();
240 bool usedbefore =
false;
243 GlobalPoint gp1dinsegHit = (*ihit1)->globalPosition();
245 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit2 = allhitscorrelated.begin();
246 ihit2 != allhitscorrelated.end();
250 GlobalPoint gp1dinsegHit2 = (*ihit2)->globalPosition();
252 if ((gp1dinsegHit2 - gp1dinsegHit).
mag() < 1.0)
256 allhitscorrelated.push_back(*ihit1);
260 return allhitscorrelated;
269 if (muonRecHits.empty())
276 stable_sort(muonRecHits.begin(), muonRecHits.end(),
AbsLessDTheta(refpoint));
278 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit = muonRecHits.begin();
279 ihit != muonRecHits.end() - 1;
281 if (fabs((*(ihit + 1))->globalPosition().
theta() - (*ihit)->globalPosition().theta()) < step) {
282 result.push_back(*ihit);
296 if (muonRecHits.empty())
299 stable_sort(muonRecHits.begin(), muonRecHits.end(),
LessPerp());
301 MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator seedhit =
302 min_element(muonRecHits.begin(), muonRecHits.end(),
LessPerp());
304 MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator ihigh = seedhit;
305 MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator ilow = seedhit;
308 while (ihigh != muonRecHits.end() - 1 &&
309 (fabs((*(ihigh + 1))->globalPosition().
perp() - (*ihigh)->globalPosition().perp()) < step)) {
312 while (ilow != muonRecHits.begin() &&
313 (fabs((*ilow)->globalPosition().perp() - (*(ilow - 1))->globalPosition().perp()) < step)) {
326 vector<const GeomDet*>
total;
329 LogTrace(
category_) <<
"Consider a track " << track.
p() <<
" eta: " << track.
eta() <<
" phi " << track.
phi() << endl;
339 vector<GlobalPoint> allCrossingPoints;
341 const vector<const DetLayer*>& dtlayers =
theService->detLayerGeometry()->allDTLayers();
343 for (
auto iLayer = dtlayers.begin(); iLayer != dtlayers.end(); ++iLayer) {
348 if ((fabs(xPoint.
y()) < 1000.0) && (fabs(xPoint.
z()) < 1500) &&
349 (!(xPoint.
y() == 0 && xPoint.
x() == 0 && xPoint.
z() == 0)))
350 allCrossingPoints.push_back(xPoint);
353 stable_sort(allCrossingPoints.begin(), allCrossingPoints.end(),
LessMag(innerPos));
355 vector<const GeomDet*> tempDT;
357 for (vector<GlobalPoint>::const_iterator ipos = allCrossingPoints.begin(); ipos != allCrossingPoints.end(); ++ipos) {
359 vector<const GeomDet*>::const_iterator
begin = tempDT.begin();
360 vector<const GeomDet*>::const_iterator
end = tempDT.end();
363 total.push_back(*begin);
366 allCrossingPoints.clear();
368 const vector<const DetLayer*>& csclayers =
theService->detLayerGeometry()->allCSCLayers();
369 for (
auto iLayer = csclayers.begin(); iLayer != csclayers.end(); ++iLayer) {
373 if ((fabs(xPoint.
y()) < 1000.0) && (fabs(xPoint.
z()) < 1500.0) &&
374 (!(xPoint.
y() == 0 && xPoint.
x() == 0 && xPoint.
z() == 0)))
375 allCrossingPoints.push_back(xPoint);
377 stable_sort(allCrossingPoints.begin(), allCrossingPoints.end(),
LessMag(innerPos));
379 vector<const GeomDet*> tempCSC;
380 for (vector<GlobalPoint>::const_iterator ipos = allCrossingPoints.begin(); ipos != allCrossingPoints.end(); ++ipos) {
382 vector<const GeomDet*>::const_iterator
begin = tempCSC.begin();
383 vector<const GeomDet*>::const_iterator
end = tempCSC.end();
386 total.push_back(*begin);
410 float a = p1.
x() - slope * p1.
y();
412 float n2 = (1 + slope *
slope);
413 float n1 = 2 * a *
slope;
418 if (n1 * n1 - 4 * n2 * n0 > 0) {
419 y1 = (-n1 +
sqrt(n1 * n1 - 4 * n2 * n0)) / (2 * n2);
420 y2 = (-n1 -
sqrt(n1 * n1 - 4 * n2 * n0)) / (2 * n2);
423 float x1 = p1.
x() + slope * (y1 - p1.
y());
424 float x2 = p1.
x() + slope * (y2 - p1.
y());
426 float slopeZ = dp.
z() / dp.
y();
428 float z1 = p1.
z() + slopeZ * (y1 - p1.
y());
429 float z2 = p1.
z() + slopeZ * (y2 - p1.
y());
432 if ((p2.x() * x1 > 0) && (y1 * p2.y() > 0) && (z1 * p2.z() > 0)) {
452 float diskZ = disk.position().z();
453 int endcap = diskZ > 0 ? 1 : (diskZ < 0 ? -1 : 0);
458 float slopeZ = dp.
z() / dp.
y();
459 float y1 = diskZ / slopeZ;
466 if (p2.z() * z1 > 0) {
479 if (gp.
z() < -680.0) {
482 }
else if (gp.
z() < -396.0) {
485 }
else if (gp.
z() < -126.8) {
488 }
else if (gp.
z() < 126.8) {
491 }
else if (gp.
z() < 396.0) {
494 }
else if (gp.
z() < 680.0) {
503 if (gp.
perp() > 680.0 && gp.
perp() < 755.0)
505 else if (gp.
perp() > 580.0)
507 else if (gp.
perp() > 480.0)
509 else if (gp.
perp() > 380.0)
516 float phistep =
M_PI / 6;
520 if (fabs(
deltaPhi(phigp, 0 * phistep)) < phistep)
521 sectors.push_back(1);
522 if (fabs(
deltaPhi(phigp, phistep)) < phistep)
523 sectors.push_back(2);
524 if (fabs(
deltaPhi(phigp, 2 * phistep)) < phistep)
525 sectors.push_back(3);
526 if (fabs(
deltaPhi(phigp, 3 * phistep)) < phistep) {
527 sectors.push_back(4);
529 sectors.push_back(13);
531 if (fabs(
deltaPhi(phigp, 4 * phistep)) < phistep)
532 sectors.push_back(5);
533 if (fabs(
deltaPhi(phigp, 5 * phistep)) < phistep)
534 sectors.push_back(6);
535 if (fabs(
deltaPhi(phigp, 6 * phistep)) < phistep)
536 sectors.push_back(7);
537 if (fabs(
deltaPhi(phigp, 7 * phistep)) < phistep)
538 sectors.push_back(8);
539 if (fabs(
deltaPhi(phigp, 8 * phistep)) < phistep)
540 sectors.push_back(9);
541 if (fabs(
deltaPhi(phigp, 9 * phistep)) < phistep) {
542 sectors.push_back(10);
544 sectors.push_back(14);
546 if (fabs(
deltaPhi(phigp, 10 * phistep)) < phistep)
547 sectors.push_back(11);
548 if (fabs(
deltaPhi(phigp, 11 * phistep)) < phistep)
549 sectors.push_back(12);
552 LogTrace(
category_) <<
"number of sectors to consider: " << sectors.size() << endl;
553 LogTrace(
category_) <<
"station: " << station <<
" wheels: " << minwheel <<
" " << maxwheel << endl;
555 vector<const GeomDet*>
result;
556 if (station > 4 || station < 1)
558 if (minwheel > 2 || maxwheel < -2)
561 for (vector<int>::const_iterator isector = sectors.begin(); isector != sectors.end(); ++isector) {
562 for (
int iwheel = minwheel; iwheel != maxwheel + 1; ++iwheel) {
563 DTChamberId chamberid(iwheel, station, (*isector));
564 result.push_back(
theService->trackingGeometry()->idToDet(chamberid));
568 LogTrace(
category_) <<
"number of GeomDets for this track: " << result.size() << endl;
589 if (fabs(gp.
z()) > 1000. && fabs(gp.
z()) < 1055.0) {
591 }
else if (fabs(gp.
z()) > 910.0 && fabs(gp.
z()) < 965.0) {
593 }
else if (fabs(gp.
z()) > 800.0 && fabs(gp.
z()) < 860.0) {
595 }
else if (fabs(gp.
z()) > 570.0 && fabs(gp.
z()) < 730.0) {
601 float phistep1 =
M_PI / 18.;
602 float phistep2 =
M_PI / 9.;
610 if (gp.
perp() > 100 && gp.
perp() < 270)
612 else if (gp.
perp() > 270 && gp.
perp() < 450)
614 else if (gp.
perp() > 450 && gp.
perp() < 695)
616 else if (gp.
perp() > 100 && gp.
perp() < 270)
619 }
else if (station == 2) {
620 if (gp.
perp() > 140 && gp.
perp() < 350)
622 else if (gp.
perp() > 350 && gp.
perp() < 700)
625 }
else if (station == 3) {
626 if (gp.
perp() > 160 && gp.
perp() < 350)
628 else if (gp.
perp() > 350 && gp.
perp() < 700)
631 }
else if (station == 4) {
632 if (gp.
perp() > 175 && gp.
perp() < 350)
634 else if (gp.
perp() > 350 && gp.
perp() < 700)
638 if (station > 1 && ring == 1) {
640 for (
int i = 0;
i < 18;
i++) {
641 if (fabs(
deltaPhi(phigp,
i * phistep2)) < phistep2)
642 sectors.push_back(
i + 1);
647 for (
int i = 0;
i < 36;
i++) {
648 if (fabs(
deltaPhi(phigp,
i * phistep1)) < phistep1)
649 sectors.push_back(
i + 1);
657 LogTrace(
category_) <<
"CSC number of sectors to consider: " << sectors.size() << endl;
660 vector<const GeomDet*>
result;
661 if (station > 4 || station < 1)
671 for (vector<int>::const_iterator isector = sectors.begin(); isector != sectors.end(); ++isector) {
672 for (
int ilayer = minlayer; ilayer != maxlayer + 1; ++ilayer) {
673 CSCDetId cscid(endcap, station, ring, (*isector), ilayer);
674 result.push_back(
theService->trackingGeometry()->idToDet(cscid));
694 vector<MuonRecHitContainer> muonRecHits(4);
697 vector<TransientTrackingRecHit::ConstRecHitContainer> muonCorrelatedHits(4);
704 bool dtOverlapToCheck =
false;
705 bool cscOverlapToCheck =
false;
707 for (vector<const GeomDet*>::const_iterator igd = compatibleLayers.begin(); igd != compatibleLayers.end(); igd++) {
709 DetId geoId = (*igd)->geographicalId();
720 int wheel = detid.wheel();
725 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_begin = muonCorrelatedHitsTmp.begin();
726 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_end = muonCorrelatedHitsTmp.end();
728 for (; hits_begin != hits_end; ++hits_begin) {
729 muonCorrelatedHits.at(station - 1).push_back(*hits_begin);
733 if (
abs(wheel) == 2 && station != 4 && station != 1)
734 dtOverlapToCheck =
true;
741 DTLayerId lid(detid, isuperlayer, ilayer);
744 vector<const TrackingRecHit*> subrechits = (*rechit).recHits();
745 for (vector<const TrackingRecHit*>::iterator irechit = subrechits.begin(); irechit != subrechits.end();
756 int ring = did.ring();
761 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_begin = muonCorrelatedHitsTmp.begin();
762 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_end = muonCorrelatedHitsTmp.end();
764 for (; hits_begin != hits_end; ++hits_begin) {
765 muonCorrelatedHits.at(station - 1).push_back(*hits_begin);
768 if ((station == 1 && ring == 3) && dtOverlapToCheck)
769 cscOverlapToCheck =
true;
774 if (!cscOverlapToCheck) {
785 if (temp.size() > 1) {
786 center = (temp.front()->globalPosition().perp() + temp.back()->globalPosition().perp()) / 2.;
788 center = temp.front()->globalPosition().perp();
793 muonRecHits.at(2).insert(muonRecHits.at(2).end(), tmpCSC1.begin(), tmpCSC1.end());
795 muonRecHits.at(1).insert(muonRecHits.at(1).end(), tmpCSC1.begin(), tmpCSC1.end());
823 const size_t nhit = muonRecHits[
stat].size();
826 muonRecHitsPhiBest.clear();
827 muonRecHitsPhiBest.reserve(nhit);
834 std::vector<size_t> clUppers;
835 for (
size_t ihit = 0; ihit < nhit; ++ihit) {
836 const size_t jhit = (ihit + 1) % nhit;
837 const double phi1 = muonRecHits[
stat].at(ihit)->globalPosition().barePhi();
838 const double phi2 = muonRecHits[
stat].at(jhit)->globalPosition().barePhi();
842 clUppers.push_back(ihit);
847 if (clUppers.empty()) {
849 const double refPhi = muonRecHits[
stat].at(0)->globalPosition().barePhi();
850 double dphilo = 0, dphihi = 0;
851 for (
auto&
hit : muonRecHits[
stat]) {
852 muonRecHitsPhiBest.push_back(
hit);
853 const double phi =
hit->globalPosition().barePhi();
857 dphimax =
std::abs(dphihi + dphilo);
861 size_t bestUpper = 0, bestLower = 0;
862 for (
auto icl = clUppers.begin(); icl != clUppers.end(); ++icl) {
864 const size_t upper = *icl;
866 const auto prevCl = (icl == clUppers.begin()) ? clUppers.end() : icl;
867 const size_t lower = (*(prevCl - 1) + 1) % nhit;
873 const double phi1 = muonRecHits[
stat].at(upper)->globalPosition().barePhi();
874 const double phi2 = muonRecHits[
stat].at(lower)->globalPosition().barePhi();
877 if (dphimax < dphi) {
884 if (bestUpper > bestLower) {
885 muonRecHitsPhiBest.reserve(bestUpper - bestLower + 1);
887 muonRecHits[
stat].
begin() + bestUpper + 1,
888 std::back_inserter(muonRecHitsPhiBest));
889 }
else if (bestUpper < bestLower) {
890 muonRecHitsPhiBest.reserve(bestUpper + (nhit - bestLower) + 1);
892 muonRecHits[
stat].
begin() + bestUpper + 1,
893 std::back_inserter(muonRecHitsPhiBest));
895 muonRecHits[
stat].
begin() + bestLower, muonRecHits[
stat].
end(), std::back_inserter(muonRecHitsPhiBest));
900 if (!muonRecHitsPhiBest.empty()) {
901 muonRecHits[
stat] = muonRecHitsPhiBest;
903 muonRecHits[
stat].front();
909 if (!muonCorrelatedHits.at(
stat).empty()) {
911 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator
iseed = muonCorrelatedHits.at(
stat).begin();
912 iseed != muonCorrelatedHits.at(
stat).end();
914 if (!(*iseed)->isValid())
917 muonRecHitsThetaTemp.clear();
919 if (muonRecHitsThetaTemp.size() > 1) {
920 float dtheta = fabs((
float)muonRecHitsThetaTemp.back()->globalPosition().theta() -
921 (
float)muonRecHitsThetaTemp.front()->globalPosition().theta());
922 if (dtheta > dthetamax) {
924 muonRecHitsThetaBest = muonRecHitsThetaTemp;
931 if (muonRecHitsThetaBest.size() > 1 && muonRecHitsPhiBest.size() > 1)
933 muonRecHitsPhiBest.back()->globalPosition().barePhi()),
935 pow(muonRecHitsThetaBest.front()->globalPosition().theta() -
936 muonRecHitsThetaBest.back()->globalPosition().theta(),
941 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)
T getParameter(std::string const &) const
std::pair< const_iterator, const_iterator > range
iterator range
bool isStandAloneMuon() const override
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
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
std::vector< int > nStationHits
number of all the muon RecHits per chamber crossed by a track (1D hits)
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
bool isGlobalMuon() const override
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
virtual const BoundDisk & specificSurface() const final
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
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
std::vector< MuonRecHitPointer > MuonRecHitContainer
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