Go to the documentation of this file.00001 #include "RecoVertex/MultiVertexFit/interface/MultiVertexReconstructor.h"
00002
00003 using namespace std;
00004
00005 namespace {
00006 typedef MultiVertexFitter::TrackAndWeight TrackAndWeight;
00007
00008 int verbose()
00009 {
00010 return 0;
00011 }
00012
00013 void remove ( vector < TransientVertex > & vtces,
00014 const vector < reco::TransientTrack > & trks )
00015 {
00016 cout << "[MultiVertexReconstructor] fixme remove not yet implemented" << endl;
00017
00018 }
00019
00020 vector < vector < TrackAndWeight > > recover (
00021 const vector < TransientVertex > & vtces, const vector < reco::TransientTrack > & trks )
00022 {
00023 set < reco::TransientTrack > st;
00024 for ( vector< reco::TransientTrack >::const_iterator i=trks.begin();
00025 i!=trks.end() ; ++i )
00026 {
00027 st.insert ( *i );
00028 }
00029
00030 vector < vector < TrackAndWeight > > bundles;
00031 for ( vector< TransientVertex >::const_iterator vtx=vtces.begin();
00032 vtx!=vtces.end() ; ++vtx )
00033 {
00034 vector < reco::TransientTrack > trks = vtx->originalTracks();
00035 vector < TrackAndWeight > tnws;
00036 for ( vector< reco::TransientTrack >::const_iterator trk=trks.begin();
00037 trk!=trks.end() ; ++trk )
00038 {
00039 float w = vtx->trackWeight ( *trk );
00040 if ( w > 1e-5 )
00041 {
00042 TrackAndWeight tmp ( *trk, w );
00043 set < reco::TransientTrack >::iterator pos = st.find( *trk );
00044 if ( pos != st.end() )
00045 {
00046 st.erase ( pos );
00047 }
00048 tnws.push_back ( tmp );
00049 };
00050 };
00051 bundles.push_back ( tnws );
00052 };
00053
00054 if ( bundles.size() == 0 ) return bundles;
00055
00056
00057 for ( set < reco::TransientTrack >::const_iterator i=st.begin();
00058 i!=st.end() ; ++i )
00059 {
00060
00061 TrackAndWeight tmp ( *i, 0. );
00062 bundles[0].push_back ( tmp );
00063 }
00064 return bundles;
00065 }
00066 }
00067
00068 MultiVertexReconstructor::MultiVertexReconstructor (
00069 const VertexReconstructor & o, const AnnealingSchedule & s, float revive ) :
00070 theOldReconstructor ( o.clone() ), theFitter (
00071 MultiVertexFitter ( s, DefaultLinearizationPointFinder(), revive ) )
00072 {
00073 }
00074
00075 MultiVertexReconstructor::~MultiVertexReconstructor()
00076 {
00077 delete theOldReconstructor;
00078 }
00079
00080 MultiVertexReconstructor * MultiVertexReconstructor::clone() const
00081 {
00082 return new MultiVertexReconstructor ( * this );
00083 }
00084
00085 MultiVertexReconstructor::MultiVertexReconstructor (
00086 const MultiVertexReconstructor & o ) :
00087 theOldReconstructor ( o.theOldReconstructor->clone() ),
00088 theFitter ( o.theFitter )
00089 {}
00090
00091 vector < TransientVertex > MultiVertexReconstructor::vertices (
00092 const vector < reco::TransientTrack > & trks,
00093 const reco::BeamSpot & s ) const
00094 {
00095 return vertices ( trks );
00096 }
00097
00098 vector < TransientVertex > MultiVertexReconstructor::vertices (
00099 const vector < reco::TransientTrack > & trks,
00100 const vector < reco::TransientTrack > & primaries,
00101 const reco::BeamSpot & s ) const
00102 {
00103 return vertices ( trks, primaries );
00104 }
00105
00106
00107 vector < TransientVertex > MultiVertexReconstructor::vertices (
00108 const vector < reco::TransientTrack > & trks ) const
00109 {
00110
00111
00112
00113
00114
00115
00116
00117
00118 vector < TransientVertex > tmp = theOldReconstructor->vertices ( trks );
00119 if ( verbose() )
00120 {
00121 cout << "[MultiVertexReconstructor] non-freezing seeder found " << tmp.size()
00122 << " vertices from " << trks.size() << " tracks." << endl;
00123 }
00124 vector < vector < TrackAndWeight > > rc = recover ( tmp, trks );
00125 vector < CachingVertex<5> > cvts = theFitter.vertices ( rc );
00126 vector < TransientVertex > ret;
00127 for ( vector< CachingVertex<5> >::const_iterator i=cvts.begin();
00128 i!=cvts.end() ; ++i )
00129 {
00130 ret.push_back ( *i );
00131 };
00132
00133 if ( verbose() )
00134 {
00135 cout << "[MultiVertexReconstructor] input " << tmp.size()
00136 << " vertices, output " << ret.size() << " vertices."
00137 << endl;
00138 };
00139 return ret;
00140 }
00141
00142 vector < TransientVertex > MultiVertexReconstructor::vertices (
00143 const vector < reco::TransientTrack > & trks,
00144 const vector < reco::TransientTrack > & primaries ) const
00145 {
00146
00147
00148
00149
00150
00151 map < reco::TransientTrack, bool > st;
00152
00153 vector < reco::TransientTrack > total = trks;
00154 for ( vector< reco::TransientTrack >::const_iterator i=trks.begin();
00155 i!=trks.end() ; ++i )
00156 {
00157 st[(*i)]=true;
00158 }
00159
00160
00161 for ( vector< reco::TransientTrack >::const_iterator i=primaries.begin();
00162 i!=primaries.end() ; ++i )
00163 {
00164 if (!(st[(*i)]))
00165 {
00166 total.push_back ( *i );
00167 }
00168 }
00169
00170 vector < TransientVertex > tmp = theOldReconstructor->vertices ( total );
00171
00172 if ( verbose() )
00173 {
00174 cout << "[MultiVertexReconstructor] freezing seeder found " << tmp.size()
00175 << " vertices from " << total.size() << " tracks." << endl;
00176 }
00177 vector < vector < TrackAndWeight > > rc = recover ( tmp, trks );
00178 vector < CachingVertex<5> > cvts = theFitter.vertices ( rc, primaries );
00179
00180 vector < TransientVertex > ret;
00181 for ( vector< CachingVertex<5> >::const_iterator i=cvts.begin();
00182 i!=cvts.end() ; ++i )
00183 {
00184 ret.push_back ( *i );
00185 };
00186 if ( verbose() )
00187 {
00188 cout << "[MultiVertexReconstructor] input " << tmp.size()
00189 << " vertices, output " << ret.size() << " vertices."
00190 << endl;
00191 };
00192 return ret;
00193 }
00194
00195 VertexReconstructor * MultiVertexReconstructor::reconstructor() const
00196 {
00197 return theOldReconstructor;
00198 }