29 : inputCollection_(iConfig.getParameter<
edm::
InputTag>(
"InputCollection")),
30 inputLinksCollection_(iConfig.getParameter<
edm::
InputTag>(
"InputLinksCollection")),
33 theGlbRefitter(nullptr),
34 theGlbMatcher(nullptr) {
54 produces<edm::ValueMap<reco::MuonQuality>>();
69 const std::string theCategory =
"Muon|RecoMuon|GlobalTrackQualityProducer";
88 std::vector<reco::MuonQuality> valuesQual;
89 valuesQual.reserve(glbMuons->size());
92 for (reco::TrackCollection::const_iterator
track = glbMuons->begin();
track != glbMuons->end();
93 ++
track, ++trackIndex) {
99 LogTrace(theCategory) <<
"GLBQual N refitted " << refitted.size();
101 std::pair<double, double> thisKink;
102 double relative_muon_chi2 = 0.0;
103 double relative_tracker_chi2 = 0.0;
104 double glbTrackProbability = 0.0;
105 if (!refitted.empty()) {
106 thisKink =
kink(refitted.front());
107 std::pair<double, double> chi =
newChi2(refitted.front());
108 relative_muon_chi2 = chi.second;
109 relative_tracker_chi2 = chi.first;
113 LogTrace(theCategory) <<
"GLBQual: Kink " << thisKink.first <<
" " << thisKink.second;
114 LogTrace(theCategory) <<
"GLBQual: Rel Chi2 " << relative_tracker_chi2 <<
" " << relative_muon_chi2;
115 LogTrace(theCategory) <<
"GLBQual: trackProbability " << glbTrackProbability;
118 float chi2,
d, dist, Rpos;
119 chi2 =
d = dist = Rpos = -1.0;
120 bool passTight =
false;
122 if (linkCollectionHandle.
isValid()) {
123 for (reco::MuonTrackLinksCollection::const_iterator
links = linkCollectionHandle->begin();
124 links != linkCollectionHandle->end();
126 if (
links->trackerTrack().isNull() ||
links->standAloneTrack().isNull() ||
links->globalTrack().isNull()) {
127 edm::LogWarning(theCategory) <<
"Global muon links to constituent tracks are invalid. There should be no "
128 "such object. Muon is skipped.";
131 if (
links->globalTrack() == glbRef) {
145 LogTrace(theCategory) <<
"GLBQual: Used UpdatedAtVtx : "
146 << (
iEvent.getStableProvenance(staTrack.
id()).productInstanceName() ==
154 iEvent.getStableProvenance(staTrack.
id()).productInstanceName() ==
std::string(
"UpdatedAtVtx");
155 muQual.
trkKink = thisKink.first > maxFloat01 ? maxFloat01 : thisKink.first;
156 muQual.
glbKink = thisKink.second > maxFloat01 ? maxFloat01 : thisKink.second;
157 muQual.
trkRelChi2 = relative_tracker_chi2 > maxFloat01 ? maxFloat01 : relative_tracker_chi2;
158 muQual.
staRelChi2 = relative_muon_chi2 > maxFloat01 ? maxFloat01 : relative_muon_chi2;
165 valuesQual.push_back(muQual);
175 auto outQual = std::make_unique<edm::ValueMap<reco::MuonQuality>>();
177 fillerQual.insert(glbMuons, valuesQual.begin(), valuesQual.end());
185 const std::string theCategory =
"Muon|RecoMuon|GlobalTrackQualityProducer";
189 using namespace reco;
192 double resultGlb = 0.0;
196 typedef std::vector<TrajectoryMeasurement>::const_iterator TMI;
198 vector<TrajectoryMeasurement> meas =
muon.measurements();
200 for (TMI
m = meas.begin();
m != meas.end();
m++) {
205 RecHit rhit = (*m).recHit();
207 if (rhit->isValid()) {
216 if (tsos.
isValid() && rhit->isValid() && rhit->hit()->isValid() &&
222 phi1 = 2 *
M_PI + phi1;
224 double phi2 = rhit->globalPosition().phi();
226 phi2 = 2 *
M_PI + phi2;
228 double diff = fabs(phi1 - phi2);
246 return std::pair<double, double>(
result, resultGlb);
250 const std::string theCategory =
"Muon|RecoMuon|GlobalTrackQualityProducer";
254 using namespace reco;
258 unsigned int muNdof = 0;
259 unsigned int tkNdof = 0;
263 typedef vector<TrajectoryMeasurement>::const_iterator TMI;
265 vector<TrajectoryMeasurement> meas =
muon.measurements();
267 for (TMI
m = meas.begin();
m != meas.end();
m++) {
272 const auto& preciseHit =
hit;
273 double estimate = 0.0;
274 if (preciseHit->isValid() && uptsos.
isValid()) {
284 tkNdof +=
hit->dimension();
289 muNdof +=
hit->dimension();
296 tkChi2 /= (tkNdof - 5.);
302 muChi2 /= (muNdof - 5.);
305 return std::pair<double, double>(tkChi2, muChi2);
312 if (
track.ndof() > 0 &&
track.chiSquared() > 0) {
343 descGlbMuonRefitter.
add<
std::string>(
"Fitter",
"KFFitterForRefitInsideOut");
344 descGlbMuonRefitter.
add<
std::string>(
"Smoother",
"KFSmootherForRefitInsideOut");
345 descGlbMuonRefitter.
add<
std::string>(
"Propagator",
"SmartPropagatorAnyRK");
346 descGlbMuonRefitter.
add<
std::string>(
"TrackerRecHitBuilder",
"WithAngleAndTemplate");
347 descGlbMuonRefitter.
add<
std::string>(
"MuonRecHitBuilder",
"MuonRecHitBuilder");
348 descGlbMuonRefitter.
add<
bool>(
"DoPredictionsOnly",
false);
349 descGlbMuonRefitter.
add<
std::string>(
"RefitDirection",
"insideOut");
350 descGlbMuonRefitter.
add<
bool>(
"PropDirForCosmics",
false);
351 descGlbMuonRefitter.
add<
bool>(
"RefitRPCHits",
true);
353 descGlbMuonRefitter.
add<std::vector<int>>(
"DYTthrs", {10, 10});
354 descGlbMuonRefitter.
add<
int>(
"DYTselector", 1);
355 descGlbMuonRefitter.
add<
bool>(
"DYTupdator",
false);
356 descGlbMuonRefitter.
add<
bool>(
"DYTuseAPE",
false);
357 descGlbMuonRefitter.
add<
bool>(
"DYTuseThrsParametrization",
true);
360 descDYTthrs.
add<std::vector<double>>(
"eta0p8", {1, -0.919853, 0.990742});
361 descDYTthrs.
add<std::vector<double>>(
"eta1p2", {1, -0.897354, 0.987738});
362 descDYTthrs.
add<std::vector<double>>(
"eta2p0", {4, -0.986855, 0.998516});
363 descDYTthrs.
add<std::vector<double>>(
"eta2p2", {1, -0.940342, 0.992955});
364 descDYTthrs.
add<std::vector<double>>(
"eta2p4", {1, -0.947633, 0.993762});
368 descGlbMuonRefitter.
add<
int>(
"SkipStation", -1);
369 descGlbMuonRefitter.
add<
int>(
"TrackerSkipSystem", -1);
370 descGlbMuonRefitter.
add<
int>(
"TrackerSkipSection", -1);
371 descGlbMuonRefitter.
add<
bool>(
"RefitFlag",
true);
375 desc.add<
double>(
"nSigma", 3.0);
376 desc.add<
double>(
"MaxChi2", 100000.0);
378 descriptions.
add(
"globalTrackQualityProducer",
desc);