CMS 3D CMS Logo

DivisiveVertexFinder.cc
Go to the documentation of this file.
7 #include <utility>
8 #include <vector>
9 #include <map>
10 #include <algorithm>
11 #include <cmath>
12 
14  double track_pt_max,
15  double track_chi2_max,
16  double track_prob_min,
17  double zOffset,
18  int ntrkMin,
19  bool useError,
20  double zSeparation,
21  bool wtAverage,
22  int verbosity)
23  : zOffset_(zOffset),
24  zSeparation_(zSeparation),
25  ntrkMin_(ntrkMin),
26  useError_(useError),
27  wtAverage_(wtAverage),
28  divmeth_(zOffset, ntrkMin, useError, zSeparation, wtAverage),
29  verbose_(verbosity) {
31 }
32 
34 
36  reco::VertexCollection &vertexes) { // output
38  Measurement1D vz;
39  if (wtAverage_) {
40  vz = pos.wtAverage(trks);
41  } else {
42  vz = pos.average(trks);
43  }
45  err(2, 2) = vz.error() * vz.error();
46 
47  reco::Vertex v(reco::Vertex::Point(0, 0, vz.value()), err, 0, 1, trks.size());
48  for (unsigned int i = 0; i < trks.size(); i++) {
49  double vz = trks[i]->vz();
50  if (edm::isNotFinite(vz))
51  continue;
52  v.add(reco::TrackBaseRef(trks[i]));
53  }
54 
55  vertexes.push_back(v);
56 
57  return true;
58 }
59 
62  const math::XYZPoint &bs) { // output
63  std::vector<PVCluster> in;
64  std::pair<std::vector<PVCluster>, std::vector<const reco::Track *> > out;
65 
66  // Convert input track collection into container needed by Wolfgang's templated code
67  // Need to save a map to reconvert from bare pointers, oy vey
68  std::map<const reco::Track *, reco::TrackRef> mapa;
69  // std::vector< std::vector< const reco::Track* > > trkps;
70  for (unsigned int i = 0; i < trks.size(); ++i) {
71  double vz = trks[i]->vz();
72  if (edm::isNotFinite(vz))
73  continue;
74  std::vector<const reco::Track *> temp;
75  temp.clear();
76  temp.push_back(&(*trks[i]));
77 
78  in.push_back(PVCluster(Measurement1D(trks[i]->dz(bs), trks[i]->dzError()), temp));
79  mapa[temp[0]] = trks[i];
80  }
81 
82  if (verbose_ > 0) {
83  edm::LogInfo("DivisiveVertexFinder") << "size of input vector of clusters " << in.size();
84  for (unsigned int i = 0; i < in.size(); ++i) {
85  edm::LogInfo("DivisiveVertexFinder")
86  << "Track " << i << " addr " << in[i].tracks()[0] << " dz " << in[i].tracks()[0]->dz(bs) << " +- "
87  << in[i].tracks()[0]->dzError() << " prodID " << mapa[in[i].tracks()[0]].id() << " dz from RefTrack "
88  << mapa[in[i].tracks()[0]]->dz(bs) << " +- " << mapa[in[i].tracks()[0]]->dzError();
89  }
90  }
91 
92  // Run the darn thing
94  out = divmeth_(in);
95 
96  if (verbose_ > 0)
97  edm::LogInfo("DivisiveVertexFinder") << " DivisiveClusterizer1D found " << out.first.size() << " vertexes";
98 
99  // Now convert the output yet again into something we can safely store in the event
100  for (unsigned int iv = 0; iv < out.first.size(); ++iv) { // loop over output vertexes
102  err(2, 2) = out.first[iv].position().error() * out.first[iv].position().error();
103 
104  reco::Vertex v(reco::Vertex::Point(0, 0, out.first[iv].position().value()), err, 0, 1, out.second.size());
105  if (verbose_ > 0)
106  edm::LogInfo("DivisiveVertexFinder")
107  << " DivisiveClusterizer1D vertex " << iv << " has " << out.first[iv].tracks().size()
108  << " tracks and a position of " << v.z() << " +- " << std::sqrt(v.covariance(2, 2));
109  for (unsigned int itrk = 0; itrk < out.first[iv].tracks().size(); ++itrk) {
110  v.add(reco::TrackBaseRef(mapa[out.first[iv].tracks()[itrk]]));
111  }
112  vertexes.push_back(v); // Done with horrible conversion, save it
113  }
114 
115  // Finally, sort the vertexes in decreasing sumPtSquared
116  // std::sort(vertexes.begin(), vertexes.end(), PVClusterComparer());
117  std::sort(vertexes.begin(), vertexes.end(), *pvComparer_);
118 
119  return true;
120 }
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
HLT_FULL_cff.track_pt_min
track_pt_min
Definition: HLT_FULL_cff.py:256
Measurement1D
Definition: Measurement1D.h:11
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track_prob_min
track_prob_min
Definition: HLT_FULL_cff.py:255
PVPositionBuilder.h
MessageLogger.h
PVCluster.h
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
HLT_FULL_cff.zSeparation
zSeparation
Definition: HLT_FULL_cff.py:104357
Measurement1D::value
double value() const
Definition: Measurement1D.h:25
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
DivisiveVertexFinder::findVertexesAlt
bool findVertexesAlt(const reco::TrackRefVector &trks, reco::VertexCollection &vertexes, const math::XYZPoint &bs)
Definition: DivisiveVertexFinder.cc:60
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
pos
Definition: PixelAliasList.h:18
Measurement1D.h
jets_cff.vertexes
vertexes
Definition: jets_cff.py:702
edm::RefVector< TrackCollection >
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
findQualityFiles.v
v
Definition: findQualityFiles.py:179
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
cms::cuda::bs
bs
Definition: HistoContainer.h:127
DivisiveVertexFinder::DivisiveVertexFinder
DivisiveVertexFinder(double track_pt_min, double track_pt_max, double track_chi2_max, double track_prob_min, double zOffset=5.0, int ntrkMin=5, bool useError=true, double zSeparation=0.05, bool wtAverage=true, int verbosity=0)
Definition: DivisiveVertexFinder.cc:13
PVCluster
Cluster1D< reco::Track > PVCluster
Definition: PVCluster.h:14
pixeltemp::DivisiveClusterizer1D::setBeamSpot
void setBeamSpot(const math::XYZPoint &bs)
Definition: DivisiveClusterizer1D.h:40
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DivisiveVertexFinder::pvComparer_
PVClusterComparer * pvComparer_
Definition: DivisiveVertexFinder.h:67
DivisiveVertexFinder.h
HLT_FULL_cff.track_chi2_max
track_chi2_max
Definition: HLT_FULL_cff.py:253
Measurement1D::error
double error() const
Definition: Measurement1D.h:27
HLT_FULL_cff.track_pt_max
track_pt_max
Definition: HLT_FULL_cff.py:254
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
recoMuon::in
Definition: RecoMuonEnumerators.h:6
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
PVPositionBuilder
Definition: PVPositionBuilder.h:17
reco::Vertex::Point
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
isFinite.h
PVValHelper::dz
Definition: PVValidationHelpers.h:50
DivisiveVertexFinder::findVertexes
bool findVertexes(const reco::TrackRefVector &trks, reco::VertexCollection &vertexes)
Run the divisive algorithm and return a vector of vertexes for the input track collection.
Definition: DivisiveVertexFinder.cc:35
DivisiveVertexFinder::divmeth_
pixeltemp::DivisiveClusterizer1D< reco::Track > divmeth_
We use Wolfgang's templated class that implements the actual divisive method.
Definition: DivisiveVertexFinder.h:61
edm::RefToBase< reco::Track >
DivisiveVertexFinder::verbose_
int verbose_
Definition: DivisiveVertexFinder.h:65
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
PVClusterComparer
Definition: PVClusterComparer.h:16
DivisiveVertexFinder::~DivisiveVertexFinder
~DivisiveVertexFinder()
Definition: DivisiveVertexFinder.cc:33
edm::RefVector::size
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
reco::Vertex
Definition: Vertex.h:35
DivisiveVertexFinder::wtAverage_
bool wtAverage_
Definition: DivisiveVertexFinder.h:58