CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Cluster1DMerger.h
Go to the documentation of this file.
1 #ifndef _Cluster1DMerger_H_
2 #define _Cluster1DMerger_H_
3 
6 
12 namespace pixeltemp {
13 
14 template < class T >
16 {
17 public:
18  Cluster1DMerger ( const WeightEstimator<T> &, const math::XYZPoint & bs = math::XYZPoint(0.,0.,0.) );
19  void setBeamSpot(const math::XYZPoint & bs) { theBS = bs; }
21  Cluster1DMerger ( const Cluster1DMerger & );
23  const Cluster1D<T> & second ) const;
24 private:
27 };
28 
29 /*
30  * implementation
31  */
32 
33 template <class T>
35 ( const WeightEstimator<T> & est, const math::XYZPoint & bs ) : theEstimator ( est.clone() ), theBS(bs)
36 {}
37 
38 template <class T>
40 {
41  delete theEstimator;
42 }
43 
44 template <class T>
46  theEstimator ( other.theEstimator->clone() ), theBS(other.theBS)
47 {}
48 
49 template <class T>
51  const Cluster1D<T> & second ) const
52 {
53  std::vector < const T * > tracks = first.tracks();
54  std::vector < const T * > sectracks = second.tracks();
55  for ( typename std::vector< const T * >::const_iterator i=sectracks.begin(); i!=sectracks.end() ; ++i )
56  {
57  tracks.push_back ( *i );
58  };
59  float newpos = ( first.position().value() * first.weight() / first.position().error() / first.position().error() +
60  second.position().value() * second.weight() / second.position().error() / second.position().error() ) /
61  ( first.weight() / first.position().error()/ first.position().error() +
62  second.weight() / second.position().error()/ second.position().error() );
63 
64  float newerr = sqrt ( first.position().error() * first.position().error() +
65  second.position().error() * second.position().error() );
66  float newWeight = theEstimator->weight ( tracks );
67 
68  // Now try a different method
69  float sumUp = 0;
70  float sumDown = 0;
71  float err = 0;
72  for (unsigned int i=0; i<tracks.size(); ++i) {
73 
74 // float err2 = tracks[i]->covariance( reco::TrackBase::i_dz, reco::TrackBase::i_dz );
75  float err2 = tracks[i]->dzError(); err2 *= err2;
76 
77  if (err2 != 0){
78  sumUp += tracks[i]->dz(theBS) * 1/err2; // error-weighted average of Z at IP
79  sumDown += 1/err2;
80  }
81  err += sqrt( err2 );
82  }
83 
84  newpos = sumUp/sumDown;
85  newerr = err/tracks.size()/sqrt(1.0*tracks.size());
86 
87  Measurement1D newmeas ( newpos, newerr );
88  return Cluster1D<T> ( newmeas, tracks, newWeight );
89 }
90 } // end of temporary namespace
91 #endif
int i
Definition: DBlmapReader.cc:9
void setBeamSpot(const math::XYZPoint &bs)
Cluster1D< T > operator()(const Cluster1D< T > &first, const Cluster1D< T > &second) const
double error() const
Definition: Measurement1D.h:30
Cluster1DMerger(const WeightEstimator< T > &, const math::XYZPoint &bs=math::XYZPoint(0., 0., 0.))
U second(std::pair< T, U > const &p)
T sqrt(T t)
Definition: SSEVec.h:46
WeightEstimator< T > * theEstimator
std::vector< const T * > tracks() const
Definition: Cluster1D.h:49
bool first
Definition: L1TdeRCT.cc:94
Measurement1D position() const
Definition: Cluster1D.h:55
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
double weight() const
Definition: Cluster1D.h:61
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
double value() const
Definition: Measurement1D.h:28
virtual WeightEstimator * clone() const =0