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 
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:367
MultiVertexReconstructor::~MultiVertexReconstructor
~MultiVertexReconstructor() override
Definition: MultiVertexReconstructor.cc:60
MultiVertexReconstructor
Definition: MultiVertexReconstructor.h:12
MultiVertexReconstructor::theFitter
MultiVertexFitter theFitter
Definition: MultiVertexReconstructor.h:36
mps_fire.i
i
Definition: mps_fire.py:428
MultiVertexReconstructor::clone
MultiVertexReconstructor * clone() const override
Definition: MultiVertexReconstructor.cc:62
CachingVertex< 5 >
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
MultiVertexFitter
Definition: MultiVertexFitter.h:15
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
MultiVertexFitter::vertices
std::vector< CachingVertex< 5 > > vertices(const std::vector< std::vector< reco::TransientTrack > > &, const std::vector< reco::TransientTrack > &primaries=std::vector< reco::TransientTrack >())
Definition: MultiVertexFitter.cc:233
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
MultiVertexReconstructor::MultiVertexReconstructor
MultiVertexReconstructor(const VertexReconstructor &, const AnnealingSchedule &s=DefaultMVFAnnealing(), float revive=-1.)
Definition: MultiVertexReconstructor.cc:55
alignCSCRings.s
s
Definition: alignCSCRings.py:92
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
w
const double w
Definition: UKUtility.cc:23
reco::BeamSpot
Definition: BeamSpot.h:21
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
MultiVertexReconstructor::reconstructor
VertexReconstructor * reconstructor() const
Definition: MultiVertexReconstructor.cc:147
AnnealingSchedule
Definition: AnnealingSchedule.h:6
VertexReconstructor::vertices
virtual std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &) const =0
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
VertexReconstructor
Definition: VertexReconstructor.h:13
DefaultLinearizationPointFinder
Definition: DefaultLinearizationPointFinder.h:13
MultiVertexFitter::TrackAndWeight
std::pair< reco::TransientTrack, float > TrackAndWeight
Definition: MultiVertexFitter.h:41
std
Definition: JetResolutionObject.h:76
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
MatrixUtil.remove
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:219
MultiVertexReconstructor::theOldReconstructor
VertexReconstructor * theOldReconstructor
Definition: MultiVertexReconstructor.h:35
MultiVertexReconstructor::vertices
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &, const reco::BeamSpot &) const override
Definition: MultiVertexReconstructor.cc:67
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
MultiVertexReconstructor.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37