CMS 3D CMS Logo

DAClusterizerInZ_vect.h
Go to the documentation of this file.
1 #ifndef RecoVertex_PrimaryVertexProducer_DAClusterizerInZ_vect_h
2 #define RecoVertex_PrimaryVertexProducer_DAClusterizerInZ_vect_h
3 
16 #include <vector>
20 
22 public:
24 
25  // internal data structure for tracks
26  struct track_t {
27  std::vector<double> zpca_vec; // z-coordinate at point of closest approach to the beamline
28  std::vector<double> dz2_vec; // square of the error of z(pca)
29  std::vector<double> sum_Z_vec; // track contribution to the partition function, Z
30  std::vector<double> tkwt_vec; // track weight, close to 1.0 for most tracks
31  std::vector<unsigned int> kmin; // index of the first cluster within zrange
32  std::vector<unsigned int> kmax; // 1 + index of the last cluster within zrange
33  std::vector<const reco::TransientTrack *> tt; // a pointer to the Transient Track
34 
35  double osumtkwt; // 1. / (sum of all track weights)
36 
37  void addItemSorted(double new_zpca, double new_dz2, const reco::TransientTrack *new_tt, double new_tkwt) {
38  // sort tracks with decreasing resolution (note that dz2 = 1/sigma^2)
39  unsigned int i = 0;
40  for (i = 0; i < zpca_vec.size(); i++) {
41  if (new_dz2 > dz2_vec[i])
42  break;
43  }
44  insertItem(i, new_zpca, new_dz2, new_tt, new_tkwt);
45  }
46 
47  void insertItem(
48  unsigned int i, double new_zpca, double new_dz2, const reco::TransientTrack *new_tt, double new_tkwt) {
49  zpca_vec.insert(zpca_vec.begin() + i, new_zpca);
50  dz2_vec.insert(dz2_vec.begin() + i, new_dz2);
51  tt.insert(tt.begin() + i, new_tt);
52  tkwt_vec.insert(tkwt_vec.begin() + i, new_tkwt);
53  sum_Z_vec.insert(sum_Z_vec.begin() + i, 1.0);
54  kmin.insert(kmin.begin() + i, 0);
55  kmax.insert(kmax.begin() + i, 0);
56  }
57 
58  unsigned int getSize() const { return zpca_vec.size(); }
59 
60  // has to be called everytime the items are modified
61  void extractRaw() {
62  zpca = &zpca_vec.front();
63  dz2 = &dz2_vec.front();
64  tkwt = &tkwt_vec.front();
65  sum_Z = &sum_Z_vec.front();
66  }
67 
68  // pointers to the first element of vectors, needed for vectorized code
69  double *__restrict__ zpca;
70  double *__restrict__ dz2;
71  double *__restrict__ tkwt;
72  double *__restrict__ sum_Z;
73  };
74 
75  // internal data structure for clusters
76  struct vertex_t {
77  std::vector<double> zvtx_vec; // z coordinate
78  std::vector<double> rho_vec; // vertex "mass" for mass-constrained clustering
79  // --- temporary numbers, used during update
80  std::vector<double> exp_arg_vec;
81  std::vector<double> exp_vec;
82  std::vector<double> sw_vec;
83  std::vector<double> swz_vec;
84  std::vector<double> se_vec;
85  std::vector<double> swE_vec;
86 
87  unsigned int getSize() const { return zvtx_vec.size(); }
88 
89  void addItem(double new_zvtx, double new_rho) {
90  zvtx_vec.push_back(new_zvtx);
91  rho_vec.push_back(new_rho);
92  exp_arg_vec.push_back(0.0);
93  exp_vec.push_back(0.0);
94  sw_vec.push_back(0.0);
95  swz_vec.push_back(0.0);
96  se_vec.push_back(0.0);
97  swE_vec.push_back(0.0);
98 
99  extractRaw();
100  }
101 
102  void insertItem(unsigned int k, double new_zvtx, double new_rho, track_t &tks) {
103  zvtx_vec.insert(zvtx_vec.begin() + k, new_zvtx);
104  rho_vec.insert(rho_vec.begin() + k, new_rho);
105 
106  exp_arg_vec.insert(exp_arg_vec.begin() + k, 0.0);
107  exp_vec.insert(exp_vec.begin() + k, 0.0);
108  sw_vec.insert(sw_vec.begin() + k, 0.0);
109  swz_vec.insert(swz_vec.begin() + k, 0.0);
110  se_vec.insert(se_vec.begin() + k, 0.0);
111  swE_vec.insert(swE_vec.begin() + k, 0.0);
112 
113  // adjust vertex lists of tracks
114  for (unsigned int i = 0; i < tks.getSize(); i++) {
115  if (tks.kmin[i] > k) {
116  tks.kmin[i]++;
117  }
118  if ((tks.kmax[i] >= k) || (tks.kmax[i] == tks.kmin[i])) {
119  tks.kmax[i]++;
120  }
121  }
122 
123  extractRaw();
124  }
125 
126  void removeItem(unsigned int k, track_t &tks) {
127  zvtx_vec.erase(zvtx_vec.begin() + k);
128  rho_vec.erase(rho_vec.begin() + k);
129 
130  exp_arg_vec.erase(exp_arg_vec.begin() + k);
131  exp_vec.erase(exp_vec.begin() + k);
132  sw_vec.erase(sw_vec.begin() + k);
133  swz_vec.erase(swz_vec.begin() + k);
134  se_vec.erase(se_vec.begin() + k);
135  swE_vec.erase(swE_vec.begin() + k);
136 
137  // adjust vertex lists of tracks
138  for (unsigned int i = 0; i < tks.getSize(); i++) {
139  if (tks.kmax[i] > k) {
140  tks.kmax[i]--;
141  }
142  if ((tks.kmin[i] > k) || (((tks.kmax[i] < (tks.kmin[i] + 1)) && (tks.kmin[i] > 0)))) {
143  tks.kmin[i]--;
144  }
145  }
146 
147  extractRaw();
148  }
149 
150  // pointers to the first element of vectors, needed for vectorized code
151  double *__restrict__ zvtx;
152  double *__restrict__ rho;
153  double *__restrict__ exp_arg;
154  double *__restrict__ exp;
155  double *__restrict__ sw;
156  double *__restrict__ swz;
157  double *__restrict__ se;
158  double *__restrict__ swE;
159 
160  // has to be called everytime the items are modified
161  void extractRaw() {
162  zvtx = &zvtx_vec.front();
163  rho = &rho_vec.front();
164  exp = &exp_vec.front();
165  sw = &sw_vec.front();
166  swz = &swz_vec.front();
167  se = &se_vec.front();
168  swE = &swE_vec.front();
169  exp_arg = &exp_arg_vec.front();
170  }
171  };
172 
174 
175  std::vector<std::vector<reco::TransientTrack> > clusterize(
176  const std::vector<reco::TransientTrack> &tracks) const override;
177 
178  std::vector<TransientVertex> vertices(const std::vector<reco::TransientTrack> &tracks) const override;
179  std::vector<TransientVertex> vertices_no_blocks(const std::vector<reco::TransientTrack> &tracks) const;
180  std::vector<TransientVertex> vertices_in_blocks(const std::vector<reco::TransientTrack> &tracks) const;
181  std::vector<TransientVertex> fill_vertices(double beta, double rho0, track_t &tracks, vertex_t &vertices) const;
182 
183  track_t fill(const std::vector<reco::TransientTrack> &tracks) const;
184 
185  void set_vtx_range(double beta, track_t &gtracks, vertex_t &gvertices) const;
186 
187  void clear_vtx_range(track_t &gtracks, vertex_t &gvertices) const;
188 
189  unsigned int thermalize(
190  double beta, track_t &gtracks, vertex_t &gvertices, const double delta_max, const double rho0 = 0.) const;
191 
192  double update(
193  double beta, track_t &gtracks, vertex_t &gvertices, const double rho0 = 0, const bool updateTc = false) const;
194 
195  void dump(
196  const double beta, const vertex_t &y, const track_t &tks, const int verbosity = 0, const double rho0 = 0.) const;
197  bool merge(vertex_t &y, track_t &tks, double &beta) const;
198  bool purge(vertex_t &, track_t &, double &, const double) const;
199  bool split(const double beta, track_t &t, vertex_t &y, double threshold = 1.) const;
200 
201  double beta0(const double betamax, track_t const &tks, vertex_t const &y) const;
202  void verify(const vertex_t &v, const track_t &tks, unsigned int nv = 999999, unsigned int nt = 999999) const;
203 
204 private:
205  double zdumpcenter_;
206  double zdumpwidth_;
207 
208  double vertexSize_;
209  unsigned int maxIterations_;
211  double betamax_;
212  double betastop_;
213  double dzCutOff_;
214  double d0CutOff_;
215 
219  double zmerge_;
220  double betapurge_;
221 
222  unsigned int convergence_mode_;
223  double delta_highT_;
224  double delta_lowT_;
225 
226  double sel_zrange_;
227  const double zrange_min_ = 0.1; // smallest z-range to be included in a tracks cluster list
228 
230  unsigned int block_size_;
232 };
233 
234 //#ifndef DAClusterizerInZ_vect_h
235 #endif
double beta0(const double betamax, track_t const &tks, vertex_t const &y) const
void addItemSorted(double new_zpca, double new_dz2, const reco::TransientTrack *new_tt, double new_tkwt)
void insertItem(unsigned int k, double new_zvtx, double new_rho, track_t &tks)
bool merge(vertex_t &y, track_t &tks, double &beta) const
void clear_vtx_range(track_t &gtracks, vertex_t &gvertices) const
bool purge(vertex_t &, track_t &, double &, const double) const
static void fillPSetDescription(edm::ParameterSetDescription &desc)
std::vector< const reco::TransientTrack * > tt
std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const override
void addItem(double new_zvtx, double new_rho)
std::vector< TransientVertex > fill_vertices(double beta, double rho0, track_t &tracks, vertex_t &vertices) const
Definition: TTTypes.h:54
std::vector< unsigned int > kmin
double update(double beta, track_t &gtracks, vertex_t &gvertices, const double rho0=0, const bool updateTc=false) const
void insertItem(unsigned int i, double new_zpca, double new_dz2, const reco::TransientTrack *new_tt, double new_tkwt)
std::vector< unsigned int > kmax
void removeItem(unsigned int k, track_t &tks)
void dump(const double beta, const vertex_t &y, const track_t &tks, const int verbosity=0, const double rho0=0.) const
track_t fill(const std::vector< reco::TransientTrack > &tracks) const
std::vector< TransientVertex > vertices_no_blocks(const std::vector< reco::TransientTrack > &tracks) const
std::vector< TransientVertex > vertices_in_blocks(const std::vector< reco::TransientTrack > &tracks) const
int nt
Definition: AMPTWrapper.h:42
const int verbosity
DAClusterizerInZ_vect(const edm::ParameterSet &conf)
unsigned int thermalize(double beta, track_t &gtracks, vertex_t &gvertices, const double delta_max, const double rho0=0.) const
void set_vtx_range(double beta, track_t &gtracks, vertex_t &gvertices) const
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks) const override
void verify(const vertex_t &v, const track_t &tks, unsigned int nv=999999, unsigned int nt=999999) const
bool split(const double beta, track_t &t, vertex_t &y, double threshold=1.) const