CMS 3D CMS Logo

GapClusterizerInZ.cc
Go to the documentation of this file.
4 
5 
6 using namespace std;
7 
8 
9 namespace {
10 
11  bool recTrackLessZ(const reco::TransientTrack & tk1,
12  const reco::TransientTrack & tk2)
13  {
15  }
16 
17 }
18 
19 
20 
22 {
23  // some defaults to avoid uninitialized variables
24  verbose_= conf.getUntrackedParameter<bool>("verbose", false);
25  zSep = conf.getParameter<double>("zSeparation");
26  if(verbose_) {std::cout << "TrackClusterizerInZ: algorithm=gap, zSeparation="<< zSep << std::endl;}
27 }
28 
29 
30 
32 {
33  return zSep;
34 }
35 
36 
37 
38 
39 vector< vector<reco::TransientTrack> >
40 GapClusterizerInZ::clusterize(const vector<reco::TransientTrack> & tracks)
41  const
42 {
43 
44  vector<reco::TransientTrack> tks = tracks; // copy to be sorted
45 
46  vector< vector<reco::TransientTrack> > clusters;
47  if (tks.empty()) return clusters;
48 
49  // sort in increasing order of z
50  stable_sort(tks.begin(), tks.end(), recTrackLessZ);
51 
52  // init first cluster
53  vector<reco::TransientTrack>::const_iterator it = tks.begin();
54  vector <reco::TransientTrack> currentCluster; currentCluster.push_back(*it);
55 
56  it++;
57  for ( ; it != tks.end(); it++) {
58 
59  double zPrev = currentCluster.back().stateAtBeamLine().trackStateAtPCA().position().z();
60  double zCurr = (*it).stateAtBeamLine().trackStateAtPCA().position().z();
61 
62  if ( abs(zCurr - zPrev) < zSeparation() ) {
63  // close enough ? cluster together
64  currentCluster.push_back(*it);
65  }
66  else {
67  // store current cluster, start new one
68  clusters.push_back(currentCluster);
69  currentCluster.clear();
70  currentCluster.push_back(*it);
71  }
72  }
73 
74  // store last cluster
75  clusters.push_back(currentCluster);
76 
77  return clusters;
78 
79 }
80 
81 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
GapClusterizerInZ(const edm::ParameterSet &conf)
TrajectoryStateClosestToBeamLine stateAtBeamLine() const
T z() const
Definition: PV3DBase.h:64
float zSeparation() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const
GlobalPoint position() const