File indexing completed on 2024-04-06 12:26:54
0001 #ifndef RecoMuon_GlobalTrackingTools_GlobalTrajectoryBuilderBase_H
0002 #define RecoMuon_GlobalTrackingTools_GlobalTrajectoryBuilderBase_H
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0022 #include "RecoMuon/TrackingTools/interface/MuonTrajectoryBuilder.h"
0023 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
0024 #include "FWCore/Framework/interface/ConsumesCollector.h"
0025
0026 #include "MagneticField/Engine/interface/MagneticField.h"
0027 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0028 #include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h"
0029 #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"
0030 #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
0031 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0032 #include "TrackingTools/TrackRefitter/interface/TrackTransformer.h"
0033 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0034 #include "TrackingTools/TrackFitters/interface/TrajectoryFitter.h"
0035 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
0036 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0037
0038
0039 class GlobalMuonTrackMatcher;
0040 class MuonDetLayerMeasurements;
0041 class MuonServiceProxy;
0042 class MuonTrackingRegionBuilder;
0043 class GlobalMuonRefitter;
0044 class TransientRecHitRecord;
0045
0046 class GlobalTrajectoryBuilderBase : public MuonTrajectoryBuilder {
0047 public:
0048 typedef TransientTrackingRecHit::RecHitContainer RecHitContainer;
0049 typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer;
0050 typedef TransientTrackingRecHit::RecHitPointer RecHitPointer;
0051 typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer;
0052 typedef MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer;
0053 typedef MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer;
0054 typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer;
0055 typedef MuonTransientTrackingRecHit::ConstMuonRecHitContainer ConstMuonRecHitContainer;
0056 typedef std::vector<Trajectory> TC;
0057 typedef TC::const_iterator TI;
0058
0059
0060 GlobalTrajectoryBuilderBase(const edm::ParameterSet&, const MuonServiceProxy*, edm::ConsumesCollector&);
0061
0062
0063 ~GlobalTrajectoryBuilderBase() override;
0064
0065
0066 MuonTrajectoryBuilder::TrajectoryContainer trajectories(const TrajectorySeed&) override {
0067 return MuonTrajectoryBuilder::TrajectoryContainer();
0068 }
0069
0070
0071 void setEvent(const edm::Event&) override;
0072
0073 protected:
0074 enum RefitDirection { inToOut, outToIn, undetermined };
0075
0076
0077 MuonTrajectoryBuilder::CandidateContainer build(const TrackCand&, MuonTrajectoryBuilder::CandidateContainer&) const;
0078
0079
0080 virtual std::vector<TrackCand> makeTkCandCollection(const TrackCand&) = 0;
0081
0082
0083 std::vector<TrackCand> chooseRegionalTrackerTracks(const TrackCand&, const std::vector<TrackCand>&);
0084
0085
0086 RectangularEtaPhiTrackingRegion defineRegionOfInterest(const reco::TrackRef&) const;
0087
0088
0089 void checkMuonHits(const reco::Track&, ConstRecHitContainer&, ConstRecHitContainer&, std::vector<int>&) const;
0090
0091
0092 ConstRecHitContainer selectMuonHits(const Trajectory&, const std::vector<int>&) const;
0093
0094
0095 ConstRecHitContainer selectTrackerHits(const ConstRecHitContainer&) const;
0096
0097
0098 void fixTEC(ConstRecHitContainer& all, double scl_x, double scl_y) const;
0099
0100
0101 const Trajectory* chooseTrajectory(const std::vector<Trajectory*>&, int) const;
0102
0103
0104 double trackProbability(const Trajectory&) const;
0105
0106
0107 void printHits(const ConstRecHitContainer&) const;
0108
0109
0110 void addTraj(TrackCand&) {}
0111
0112
0113 RefitDirection checkRecHitsOrdering(const ConstRecHitContainer&) const;
0114
0115
0116 TransientTrackingRecHit::ConstRecHitContainer getTransientRecHits(const reco::Track&) const;
0117
0118
0119 GlobalMuonTrackMatcher* trackMatcher() const { return theTrackMatcher; }
0120
0121
0122 const MuonServiceProxy* service() const { return theService; }
0123
0124 struct ComparatorInOut {
0125 bool operator()(const TransientTrackingRecHit::ConstRecHitPointer& a,
0126 const TransientTrackingRecHit::ConstRecHitPointer& b) const {
0127 bool barrel_a = (a->det()->subDetector() == GeomDetEnumerators::DT ||
0128 a->det()->subDetector() == GeomDetEnumerators::RPCBarrel);
0129
0130 bool barrel_b = (b->det()->subDetector() == GeomDetEnumerators::DT ||
0131 b->det()->subDetector() == GeomDetEnumerators::RPCBarrel);
0132
0133 if (barrel_a && barrel_b)
0134 return a->det()->surface().position().perp() < b->det()->surface().position().perp();
0135
0136 else if (!barrel_a && !barrel_b)
0137 return fabs(a->globalPosition().z()) < fabs(b->globalPosition().z());
0138 else if (barrel_a && !barrel_b)
0139 return true;
0140 else if (!barrel_a && barrel_b)
0141 return false;
0142
0143 return false;
0144 }
0145 };
0146
0147 std::string theCategory;
0148 float thePtCut;
0149 float thePCut;
0150
0151 private:
0152 GlobalMuonTrackMatcher* theTrackMatcher;
0153 MuonDetLayerMeasurements* theLayerMeasurements;
0154 TrackTransformer* theTrackTransformer;
0155 MuonTrackingRegionBuilder* theRegionBuilder;
0156 const MuonServiceProxy* theService;
0157 GlobalMuonRefitter* theGlbRefitter;
0158 bool theRPCInTheFit;
0159 bool theRefitFlag;
0160 int theMuonHitsOption;
0161 float theTECxScale;
0162 float theTECyScale;
0163 std::string theTrackerPropagatorName;
0164 const edm::Event* theEvent;
0165 edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theTrackerRecHitBuilderToken;
0166 const TransientTrackingRecHitBuilder* theTrackerRecHitBuilder;
0167 edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theMuonRecHitBuilderToken;
0168 const TransientTrackingRecHitBuilder* theMuonRecHitBuilder;
0169 edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theTopoToken;
0170 const TrackerTopology* theTopo;
0171 edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
0172 const MagneticField* theField;
0173 edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> theMSMakerToken;
0174 const MultipleScatteringParametrisationMaker* theMSMaker;
0175 };
0176 #endif