Go to the documentation of this file.00001 #include "TMath.h"
00002 #include "DataFormats/MuonReco/interface/MuonCocktails.h"
00003 #include "DataFormats/TrackReco/interface/Track.h"
00004
00005
00006
00007
00008 reco::TrackRef muon::tevOptimized(const reco::TrackRef& combinedTrack,
00009 const reco::TrackRef& trackerTrack,
00010 const reco::TrackRef& tpfmsTrack,
00011 const reco::TrackRef& pickyTrack,
00012 const double tune1,
00013 const double tune2) {
00014
00015 const reco::TrackRef refit[4] = {
00016 trackerTrack,
00017 combinedTrack,
00018 tpfmsTrack,
00019 pickyTrack
00020 };
00021
00022
00023
00024
00025
00026
00027 double prob[4] = {0.};
00028 for (unsigned int i = 0; i < 4; ++i)
00029 if (refit[i].isNonnull() && refit[i]->numberOfValidHits())
00030 prob[i] = muon::trackProbability(refit[i]);
00031
00032
00033
00034
00035 int chosen = 3;
00036
00037
00038
00039 if (prob[3] == 0.) {
00040 if (prob[2] > 0.) chosen = 2;
00041 else if (prob[1] > 0.) chosen = 1;
00042 else if (prob[0] > 0.) chosen = 0;
00043 }
00044
00045
00046
00047
00048
00049
00050 if (prob[0] > 0. && prob[3] > 0. && (prob[3] - prob[0]) > tune1)
00051 chosen = 0;
00052 if (prob[2] > 0. && (prob[chosen] - prob[2]) > tune2)
00053 chosen = 2;
00054
00055
00056
00057 return refit[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 double muon::trackProbability(const reco::TrackRef track) {
00130
00131 int nDOF = (int)track->ndof();
00132 if ( nDOF > 0 && track->chi2()> 0) {
00133 return -log(TMath::Prob(track->chi2(), nDOF));
00134 } else {
00135 return 0.0;
00136 }
00137
00138 }
00139
00140
00141
00142
00143 reco::TrackRef muon::sigmaSwitch(const reco::TrackRef& combinedTrack,
00144 const reco::TrackRef& trackerTrack,
00145 const double nSigma,
00146 const double ptThreshold) {
00147
00148
00149 if (combinedTrack->pt() < ptThreshold || trackerTrack->pt() < ptThreshold)
00150 return trackerTrack;
00151
00152
00153
00154
00155 const double delta = fabs(trackerTrack->qoverp() - combinedTrack->qoverp());
00156 const double threshold = nSigma * trackerTrack->qoverpError();
00157 return delta > threshold ? trackerTrack : combinedTrack;
00158 }
00159
00160
00161
00162
00163 reco::TrackRef muon::TMR(const reco::TrackRef& trackerTrack,
00164 const reco::TrackRef& fmsTrack,
00165 const double tune) {
00166 double probTK = 0;
00167 double probFMS = 0;
00168
00169 if (trackerTrack.isNonnull() && trackerTrack->numberOfValidHits())
00170 probTK = muon::trackProbability(trackerTrack);
00171 if (fmsTrack.isNonnull() && fmsTrack->numberOfValidHits())
00172 probFMS = muon::trackProbability(fmsTrack);
00173
00174 bool TKok = probTK > 0;
00175 bool FMSok = probFMS > 0;
00176
00177 if (TKok && FMSok) {
00178 if (probFMS - probTK > tune)
00179 return trackerTrack;
00180 else
00181 return fmsTrack;
00182 }
00183 else if (FMSok)
00184 return fmsTrack;
00185 else if (TKok)
00186 return trackerTrack;
00187 else
00188 return reco::TrackRef();
00189 }