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;
179 
180  track_t fill(const std::vector<reco::TransientTrack> &tracks) const;
181 
182  void set_vtx_range(double beta, track_t &gtracks, vertex_t &gvertices) const;
183 
184  void clear_vtx_range(track_t &gtracks, vertex_t &gvertices) const;
185 
186  unsigned int thermalize(
187  double beta, track_t &gtracks, vertex_t &gvertices, const double delta_max, const double rho0 = 0.) const;
188 
189  double update(
190  double beta, track_t &gtracks, vertex_t &gvertices, const double rho0 = 0, const bool updateTc = false) const;
191 
192  void dump(
193  const double beta, const vertex_t &y, const track_t &tks, const int verbosity = 0, const double rho0 = 0.) const;
194  bool merge(vertex_t &y, track_t &tks, double &beta) const;
195  bool purge(vertex_t &, track_t &, double &, const double) const;
196  bool split(const double beta, track_t &t, vertex_t &y, double threshold = 1.) const;
197 
198  double beta0(const double betamax, track_t const &tks, vertex_t const &y) const;
199  void verify(const vertex_t &v, const track_t &tks, unsigned int nv = 999999, unsigned int nt = 999999) const;
200 
201 private:
202  double zdumpcenter_;
203  double zdumpwidth_;
204 
205  double vertexSize_;
206  unsigned int maxIterations_;
208  double betamax_;
209  double betastop_;
210  double dzCutOff_;
211  double d0CutOff_;
212 
216  double zmerge_;
217  double betapurge_;
218 
219  unsigned int convergence_mode_;
220  double delta_highT_;
221  double delta_lowT_;
222 
223  double sel_zrange_;
224  const double zrange_min_ = 0.1; // smallest z-range to be included in a tracks cluster list
225 };
226 
227 //#ifndef DAClusterizerInZ_vect_h
228 #endif
ConfigurationDescriptions.h
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
DAClusterizerInZ_vect::vertex_t::swE_vec
std::vector< double > swE_vec
Definition: DAClusterizerInZ_vect.h:85
DDAxes::y
DAClusterizerInZ_vect::fill
track_t fill(const std::vector< reco::TransientTrack > &tracks) const
Definition: DAClusterizerInZ_vect.cc:170
mps_fire.i
i
Definition: mps_fire.py:428
DAClusterizerInZ_vect::vertex_t::exp_vec
std::vector< double > exp_vec
Definition: DAClusterizerInZ_vect.h:81
DAClusterizerInZ_vect::vertex_t::insertItem
void insertItem(unsigned int k, double new_zvtx, double new_rho, track_t &tks)
Definition: DAClusterizerInZ_vect.h:102
nt
int nt
Definition: AMPTWrapper.h:42
DAClusterizerInZ_vect::track_t::sum_Z
double *__restrict__ sum_Z
Definition: DAClusterizerInZ_vect.h:72
HLT_FULL_cff.beta
beta
Definition: HLT_FULL_cff.py:8686
DAClusterizerInZ_vect::thermalize
unsigned int thermalize(double beta, track_t &gtracks, vertex_t &gvertices, const double delta_max, const double rho0=0.) const
Definition: DAClusterizerInZ_vect.cc:414
DAClusterizerInZ_vect::track_t::tkwt
double *__restrict__ tkwt
Definition: DAClusterizerInZ_vect.h:71
DAClusterizerInZ_vect::vertex_t::rho
double *__restrict__ rho
Definition: DAClusterizerInZ_vect.h:152
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
DAClusterizerInZ_vect::vertex_t::se_vec
std::vector< double > se_vec
Definition: DAClusterizerInZ_vect.h:84
DAClusterizerInZ_vect::track_t::addItemSorted
void addItemSorted(double new_zpca, double new_dz2, const reco::TransientTrack *new_tt, double new_tkwt)
Definition: DAClusterizerInZ_vect.h:37
DAClusterizerInZ_vect::DAClusterizerInZ_vect
DAClusterizerInZ_vect(const edm::ParameterSet &conf)
Definition: DAClusterizerInZ_vect.cc:20
DAClusterizerInZ_vect::track_t::tt
std::vector< const reco::TransientTrack * > tt
Definition: DAClusterizerInZ_vect.h:33
DAClusterizerInZ_vect::convergence_mode_
unsigned int convergence_mode_
Definition: DAClusterizerInZ_vect.h:219
DAClusterizerInZ_vect::set_vtx_range
void set_vtx_range(double beta, track_t &gtracks, vertex_t &gvertices) const
Definition: DAClusterizerInZ_vect.cc:220
DAClusterizerInZ_vect::vertex_t::removeItem
void removeItem(unsigned int k, track_t &tks)
Definition: DAClusterizerInZ_vect.h:126
DAClusterizerInZ_vect::coolingFactor_
double coolingFactor_
Definition: DAClusterizerInZ_vect.h:207
TransientTrack.h
findQualityFiles.v
v
Definition: findQualityFiles.py:179
TrackClusterizerInZ
Definition: TrackClusterizerInZ.h:14
DAClusterizerInZ_vect::track_t::extractRaw
void extractRaw()
Definition: DAClusterizerInZ_vect.h:61
DAClusterizerInZ_vect::verify
void verify(const vertex_t &v, const track_t &tks, unsigned int nv=999999, unsigned int nt=999999) const
Definition: DAClusterizerInZ_vect.cc:108
DAClusterizerInZ_vect::maxIterations_
unsigned int maxIterations_
Definition: DAClusterizerInZ_vect.h:206
DAClusterizerInZ_vect::vertex_t::zvtx
double *__restrict__ zvtx
Definition: DAClusterizerInZ_vect.h:151
DAClusterizerInZ_vect::track_t::kmax
std::vector< unsigned int > kmax
Definition: DAClusterizerInZ_vect.h:32
DAClusterizerInZ_vect::track_t::kmin
std::vector< unsigned int > kmin
Definition: DAClusterizerInZ_vect.h:31
DAClusterizerInZ_vect::track_t::insertItem
void insertItem(unsigned int i, double new_zpca, double new_dz2, const reco::TransientTrack *new_tt, double new_tkwt)
Definition: DAClusterizerInZ_vect.h:47
DAClusterizerInZ_vect::split
bool split(const double beta, track_t &t, vertex_t &y, double threshold=1.) const
Definition: DAClusterizerInZ_vect.cc:641
DAClusterizerInZ_vect::vertex_t::se
double *__restrict__ se
Definition: DAClusterizerInZ_vect.h:157
DAClusterizerInZ_vect::vertex_t::exp_arg_vec
std::vector< double > exp_arg_vec
Definition: DAClusterizerInZ_vect.h:80
DAClusterizerInZ_vect::track_t::zpca
double *__restrict__ zpca
Definition: DAClusterizerInZ_vect.h:69
VertexDistanceXY.h
DAClusterizerInZ_vect::vertex_t::addItem
void addItem(double new_zvtx, double new_rho)
Definition: DAClusterizerInZ_vect.h:89
DAClusterizerInZ_vect::dzCutOff_
double dzCutOff_
Definition: DAClusterizerInZ_vect.h:210
DAClusterizerInZ_vect::zmerge_
double zmerge_
Definition: DAClusterizerInZ_vect.h:216
DAClusterizerInZ_vect::betamax_
double betamax_
Definition: DAClusterizerInZ_vect.h:208
DAClusterizerInZ_vect::vertex_t::swE
double *__restrict__ swE
Definition: DAClusterizerInZ_vect.h:158
DAClusterizerInZ_vect::vertex_t::extractRaw
void extractRaw()
Definition: DAClusterizerInZ_vect.h:161
DAClusterizerInZ_vect::track_t::dz2_vec
std::vector< double > dz2_vec
Definition: DAClusterizerInZ_vect.h:28
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DAClusterizerInZ_vect::track_t::sum_Z_vec
std::vector< double > sum_Z_vec
Definition: DAClusterizerInZ_vect.h:29
DAClusterizerInZ_vect::mintrkweight_
double mintrkweight_
Definition: DAClusterizerInZ_vect.h:213
DAClusterizerInZ_vect::beta0
double beta0(const double betamax, track_t const &tks, vertex_t const &y) const
Definition: DAClusterizerInZ_vect.cc:590
DAClusterizerInZ_vect::track_t::dz2
double *__restrict__ dz2
Definition: DAClusterizerInZ_vect.h:70
DAClusterizerInZ_vect::vertex_t::sw
double *__restrict__ sw
Definition: DAClusterizerInZ_vect.h:155
DAClusterizerInZ_vect::track_t
Definition: DAClusterizerInZ_vect.h:26
DAClusterizerInZ_vect::track_t::tkwt_vec
std::vector< double > tkwt_vec
Definition: DAClusterizerInZ_vect.h:30
DAClusterizerInZ_vect::merge
bool merge(vertex_t &y, track_t &tks, double &beta) const
Definition: DAClusterizerInZ_vect.cc:462
Error.h
edm::ParameterSet
Definition: ParameterSet.h:47
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
DAClusterizerInZ_vect::vertex_t::swz
double *__restrict__ swz
Definition: DAClusterizerInZ_vect.h:156
DAClusterizerInZ_vect::vertex_t::getSize
unsigned int getSize() const
Definition: DAClusterizerInZ_vect.h:87
DAClusterizerInZ_vect::track_t::getSize
unsigned int getSize() const
Definition: DAClusterizerInZ_vect.h:58
DAClusterizerInZ_vect::zdumpwidth_
double zdumpwidth_
Definition: DAClusterizerInZ_vect.h:203
DAClusterizerInZ_vect::sel_zrange_
double sel_zrange_
Definition: DAClusterizerInZ_vect.h:223
DAClusterizerInZ_vect::clear_vtx_range
void clear_vtx_range(track_t &gtracks, vertex_t &gvertices) const
Definition: DAClusterizerInZ_vect.cc:269
DAClusterizerInZ_vect::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: DAClusterizerInZ_vect.cc:1170
DAClusterizerInZ_vect::clusterize
std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const override
Definition: DAClusterizerInZ_vect.cc:974
DAClusterizerInZ_vect::vertex_t::exp_arg
double *__restrict__ exp_arg
Definition: DAClusterizerInZ_vect.h:153
TransientVertex.h
DAClusterizerInZ_vect
Definition: DAClusterizerInZ_vect.h:21
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
DAClusterizerInZ_vect::delta_highT_
double delta_highT_
Definition: DAClusterizerInZ_vect.h:220
DAClusterizerInZ_vect::d0CutOff_
double d0CutOff_
Definition: DAClusterizerInZ_vect.h:211
reco::TransientTrack
Definition: TransientTrack.h:19
DAClusterizerInZ_vect::vertex_t::swz_vec
std::vector< double > swz_vec
Definition: DAClusterizerInZ_vect.h:83
DAClusterizerInZ_vect::vertex_t::sw_vec
std::vector< double > sw_vec
Definition: DAClusterizerInZ_vect.h:82
DAClusterizerInZ_vect::track_t::zpca_vec
std::vector< double > zpca_vec
Definition: DAClusterizerInZ_vect.h:27
DAClusterizerInZ_vect::purge
bool purge(vertex_t &, track_t &, double &, const double) const
Definition: DAClusterizerInZ_vect.cc:511
DAClusterizerInZ_vect::update
double update(double beta, track_t &gtracks, vertex_t &gvertices, const double rho0=0, const bool updateTc=false) const
Definition: DAClusterizerInZ_vect.cc:278
DAClusterizerInZ_vect::uniquetrkweight_
double uniquetrkweight_
Definition: DAClusterizerInZ_vect.h:214
DAClusterizerInZ_vect::vertex_t::exp
double *__restrict__ exp
Definition: DAClusterizerInZ_vect.h:154
DAClusterizerInZ_vect::vertices
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks) const
Definition: DAClusterizerInZ_vect.cc:763
DAClusterizerInZ_vect::vertexSize_
double vertexSize_
Definition: DAClusterizerInZ_vect.h:205
ParameterSet.h
DAClusterizerInZ_vect::uniquetrkminp_
double uniquetrkminp_
Definition: DAClusterizerInZ_vect.h:215
DAClusterizerInZ_vect::track_t::osumtkwt
double osumtkwt
Definition: DAClusterizerInZ_vect.h:35
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
DAClusterizerInZ_vect::dump
void dump(const double beta, const vertex_t &y, const track_t &tks, const int verbosity=0, const double rho0=0.) const
Definition: DAClusterizerInZ_vect.cc:1017
TrackClusterizerInZ.h
DAClusterizerInZ_vect::zdumpcenter_
double zdumpcenter_
Definition: DAClusterizerInZ_vect.h:202
DAClusterizerInZ_vect::vertex_t::rho_vec
std::vector< double > rho_vec
Definition: DAClusterizerInZ_vect.h:78
DAClusterizerInZ_vect::vertex_t
Definition: DAClusterizerInZ_vect.h:76
DAClusterizerInZ_vect::delta_lowT_
double delta_lowT_
Definition: DAClusterizerInZ_vect.h:221
DAClusterizerInZ_vect::vertex_t::zvtx_vec
std::vector< double > zvtx_vec
Definition: DAClusterizerInZ_vect.h:77
DAClusterizerInZ_vect::betapurge_
double betapurge_
Definition: DAClusterizerInZ_vect.h:217
DAClusterizerInZ_vect::zrange_min_
const double zrange_min_
Definition: DAClusterizerInZ_vect.h:224
DAClusterizerInZ_vect::betastop_
double betastop_
Definition: DAClusterizerInZ_vect.h:209