CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoVertex/PrimaryVertexProducer/interface/DAClusterizerInZ_vect.h

Go to the documentation of this file.
00001 #ifndef DAClusterizerInZ_vect_h
00002 #define DAClusterizerInZ_vect_h
00003 
00012 #include "RecoVertex/PrimaryVertexProducer/interface/TrackClusterizerInZ.h"
00013 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include <vector>
00016 #include "DataFormats/Math/interface/Error.h"
00017 #include "RecoVertex/VertexTools/interface/VertexDistanceXY.h"
00018 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
00019 
00020 
00021 class DAClusterizerInZ_vect: public TrackClusterizerInZ {
00022 
00023 public:
00024         // Internal data structure to 
00025         struct track_t {
00026 
00027                 void AddItem( double new_z, double new_dz2, const reco::TransientTrack* new_tt, double new_pi   )
00028                 {
00029                         z.push_back( new_z );
00030                         dz2.push_back( new_dz2 );
00031                         tt.push_back( new_tt );
00032 
00033                         pi.push_back( new_pi ); // track weight
00034                         Z_sum.push_back( 1.0); // Z[i]   for DA clustering, initial value as done in ::fill
00035                 }
00036 
00037 
00038 
00039                 unsigned int GetSize() const
00040                 {
00041                         return z.size();
00042                 }
00043 
00044 
00045                 // has to be called everytime the items are modified
00046                 void ExtractRaw()
00047                 {
00048                         _z = &z.front();
00049                         _dz2 = &dz2.front();
00050                         _Z_sum = &Z_sum.front();
00051                         _pi = &pi.front();
00052                 }
00053 
00054                 double * __restrict__ _z; // z-coordinate at point of closest approach to the beamline
00055                 double * __restrict__  _dz2; // square of the error of z(pca)
00056 
00057                 double * __restrict__  _Z_sum; // Z[i]   for DA clustering
00058                 double * __restrict__  _pi; // track weight
00059 
00060                 std::vector<double> z; // z-coordinate at point of closest approach to the beamline
00061                 std::vector<double> dz2; // square of the error of z(pca)
00062                 std::vector< const reco::TransientTrack* > tt; // a pointer to the Transient Track
00063 
00064                 std::vector<double> Z_sum; // Z[i]   for DA clustering
00065                 std::vector<double> pi; // track weight
00066         };
00067 
00068         struct vertex_t {
00069                 std::vector<double> z; //           z coordinate
00070                 std::vector<double> pk; //           vertex weight for "constrained" clustering
00071 
00072                 // --- temporary numbers, used during update
00073                 std::vector<double> ei_cache;
00074                 std::vector<double> ei;
00075                 std::vector<double> sw;
00076                 std::vector<double> swz;
00077                 std::vector<double> se;
00078                 std::vector<double> swE;
00079 
00080 
00081                 unsigned int GetSize() const
00082                 {
00083                         return z.size();
00084                 }
00085 
00086                 void AddItem( double new_z, double new_pk   )
00087                 {
00088                         z.push_back( new_z);
00089                         pk.push_back( new_pk);
00090 
00091                         ei_cache.push_back( 0.0 );
00092                         ei.push_back( 0.0 );
00093                         sw.push_back( 0.0 );
00094                         swz.push_back( 0.0);
00095                         se.push_back( 0.0);
00096                         swE.push_back( 0.0);
00097 
00098                         ExtractRaw();
00099                 }
00100 
00101                 void InsertItem( unsigned int i, double new_z, double new_pk   )
00102                 {
00103                         z.insert(z.begin() + i, new_z);
00104                         pk.insert(pk.begin() + i, new_pk);
00105 
00106                         ei_cache.insert(ei_cache.begin() + i, 0.0 );
00107                         ei.insert( ei.begin()  + i, 0.0 );
00108                         sw.insert( sw.begin()  + i, 0.0 );
00109                         swz.insert(swz.begin() + i, 0.0 );
00110                         se.insert( se.begin()  + i, 0.0 );
00111                         swE.insert(swE.begin() + i, 0.0 );
00112 
00113                         ExtractRaw();
00114                 }
00115 
00116                 void RemoveItem( unsigned int i )
00117                 {
00118                         z.erase( z.begin() + i );
00119                         pk.erase( pk.begin() + i );
00120 
00121                         ei_cache.erase( ei_cache.begin() + i);
00122                         ei.erase( ei.begin() + i);
00123                         sw.erase( sw.begin() + i);
00124                         swz.erase( swz.begin() + i);
00125                         se.erase(se.begin() + i);
00126                         swE.erase(swE.begin() + i);
00127 
00128                         ExtractRaw();
00129                 }
00130 
00131                 void DebugOut()
00132                 {
00133                         std::cout <<  "vertex_t size: " << GetSize() << std::endl;
00134 
00135                         for ( unsigned int i =0; i < GetSize(); ++ i)
00136                         {
00137                                 std::cout << " z = " << _z[i] << " pk = " << _pk[i] << std::endl;
00138                         }
00139                 }
00140 
00141                 // has to be called everytime the items are modified
00142                 void ExtractRaw()
00143                 {
00144                         _z = &z.front();
00145                         _pk = &pk.front();
00146 
00147                         _ei = &ei.front();
00148                         _sw = &sw.front();
00149                         _swz = &swz.front();
00150                         _se = &se.front();
00151                         _swE = &swE.front();
00152                         _ei_cache = &ei_cache.front();
00153 
00154                 }
00155 
00156                 double * __restrict__ _z;
00157                 double * __restrict__ _pk;
00158 
00159                 double * __restrict__ _ei_cache;
00160                 double * __restrict__ _ei;
00161                 double * __restrict__ _sw;
00162                 double * __restrict__ _swz;
00163                 double * __restrict__ _se;
00164                 double * __restrict__ _swE;
00165 
00166         };
00167 
00168         DAClusterizerInZ_vect(const edm::ParameterSet& conf);
00169 
00170 
00171         std::vector<std::vector<reco::TransientTrack> >
00172         clusterize(const std::vector<reco::TransientTrack> & tracks) const;
00173 
00174 
00175         std::vector<TransientVertex>
00176         vertices(const std::vector<reco::TransientTrack> & tracks,
00177                         const int verbosity = 0) const ;
00178 
00179         track_t fill(const std::vector<reco::TransientTrack> & tracks) const;
00180 
00181         double update(double beta, track_t & gtracks,
00182                         vertex_t & gvertices, bool useRho0, double & rho0) const;
00183 
00184         void dump(const double beta, const vertex_t & y,
00185                         const track_t & tks, const int verbosity = 0) const;
00186         bool merge(vertex_t &) const;
00187         bool merge(vertex_t & y, double & beta)const;
00188         bool purge(vertex_t &, track_t &, double &,
00189                         const double) const;
00190 
00191         void splitAll( vertex_t & y) const;
00192         bool split(const double beta,  track_t &t, vertex_t & y ) const;
00193 
00194         double beta0(const double betamax, track_t & tks, vertex_t & y) const;
00195 
00196         double Eik( double const& t_z, double const& k_z, double const& t_dz2) const;
00197 
00198         inline double local_exp( double const& inp) const;
00199         inline void local_exp_list( double* arg_inp, double* arg_out,const int arg_arr_size) const;
00200 
00201 private:
00202         bool verbose_;
00203         float vertexSize_;
00204         int maxIterations_;
00205         double coolingFactor_;
00206         float betamax_;
00207         float betastop_;
00208         double dzCutOff_;
00209         double d0CutOff_;
00210         bool use_vdt_;
00211         bool useTc_;
00212 };
00213 
00214 
00215 //#ifndef DAClusterizerInZ_new_h
00216 #endif