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) {
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;
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();
370 for (; begin !=
end; ++begin) {
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();
393 for (; begin !=
end; ++begin) {
394 total.push_back(*begin);
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);
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;
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)
530 if (fabs(
deltaPhi(phigp, phistep)) < phistep)
532 if (fabs(
deltaPhi(phigp, 2 * phistep)) < phistep)
534 if (fabs(
deltaPhi(phigp, 3 * phistep)) < phistep) {
539 if (fabs(
deltaPhi(phigp, 4 * phistep)) < phistep)
541 if (fabs(
deltaPhi(phigp, 5 * phistep)) < phistep)
543 if (fabs(
deltaPhi(phigp, 6 * phistep)) < phistep)
545 if (fabs(
deltaPhi(phigp, 7 * phistep)) < phistep)
547 if (fabs(
deltaPhi(phigp, 8 * phistep)) < phistep)
549 if (fabs(
deltaPhi(phigp, 9 * phistep)) < phistep) {
554 if (fabs(
deltaPhi(phigp, 10 * phistep)) < phistep)
556 if (fabs(
deltaPhi(phigp, 11 * phistep)) < phistep)
563 vector<const GeomDet*>
result;
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) {
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)
628 if (
gp.perp() > 140 &&
gp.perp() < 350)
630 else if (
gp.perp() > 350 &&
gp.perp() < 700)
634 if (
gp.perp() > 160 &&
gp.perp() < 350)
636 else if (
gp.perp() > 350 &&
gp.perp() < 700)
640 if (
gp.perp() > 175 &&
gp.perp() < 350)
642 else if (
gp.perp() > 350 &&
gp.perp() < 700)
648 for (
int i = 0;
i < 18;
i++) {
649 if (fabs(
deltaPhi(phigp,
i * phistep2)) < phistep2)
655 for (
int i = 0;
i < 36;
i++) {
656 if (fabs(
deltaPhi(phigp,
i * phistep1)) < phistep1)
668 vector<const GeomDet*>
result;
679 for (vector<int>::const_iterator isector =
sectors.begin(); isector !=
sectors.end(); ++isector) {
680 for (
int ilayer = minlayer; ilayer != maxlayer + 1; ++ilayer) {
694 if (
muon.isGlobalMuon())
696 else if (
muon.isStandAloneMuon())
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);
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 "
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
std::pair< const_iterator, const_iterator > range
iterator range
static const double slope[3]
Global3DPoint GlobalPoint
std::vector< int > nStationHits
number of all the muon RecHits per chamber crossed by a track (1D hits)
constexpr Detector det() const
get the detector field from this detid
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
GlobalPoint globalPosition() const
static const int maxLayerId
highest layer id
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Abs< T >::type abs(const T &t)
static const int minLayerId
lowest layer id. 0 indicates a full SL
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
static const int maxSuperLayerId
highest superlayer id
DetId geographicalId() const
The label of this GeomDet.
T perp() const
Magnitude of transverse component.
std::vector< ConstRecHitPointer > ConstRecHitContainer
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
constexpr uint32_t rawId() const
get the raw id
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
static const int minSuperLayerId
loweset super layer id. 0 indicates a full chamber
Scalar radius() const
Radius of the cylinder.
std::vector< float > stationShowerSizeT
the transverse size of the hit cluster
virtual const BoundDisk & specificSurface() const final
Geom::Theta< T > theta() const
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)
std::vector< MuonRecHitPointer > MuonRecHitContainer
Power< A, B >::type pow(const A &a, const B &b)
std::vector< float > stationShowerDeltaR
the radius of the cone containing the all the hits around the track