Go to the documentation of this file.00001 #include "DataFormats/MuonReco/interface/MuonCocktails.h"
00002 #include "TMath.h"
00003
00004 #include "DataFormats/TrackReco/interface/Track.h"
00005
00006 #include <TROOT.h>
00007
00008
00009
00010
00011 reco::TrackRef muon::tevOptimized( const reco::TrackRef& combinedTrack,
00012 const reco::TrackRef& trackerTrack,
00013 const reco::TrackToTrackMap tevMap1,
00014 const reco::TrackToTrackMap tevMap2,
00015 const reco::TrackToTrackMap tevMap3 ) {
00016
00017 std::vector<reco::TrackRef> refit(4);
00018 bool ok[4];
00019 ok[0] = true;
00020
00021 reco::TrackToTrackMap::const_iterator gmrTrack = tevMap1.find(combinedTrack);
00022 reco::TrackToTrackMap::const_iterator fmsTrack = tevMap2.find(combinedTrack);
00023 reco::TrackToTrackMap::const_iterator pmrTrack = tevMap3.find(combinedTrack);
00024
00025 ok[1] = gmrTrack != tevMap1.end();
00026 ok[2] = fmsTrack != tevMap2.end();
00027 ok[3] = pmrTrack != tevMap3.end();
00028
00029 double prob[4];
00030 int chosen=3;
00031
00032 if (ok[0]) refit[0] = trackerTrack;
00033 if (ok[1]) refit[1] = (*gmrTrack).val;
00034 if (ok[2]) refit[2] = (*fmsTrack).val;
00035 if (ok[3]) refit[3] = (*pmrTrack).val;
00036
00037 for (unsigned int i=0; i<4; i++)
00038 prob[i] = (ok[i] && refit[i]->numberOfValidHits())
00039 ? trackProbability(refit[i]) : 0.0;
00040
00041
00042
00043 if (prob[3]==0.){
00044 if (prob[2]>0.){
00045 chosen=2;
00046 } else {
00047 if (prob[1]>0.){
00048 chosen=1;
00049 } else {
00050 if (prob[0]>0.) chosen=0;
00051 }
00052 }
00053 }
00054 if ( prob[0]>0. && prob[3]>0. && ((prob[3]-prob[0]) > 30.) ) chosen=0;
00055 if ( prob[2]>0. && ((prob[chosen]-prob[2]) > 0.) ) chosen=2;
00056
00057 return refit.at(chosen);
00058 }
00059
00060
00061
00062
00063 reco::TrackRef muon::tevOptimizedOld( const reco::TrackRef& combinedTrack,
00064 const reco::TrackRef& trackerTrack,
00065 const reco::TrackToTrackMap tevMap1,
00066 const reco::TrackToTrackMap tevMap2,
00067 const reco::TrackToTrackMap tevMap3 ) {
00068
00069 std::vector<reco::TrackRef> refit(4);
00070 reco::TrackRef result;
00071 bool ok[4];
00072 ok[0] = true;
00073
00074 reco::TrackToTrackMap::const_iterator gmrTrack = tevMap1.find(combinedTrack);
00075 reco::TrackToTrackMap::const_iterator fmsTrack = tevMap2.find(combinedTrack);
00076 reco::TrackToTrackMap::const_iterator pmrTrack = tevMap3.find(combinedTrack);
00077
00078 ok[1] = gmrTrack != tevMap1.end();
00079 ok[2] = fmsTrack != tevMap2.end();
00080 ok[3] = pmrTrack != tevMap3.end();
00081
00082 double prob[4];
00083
00084 if (ok[0]) refit[0] = trackerTrack;
00085 if (ok[1]) refit[1] = (*gmrTrack).val;
00086 if (ok[2]) refit[2] = (*fmsTrack).val;
00087 if (ok[3]) refit[3] = (*pmrTrack).val;
00088
00089 for (unsigned int i=0; i<4; i++)
00090 prob[i] = (ok[i] && refit[i]->numberOfValidHits())
00091 ? trackProbability(refit[i]) : 0.0;
00092
00093
00094
00095 if (prob[1] ) result = refit[1];
00096 if ((prob[1] == 0) && prob[3]) result = refit[3];
00097
00098 if (prob[1] && prob[3] && ((prob[1] - prob[3]) > 0.05 )) result = refit[3];
00099
00100 if (prob[0] && prob[2] && fabs(prob[2] - prob[0]) > 30.) {
00101 result = refit[0];
00102 return result;
00103 }
00104
00105 if ((prob[1] == 0) && (prob[3] == 0) && prob[2]) result = refit[2];
00106
00107 reco::TrackRef tmin;
00108 double probmin = 0.0;
00109
00110 if (prob[1] && prob[3]) {
00111 probmin = prob[3]; tmin = refit[3];
00112 if ( prob[1] < prob[3] ) { probmin = prob[1]; tmin = refit[1]; }
00113 } else if ((prob[3] == 0) && prob[1]) {
00114 probmin = prob[1]; tmin = refit[1];
00115 } else if ((prob[1] == 0) && prob[3]) {
00116 probmin = prob[3]; tmin = refit[3];
00117 }
00118
00119 if (probmin && prob[2] && ( (probmin - prob[2]) > 3.5 )) {
00120 result = refit[2];
00121 }
00122
00123 return result;
00124 }
00125
00126
00127
00128
00129 reco::TrackRef muon::tevOptimized( const reco::Muon& muon,
00130 const reco::TrackToTrackMap tevMap1,
00131 const reco::TrackToTrackMap tevMap2,
00132 const reco::TrackToTrackMap tevMap3 ) {
00133 return muon::tevOptimized(muon.combinedMuon(), muon.track(),
00134 tevMap1, tevMap2, tevMap3);
00135 }
00136
00137
00138
00139
00140 reco::TrackRef muon::tevOptimizedOld( const reco::Muon& muon,
00141 const reco::TrackToTrackMap tevMap1,
00142 const reco::TrackToTrackMap tevMap2,
00143 const reco::TrackToTrackMap tevMap3 ) {
00144 return muon::tevOptimizedOld(muon.combinedMuon(), muon.track(),
00145 tevMap1, tevMap2, tevMap3);
00146 }
00147
00148
00149
00150
00151 double muon::trackProbability(const reco::TrackRef track) {
00152
00153 int nDOF = (int)track->ndof();
00154 if ( nDOF > 0 && track->chi2()> 0) {
00155 return -log(TMath::Prob(track->chi2(), nDOF));
00156 } else {
00157 return 0.0;
00158 }
00159
00160 }
00161
00162