CMS 3D CMS Logo

DAClusterizerInZ_vect.h
Go to the documentation of this file.
1 #ifndef DAClusterizerInZ_vect_h
2 #define DAClusterizerInZ_vect_h
3 
15 #include <vector>
19 
21 public:
22  // Internal data structure to
23  struct track_t {
24  void addItem(double new_z, double new_dz2, const reco::TransientTrack *new_tt, double new_pi) {
25  z.push_back(new_z);
26  dz2.push_back(new_dz2);
27  tt.push_back(new_tt);
28 
29  pi.push_back(new_pi); // track weight
30  Z_sum.push_back(1.0); // Z[i] for DA clustering, initial value as done in ::fill
31 
32  kmin.push_back(0);
33  kmax.push_back(0);
34  }
35 
36  void addItemSorted(double new_z, double new_dz2, const reco::TransientTrack *new_tt, double new_pi) {
37  // sort tracks with decreasing resolution (note that dz2 = 1/sigma^2)
38  unsigned int i = 0;
39  for (i = 0; i < z.size(); i++) {
40  if (new_dz2 > dz2[i])
41  break;
42  }
43  insertItem(i, new_z, new_dz2, new_tt, new_pi);
44  }
45 
46  void insertItem(unsigned int i, double new_z, double new_dz2, const reco::TransientTrack *new_tt, double new_pi) {
47  z.insert(z.begin() + i, new_z);
48  dz2.insert(dz2.begin() + i, new_dz2);
49  tt.insert(tt.begin() + i, new_tt);
50  pi.insert(pi.begin() + i, new_pi); // track weight
51 
52  Z_sum.insert(Z_sum.begin() + i, 1.0); // Z[i] for DA clustering, initial value as done in ::fill
53  kmin.insert(kmin.begin() + i, 0);
54  kmax.insert(kmax.begin() + i, 0);
55  }
56 
57  unsigned int getSize() const { return z.size(); }
58 
59  // has to be called everytime the items are modified
60  void extractRaw() {
61  z_ptr = &z.front();
62  dz2_ptr = &dz2.front();
63  Z_sum_ptr = &Z_sum.front();
64  pi_ptr = &pi.front();
65  }
66 
67  double *__restrict__ z_ptr; // z-coordinate at point of closest approach to the beamline
68  double *__restrict__ dz2_ptr; // square of the error of z(pca)
69 
70  double *__restrict__ Z_sum_ptr; // Z[i] for DA clustering
71  double *__restrict__ pi_ptr; // track weight
72 
73  std::vector<double> z; // z-coordinate at point of closest approach to the beamline
74  std::vector<double> dz2; // square of the error of z(pca)
75  std::vector<double> Z_sum; // Z[i] for DA clustering
76  std::vector<double> pi; // track weight
77  std::vector<unsigned int> kmin;
78  std::vector<unsigned int> kmax;
79  std::vector<const reco::TransientTrack *> tt; // a pointer to the Transient Track
80  };
81 
82  struct vertex_t {
83  std::vector<double> z; // z coordinate
84  std::vector<double> pk; // vertex weight for "constrained" clustering
85 
86  // --- temporary numbers, used during update
87  std::vector<double> ei_cache;
88  std::vector<double> ei;
89  std::vector<double> sw;
90  std::vector<double> swz;
91  std::vector<double> se;
92  std::vector<double> swE;
93 
94  unsigned int getSize() const { return z.size(); }
95 
96  void addItem(double new_z, double new_pk) {
97  z.push_back(new_z);
98  pk.push_back(new_pk);
99 
100  ei_cache.push_back(0.0);
101  ei.push_back(0.0);
102  sw.push_back(0.0);
103  swz.push_back(0.0);
104  se.push_back(0.0);
105  swE.push_back(0.0);
106 
107  extractRaw();
108  }
109 
110  void insertItem(unsigned int k, double new_z, double new_pk) {
111  z.insert(z.begin() + k, new_z);
112  pk.insert(pk.begin() + k, new_pk);
113 
114  ei_cache.insert(ei_cache.begin() + k, 0.0);
115  ei.insert(ei.begin() + k, 0.0);
116  sw.insert(sw.begin() + k, 0.0);
117  swz.insert(swz.begin() + k, 0.0);
118  se.insert(se.begin() + k, 0.0);
119  swE.insert(swE.begin() + k, 0.0);
120 
121  extractRaw();
122  }
123 
124  void insertItem(unsigned int k, double new_z, double new_pk, track_t &tks) {
125  z.insert(z.begin() + k, new_z);
126  pk.insert(pk.begin() + k, new_pk);
127 
128  ei_cache.insert(ei_cache.begin() + k, 0.0);
129  ei.insert(ei.begin() + k, 0.0);
130  sw.insert(sw.begin() + k, 0.0);
131  swz.insert(swz.begin() + k, 0.0);
132  se.insert(se.begin() + k, 0.0);
133  swE.insert(swE.begin() + k, 0.0);
134 
135  // adjust vertex lists of tracks
136  for (unsigned int i = 0; i < tks.getSize(); i++) {
137  if (tks.kmin[i] > k) {
138  tks.kmin[i]++;
139  }
140  if ((tks.kmax[i] >= k) || (tks.kmax[i] == tks.kmin[i])) {
141  tks.kmax[i]++;
142  }
143  }
144 
145  extractRaw();
146  }
147 
148  void removeItem(unsigned int k, track_t &tks) {
149  z.erase(z.begin() + k);
150  pk.erase(pk.begin() + k);
151 
152  ei_cache.erase(ei_cache.begin() + k);
153  ei.erase(ei.begin() + k);
154  sw.erase(sw.begin() + k);
155  swz.erase(swz.begin() + k);
156  se.erase(se.begin() + k);
157  swE.erase(swE.begin() + k);
158 
159  // adjust vertex lists of tracks
160  for (unsigned int i = 0; i < tks.getSize(); i++) {
161  if (tks.kmax[i] > k) {
162  tks.kmax[i]--;
163  }
164  if ((tks.kmin[i] > k) || (((tks.kmax[i] < (tks.kmin[i] + 1)) && (tks.kmin[i] > 0)))) {
165  tks.kmin[i]--;
166  }
167  }
168 
169  extractRaw();
170  }
171 
172  void DebugOut() {
173  std::cout << "vertex_t size: " << getSize() << std::endl;
174 
175  for (unsigned int i = 0; i < getSize(); ++i) {
176  std::cout << " z = " << z_ptr[i] << " pk = " << pk_ptr[i] << std::endl;
177  }
178  }
179 
180  // has to be called everytime the items are modified
181  void extractRaw() {
182  z_ptr = &z.front();
183  pk_ptr = &pk.front();
184 
185  ei_ptr = &ei.front();
186  sw_ptr = &sw.front();
187  swz_ptr = &swz.front();
188  se_ptr = &se.front();
189  swE_ptr = &swE.front();
190  ei_cache_ptr = &ei_cache.front();
191  }
192 
193  double *__restrict__ z_ptr;
194  double *__restrict__ pk_ptr;
195 
196  double *__restrict__ ei_cache_ptr;
197  double *__restrict__ ei_ptr;
198  double *__restrict__ sw_ptr;
199  double *__restrict__ swz_ptr;
200  double *__restrict__ se_ptr;
201  double *__restrict__ swE_ptr;
202  };
203 
205 
206  std::vector<std::vector<reco::TransientTrack> > clusterize(
207  const std::vector<reco::TransientTrack> &tracks) const override;
208 
209  std::vector<TransientVertex> vertices(const std::vector<reco::TransientTrack> &tracks, const int verbosity = 0) const;
210 
211  track_t fill(const std::vector<reco::TransientTrack> &tracks) const;
212 
213  void set_vtx_range(double beta, track_t &gtracks, vertex_t &gvertices) const;
214 
215  void clear_vtx_range(track_t &gtracks, vertex_t &gvertices) const;
216 
217  unsigned int thermalize(
218  double beta, track_t &gtracks, vertex_t &gvertices, const double delta_max, const double rho0 = 0.) const;
219 
220  double update(double beta, track_t &gtracks, vertex_t &gvertices, const double rho0 = 0) const;
221  double updateTc(double beta, track_t &gtracks, vertex_t &gvertices, const double rho0 = 0) const;
222 
223  void dump(const double beta, const vertex_t &y, const track_t &tks, const int verbosity = 0) const;
224  bool merge(vertex_t &y, track_t &tks, double &beta) const;
225  bool purge(vertex_t &, track_t &, double &, const double) const;
226  bool split(const double beta, track_t &t, vertex_t &y, double threshold = 1.) const;
227 
228  double beta0(const double betamax, track_t const &tks, vertex_t const &y) const;
229  double evalF(const double beta, track_t const &tks, vertex_t const &v) const;
230  void verify(const vertex_t &v, const track_t &tks, unsigned int nv = 999999, unsigned int nt = 999999) const;
231 
232 private:
233  bool verbose_;
234  double zdumpcenter_;
235  double zdumpwidth_;
236 
237  double vertexSize_;
238  unsigned int maxIterations_;
240  double betamax_;
241  double betastop_;
242  double dzCutOff_;
243  double d0CutOff_;
244 
247  double zmerge_;
248  double betapurge_;
249 
250  unsigned int convergence_mode_;
251  double delta_highT_;
252  double delta_lowT_;
253 
254  double sel_zrange_;
255  const double zrange_min_ = 0.1; // smallest z-range to be included in a tracks cluster list
256 };
257 
258 //#ifndef DAClusterizerInZ_vect_h
259 #endif
HIPAlignmentAlgorithm_cfi.verbosity
verbosity
Definition: HIPAlignmentAlgorithm_cfi.py:7
DAClusterizerInZ_vect::vertex_t::z
std::vector< double > z
Definition: DAClusterizerInZ_vect.h:83
DAClusterizerInZ_vect::vertex_t::ei
std::vector< double > ei
Definition: DAClusterizerInZ_vect.h:88
DDAxes::y
DAClusterizerInZ_vect::track_t::addItemSorted
void addItemSorted(double new_z, double new_dz2, const reco::TransientTrack *new_tt, double new_pi)
Definition: DAClusterizerInZ_vect.h:36
DAClusterizerInZ_vect::fill
track_t fill(const std::vector< reco::TransientTrack > &tracks) const
Definition: DAClusterizerInZ_vect.cc:173
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:355
DAClusterizerInZ_vect::vertex_t::DebugOut
void DebugOut()
Definition: DAClusterizerInZ_vect.h:172
DAClusterizerInZ_vect::vertices
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks, const int verbosity=0) const
Definition: DAClusterizerInZ_vect.cc:857
DAClusterizerInZ_vect::track_t::insertItem
void insertItem(unsigned int i, double new_z, double new_dz2, const reco::TransientTrack *new_tt, double new_pi)
Definition: DAClusterizerInZ_vect.h:46
DAClusterizerInZ_vect::vertex_t::ei_cache_ptr
double *__restrict__ ei_cache_ptr
Definition: DAClusterizerInZ_vect.h:196
DAClusterizerInZ_vect::vertex_t::ei_cache
std::vector< double > ei_cache
Definition: DAClusterizerInZ_vect.h:87
DAClusterizerInZ_vect::vertex_t::insertItem
void insertItem(unsigned int k, double new_z, double new_pk)
Definition: DAClusterizerInZ_vect.h:110
nt
int nt
Definition: AMPTWrapper.h:42
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
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:535
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DAClusterizerInZ_vect::vertex_t::se
std::vector< double > se
Definition: DAClusterizerInZ_vect.h:91
DAClusterizerInZ_vect::vertex_t::pk_ptr
double *__restrict__ pk_ptr
Definition: DAClusterizerInZ_vect.h:194
DAClusterizerInZ_vect::vertex_t::sw_ptr
double *__restrict__ sw_ptr
Definition: DAClusterizerInZ_vect.h:198
DAClusterizerInZ_vect::vertex_t::swz_ptr
double *__restrict__ swz_ptr
Definition: DAClusterizerInZ_vect.h:199
DAClusterizerInZ_vect::DAClusterizerInZ_vect
DAClusterizerInZ_vect(const edm::ParameterSet &conf)
Definition: DAClusterizerInZ_vect.cc:22
DAClusterizerInZ_vect::vertex_t::addItem
void addItem(double new_z, double new_pk)
Definition: DAClusterizerInZ_vect.h:96
DAClusterizerInZ_vect::track_t::tt
std::vector< const reco::TransientTrack * > tt
Definition: DAClusterizerInZ_vect.h:79
DAClusterizerInZ_vect::convergence_mode_
unsigned int convergence_mode_
Definition: DAClusterizerInZ_vect.h:250
DAClusterizerInZ_vect::set_vtx_range
void set_vtx_range(double beta, track_t &gtracks, vertex_t &gvertices) const
Definition: DAClusterizerInZ_vect.cc:218
DAClusterizerInZ_vect::vertex_t::removeItem
void removeItem(unsigned int k, track_t &tks)
Definition: DAClusterizerInZ_vect.h:148
DAClusterizerInZ_vect::coolingFactor_
double coolingFactor_
Definition: DAClusterizerInZ_vect.h:239
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:60
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::track_t::pi_ptr
double *__restrict__ pi_ptr
Definition: DAClusterizerInZ_vect.h:71
DAClusterizerInZ_vect::maxIterations_
unsigned int maxIterations_
Definition: DAClusterizerInZ_vect.h:238
DAClusterizerInZ_vect::track_t::kmax
std::vector< unsigned int > kmax
Definition: DAClusterizerInZ_vect.h:78
DAClusterizerInZ_vect::track_t::kmin
std::vector< unsigned int > kmin
Definition: DAClusterizerInZ_vect.h:77
DAClusterizerInZ_vect::vertex_t::se_ptr
double *__restrict__ se_ptr
Definition: DAClusterizerInZ_vect.h:200
DAClusterizerInZ_vect::track_t::Z_sum_ptr
double *__restrict__ Z_sum_ptr
Definition: DAClusterizerInZ_vect.h:70
DAClusterizerInZ_vect::split
bool split(const double beta, track_t &t, vertex_t &y, double threshold=1.) const
Definition: DAClusterizerInZ_vect.cc:740
DAClusterizerInZ_vect::vertex_t::z_ptr
double *__restrict__ z_ptr
Definition: DAClusterizerInZ_vect.h:193
DAClusterizerInZ_vect::update
double update(double beta, track_t &gtracks, vertex_t &gvertices, const double rho0=0) const
Definition: DAClusterizerInZ_vect.cc:276
DAClusterizerInZ_vect::vertex_t::ei_ptr
double *__restrict__ ei_ptr
Definition: DAClusterizerInZ_vect.h:197
VertexDistanceXY.h
DAClusterizerInZ_vect::vertex_t::sw
std::vector< double > sw
Definition: DAClusterizerInZ_vect.h:89
DAClusterizerInZ_vect::dzCutOff_
double dzCutOff_
Definition: DAClusterizerInZ_vect.h:242
DAClusterizerInZ_vect::zmerge_
double zmerge_
Definition: DAClusterizerInZ_vect.h:247
DAClusterizerInZ_vect::betamax_
double betamax_
Definition: DAClusterizerInZ_vect.h:240
DAClusterizerInZ_vect::vertex_t::extractRaw
void extractRaw()
Definition: DAClusterizerInZ_vect.h:181
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DAClusterizerInZ_vect::mintrkweight_
double mintrkweight_
Definition: DAClusterizerInZ_vect.h:245
DAClusterizerInZ_vect::dump
void dump(const double beta, const vertex_t &y, const track_t &tks, const int verbosity=0) const
Definition: DAClusterizerInZ_vect.cc:1102
OrderedSet.t
t
Definition: OrderedSet.py:90
DAClusterizerInZ_vect::updateTc
double updateTc(double beta, track_t &gtracks, vertex_t &gvertices, const double rho0=0) const
Definition: DAClusterizerInZ_vect.cc:397
DAClusterizerInZ_vect::beta0
double beta0(const double betamax, track_t const &tks, vertex_t const &y) const
Definition: DAClusterizerInZ_vect.cc:689
DAClusterizerInZ_vect::track_t
Definition: DAClusterizerInZ_vect.h:23
DAClusterizerInZ_vect::merge
bool merge(vertex_t &y, track_t &tks, double &beta) const
Definition: DAClusterizerInZ_vect.cc:583
Error.h
DAClusterizerInZ_vect::track_t::addItem
void addItem(double new_z, double new_dz2, const reco::TransientTrack *new_tt, double new_pi)
Definition: DAClusterizerInZ_vect.h:24
DAClusterizerInZ_vect::track_t::dz2_ptr
double *__restrict__ dz2_ptr
Definition: DAClusterizerInZ_vect.h:68
edm::ParameterSet
Definition: ParameterSet.h:36
DAClusterizerInZ_vect::track_t::z
std::vector< double > z
Definition: DAClusterizerInZ_vect.h:73
DAClusterizerInZ_vect::evalF
double evalF(const double beta, track_t const &tks, vertex_t const &v) const
Definition: DAClusterizerInZ_vect.cc:514
DAClusterizerInZ_vect::vertex_t::getSize
unsigned int getSize() const
Definition: DAClusterizerInZ_vect.h:94
DAClusterizerInZ_vect::track_t::getSize
unsigned int getSize() const
Definition: DAClusterizerInZ_vect.h:57
DAClusterizerInZ_vect::zdumpwidth_
double zdumpwidth_
Definition: DAClusterizerInZ_vect.h:235
DAClusterizerInZ_vect::track_t::dz2
std::vector< double > dz2
Definition: DAClusterizerInZ_vect.h:74
DAClusterizerInZ_vect::sel_zrange_
double sel_zrange_
Definition: DAClusterizerInZ_vect.h:254
DAClusterizerInZ_vect::vertex_t::insertItem
void insertItem(unsigned int k, double new_z, double new_pk, track_t &tks)
Definition: DAClusterizerInZ_vect.h:124
DAClusterizerInZ_vect::clear_vtx_range
void clear_vtx_range(track_t &gtracks, vertex_t &gvertices) const
Definition: DAClusterizerInZ_vect.cc:267
DAClusterizerInZ_vect::clusterize
std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const override
Definition: DAClusterizerInZ_vect.cc:1059
DAClusterizerInZ_vect::track_t::pi
std::vector< double > pi
Definition: DAClusterizerInZ_vect.h:76
DAClusterizerInZ_vect::track_t::z_ptr
double *__restrict__ z_ptr
Definition: DAClusterizerInZ_vect.h:67
DAClusterizerInZ_vect::vertex_t::swE
std::vector< double > swE
Definition: DAClusterizerInZ_vect.h:92
TransientVertex.h
DAClusterizerInZ_vect
Definition: DAClusterizerInZ_vect.h:20
DAClusterizerInZ_vect::delta_highT_
double delta_highT_
Definition: DAClusterizerInZ_vect.h:251
DAClusterizerInZ_vect::d0CutOff_
double d0CutOff_
Definition: DAClusterizerInZ_vect.h:243
reco::TransientTrack
Definition: TransientTrack.h:19
DAClusterizerInZ_vect::purge
bool purge(vertex_t &, track_t &, double &, const double) const
Definition: DAClusterizerInZ_vect.cc:638
DAClusterizerInZ_vect::uniquetrkweight_
double uniquetrkweight_
Definition: DAClusterizerInZ_vect.h:246
DAClusterizerInZ_vect::verbose_
bool verbose_
Definition: DAClusterizerInZ_vect.h:233
DAClusterizerInZ_vect::vertexSize_
double vertexSize_
Definition: DAClusterizerInZ_vect.h:237
ParameterSet.h
DAClusterizerInZ_vect::vertex_t::swE_ptr
double *__restrict__ swE_ptr
Definition: DAClusterizerInZ_vect.h:201
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:426
TrackClusterizerInZ.h
DAClusterizerInZ_vect::zdumpcenter_
double zdumpcenter_
Definition: DAClusterizerInZ_vect.h:234
DAClusterizerInZ_vect::vertex_t::pk
std::vector< double > pk
Definition: DAClusterizerInZ_vect.h:84
DAClusterizerInZ_vect::vertex_t
Definition: DAClusterizerInZ_vect.h:82
DAClusterizerInZ_vect::track_t::Z_sum
std::vector< double > Z_sum
Definition: DAClusterizerInZ_vect.h:75
DAClusterizerInZ_vect::delta_lowT_
double delta_lowT_
Definition: DAClusterizerInZ_vect.h:252
DAClusterizerInZ_vect::vertex_t::swz
std::vector< double > swz
Definition: DAClusterizerInZ_vect.h:90
DAClusterizerInZ_vect::betapurge_
double betapurge_
Definition: DAClusterizerInZ_vect.h:248
DAClusterizerInZ_vect::zrange_min_
const double zrange_min_
Definition: DAClusterizerInZ_vect.h:255
DAClusterizerInZ_vect::betastop_
double betastop_
Definition: DAClusterizerInZ_vect.h:241