70 theDTRecHitLabel(par.getParameter<
InputTag>(
"DTRecSegmentLabel")),
71 theCSCRecHitLabel(par.getParameter<
InputTag>(
"CSCRecSegmentLabel")),
72 theCSCSegmentsLabel(par.getParameter<
InputTag>(
"CSCSegmentLabel")),
73 theDT4DRecSegmentLabel(par.getParameter<
InputTag>(
"DT4DRecSegmentLabel"))
91 category_ =
"MuonShowerInformationFiller";
93 for (
int istat = 0; istat < 4; istat++) {
147 for (
int istat = 0; istat < 4; istat++) {
195 for (chamberIdIt = dtSegments->id_begin();
196 chamberIdIt != dtSegments->id_end();
199 if (*chamberIdIt != chamberId)
continue;
205 iseg!=range.second;++iseg) {
206 if (iseg->dimension() != 4)
continue;
216 chamberId != cscSegments->id_end(); ++chamberId) {
218 if ((*chamberId).chamber() != did.chamber())
continue;
224 iseg!=range.second;++iseg) {
225 if (iseg->dimension() != 3)
continue;
236 if (segments.empty())
return allhitscorrelated;
241 if (segments.size() == 1)
return allhitscorrelated;
243 for (MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator iseg = segments.begin() + 1;
244 iseg != segments.end(); ++iseg) {
249 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit1 = hits1.begin();
250 ihit1 != hits1.end(); ++ihit1 ) {
252 bool usedbefore =
false;
255 GlobalPoint gp1dinsegHit = (*ihit1)->globalPosition();
257 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit2 = allhitscorrelated.begin();
258 ihit2 != allhitscorrelated.end(); ++ihit2 ) {
262 GlobalPoint gp1dinsegHit2 = (*ihit2)->globalPosition();
264 if ( (gp1dinsegHit2 - gp1dinsegHit).
mag() < 1.0 ) usedbefore =
true;
267 if ( !usedbefore ) allhitscorrelated.push_back(*ihit1);
271 return allhitscorrelated;
284 if ( muonRecHits.empty() )
return muonRecHits;
290 stable_sort(muonRecHits.begin(), muonRecHits.end(),
AbsLessDTheta(refpoint));
292 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit = muonRecHits.begin(); ihit != muonRecHits.end() - 1; ++ihit) {
293 if (fabs((*(ihit+1))->globalPosition().
theta() - (*ihit)->globalPosition().theta() ) < step) {
294 result.push_back(*ihit);
310 if ( muonRecHits.empty() )
return muonRecHits;
312 stable_sort(muonRecHits.begin(), muonRecHits.end(),
LessPerp());
314 MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator
315 seedhit = min_element(muonRecHits.begin(), muonRecHits.end(),
LessPerp());
317 MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator ihigh = seedhit;
318 MuonTransientTrackingRecHit::MuonRecHitContainer::const_iterator ilow = seedhit;
321 while (ihigh != muonRecHits.end()-1 && ( fabs((*(ihigh+1))->globalPosition().
perp() - (*ihigh)->globalPosition().perp() ) < step) ) {
324 while (ilow != muonRecHits.begin() && ( fabs((*ilow)->globalPosition().perp() - (*(ilow -1))->globalPosition().perp()) < step ) ) {
339 vector<const GeomDet*>
total;
342 LogTrace(
category_) <<
"Consider a track " << track.
p() <<
" eta: " << track.
eta() <<
" phi " << track.
phi() << endl;
351 vector<GlobalPoint> allCrossingPoints;
353 const vector<const DetLayer*>& dtlayers =
theService->detLayerGeometry()->allDTLayers();
355 for (
auto iLayer = dtlayers.begin(); iLayer != dtlayers.end(); ++iLayer) {
361 if ((fabs(xPoint.
y()) < 1000.0) && (fabs(xPoint.
z()) < 1500 ) &&
362 (!(xPoint.
y() == 0 && xPoint.
x() == 0 && xPoint.
z() == 0))) allCrossingPoints.push_back(xPoint);
365 stable_sort(allCrossingPoints.begin(), allCrossingPoints.end(),
LessMag(innerPos) );
367 vector<const GeomDet*> tempDT;
369 for (vector<GlobalPoint>::const_iterator ipos = allCrossingPoints.begin(); ipos != allCrossingPoints.end(); ++ipos) {
372 vector<const GeomDet*>::const_iterator
begin = tempDT.begin();
373 vector<const GeomDet*>::const_iterator
end = tempDT.end();
376 total.push_back(*begin);
380 allCrossingPoints.clear();
382 const vector<const DetLayer*>& csclayers =
theService->detLayerGeometry()->allCSCLayers();
383 for (
auto iLayer = csclayers.begin(); iLayer != csclayers.end(); ++iLayer) {
388 if ((fabs(xPoint.
y()) < 1000.0) && (fabs(xPoint.
z()) < 1500.0)
389 && (!(xPoint.
y() == 0 && xPoint.
x() == 0 && xPoint.
z() == 0))) allCrossingPoints.push_back(xPoint);
391 stable_sort(allCrossingPoints.begin(), allCrossingPoints.end(),
LessMag(innerPos) );
393 vector<const GeomDet*> tempCSC;
394 for (vector<GlobalPoint>::const_iterator ipos = allCrossingPoints.begin(); ipos != allCrossingPoints.end(); ++ipos) {
397 vector<const GeomDet*>::const_iterator
begin = tempCSC.begin();
398 vector<const GeomDet*>::const_iterator
end = tempCSC.end();
401 total.push_back(*begin);
431 float a = p1.
x() - slope * p1.
y();
433 float n2 = (1 + slope *
slope);
434 float n1 = 2*a*
slope;
439 if ( n1*n1 - 4*n2*n0 > 0 ) {
440 y1 = (-n1 +
sqrt(n1*n1 - 4*n2*n0) ) / (2 * n2);
441 y2 = (-n1 -
sqrt(n1*n1 - 4*n2*n0) ) / (2 * n2);
444 float x1 = p1.
x() + slope * (y1 - p1.
y());
445 float x2 = p1.
x() + slope * (y2 - p1.
y());
447 float slopeZ = dp.
z()/dp.
y();
449 float z1 = p1.
z() + slopeZ * (y1 - p1.
y());
450 float z2 = p1.
z() + slopeZ * (y2 - p1.
y());
453 if ((p2.x()*x1 > 0) && (y1*p2.y() > 0) && (z1*p2.z() > 0)) {
478 float diskZ = disk.position().z();
479 int endcap = diskZ > 0 ? 1 : (diskZ < 0 ? -1 : 0);
480 diskZ = diskZ + endcap*
dynamic_cast<const SimpleDiskBounds&
>(disk.bounds()).thickness()/2.;
484 float slopeZ = dp.
z()/dp.
y();
485 float y1 = diskZ / slopeZ;
508 if ( gp.
z() < -680.0 ) { minwheel = -3; maxwheel = -3;}
509 else if ( gp.
z() < -396.0 ) { minwheel = -2; maxwheel = -1;}
510 else if (gp.
z() < -126.8) { minwheel = -2; maxwheel = 0; }
511 else if (gp.
z() < 126.8) { minwheel = -1; maxwheel = 1; }
512 else if (gp.
z() < 396.0) { minwheel = 0; maxwheel = 2; }
513 else if (gp.
z() < 680.0) { minwheel = 1; maxwheel = 2; }
514 else { minwheel = 3; maxwheel = 3; }
517 if ( gp.
perp() > 680.0 && gp.
perp() < 755.0 ) station = 4;
518 else if ( gp.
perp() > 580.0 ) station = 3;
519 else if ( gp.
perp() > 480.0 ) station = 2;
520 else if ( gp.
perp() > 380.0 ) station = 1;
525 float phistep =
M_PI/6;
529 if ( fabs(
deltaPhi(phigp, 0*phistep)) < phistep ) sectors.push_back(1);
530 if ( fabs(
deltaPhi(phigp, phistep)) < phistep ) sectors.push_back(2);
531 if ( fabs(
deltaPhi(phigp, 2*phistep)) < phistep ) sectors.push_back(3);
532 if ( fabs(
deltaPhi(phigp, 3*phistep)) < phistep ) {
533 sectors.push_back(4);
534 if (station == 4) sectors.push_back(13);
536 if ( fabs(
deltaPhi(phigp, 4*phistep)) < phistep ) sectors.push_back(5);
537 if ( fabs(
deltaPhi(phigp, 5*phistep)) < phistep ) sectors.push_back(6);
538 if ( fabs(
deltaPhi(phigp, 6*phistep)) < phistep ) sectors.push_back(7);
539 if ( fabs(
deltaPhi(phigp, 7*phistep)) < phistep ) sectors.push_back(8);
540 if ( fabs(
deltaPhi(phigp, 8*phistep)) < phistep ) sectors.push_back(9);
541 if ( fabs(
deltaPhi(phigp, 9*phistep)) < phistep ) {
542 sectors.push_back(10);
543 if (station == 4) sectors.push_back(14);
545 if ( fabs(
deltaPhi(phigp, 10*phistep)) < phistep ) sectors.push_back(11);
546 if ( fabs(
deltaPhi(phigp, 11*phistep)) < phistep ) sectors.push_back(12);
549 LogTrace(
category_) <<
"number of sectors to consider: " << sectors.size() << endl;
550 LogTrace(
category_) <<
"station: " << station <<
" wheels: " << minwheel <<
" " << maxwheel << endl;
552 vector<const GeomDet*>
result;
553 if (station > 4 || station < 1)
return result;
554 if (minwheel > 2 || maxwheel < -2)
return result;
556 for (vector<int>::const_iterator isector = sectors.begin(); isector != sectors.end(); ++isector ) {
557 for (
int iwheel = minwheel; iwheel != maxwheel + 1; ++iwheel) {
558 DTChamberId chamberid(iwheel, station, (*isector));
559 result.push_back(
theService->trackingGeometry()->idToDet(chamberid));
563 LogTrace(
category_) <<
"number of GeomDets for this track: " << result.size() << endl;
577 if (gp.
z() > 0) {endcap = 1;}
else {endcap = 2;}
583 if ( fabs(gp.
z()) > 1000. && fabs(gp.
z()) < 1055.0 ) {
586 else if ( fabs(gp.
z()) > 910.0 && fabs(gp.
z()) < 965.0) {
589 else if ( fabs(gp.
z()) > 800.0 && fabs(gp.
z()) < 860.0) {
592 else if ( fabs(gp.
z()) > 570.0 && fabs(gp.
z()) < 730.0) {
598 float phistep1 =
M_PI/18.;
599 float phistep2 =
M_PI/9.;
608 if (gp.
perp() > 100 && gp.
perp() < 270) ring = 1;
609 else if (gp.
perp() > 270 && gp.
perp() < 450) ring = 2;
610 else if (gp.
perp() > 450 && gp.
perp() < 695) ring = 3;
611 else if (gp.
perp() > 100 && gp.
perp() < 270) ring = 4;
614 else if (station == 2) {
616 if (gp.
perp() > 140 && gp.
perp() < 350) ring = 1;
617 else if (gp.
perp() > 350 && gp.
perp() < 700) ring = 2;
620 else if (station == 3) {
622 if (gp.
perp() > 160 && gp.
perp() < 350) ring = 1;
623 else if (gp.
perp() > 350 && gp.
perp() < 700) ring = 2;
626 else if (station == 4) {
628 if (gp.
perp() > 175 && gp.
perp() < 350) ring = 1;
629 else if (gp.
perp() > 350 && gp.
perp() < 700) ring = 2;
633 if (station > 1 && ring == 1) {
636 for (
int i = 0;
i < 18;
i++) {
637 if ( fabs(
deltaPhi(phigp,
i*phistep2)) < phistep2 ) sectors.push_back(
i+1);
643 for (
int i = 0;
i < 36;
i++) {
644 if ( fabs(
deltaPhi(phigp,
i*phistep1)) < phistep1 ) sectors.push_back(
i+1);
652 LogTrace(
category_) <<
"CSC number of sectors to consider: " << sectors.size() << endl;
656 vector<const GeomDet*>
result;
657 if (station > 4 || station < 1)
return result;
658 if (endcap == 0)
return result;
659 if (ring == -1)
return result;
664 for (vector<int>::const_iterator isector = sectors.begin(); isector != sectors.end(); ++isector) {
665 for (
int ilayer = minlayer; ilayer != maxlayer + 1; ++ ilayer) {
666 CSCDetId cscid(endcap, station, ring, (*isector), ilayer);
667 result.push_back(
theService->trackingGeometry()->idToDet(cscid));
686 vector<MuonRecHitContainer> muonRecHits(4);
689 vector<TransientTrackingRecHit::ConstRecHitContainer> muonCorrelatedHits(4);
696 bool dtOverlapToCheck =
false;
697 bool cscOverlapToCheck =
false;
699 for (vector<const GeomDet*>::const_iterator igd = compatibleLayers.begin(); igd != compatibleLayers.end(); igd++ ) {
702 DetId geoId = (*igd)->geographicalId();
713 int wheel = detid.wheel();
717 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_begin = muonCorrelatedHitsTmp.begin();
718 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_end = muonCorrelatedHitsTmp.end();
720 for (; hits_begin!= hits_end;++hits_begin) {
721 muonCorrelatedHits.at(station-1).push_back(*hits_begin);
725 if (
abs(wheel) == 2 && station != 4 && station != 1) dtOverlapToCheck =
true;
731 DTLayerId lid(detid, isuperlayer, ilayer);
734 vector<const TrackingRecHit*> subrechits = (*rechit).recHits();
735 for (vector<const TrackingRecHit*>::iterator irechit = subrechits.begin(); irechit != subrechits.end(); ++irechit) {
747 int ring = did.ring();
751 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_begin = muonCorrelatedHitsTmp.begin();
752 TransientTrackingRecHit::ConstRecHitContainer::const_iterator hits_end = muonCorrelatedHitsTmp.end();
754 for (; hits_begin!= hits_end;++hits_begin) {
755 muonCorrelatedHits.at(station-1).push_back(*hits_begin);
758 if ((station == 1 && ring == 3) && dtOverlapToCheck) cscOverlapToCheck =
true;
764 if (!cscOverlapToCheck) {
771 if (temp.empty())
continue;
774 if (temp.size() > 1) {
775 center = (temp.front()->globalPosition().perp() + temp.back()->globalPosition().perp())/2.;
777 center = temp.front()->globalPosition().perp();
782 muonRecHits.at(2).insert(muonRecHits.at(2).end(),tmpCSC1.begin(),tmpCSC1.end());
784 muonRecHits.at(1).insert(muonRecHits.at(1).end(),tmpCSC1.begin(),tmpCSC1.end());
816 const size_t nhit = muonRecHits[
stat].size();
817 if (nhit < 2)
continue;
818 muonRecHitsPhiBest.clear();
819 muonRecHitsPhiBest.reserve(nhit);
826 std::vector<size_t> clUppers;
827 for (
size_t ihit = 0; ihit < nhit; ++ihit ) {
828 const size_t jhit = (ihit+1)%nhit;
829 const double phi1 = muonRecHits[
stat].at(ihit)->globalPosition().barePhi();
830 const double phi2 = muonRecHits[
stat].at(jhit)->globalPosition().barePhi();
833 if ( dphi >= 0.05 ) clUppers.push_back(ihit);
838 if ( clUppers.empty() ) {
840 const double refPhi = muonRecHits[
stat].at(0)->globalPosition().barePhi();
841 double dphilo = 0, dphihi = 0;
842 for (
auto&
hit : muonRecHits[
stat] ) {
843 muonRecHitsPhiBest.push_back(
hit);
844 const double phi =
hit->globalPosition().barePhi();
852 size_t bestUpper = 0, bestLower = 0;
853 for (
auto icl = clUppers.begin(); icl != clUppers.end(); ++icl ) {
855 const size_t upper = *icl;
857 const auto prevCl = (icl == clUppers.begin()) ? clUppers.end() : icl;
858 const size_t lower = (*(prevCl-1)+1)%nhit;
861 if ( upper == lower )
continue;
863 const double phi1 = muonRecHits[
stat].at(upper)->globalPosition().barePhi();
864 const double phi2 = muonRecHits[
stat].at(lower)->globalPosition().barePhi();
867 if ( dphimax < dphi ) {
874 if ( bestUpper > bestLower ) {
875 muonRecHitsPhiBest.reserve(bestUpper-bestLower+1);
878 std::back_inserter(muonRecHitsPhiBest));
879 }
else if ( bestUpper < bestLower ) {
880 muonRecHitsPhiBest.reserve(bestUpper+(nhit-bestLower)+1);
883 std::back_inserter(muonRecHitsPhiBest));
886 std::back_inserter(muonRecHitsPhiBest));
891 if (!muonRecHitsPhiBest.empty()) {
892 muonRecHits[
stat] = muonRecHitsPhiBest;
894 muonRecHits[
stat].front();
900 if (!muonCorrelatedHits.at(
stat).empty()) {
903 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator
iseed = muonCorrelatedHits.at(
stat).begin();
iseed != muonCorrelatedHits.at(
stat).end(); ++
iseed) {
904 if (!(*iseed)->isValid())
continue;
906 muonRecHitsThetaTemp.clear();
908 if (muonRecHitsThetaTemp.size() > 1) {
909 float dtheta = fabs((
float)muonRecHitsThetaTemp.back()->globalPosition().theta() - (
float)muonRecHitsThetaTemp.front()->globalPosition().theta());
910 if (dtheta > dthetamax) {
912 muonRecHitsThetaBest = muonRecHitsThetaTemp;
919 if (muonRecHitsThetaBest.size() > 1 && muonRecHitsPhiBest.size() > 1)
920 theStationShowerDeltaR.at(
stat) =
sqrt(
pow(
deltaPhi(muonRecHitsPhiBest.front()->globalPosition().barePhi(),muonRecHitsPhiBest.back()->globalPosition().barePhi()),2)+
pow(muonRecHitsThetaBest.front()->globalPosition().theta()-muonRecHitsThetaBest.back()->globalPosition().theta(),2));
924 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
def setup(process, global_tag, zero_tesla=False)
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