1616//
1717//
1818
19- #include " Geometry/Records/interface/CaloGeometryRecord.h"
2019#include " TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h"
2120#include " TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
21+ #include " TrackingTools/TrackAssociator/interface/DetIdInfo.h"
22+ #include " TrackingTools/Records/interface/DetIdAssociatorRecord.h"
2223
23- // user include files
2424#include " FWCore/Framework/interface/Frameworkfwd.h"
25-
26- #include " FWCore/Framework/interface/Event.h"
27- #include " FWCore/Framework/interface/EventSetup.h"
28- #include " DataFormats/Common/interface/Handle.h"
2925#include " FWCore/Utilities/interface/isFinite.h"
26+ #include " DataFormats/Common/interface/Handle.h"
3027
28+ #include " DataFormats/DetId/interface/DetId.h"
3129#include " DataFormats/TrackReco/interface/Track.h"
3230#include " DataFormats/TrackReco/interface/TrackExtra.h"
3331#include " DataFormats/CaloTowers/interface/CaloTower.h"
3634#include " DataFormats/EgammaReco/interface/SuperCluster.h"
3735#include " DataFormats/DTRecHit/interface/DTRecHitCollection.h"
3836#include " DataFormats/EcalDetId/interface/EBDetId.h"
39- #include " DataFormats/DetId/interface/DetId.h"
40-
41- // calorimeter info
42- #include " Geometry/CaloGeometry/interface/CaloGeometry.h"
43- #include " Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
44- #include " Geometry/CaloGeometry/interface/CaloCellGeometry.h"
45- #include " DataFormats/EcalDetId/interface/EcalSubdetector.h"
46- #include " DataFormats/HcalDetId/interface/HcalSubdetector.h"
47- #include " DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
37+ #include " DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
38+ #include " DataFormats/DTRecHit/interface/DTRecSegment2D.h"
39+ #include " DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
40+ #include " DataFormats/GEMRecHit/interface/GEMSegmentCollection.h"
41+ #include " DataFormats/GEMRecHit/interface/ME0SegmentCollection.h"
4842
49- #include " Geometry/DTGeometry/interface/DTLayer.h"
50- #include " Geometry/DTGeometry/interface/DTGeometry.h"
43+ // calorimeter and muon infos
44+ #include " Geometry/CommonDetUnit/interface/GeomDet.h"
45+ #include " Geometry/Records/interface/CaloGeometryRecord.h"
5146#include " Geometry/Records/interface/MuonGeometryRecord.h"
52-
47+ # include " Geometry/DTGeometry/interface/DTGeometry.h "
5348#include " Geometry/CSCGeometry/interface/CSCGeometry.h"
54- #include " Geometry/CSCGeometry/interface/CSCChamberSpecs.h"
55-
5649#include " Geometry/GEMGeometry/interface/GEMGeometry.h"
5750#include " Geometry/GEMGeometry/interface/ME0Geometry.h"
5851
59- #include " DataFormats/GeometrySurface/interface/Cylinder.h"
60- #include " DataFormats/GeometrySurface/interface/Plane.h"
61-
62- #include " Geometry/CommonDetUnit/interface/GeomDet.h"
63-
64- #include " MagneticField/Engine/interface/MagneticField.h"
65- #include " MagneticField/Records/interface/IdealMagneticFieldRecord.h"
66-
6752#include " TrackPropagation/SteppingHelixPropagator/interface/SteppingHelixPropagator.h"
6853#include < stack>
6954#include < set>
7257#include " Math/VectorUtil.h"
7358#include < algorithm>
7459
75- #include " TrackingTools/TrackAssociator/interface/DetIdAssociator.h"
76- #include " TrackingTools/TrackAssociator/interface/DetIdInfo.h"
77- // #include "TrackingTools/TrackAssociator/interface/CaloDetIdAssociator.h"
78- // #include "TrackingTools/TrackAssociator/interface/EcalDetIdAssociator.h"
79- // #include "TrackingTools/TrackAssociator/interface/PreshowerDetIdAssociator.h"
80-
81- #include " DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
82- #include " DataFormats/DTRecHit/interface/DTRecSegment2D.h"
83- #include " DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
84- #include " DataFormats/GEMRecHit/interface/GEMSegmentCollection.h"
85- #include " DataFormats/GEMRecHit/interface/ME0SegmentCollection.h"
86- #include " DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
87-
8860#include " SimDataFormats/TrackingHit/interface/PSimHit.h"
8961#include " SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
90- #include " SimDataFormats/Track/interface/SimTrack.h"
9162#include " SimDataFormats/Track/interface/SimTrackContainer.h"
92- #include " SimDataFormats/Vertex/interface/SimVertex.h"
9363#include " SimDataFormats/Vertex/interface/SimVertexContainer.h"
9464#include " SimDataFormats/CaloHit/interface/PCaloHit.h"
9565#include " SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
9666
97- #include " TrackingTools/Records/interface/DetIdAssociatorRecord.h"
98-
9967using namespace reco ;
10068
10169TrackDetectorAssociator::TrackDetectorAssociator () {
@@ -119,7 +87,7 @@ void TrackDetectorAssociator::init(const edm::EventSetup& iSetup, const Associat
11987 // get the tracking Geometry
12088 theTrackingGeometry_ = &iSetup.getData (parameters.theTrackingGeometryToken );
12189
122- if (useDefaultPropagator_ && (!defProp_ || theMagneticFeildWatcher_ .check (iSetup))) {
90+ if (useDefaultPropagator_ && (!defProp_ || theMagneticFieldWatcher_ .check (iSetup))) {
12391 // setup propagator
12492 const MagneticField* bField = &iSetup.getData (parameters.bFieldToken );
12593
@@ -199,7 +167,7 @@ TrackDetMatchInfo TrackDetectorAssociator::associate(const edm::Event& iEvent,
199167
200168 // If track extras exist and outerState is before HO maximum, then use outerState
201169 if (outerState) {
202- if (outerState->position ().perp () < HOmaxR && fabs (outerState->position ().z ()) < HOmaxZ) {
170+ if (outerState->position ().perp () < HOmaxR && std::abs (outerState->position ().z ()) < HOmaxZ) {
203171 LogTrace (" TrackAssociator" ) << " Using outerState as trackOrigin at Rho=" << outerState->position ().perp ()
204172 << " Z=" << outerState->position ().z () << " \n " ;
205173 trackOrigin = SteppingHelixStateInfo (*outerState);
@@ -610,11 +578,11 @@ DetIdAssociator::MapRange TrackDetectorAssociator::getMapRange(const std::pair<f
610578 if (delta.first > 0 )
611579 mapRange.dThetaPlus += delta.first ;
612580 else
613- mapRange.dThetaMinus += fabs (delta.first );
581+ mapRange.dThetaMinus += std::abs (delta.first );
614582 if (delta.second > 0 )
615583 mapRange.dPhiPlus += delta.second ;
616584 else
617- mapRange.dPhiMinus += fabs (delta.second );
585+ mapRange.dPhiMinus += std::abs (delta.second );
618586 LogTrace (" TrackAssociator" ) << " Selection range: (dThetaPlus, dThetaMinus, dPhiPlus, dPhiMinus, dRPreselection): "
619587 << mapRange.dThetaPlus << " , " << mapRange.dThetaMinus << " , " << mapRange.dPhiPlus
620588 << " , " << mapRange.dPhiMinus << " , " << dR;
@@ -662,10 +630,8 @@ void TrackDetectorAssociator::getTAMuonChamberMatches(std::vector<TAMuonChamberM
662630 }
663631 LocalPoint localPoint = geomDet->surface ().toLocal (stateOnSurface.freeState ()->position ());
664632 LocalError localError = stateOnSurface.localError ().positionError ();
665- float distanceX = 0 ;
666- float distanceY = 0 ;
667- float sigmaX = 0.0 ;
668- float sigmaY = 0.0 ;
633+ float distanceX = 0 .f ;
634+ float distanceY = 0 .f ;
669635 if (const CSCChamber* cscChamber = dynamic_cast <const CSCChamber*>(geomDet)) {
670636 const CSCChamberSpecs* chamberSpecs = cscChamber->specs ();
671637 if (!chamberSpecs) {
@@ -687,28 +653,27 @@ void TrackDetectorAssociator::getTAMuonChamberMatches(std::vector<TAMuonChamberM
687653 float narrowWidth = wireTopology->narrowWidthOfPlane ();
688654 float length = wireTopology->lengthOfPlane ();
689655 // If slanted, there is no y offset between local origin and symmetry center of wire plane
690- float yOfFirstWire = fabs (wireTopology->wireAngle ()) > 1 .E -06 ? -0.5 * length : wireTopology->yOfWire (1 );
656+ float yOfFirstWire = std::abs (wireTopology->wireAngle ()) > 1 .E -06f ? -0.5 * length : wireTopology->yOfWire (1 );
691657 // y offset between local origin and symmetry center of wire plane
692- float yCOWPOffset = yOfFirstWire + 0.5 * length;
658+ float yCOWPOffset = yOfFirstWire + 0 .5f * length;
693659
694660 // tangent of the incline angle from inside the trapezoid
695- float tangent = (wideWidth - narrowWidth) / (2 . * length);
661+ float tangent = (wideWidth - narrowWidth) / (2 .f * length);
696662 // y position wrt bottom of trapezoid
697- float yPrime = localPoint.y () + fabs (yOfFirstWire);
663+ float yPrime = localPoint.y () + std::abs (yOfFirstWire);
698664 // half trapezoid width at y' is 0.5 * narrowWidth + x side of triangle with the above tangent and side y'
699- float halfWidthAtYPrime = 0.5 * narrowWidth + yPrime * tangent;
700- distanceX = fabs (localPoint.x ()) - halfWidthAtYPrime;
701- distanceY = fabs (localPoint.y () - yCOWPOffset) - 0.5 * length;
702- sigmaX = distanceX / sqrt (localError.xx ());
703- sigmaY = distanceY / sqrt (localError.yy ());
665+ float halfWidthAtYPrime = 0 .5f * narrowWidth + yPrime * tangent;
666+ distanceX = std::abs (localPoint.x ()) - halfWidthAtYPrime;
667+ distanceY = std::abs (localPoint.y () - yCOWPOffset) - 0 .5f * length;
704668 } else {
705- distanceX = fabs (localPoint.x ()) - geomDet->surface ().bounds ().width () / 2 .;
706- distanceY = fabs (localPoint.y ()) - geomDet->surface ().bounds ().length () / 2 .;
707- sigmaX = distanceX / sqrt (localError.xx ());
708- sigmaY = distanceY / sqrt (localError.yy ());
669+ distanceX = std::abs (localPoint.x ()) - 0 .5f * geomDet->surface ().bounds ().width ();
670+ distanceY = std::abs (localPoint.y ()) - 0 .5f * geomDet->surface ().bounds ().length ();
709671 }
710672 if ((distanceX < parameters.muonMaxDistanceX && distanceY < parameters.muonMaxDistanceY ) ||
711- (sigmaX < parameters.muonMaxDistanceSigmaX && sigmaY < parameters.muonMaxDistanceSigmaY )) {
673+ (distanceX * distanceX <
674+ localError.xx () * parameters.muonMaxDistanceSigmaX * parameters.muonMaxDistanceSigmaX &&
675+ distanceY * distanceY <
676+ localError.yy () * parameters.muonMaxDistanceSigmaY * parameters.muonMaxDistanceSigmaY )) {
712677 LogTrace (" TrackAssociator" ) << " found a match: " << DetIdInfo::info (*detId, nullptr ) << " \n " ;
713678 TAMuonChamberMatch match;
714679 match.tState = stateOnSurface;
@@ -719,7 +684,8 @@ void TrackDetectorAssociator::getTAMuonChamberMatches(std::vector<TAMuonChamberM
719684 } else {
720685 LogTrace (" TrackAssociator" ) << " chamber is too far: " << DetIdInfo::info (*detId, nullptr )
721686 << " \n\t distanceX: " << distanceX << " \t distanceY: " << distanceY
722- << " \t sigmaX: " << sigmaX << " \t sigmaY: " << sigmaY << " \n " ;
687+ << " \t sigmaX: " << distanceX / sqrt (localError.xx ())
688+ << " \t sigmaY: " << distanceY / sqrt (localError.yy ()) << " \n " ;
723689 }
724690 }
725691}
@@ -848,17 +814,17 @@ bool TrackDetectorAssociator::addTAMuonSegmentMatch(TAMuonChamberMatch& matchedC
848814 if (dtseg && (!dtseg->hasZed ()))
849815 isDTWithoutY = true ;
850816
851- double deltaPhi (fabs (segmentGlobalPosition.phi () - trajectoryStateOnSurface.freeState ()->position ().phi ()));
852- if (deltaPhi > M_PI)
853- deltaPhi = fabs (deltaPhi - M_PI * 2 .);
817+ float deltaPhi (std::abs (segmentGlobalPosition.phi () - trajectoryStateOnSurface.freeState ()->position ().phi ()));
818+ if (deltaPhi > float (M_PI))
819+ deltaPhi = std::abs (deltaPhi - float (M_PI) * 2 .f );
820+ float deltaEta = std::abs (segmentGlobalPosition.eta () - trajectoryStateOnSurface.freeState ()->position ().eta ());
854821
855822 if (isDTWithoutY) {
856823 isGood = deltaPhi < parameters.dRMuon ;
857824 // Be in chamber
858- isGood &= fabs (segmentGlobalPosition. eta () - trajectoryStateOnSurface. freeState ()-> position (). eta ()) < .3 ;
825+ isGood &= deltaEta < .3f ;
859826 } else
860- isGood = sqrt (pow (segmentGlobalPosition.eta () - trajectoryStateOnSurface.freeState ()->position ().eta (), 2 ) +
861- deltaPhi * deltaPhi) < parameters.dRMuon ;
827+ isGood = deltaEta * deltaEta + deltaPhi * deltaPhi < parameters.dRMuon * parameters.dRMuon ;
862828
863829 if (isGood) {
864830 TAMuonSegmentMatch muonSegment;
@@ -875,13 +841,13 @@ bool TrackDetectorAssociator::addTAMuonSegmentMatch(TAMuonChamberMatch& matchedC
875841 // AlgebraicSymMatrix segmentCovMatrix = segment->parametersError();
876842 // muonSegment.segmentLocalErrorXDxDz = segmentCovMatrix[2][0];
877843 // muonSegment.segmentLocalErrorYDyDz = segmentCovMatrix[3][1];
878- muonSegment.segmentLocalErrorXDxDz = -999 ;
879- muonSegment.segmentLocalErrorYDyDz = -999 ;
844+ muonSegment.segmentLocalErrorXDxDz = -999 . f ;
845+ muonSegment.segmentLocalErrorYDyDz = -999 . f ;
880846 muonSegment.hasZed = true ;
881847 muonSegment.hasPhi = true ;
882848
883849 // timing information
884- muonSegment.t0 = 0 ;
850+ muonSegment.t0 = 0 . f ;
885851 if (dtseg) {
886852 if ((dtseg->hasPhi ()) && (!isDTWithoutY)) {
887853 int phiHits = dtseg->phiSegment ()->specificRecHits ().size ();
@@ -960,8 +926,8 @@ void TrackDetectorAssociator::fillCaloTruth(const edm::Event& iEvent,
960926 }
961927 if (simTrack != simTracks->end ()) {
962928 info.simTrack = &(*simTrack);
963- double ecalTrueEnergy (0 );
964- double hcalTrueEnergy (0 );
929+ float ecalTrueEnergy (0 );
930+ float hcalTrueEnergy (0 );
965931
966932 // loop over calo hits
967933 for (PCaloHitContainer::const_iterator hit = simEcalHitsEB->begin (); hit != simEcalHitsEB->end (); ++hit)
@@ -979,10 +945,10 @@ void TrackDetectorAssociator::fillCaloTruth(const edm::Event& iEvent,
979945 info.ecalTrueEnergy = ecalTrueEnergy;
980946 info.hcalTrueEnergy = hcalTrueEnergy;
981947 info.hcalTrueEnergyCorrected = hcalTrueEnergy;
982- if (fabs (info.trkGlobPosAtHcal .eta ()) < 1.3 )
983- info.hcalTrueEnergyCorrected = hcalTrueEnergy * 113.2 ;
984- else if (fabs (info.trkGlobPosAtHcal .eta ()) < 3.0 )
985- info.hcalTrueEnergyCorrected = hcalTrueEnergy * 167.2 ;
948+ if (std::abs (info.trkGlobPosAtHcal .eta ()) < 1 .3f )
949+ info.hcalTrueEnergyCorrected = hcalTrueEnergy * 113 .2f ;
950+ else if (std::abs (info.trkGlobPosAtHcal .eta ()) < 3 .0f )
951+ info.hcalTrueEnergyCorrected = hcalTrueEnergy * 167 .2f ;
986952 }
987953}
988954
@@ -1028,7 +994,7 @@ TrackDetMatchInfo TrackDetectorAssociator::associate(const edm::Event& iEvent,
1028994 return associate (iEvent, iSetup, parameters, &referenceState, &outerState);
1029995 break ;
1030996 case OutsideIn: {
1031- cachedTrajectory_.setPropagationStep (-fabs (currentStepSize));
997+ cachedTrajectory_.setPropagationStep (-std::abs (currentStepSize));
1032998 TrackDetMatchInfo result = associate (iEvent, iSetup, parameters, &innerState, &referenceState);
1033999 cachedTrajectory_.setPropagationStep (currentStepSize);
10341000 return result;
@@ -1041,7 +1007,7 @@ TrackDetMatchInfo TrackDetectorAssociator::associate(const edm::Event& iEvent,
10411007 return associate (iEvent, iSetup, parameters, &innerState, &outerState);
10421008 break ;
10431009 case OutsideIn: {
1044- cachedTrajectory_.setPropagationStep (-fabs (currentStepSize));
1010+ cachedTrajectory_.setPropagationStep (-std::abs (currentStepSize));
10451011 TrackDetMatchInfo result = associate (iEvent, iSetup, parameters, &outerState, &innerState);
10461012 cachedTrajectory_.setPropagationStep (currentStepSize);
10471013 return result;
@@ -1051,9 +1017,9 @@ TrackDetMatchInfo TrackDetectorAssociator::associate(const edm::Event& iEvent,
10511017 // check if we deal with clear outside-in case
10521018 if (track.innerPosition ().Dot (track.innerMomentum ()) < 0 &&
10531019 track.outerPosition ().Dot (track.outerMomentum ()) < 0 ) {
1054- cachedTrajectory_.setPropagationStep (-fabs (currentStepSize));
1020+ cachedTrajectory_.setPropagationStep (-std::abs (currentStepSize));
10551021 TrackDetMatchInfo result;
1056- if (track.innerPosition ().R () < track.outerPosition ().R ())
1022+ if (track.innerPosition ().Mag2 () < track.outerPosition ().Mag2 ())
10571023 result = associate (iEvent, iSetup, parameters, &innerState, &outerState);
10581024 else
10591025 result = associate (iEvent, iSetup, parameters, &outerState, &innerState);
0 commit comments