CMS 3D CMS Logo

DAClusterizerInZT_vect.h
Go to the documentation of this file.
1 #ifndef RecoVertex_PrimaryVertexProducer_DAClusterizerInZT_vect_h
2 #define RecoVertex_PrimaryVertexProducer_DAClusterizerInZT_vect_h
3 
16 #include <vector>
20 
21 #include <memory>
22 
23 //#define USEVTXDT2
24 
26 public:
27  // internal data structure for tracks
28  struct track_t {
29  std::vector<double> zpca_vec; // z-coordinate at point of closest approach to the beamline
30  std::vector<double> tpca_vec; // t-coordinate at point of closest approach to the beamline
31  std::vector<double> dz2_vec; // square of the error of z(pca)
32  std::vector<double> dt2_vec; // square of the error of t(pca)
33  std::vector<double> sum_Z_vec; // track contribution to the partition function, Z
34  std::vector<double> tkwt_vec; // track weight, close to 1.0 for most tracks
35  std::vector<unsigned int> kmin; // index of the first cluster within zrange
36  std::vector<unsigned int> kmax; // 1 + index of the last cluster within zrange
37  std::vector<const reco::TransientTrack *> tt; // a pointer to the Transient Track
38 
39  double osumtkwt; // 1. / (sum of all track weights)
40 
41  void addItem(double new_zpca,
42  double new_tpca,
43  double new_dz2,
44  double new_dt2,
45  const reco::TransientTrack *new_tt,
46  double new_tkwt) {
47  zpca_vec.push_back(new_zpca);
48  tpca_vec.push_back(new_tpca);
49  dz2_vec.push_back(new_dz2);
50  dt2_vec.push_back(new_dt2);
51  tt.push_back(new_tt);
52  tkwt_vec.push_back(new_tkwt);
53  sum_Z_vec.push_back(1.0);
54  kmin.push_back(0);
55  kmax.push_back(0);
56  }
57 
58  void insertItem(unsigned int i,
59  double new_zpca,
60  double new_tpca,
61  double new_dz2,
62  double new_dt2,
63  const reco::TransientTrack *new_tt,
64  double new_tkwt) {
65  zpca_vec.insert(zpca_vec.begin() + i, new_zpca);
66  tpca_vec.insert(tpca_vec.begin() + i, new_tpca);
67  dz2_vec.insert(dz2_vec.begin() + i, new_dz2);
68  dt2_vec.insert(dt2_vec.begin() + i, new_dt2);
69  tt.insert(tt.begin() + i, new_tt);
70  tkwt_vec.insert(tkwt_vec.begin() + i, new_tkwt);
71  sum_Z_vec.insert(sum_Z_vec.begin() + i, 1.0);
72  kmin.insert(kmin.begin() + i, 0);
73  kmax.insert(kmax.begin() + i, 0);
74  }
75 
76  unsigned int getSize() const { return zpca_vec.size(); }
77 
78  // has to be called everytime the items are modified
79  void extractRaw() {
80  zpca = &zpca_vec.front();
81  tpca = &tpca_vec.front();
82  dz2 = &dz2_vec.front();
83  dt2 = &dt2_vec.front();
84  tkwt = &tkwt_vec.front();
85  sum_Z = &sum_Z_vec.front();
86  }
87 
88  // pointers to the first element of vectors, needed for vectorized code
89  double *__restrict__ zpca;
90  double *__restrict__ tpca;
91  double *__restrict__ dz2;
92  double *__restrict__ dt2;
93  double *__restrict__ tkwt;
94  double *__restrict__ sum_Z;
95  };
96 
97  // internal data structure for clusters
98  struct vertex_t {
99  std::vector<double> zvtx_vec; // z coordinate
100  std::vector<double> tvtx_vec; // t coordinate
101  std::vector<double> rho_vec; // vertex "mass" for mass-constrained clustering
102 #ifdef USEVTXDT2
103  std::vector<double> dt2_vec; // only used with vertex time uncertainties
104  std::vector<double> sumw_vec; // only used with vertex time uncertainties
105 #endif
106  // --- temporary numbers, used during update
107  std::vector<double> exp_arg_vec;
108  std::vector<double> exp_vec;
109  std::vector<double> sw_vec;
110  std::vector<double> swz_vec;
111  std::vector<double> swt_vec;
112  std::vector<double> se_vec;
113  std::vector<double> nuz_vec;
114  std::vector<double> nut_vec;
115  std::vector<double> szz_vec;
116  std::vector<double> stt_vec;
117  std::vector<double> szt_vec;
118 
119  unsigned int getSize() const { return zvtx_vec.size(); }
120 
121  void addItem(double new_zvtx, double new_tvtx, double new_rho) {
122  zvtx_vec.push_back(new_zvtx);
123  tvtx_vec.push_back(new_tvtx);
124  rho_vec.push_back(new_rho);
125  exp_arg_vec.push_back(0.0);
126  exp_vec.push_back(0.0);
127  swz_vec.push_back(0.0);
128  swt_vec.push_back(0.0);
129  se_vec.push_back(0.0);
130  nuz_vec.push_back(0.0);
131  nut_vec.push_back(0.0);
132  szz_vec.push_back(0.0);
133  stt_vec.push_back(0.0);
134  szt_vec.push_back(0.0);
135 #ifdef USEVTXDT2
136  dt2_vec.push_back(0.0);
137  sumw_vec.push_back(0.0);
138 #endif
139 
140  extractRaw();
141  }
142 
143  void insertItem(unsigned int k, double new_zvtx, double new_tvtx, double new_rho, track_t &tks) {
144  zvtx_vec.insert(zvtx_vec.begin() + k, new_zvtx);
145  tvtx_vec.insert(tvtx_vec.begin() + k, new_tvtx);
146  rho_vec.insert(rho_vec.begin() + k, new_rho);
147  exp_arg_vec.insert(exp_arg_vec.begin() + k, 0.0);
148  exp_vec.insert(exp_vec.begin() + k, 0.0);
149  swz_vec.insert(swz_vec.begin() + k, 0.0);
150  swt_vec.insert(swt_vec.begin() + k, 0.0);
151  se_vec.insert(se_vec.begin() + k, 0.0);
152  nuz_vec.insert(nuz_vec.begin() + k, 0.0);
153  nut_vec.insert(nut_vec.begin() + k, 0.0);
154  szz_vec.insert(szz_vec.begin() + k, 0.0);
155  stt_vec.insert(stt_vec.begin() + k, 0.0);
156  szt_vec.insert(szt_vec.begin() + k, 0.0);
157 #ifdef USEVTXDT2
158  dt2_vec.insert(dt2_vec.begin() + k, 0.0);
159  sumw_vec.insert(sumw_vec.begin() + k, 0.0);
160 #endif
161 
162  // adjust vertex lists of tracks
163  for (unsigned int i = 0; i < tks.getSize(); i++) {
164  if (tks.kmin[i] > k) {
165  tks.kmin[i]++;
166  }
167  if ((tks.kmax[i] >= k) || (tks.kmax[i] == tks.kmin[i])) {
168  tks.kmax[i]++;
169  }
170  }
171 
172  extractRaw();
173  }
174 
175  void removeItem(unsigned int k, track_t &tks) {
176  zvtx_vec.erase(zvtx_vec.begin() + k);
177  tvtx_vec.erase(tvtx_vec.begin() + k);
178  rho_vec.erase(rho_vec.begin() + k);
179  exp_arg_vec.erase(exp_arg_vec.begin() + k);
180  exp_vec.erase(exp_vec.begin() + k);
181  swz_vec.erase(swz_vec.begin() + k);
182  swt_vec.erase(swt_vec.begin() + k);
183  se_vec.erase(se_vec.begin() + k);
184  nuz_vec.erase(nuz_vec.begin() + k);
185  nut_vec.erase(nut_vec.begin() + k);
186  szz_vec.erase(szz_vec.begin() + k);
187  stt_vec.erase(stt_vec.begin() + k);
188  szt_vec.erase(szt_vec.begin() + k);
189 #ifdef USEVTXDT2
190  dt2_vec.erase(dt2_vec.begin() + k);
191  sumw_vec.erase(sumw_vec.begin() + k);
192 #endif
193 
194  // adjust vertex lists of tracks
195  for (unsigned int i = 0; i < tks.getSize(); i++) {
196  if (tks.kmax[i] > k) {
197  tks.kmax[i]--;
198  }
199  if ((tks.kmin[i] > k) || (((tks.kmax[i] < (tks.kmin[i] + 1)) && (tks.kmin[i] > 0)))) {
200  tks.kmin[i]--;
201  }
202  }
203 
204  extractRaw();
205  }
206 
207  unsigned int insertOrdered(double zvtx, double tvtx, double rho, track_t &tks) {
208  // insert a new cluster according to it's z-position, return the index at which it was inserted
209 
210  unsigned int k = 0;
211  for (; k < getSize(); k++) {
212  if (zvtx < zvtx_vec[k])
213  break;
214  }
215  insertItem(k, zvtx, tvtx, rho, tks);
216  return k;
217  }
218 
219  // pointers to the first element of vectors, needed for vectorized code
220  double *__restrict__ zvtx;
221  double *__restrict__ tvtx;
222  double *__restrict__ rho;
223  double *__restrict__ exp_arg;
224  double *__restrict__ exp;
225  double *__restrict__ swt;
226  double *__restrict__ swz;
227  double *__restrict__ se;
228  double *__restrict__ nuz;
229  double *__restrict__ nut;
230  double *__restrict__ szz;
231  double *__restrict__ stt;
232  double *__restrict__ szt;
233 #ifdef USEVTXDT2
234  double *__restrict__ dt2;
235  double *__restrict__ sumw;
236 #endif
237 
238  // has to be called everytime the items are modified
239  void extractRaw() {
240  zvtx = &zvtx_vec.front();
241  tvtx = &tvtx_vec.front();
242  rho = &rho_vec.front();
243  exp_arg = &exp_arg_vec.front();
244  exp = &exp_vec.front();
245  swz = &swz_vec.front();
246  swt = &swt_vec.front();
247  se = &se_vec.front();
248  nuz = &nuz_vec.front();
249  nut = &nut_vec.front();
250  szz = &szz_vec.front();
251  stt = &stt_vec.front();
252  szt = &szt_vec.front();
253 #ifdef USEVTXDT2
254  dt2 = &dt2_vec.front();
255  sumw = &sumw_vec.front();
256 #endif
257  }
258  };
259 
261 
263 
264  std::vector<std::vector<reco::TransientTrack> > clusterize(
265  const std::vector<reco::TransientTrack> &tracks) const override;
266 
267  std::vector<TransientVertex> vertices(const std::vector<reco::TransientTrack> &tracks) const;
268 
269  track_t fill(const std::vector<reco::TransientTrack> &tracks) const;
270 
271  void set_vtx_range(double beta, track_t &gtracks, vertex_t &gvertices) const;
272 
273  void clear_vtx_range(track_t &gtracks, vertex_t &gvertices) const;
274 
275  unsigned int thermalize(
276  double beta, track_t &gtracks, vertex_t &gvertices, const double delta_max, const double rho0 = 0.) const;
277 
278  double update(
279  double beta, track_t &gtracks, vertex_t &gvertices, const double rho0 = 0, const bool updateTc = false) const;
280 
281  void dump(const double beta, const vertex_t &y, const track_t &tks, const int verbosity = 0) const;
282  bool zorder(vertex_t &y) const;
283  bool find_nearest(double z, double t, vertex_t &y, unsigned int &k_min, double dz, double dt) const;
284  bool merge(vertex_t &, track_t &, double &beta) const;
285  bool purge(vertex_t &, track_t &, double &, const double) const;
286  bool split(const double beta, track_t &t, vertex_t &y, double threshold = 1.) const;
287 
288  double beta0(const double betamax, track_t const &tks, vertex_t const &y) const;
289 
290  double get_Tc(const vertex_t &y, int k) const;
291  void verify(const vertex_t &v, const track_t &tks, unsigned int nv = 999999, unsigned int nt = 999999) const;
292 
293 private:
294  double zdumpcenter_;
295  double zdumpwidth_;
296 
297  double vertexSize_;
299  unsigned int maxIterations_;
301  double betamax_;
302  double betastop_;
303  double dzCutOff_;
304  double d0CutOff_;
305  double dtCutOff_;
306  double t0Max_;
307 
311  double zmerge_;
312  double tmerge_;
313  double betapurge_;
314 
315  unsigned int convergence_mode_;
316  double delta_highT_;
317  double delta_lowT_;
318 
319  double sel_zrange_;
320  const double zrange_min_ = 0.1; // smallest z-range to be included in a tracks cluster list
321 };
322 
323 //#ifndef DAClusterizerInZT_vect_h
324 #endif
float dt
Definition: AMPTWrapper.h:136
void removeItem(unsigned int k, track_t &tks)
std::vector< unsigned int > kmin
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks) const
double get_Tc(const vertex_t &y, int k) const
DAClusterizerInZT_vect(const edm::ParameterSet &conf)
bool purge(vertex_t &, track_t &, double &, const double) const
void addItem(double new_zpca, double new_tpca, double new_dz2, double new_dt2, const reco::TransientTrack *new_tt, double new_tkwt)
std::vector< unsigned int > kmax
double update(double beta, track_t &gtracks, vertex_t &gvertices, const double rho0=0, const bool updateTc=false) const
void insertItem(unsigned int k, double new_zvtx, double new_tvtx, double new_rho, track_t &tks)
Definition: TTTypes.h:54
bool split(const double beta, track_t &t, vertex_t &y, double threshold=1.) const
double beta0(const double betamax, track_t const &tks, vertex_t const &y) const
void set_vtx_range(double beta, track_t &gtracks, vertex_t &gvertices) const
void addItem(double new_zvtx, double new_tvtx, double new_rho)
bool zorder(vertex_t &y) const
bool merge(vertex_t &, track_t &, double &beta) const
track_t fill(const std::vector< reco::TransientTrack > &tracks) const
void verify(const vertex_t &v, const track_t &tks, unsigned int nv=999999, unsigned int nt=999999) const
int nt
Definition: AMPTWrapper.h:42
const int verbosity
void insertItem(unsigned int i, double new_zpca, double new_tpca, double new_dz2, double new_dt2, const reco::TransientTrack *new_tt, double new_tkwt)
auto const & tracks
cannot be loose
static void fillPSetDescription(edm::ParameterSetDescription &desc)
void dump(const double beta, const vertex_t &y, const track_t &tks, const int verbosity=0) const
std::vector< const reco::TransientTrack * > tt
std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const override
unsigned int thermalize(double beta, track_t &gtracks, vertex_t &gvertices, const double delta_max, const double rho0=0.) const
bool find_nearest(double z, double t, vertex_t &y, unsigned int &k_min, double dz, double dt) const
unsigned int insertOrdered(double zvtx, double tvtx, double rho, track_t &tks)
void clear_vtx_range(track_t &gtracks, vertex_t &gvertices) const