59 produces<std::vector<reco::ME0Muon>>();
90 auto oc = std::make_unique<std::vector<ME0Muon>>();
91 std::vector<ME0Muon> TempStore;
98 for (std::vector<Track>::const_iterator thisTrack = generalTracks->begin(); thisTrack != generalTracks->end();
99 ++thisTrack, ++TrackNumber) {
103 if (
std::abs(thisTrack->eta()) < 1.8)
107 float zSign = thisTrack->pz() > 0 ? 1.0f : -1.0f;
112 int chargeReco = thisTrack->charge();
115 p3reco =
GlobalVector(thisTrack->outerPx(), thisTrack->outerPy(), thisTrack->outerPz());
116 r3reco =
GlobalVector(thisTrack->outerX(), thisTrack->outerY(), thisTrack->outerZ());
122 getFromFTS(initrecostate, p3reco, r3reco, chargeReco, covReco);
133 getFromFTS(finalrecostate, p3FinalReco_glob, r3FinalReco_globv, chargeReco, covFinalReco);
136 int SegmentNumber = 0;
139 double ClosestDelR2 = 999.;
141 for (
auto thisSegment = OurSegments->begin(); thisSegment != OurSegments->end(); ++thisSegment, ++SegmentNumber) {
142 ME0DetId id = thisSegment->me0DetId();
146 if (zSign *
chamber->toGlobal(thisSegment->localPosition()).
z() < 0)
149 GlobalPoint r3FinalReco_glob(r3FinalReco_globv.
x(), r3FinalReco_globv.
y(), r3FinalReco_globv.
z());
154 LocalPoint thisPosition(thisSegment->localPosition());
155 LocalVector thisDirection(thisSegment->localDirection().x(),
156 thisSegment->localDirection().y(),
157 thisSegment->localDirection().z());
161 for (
int i = 1;
i <= 4;
i++) {
162 for (
int j = 1;
j <= 4;
j++) {
163 thisCov(
i,
j) = thisSegment->parametersError()(
i,
j);
171 AlgebraicMatrix55 Ctmp = (jacobGlbToLoc * covFinalReco) * ROOT::Math::Transpose(jacobGlbToLoc);
173 for (
int i = 0;
i < 5; ++
i) {
174 for (
int j = 0;
j < 5; ++
j) {
175 C[
i][
j] = Ctmp[
i][
j];
179 Double_t sigmax =
sqrt(C[3][3] + thisSegment->localPositionError().xx());
180 Double_t sigmay =
sqrt(C[4][4] + thisSegment->localPositionError().yy());
182 bool X_MatchFound =
false, Y_MatchFound =
false, Dir_MatchFound =
false;
193 Dir_MatchFound =
true;
196 if (X_MatchFound && Y_MatchFound && Dir_MatchFound) {
197 TrackRef thisTrackRef(generalTracks, TrackNumber);
200 GlobalPoint TkPos(r3FinalReco_globv.
x(), r3FinalReco_globv.
y(), r3FinalReco_globv.
z());
203 if (thisDelR2 < ClosestDelR2) {
204 ClosestDelR2 = thisDelR2;
205 MuonCandidate =
reco::ME0Muon(thisTrackRef, (*thisSegment), SegmentNumber, chargeReco);
218 if (ClosestDelR2 < 500.) {
219 oc->push_back(MuonCandidate);
constexpr double deltaPhi(double phi1, double phi2)
const AlgebraicMatrix56 & jacobian() const
T getParameter(std::string const &) const
void setLocalTrackMomAtSurface(const LocalVector &localTrackMomAtSurface)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
CartesianTrajectoryError cartesianError() const
double thePHIDIR_RESIDUAL_CUT
bool getByToken(EDGetToken token, Handle< PROD > &result) const
FreeTrajectoryState getFTS(const GlobalVector &, const GlobalVector &, int, const AlgebraicSymMatrix66 &, const MagneticField *)
ME0SegmentMatcher(const edm::ParameterSet &)
Constructor.
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
edm::InputTag generalTracksTag
TrackCharge charge() const
void produce(edm::Event &, const edm::EventSetup &) override
Produce the ME0Segment collection.
void setGlobalTrackMomAtSurface(const GlobalVector &globalTrackMomAtSurface)
edm::EDGetTokenT< reco::TrackCollection > generalTracksToken_
ROOT::Math::SMatrix< double, 5, 6, ROOT::Math::MatRepStd< double, 5, 6 > > AlgebraicMatrix56
#define DEFINE_FWK_MODULE(type)
void setLocalTrackCov(const AlgebraicSymMatrix55 &trackCov)
CLHEP::HepMatrix AlgebraicMatrix
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
edm::InputTag OurSegmentsTag
static PlanePointer build(Args &&...args)
const ME0Chamber * chamber(ME0DetId id) const
Return a chamber given its id.
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< ME0SegmentCollection > OurSegmentsToken_
GlobalVector momentum() const
void setGlobalTrackCov(const AlgebraicSymMatrix66 &trackCov)
const AlgebraicSymMatrix66 & matrix() const
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
GlobalPoint position() const
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
~ME0SegmentMatcher() override
Destructor.
void getFromFTS(const FreeTrajectoryState &, GlobalVector &, GlobalVector &, int &, AlgebraicSymMatrix66 &)
void setGlobalTrackPosAtSurface(const GlobalPoint &globalTrackPosAtSurface)
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
void beginRun(edm::Run const &, edm::EventSetup const &) override
Global3DVector GlobalVector
void setLocalTrackPosAtSurface(const LocalPoint &localTrackPosAtSurface)