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 #include <cmath>
7 
13 template < class T >
15 {
16 public:
19  Cluster1DMerger ( const Cluster1DMerger & );
21  const Cluster1D<T> & second ) const;
22 private:
24 };
25 
26 /*
27  * implementation
28  */
29 
30 template <class T>
32 ( const WeightEstimator<T> & est ) : theEstimator ( est.clone() )
33 {}
34 
35 template <class T>
37 {
38  delete theEstimator;
39 }
40 
41 template <class T>
43  theEstimator ( other.theEstimator->clone() )
44 {}
45 
46 template <class T>
48  const Cluster1D<T> & second ) const
49 {
50  std::vector < const T * > tracks = first.tracks();
51  std::vector < const T * > sectracks = second.tracks();
52  for ( typename std::vector< const T * >::const_iterator i=sectracks.begin();
53  i!=sectracks.end() ; ++i )
54  {
55  tracks.push_back ( *i );
56  };
57  double V1=first.position().error() * first.position().error();
58  double V2=second.position().error() * second.position().error();
59  double C1=first.weight() / V1;
60  double C2=second.weight() / V2;
61 
62  double newpos = ( first.position().value() * C1 +
63  second.position().value() * C2 ) / ( C1 + C2 );
64 
65  double newerr = sqrt ( C1 * C1 * V1 + C2 * C2 * V2 ) / ( C1 + C2 );
66  double newWeight = theEstimator->weight ( tracks );
67 
68  Measurement1D newmeas ( newpos, newerr );
69  return Cluster1D<T> ( newmeas, tracks, newWeight );
70 }
71 
72 #endif
int i
Definition: DBlmapReader.cc:9
double error() const
Definition: Measurement1D.h:30
Cluster1DMerger(const WeightEstimator< T > &)
U second(std::pair< T, U > const &p)
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< const T * > tracks() const
Definition: Cluster1D.h:49
Cluster1D< T > operator()(const Cluster1D< T > &first, const Cluster1D< T > &second) const
Measurement1D position() const
Definition: Cluster1D.h:55
tuple tracks
Definition: testEve_cfg.py:39
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
WeightEstimator< T > * theEstimator
virtual WeightEstimator * clone() const =0