29 inputCollection_(iConfig.getParameter<edm::InputTag>(
"InputCollection")),inputLinksCollection_(iConfig.getParameter<edm::InputTag>(
"InputLinksCollection")),theService(0),theGlbRefitter(0),theGlbMatcher(0)
42 double maxChi2 = iConfig.
getParameter<
double>(
"MaxChi2");
46 produces<edm::ValueMap<reco::MuonQuality> >();
59 const std::string theCategory =
"Muon|RecoMuon|GlobalTrackQualityProducer";
75 std::vector<reco::MuonQuality> valuesQual;
76 valuesQual.reserve(glbMuons->size());
79 for (reco::TrackCollection::const_iterator track = glbMuons->begin(); track!=glbMuons->end(); ++track , ++trackIndex) {
85 LogTrace(theCategory)<<
"GLBQual N refitted " << refitted.size();
87 std::pair<double,double> thisKink;
88 double relative_muon_chi2 = 0.0;
89 double relative_tracker_chi2 = 0.0;
90 double glbTrackProbability = 0.0;
91 if(refitted.size()>0) {
92 thisKink =
kink(refitted.front()) ;
93 std::pair<double,double> chi =
newChi2(refitted.front());
94 relative_muon_chi2 = chi.second;
95 relative_tracker_chi2 = chi.first;
99 LogTrace(theCategory)<<
"GLBQual: Kink " << thisKink.first <<
" " << thisKink.second;
100 LogTrace(theCategory)<<
"GLBQual: Rel Chi2 " << relative_tracker_chi2 <<
" " << relative_muon_chi2;
101 LogTrace(theCategory)<<
"GLBQual: trackProbability " << glbTrackProbability;
104 float chi2, d, dist, Rpos;
105 chi2 = d = dist = Rpos = -1.0;
106 bool passTight =
false;
108 if ( linkCollectionHandle.
isValid() ) {
109 for ( reco::MuonTrackLinksCollection::const_iterator links = linkCollectionHandle->begin();
110 links != linkCollectionHandle->end(); ++links )
112 if ( links->trackerTrack().isNull() ||
113 links->standAloneTrack().isNull() ||
114 links->globalTrack().isNull() )
116 edm::LogWarning(theCategory) <<
"Global muon links to constituent tracks are invalid. There should be no such object. Muon is skipped.";
119 if (links->globalTrack() == glbRef) {
121 TrackCand staCand = TrackCand((
Trajectory*)(0),links->standAloneTrack());
122 TrackCand tkCand = TrackCand((
Trajectory*)(0),links->trackerTrack());
132 if(!staTrack.
isNull())
LogTrace(theCategory)<<
"GLBQual: Used UpdatedAtVtx : " << (iEvent.
getProvenance(staTrack.
id()).productInstanceName() == std::string(
"UpdatedAtVtx"));
137 muQual.
trkKink = thisKink.first > maxFloat01 ? maxFloat01 : thisKink.first;
138 muQual.
glbKink = thisKink.second > maxFloat01 ? maxFloat01 : thisKink.second;
139 muQual.
trkRelChi2 = relative_tracker_chi2 > maxFloat01 ? maxFloat01 : relative_tracker_chi2;
140 muQual.
staRelChi2 = relative_muon_chi2 > maxFloat01 ? maxFloat01 : relative_muon_chi2;
147 valuesQual.push_back(muQual);
159 fillerQual.
insert(glbMuons, valuesQual.begin(), valuesQual.end());
168 const std::string theCategory =
"Muon|RecoMuon|GlobalTrackQualityProducer";
172 using namespace reco;
175 double resultGlb = 0.0;
180 typedef std::vector<TrajectoryMeasurement>::const_iterator TMI;
183 vector<TrajectoryMeasurement> meas = muon.
measurements();
185 for ( TMI
m = meas.begin();
m != meas.end();
m++ ) {
190 RecHit rhit = (*m).recHit();
192 if ( rhit->isValid() ) {
201 if ( tsos.
isValid() && rhit->isValid() && rhit->hit()->isValid()
202 && !std::isinf(rhit->localPositionError().xx())
203 && !std::isinf(rhit->localPositionError().xy())
204 && !std::isinf(rhit->localPositionError().yy())
205 && !
std::isnan(rhit->localPositionError().xx())
206 && !
std::isnan(rhit->localPositionError().xy())
207 && !
std::isnan(rhit->localPositionError().yy())
211 if ( phi1 < 0 ) phi1 = 2*
M_PI + phi1;
213 double phi2 = rhit->globalPosition().phi();
214 if ( phi2 < 0 ) phi2 = 2*
M_PI + phi2;
216 double diff = fabs(phi1 - phi2);
225 double s = ( error > 0.0 ) ? (diff*diff)/error : (diff*
diff);
234 return std::pair<double,double>(
result,resultGlb);
239 const std::string theCategory =
"Muon|RecoMuon|GlobalTrackQualityProducer";
243 using namespace reco;
247 unsigned int muNdof = 0;
248 unsigned int tkNdof = 0;
252 typedef vector<TrajectoryMeasurement>::const_iterator TMI;
254 vector<TrajectoryMeasurement> meas = muon.
measurements();
256 for ( TMI
m = meas.begin();
m != meas.end();
m++ ) {
260 double estimate = 0.0;
261 if (preciseHit->isValid() && uptsos.
isValid()) {
268 if ( hit->isValid() && (hit->geographicalId().det()) ==
DetId::Tracker ) {
271 tkNdof += hit->dimension();
273 if ( hit->isValid() && (hit->geographicalId().det()) ==
DetId::Muon ) {
276 muNdof += hit->dimension();
280 if (tkNdof < 6 ) tkChi2 = tkChi2;
281 else tkChi2 /= (tkNdof-5.);
283 if (muNdof < 6 ) muChi2 = muChi2;
284 else muChi2 /= (muNdof-5.);
286 return std::pair<double,double>(tkChi2,muChi2);
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
MuonServiceProxy * theService
float chi2LocalMomentum
chi2 value for the STA-TK matching of local momentum
std::pair< const Trajectory *, reco::TrackRef > TrackCand
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TransientTrackingRecHit &hit) const =0
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)
bool matchTight(const TrackCand &sta, const TrackCand &track) const
check if two tracks are compatible (less than Chi2Cut, DeltaDCut, DeltaRCut)
Geom::Phi< T > phi() const
float glbTrackProbability
the tail probability (-ln(P)) of the global fit
void insert(const H &h, I begin, I end)
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
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 isNull() const
Checks for null.
bool tightMatch
if the STA-TK matching passed the tighter matching criteria
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::InputTag inputCollection_
float globalDeltaEtaPhi
global delta-Eta-Phi of STA-TK matching
double match(const TrackCand &sta, const TrackCand &track, int matchOption=0, int surfaceOption=1) const
tuple Chi2MeasurementEstimator
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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
std::vector< Trajectory > refit(const reco::Track &globalTrack, const int theMuonHitsOption) const
build combined trajectory from sta Track and tracker RecHits
tuple GlobalMuonTrackMatcher
float localDistance
local distance seperation for STA-TK TSOS matching on same surface
GlobalMuonTrackMatcher * theGlbMatcher
virtual ~GlobalTrackQualityProducer()
virtual void produce(edm::Event &, const edm::EventSetup &)
ProductID id() const
Accessor for product ID.
Provenance getProvenance(BranchID const &theID) const
double chiSquared() const
GlobalTrackQualityProducer(const edm::ParameterSet &iConfig)