CMS 3D CMS Logo

DAClusterizerInZT_vect.h
Go to the documentation of this file.
1 #ifndef DAClusterizerInZT_vect_h
2 #define DAClusterizerInZT_vect_h
3 
15 #include <vector>
19 
20 #include <memory>
21 
23 
24 public:
25 
26  // Internal data structure to
27  struct track_t {
28 
29  void addItem( double new_z, double new_t, double new_dz2, double new_dt2, const reco::TransientTrack* new_tt, double new_pi )
30  {
31  z.push_back( new_z );
32  t.push_back( new_t );
33  dz2.push_back( new_dz2 );
34  dt2.push_back( new_dt2 );
35  errsum.push_back( 1./(1./new_dz2 + 1./new_dt2) );
36  tt.push_back( new_tt );
37 
38  pi.push_back( new_pi ); // track weight
39  Z_sum.push_back( 1.0 ); // Z[i] for DA clustering, initial value as done in ::fill
40  }
41 
42  unsigned int getSize() const
43  {
44  return z.size();
45  }
46 
47  // has to be called everytime the items are modified
48  void extractRaw()
49  {
50  z_ = &z.front();
51  t_ = &t.front();
52  dz2_ = &dz2.front();
53  dt2_ = &dt2.front();
54  errsum_ = &errsum.front();
55  Z_sum_ = &Z_sum.front();
56  pi_ = &pi.front();
57  }
58 
59  double * z_; // z-coordinate at point of closest approach to the beamline
60  double * t_; // t-coordinate at point of closest approach to the beamline
61  double * pi_; // track weight
62 
63  double * dz2_; // square of the error of z(pca)
64  double * dt2_; // square of the error of t(pca)
65  double * errsum_; // sum of squares of the pca errors
66  double * Z_sum_; // Z[i] for DA clustering
67 
68  std::vector<double> z; // z-coordinate at point of closest approach to the beamline
69  std::vector<double> t; // t-coordinate at point of closest approach to the beamline
70  std::vector<double> dz2; // square of the error of z(pca)
71  std::vector<double> dt2; // square of the error of t(pca)
72  std::vector<double> errsum; // sum of squares of the pca errors
73  std::vector<double> Z_sum; // Z[i] for DA clustering
74  std::vector<double> pi; // track weight
75  std::vector< const reco::TransientTrack* > tt; // a pointer to the Transient Track
76  };
77 
78  struct vertex_t {
79 
80  void addItem( double new_z, double new_t, double new_pk )
81  {
82  z.push_back( new_z);
83  t.push_back( new_t);
84  pk.push_back( new_pk);
85 
86  ei_cache.push_back( 0.0 );
87  ei.push_back( 0.0 );
88  sw.push_back( 0.0 );
89  swz.push_back( 0.0);
90  swt.push_back( 0.0);
91  se.push_back( 0.0);
92  swE.push_back( 0.0);
93 
94  extractRaw();
95  }
96 
97  unsigned int getSize() const
98  {
99  return z.size();
100  }
101 
102  // has to be called everytime the items are modified
103  void extractRaw()
104  {
105  z_ = &z.front();
106  t_ = &t.front();
107  pk_ = &pk.front();
108 
109  ei_ = &ei.front();
110  sw_ = &sw.front();
111  swz_ = &swz.front();
112  swt_ = &swt.front();
113  se_ = &se.front();
114  swE_ = &swE.front();
115  ei_cache_ = &ei_cache.front();
116 
117  }
118 
119  void insertItem( unsigned int i, double new_z, double new_t, double new_pk )
120  {
121  z.insert(z.begin() + i, new_z);
122  t.insert(t.begin() + i, new_t);
123  pk.insert(pk.begin() + i, new_pk);
124 
125  ei_cache.insert(ei_cache.begin() + i, 0.0 );
126  ei.insert( ei.begin() + i, 0.0 );
127  sw.insert( sw.begin() + i, 0.0 );
128  swz.insert(swz.begin() + i, 0.0 );
129  swt.insert(swt.begin() + i, 0.0 );
130  se.insert( se.begin() + i, 0.0 );
131  swE.insert(swE.begin() + i, 0.0 );
132 
133  extractRaw();
134  }
135 
136  void removeItem( unsigned int i )
137  {
138  z.erase( z.begin() + i );
139  t.erase( t.begin() + i );
140  pk.erase( pk.begin() + i );
141 
142  ei_cache.erase( ei_cache.begin() + i);
143  ei.erase( ei.begin() + i);
144  sw.erase( sw.begin() + i);
145  swz.erase( swz.begin() + i);
146  swt.erase( swt.begin() + i);
147  se.erase(se.begin() + i);
148  swE.erase(swE.begin() + i);
149 
150  extractRaw();
151  }
152 
153  void debugOut()
154  {
155  std::cout << "vertex_t size: " << getSize() << std::endl;
156 
157  for ( unsigned int i =0; i < getSize(); ++ i)
158  {
159  std::cout << " z = " << z_[i] << " t = " << t_[i] << " pk = " << pk_[i] << std::endl;
160  }
161  }
162 
163  std::vector<double> z; // z coordinate
164  std::vector<double> t; // t coordinate
165  std::vector<double> pk; // vertex weight for "constrained" clustering
166 
167  double * z_;
168  double * t_;
169  double * pk_;
170 
171  double * ei_cache_;
172  double * ei_;
173  double * sw_;
174  double * swz_;
175  double * swt_;
176  double * se_;
177  double * swE_;
178 
179  // --- temporary numbers, used during update
180  std::vector<double> ei_cache;
181  std::vector<double> ei;
182  std::vector<double> sw;
183  std::vector<double> swz;
184  std::vector<double> swt;
185  std::vector<double> se;
186  std::vector<double> swE;
187  };
188 
190 
191  std::vector<std::vector<reco::TransientTrack> >
192  clusterize(const std::vector<reco::TransientTrack> & tracks) const override;
193 
194  std::vector<TransientVertex>
195  vertices(const std::vector<reco::TransientTrack> & tracks,
196  const int verbosity = 0) const ;
197 
198  track_t fill(const std::vector<reco::TransientTrack> & tracks) const;
199 
200  double update(double beta, track_t & gtracks,
201  vertex_t & gvertices, bool useRho0, const double & rho0) const;
202 
203  void dump(const double beta, const vertex_t & y,
204  const track_t & tks, const int verbosity = 0) const;
205  bool merge(vertex_t & y, double & beta)const;
206  bool purge(vertex_t &, track_t &, double &,
207  const double) const;
208  void splitAll( vertex_t & y) const;
209  bool split(const double beta, track_t &t, vertex_t & y, double threshold = 1. ) const;
210 
211  double beta0(const double betamax, track_t const & tks, vertex_t const & y) const;
212 
213 
214 private:
215  bool verbose_;
216  double zdumpcenter_;
217  double zdumpwidth_;
218 
219  double vertexSize_;
223  double betamax_;
224  double betastop_;
225  double dzCutOff_;
226  double d0CutOff_;
227  double dtCutOff_;
228  bool useTc_;
229 
232  double zmerge_;
233  double tmerge_;
234  double betapurge_;
235 
236 };
237 
238 
239 //#ifndef DAClusterizerInZT_new_h
240 #endif
const double beta
std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const override
bool split(const double beta, track_t &t, vertex_t &y, double threshold=1.) const
void splitAll(vertex_t &y) const
DAClusterizerInZT_vect(const edm::ParameterSet &conf)
bool merge(vertex_t &y, double &beta) const
void addItem(double new_z, double new_t, double new_dz2, double new_dt2, const reco::TransientTrack *new_tt, double new_pi)
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks, const int verbosity=0) const
void insertItem(unsigned int i, double new_z, double new_t, double new_pk)
bool purge(vertex_t &, track_t &, double &, const double) const
double update(double beta, track_t &gtracks, vertex_t &gvertices, bool useRho0, const double &rho0) const
void addItem(double new_z, double new_t, double new_pk)
track_t fill(const std::vector< reco::TransientTrack > &tracks) const
double beta0(const double betamax, track_t const &tks, vertex_t const &y) const
std::vector< const reco::TransientTrack * > tt
void dump(const double beta, const vertex_t &y, const track_t &tks, const int verbosity=0) const