CMS 3D CMS Logo

MultiVertexReconstructor.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 
5 namespace {
6  typedef MultiVertexFitter::TrackAndWeight TrackAndWeight;
7 
8  int verbose() { return 0; }
9 
10 #ifndef __clang__
11  inline void remove(vector<TransientVertex>& vtces, const vector<reco::TransientTrack>& trks) {
12  cout << "[MultiVertexReconstructor] fixme remove not yet implemented" << endl;
13  // remove trks from vtces
14  }
15 #endif
16 
17  vector<vector<TrackAndWeight> > recover(const vector<TransientVertex>& vtces,
18  const vector<reco::TransientTrack>& trks) {
19  set<reco::TransientTrack> st;
20  for (vector<reco::TransientTrack>::const_iterator i = trks.begin(); i != trks.end(); ++i) {
21  st.insert(*i);
22  }
23 
24  vector<vector<TrackAndWeight> > bundles;
25  for (vector<TransientVertex>::const_iterator vtx = vtces.begin(); vtx != vtces.end(); ++vtx) {
26  vector<reco::TransientTrack> trks = vtx->originalTracks();
27  vector<TrackAndWeight> tnws;
28  for (vector<reco::TransientTrack>::const_iterator trk = trks.begin(); trk != trks.end(); ++trk) {
29  float w = vtx->trackWeight(*trk);
30  if (w > 1e-5) {
31  TrackAndWeight tmp(*trk, w);
32  set<reco::TransientTrack>::iterator pos = st.find(*trk);
33  if (pos != st.end()) {
34  st.erase(pos);
35  }
36  tnws.push_back(tmp);
37  };
38  };
39  bundles.push_back(tnws);
40  };
41 
42  if (bundles.empty())
43  return bundles;
44 
45  // now add not-yet assigned tracks
46  for (set<reco::TransientTrack>::const_iterator i = st.begin(); i != st.end(); ++i) {
47  // cout << "[MultiVertexReconstructor] recovering " << i->id() << endl;
48  TrackAndWeight tmp(*i, 0.);
49  bundles[0].push_back(tmp);
50  }
51  return bundles;
52  }
53 } // namespace
54 
56  const AnnealingSchedule& s,
57  float revive)
58  : theOldReconstructor(o.clone()), theFitter(MultiVertexFitter(s, DefaultLinearizationPointFinder(), revive)) {}
59 
61 
63 
65  : theOldReconstructor(o.theOldReconstructor->clone()), theFitter(o.theFitter) {}
66 
67 vector<TransientVertex> MultiVertexReconstructor::vertices(const vector<reco::TransientTrack>& trks,
68  const reco::BeamSpot& s) const {
69  return vertices(trks);
70 }
71 
72 vector<TransientVertex> MultiVertexReconstructor::vertices(const vector<reco::TransientTrack>& trks,
73  const vector<reco::TransientTrack>& primaries,
74  const reco::BeamSpot& s) const {
75  return vertices(trks, primaries);
76 }
77 
78 vector<TransientVertex> MultiVertexReconstructor::vertices(const vector<reco::TransientTrack>& trks) const {
79  /*
80  cout << "[MultiVertexReconstructor] input trks: ";
81  for ( vector< reco::TransientTrack >::const_iterator i=trks.begin();
82  i!=trks.end() ; ++i )
83  {
84  cout << i->id() << " ";
85  }
86  cout << endl;*/
87  vector<TransientVertex> tmp = theOldReconstructor->vertices(trks);
88  if (verbose()) {
89  cout << "[MultiVertexReconstructor] non-freezing seeder found " << tmp.size() << " vertices from " << trks.size()
90  << " tracks." << endl;
91  }
92  vector<vector<TrackAndWeight> > rc = recover(tmp, trks);
93  vector<CachingVertex<5> > cvts = theFitter.vertices(rc);
94  vector<TransientVertex> ret;
95  for (vector<CachingVertex<5> >::const_iterator i = cvts.begin(); i != cvts.end(); ++i) {
96  ret.push_back(*i);
97  };
98 
99  if (verbose()) {
100  cout << "[MultiVertexReconstructor] input " << tmp.size() << " vertices, output " << ret.size() << " vertices."
101  << endl;
102  };
103  return ret;
104 }
105 
106 vector<TransientVertex> MultiVertexReconstructor::vertices(const vector<reco::TransientTrack>& trks,
107  const vector<reco::TransientTrack>& primaries) const {
108  /*
109  cout << "[MultiVertexReconstructor] with " << primaries.size()
110  << " primaries!" << endl;
111  */
112 
113  map<reco::TransientTrack, bool> st;
114 
115  vector<reco::TransientTrack> total = trks;
116  for (vector<reco::TransientTrack>::const_iterator i = trks.begin(); i != trks.end(); ++i) {
117  st[(*i)] = true;
118  }
119 
120  // cout << "[MultiVertexReconstructor] FIXME dont just add up tracks. superpose" << endl;
121  for (vector<reco::TransientTrack>::const_iterator i = primaries.begin(); i != primaries.end(); ++i) {
122  if (!(st[(*i)])) {
123  total.push_back(*i);
124  }
125  }
126 
127  vector<TransientVertex> tmp = theOldReconstructor->vertices(total);
128 
129  if (verbose()) {
130  cout << "[MultiVertexReconstructor] freezing seeder found " << tmp.size() << " vertices from " << total.size()
131  << " tracks." << endl;
132  }
133  vector<vector<TrackAndWeight> > rc = recover(tmp, trks);
134  vector<CachingVertex<5> > cvts = theFitter.vertices(rc, primaries);
135 
136  vector<TransientVertex> ret;
137  for (vector<CachingVertex<5> >::const_iterator i = cvts.begin(); i != cvts.end(); ++i) {
138  ret.push_back(*i);
139  };
140  if (verbose()) {
141  cout << "[MultiVertexReconstructor] input " << tmp.size() << " vertices, output " << ret.size() << " vertices."
142  << endl;
143  };
144  return ret;
145 }
146 
std::vector< CachingVertex< 5 > > vertices(const std::vector< std::vector< reco::TransientTrack > > &, const std::vector< reco::TransientTrack > &primaries=std::vector< reco::TransientTrack >())
T w() const
bool verbose
ret
prodAgent to be discontinued
virtual std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &) const =0
VertexReconstructor * theOldReconstructor
VertexReconstructor * reconstructor() const
std::pair< reco::TransientTrack, float > TrackAndWeight
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &, const reco::BeamSpot &) const override
MultiVertexReconstructor(const VertexReconstructor &, const AnnealingSchedule &s=DefaultMVFAnnealing(), float revive=-1.)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
tmp
align.sh
Definition: createJobs.py:716
MultiVertexReconstructor * clone() const override