28 inputCollection_(iConfig.getParameter<
edm::InputTag>(
"InputCollection")),inputLinksCollection_(iConfig.getParameter<
edm::InputTag>(
"InputLinksCollection")),theService(
nullptr),theGlbRefitter(
nullptr),theGlbMatcher(
nullptr)
49 produces<edm::ValueMap<reco::MuonQuality> >();
62 const std::string theCategory =
"Muon|RecoMuon|GlobalTrackQualityProducer";
84 std::vector<reco::MuonQuality> valuesQual;
85 valuesQual.reserve(glbMuons->size());
88 for (reco::TrackCollection::const_iterator
track = glbMuons->begin();
track!=glbMuons->end(); ++
track , ++trackIndex) {
94 LogTrace(theCategory)<<
"GLBQual N refitted " << refitted.size();
96 std::pair<double,double> thisKink;
97 double relative_muon_chi2 = 0.0;
98 double relative_tracker_chi2 = 0.0;
99 double glbTrackProbability = 0.0;
100 if(!refitted.empty()) {
101 thisKink =
kink(refitted.front()) ;
102 std::pair<double,double> chi =
newChi2(refitted.front());
103 relative_muon_chi2 = chi.second;
104 relative_tracker_chi2 = chi.first;
108 LogTrace(theCategory)<<
"GLBQual: Kink " << thisKink.first <<
" " << thisKink.second;
109 LogTrace(theCategory)<<
"GLBQual: Rel Chi2 " << relative_tracker_chi2 <<
" " << relative_muon_chi2;
110 LogTrace(theCategory)<<
"GLBQual: trackProbability " << glbTrackProbability;
113 float chi2,
d, dist, Rpos;
114 chi2 = d = dist = Rpos = -1.0;
115 bool passTight =
false;
117 if ( linkCollectionHandle.
isValid() ) {
118 for ( reco::MuonTrackLinksCollection::const_iterator links = linkCollectionHandle->begin();
119 links != linkCollectionHandle->end(); ++links )
121 if ( links->trackerTrack().isNull() ||
122 links->standAloneTrack().isNull() ||
123 links->globalTrack().isNull() )
125 edm::LogWarning(theCategory) <<
"Global muon links to constituent tracks are invalid. There should be no such object. Muon is skipped.";
128 if (links->globalTrack() == glbRef) {
130 TrackCand staCand = TrackCand((
Trajectory*)
nullptr,links->standAloneTrack());
131 TrackCand tkCand = TrackCand((
Trajectory*)
nullptr,links->trackerTrack());
146 muQual.
trkKink = thisKink.first > maxFloat01 ? maxFloat01 : thisKink.first;
147 muQual.
glbKink = thisKink.second > maxFloat01 ? maxFloat01 : thisKink.second;
148 muQual.
trkRelChi2 = relative_tracker_chi2 > maxFloat01 ? maxFloat01 : relative_tracker_chi2;
149 muQual.
staRelChi2 = relative_muon_chi2 > maxFloat01 ? maxFloat01 : relative_muon_chi2;
156 valuesQual.push_back(muQual);
166 auto outQual = std::make_unique<edm::ValueMap<reco::MuonQuality>>();
168 fillerQual.insert(glbMuons, valuesQual.begin(), valuesQual.end());
177 const std::string theCategory =
"Muon|RecoMuon|GlobalTrackQualityProducer";
181 using namespace reco;
184 double resultGlb = 0.0;
188 typedef ConstRecHitPointer RecHit;
189 typedef std::vector<TrajectoryMeasurement>::const_iterator TMI;
192 vector<TrajectoryMeasurement> meas = muon.
measurements();
194 for ( TMI
m = meas.begin();
m != meas.end();
m++ ) {
199 RecHit rhit = (*m).recHit();
201 if ( rhit->isValid() ) {
210 if ( tsos.
isValid() && rhit->isValid() && rhit->hit()->isValid()
217 if ( phi1 < 0 ) phi1 = 2*
M_PI + phi1;
219 double phi2 = rhit->globalPosition().phi();
220 if ( phi2 < 0 ) phi2 = 2*
M_PI + phi2;
222 double diff = fabs(phi1 - phi2);
231 double s = ( error > 0.0 ) ? (diff*diff)/error : (diff*
diff);
240 return std::pair<double,double>(
result,resultGlb);
245 const std::string theCategory =
"Muon|RecoMuon|GlobalTrackQualityProducer";
249 using namespace reco;
253 unsigned int muNdof = 0;
254 unsigned int tkNdof = 0;
257 typedef ConstRecHitPointer RecHit;
258 typedef vector<TrajectoryMeasurement>::const_iterator TMI;
260 vector<TrajectoryMeasurement> meas = muon.
measurements();
262 for ( TMI
m = meas.begin();
m != meas.end();
m++ ) {
267 const auto& preciseHit = hit;
268 double estimate = 0.0;
269 if (preciseHit->isValid() && uptsos.
isValid()) {
276 if ( hit->isValid() && (hit->geographicalId().det()) ==
DetId::Tracker ) {
279 tkNdof += hit->dimension();
281 if ( hit->isValid() && (hit->geographicalId().det()) ==
DetId::Muon ) {
284 muNdof += hit->dimension();
290 if (tkNdof > 5 ) {tkChi2 /= (tkNdof-5.); }
294 if (muNdof > 5 ) {muChi2 /= (muNdof-5.); }
296 return std::pair<double,double>(tkChi2,muChi2);
338 descGlbMuonRefitter.
add<
std::string>(
"Fitter",
"KFFitterForRefitInsideOut");
339 descGlbMuonRefitter.
add<
std::string>(
"Smoother",
"KFSmootherForRefitInsideOut");
340 descGlbMuonRefitter.
add<
std::string>(
"Propagator",
"SmartPropagatorAnyRK");
341 descGlbMuonRefitter.
add<
std::string>(
"TrackerRecHitBuilder",
"WithAngleAndTemplate");
342 descGlbMuonRefitter.
add<
std::string>(
"MuonRecHitBuilder",
"MuonRecHitBuilder");
343 descGlbMuonRefitter.
add<
bool>(
"DoPredictionsOnly",
false);
344 descGlbMuonRefitter.
add<
std::string>(
"RefitDirection",
"insideOut");
345 descGlbMuonRefitter.
add<
bool>(
"PropDirForCosmics",
false);
346 descGlbMuonRefitter.
add<
bool>(
"RefitRPCHits",
true);
348 descGlbMuonRefitter.
add<std::vector<int>>(
"DYTthrs",{10, 10});
349 descGlbMuonRefitter.
add<
int>(
"DYTselector",1);
350 descGlbMuonRefitter.
add<
bool>(
"DYTupdator",
false);
351 descGlbMuonRefitter.
add<
bool>(
"DYTuseAPE",
false );
352 descGlbMuonRefitter.
add<
bool>(
"DYTuseThrsParametrization",
true);
355 descDYTthrs.
add<std::vector<double>>(
"eta0p8", {1,-0.919853, 0.990742});
356 descDYTthrs.
add<std::vector<double>>(
"eta1p2", {1,-0.897354, 0.987738});
357 descDYTthrs.
add<std::vector<double>>(
"eta2p0", {4,-0.986855, 0.998516});
358 descDYTthrs.
add<std::vector<double>>(
"eta2p2", {1,-0.940342, 0.992955});
359 descDYTthrs.
add<std::vector<double>>(
"eta2p4", {1,-0.947633, 0.993762});
363 descGlbMuonRefitter.
add<
int>(
"SkipStation", -1);
364 descGlbMuonRefitter.
add<
int>(
"TrackerSkipSystem",-1);
365 descGlbMuonRefitter.
add<
int>(
"TrackerSkipSection", -1);
366 descGlbMuonRefitter.
add<
bool>(
"RefitFlag",
true );
370 desc.
add<
double>(
"nSigma", 3.0);
371 desc.
add<
double>(
"MaxChi2", 100000.0);
373 descriptions.
add(
"globalTrackQualityProducer", desc);
void update(const edm::EventSetup &setup)
update the services each event
float chi2LocalPosition
chi2 value for the STA-TK matching of local position
T getParameter(std::string const &) const
GlobalMuonRefitter * theGlbRefitter
const edm::EventSetup & eventSetup() const
get the whole EventSetup
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
MuonServiceProxy * theService
float chi2LocalMomentum
chi2 value for the STA-TK matching of local momentum
std::pair< const Trajectory *, reco::TrackRef > TrackCand
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setAllowAnything()
allow any parameter label/value pairs
constexpr bool isNotFinite(T x)
bool updatedSta
bool returns true if standAloneMuon_updatedAtVtx was used in the fit
float glbKink
value of the kink algorithm applied to the global track
float LnChiSquaredProbability(double chiSquared, double nrDOF)
edm::EDGetTokenT< reco::TrackCollection > glbMuonsToken
bool matchTight(const TrackCand &sta, const TrackCand &track) const
check if two tracks are compatible (less than Chi2Cut, DeltaDCut, DeltaRCut)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Geom::Phi< T > phi() const
float glbTrackProbability
the tail probability (-ln(P)) of the global fit
void produce(edm::Event &, const edm::EventSetup &) override
GlobalPoint globalPosition() const
void setServices(const edm::EventSetup &)
set the services needed by the TrackTransformer
float trkKink
value of the kink algorithm applied to the inner track stub
float trkRelChi2
chi2 value for the inner track stub with respect to the global track
virtual std::pair< double, double > newChi2(Trajectory &muon) const
ProductID id() const
Accessor for product ID.
virtual double trackProbability(Trajectory &track) const
T phierr(const GlobalPoint &aPoint) const
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
virtual std::pair< double, double > kink(Trajectory &muon) const
DataContainer const & measurements() const
bool tightMatch
if the STA-TK matching passed the tighter matching criteria
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
edm::InputTag inputCollection_
float globalDeltaEtaPhi
global delta-Eta-Phi of STA-TK matching
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double match(const TrackCand &sta, const TrackCand &track, int matchOption=0, int surfaceOption=1) const
bool isNull() const
Checks for null.
MeasurementEstimator * theEstimator
edm::InputTag inputLinksCollection_
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
float staRelChi2
chi2 value for the outer track stub with respect to the global track
int ndof(bool bon=true) const
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< reco::MuonTrackLinksCollection > linkCollectionToken
float localDistance
local distance seperation for STA-TK TSOS matching on same surface
GlobalMuonTrackMatcher * theGlbMatcher
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
~GlobalTrackQualityProducer() override
Provenance getProvenance(BranchID const &theID) const
T const * product() const
std::vector< Trajectory > refit(const reco::Track &globalTrack, const int theMuonHitsOption, const TrackerTopology *tTopo) const
build combined trajectory from sta Track and tracker RecHits
GlobalTrackQualityProducer(const edm::ParameterSet &iConfig)