CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
FsmwClusterizer1DNameSpace Namespace Reference

Functions

template<class T >
std::pair< typename
std::vector< Cluster1D< T >
>::const_iterator, typename
std::vector< Cluster1D< T >
>::const_iterator > 
fsmw (const std::vector< Cluster1D< T > > &values, double fraction)
 

Function Documentation

template<class T >
std::pair< typename std::vector< Cluster1D<T> >::const_iterator,typename std::vector< Cluster1D<T> >::const_iterator > FsmwClusterizer1DNameSpace::fsmw ( const std::vector< Cluster1D< T > > &  values,
double  fraction 
)

Definition at line 53 of file FsmwClusterizer1D.h.

References begin, gather_cfg::cout, end, HLT_25ns10e33_v2_cff::fraction, i, position, runTheMatrix::ret, findQualityFiles::size, createBeamHaloJobs::stepsize, makeHLTPrescaleTable::values, and w.

Referenced by FsmwClusterizer1D< T >::operator()().

54 {
55  typedef Cluster1D<T> Cluster1D;
56  typename std::vector< Cluster1D >::const_iterator begin = values.begin();
57  typename std::vector< Cluster1D >::const_iterator end = values.end()-1;
58 
59  while (1)
60  {
61 #ifdef FsmwClusterizer1DDebug
62  cout << "Begin at " << begin->position().value() << endl;
63 #endif
64 
65  const int size = (int) (end-begin);
66 #ifdef FsmwClusterizer1DDebug
67 
68  cout << "Size " << size << endl;
69 #endif
70 
71  int stepsize = (int) floor ( ( 1+ size ) * fraction );
72  if ( stepsize == 0 )
73  stepsize=1;
74 #ifdef FsmwClusterizer1DDebug
75 
76  cout << "Old end at " << end->position().value() << endl;
77 #endif
78 
79  end=begin+stepsize;
80  typename std::vector< Cluster1D >::const_iterator new_begin = begin;
81  typename std::vector< Cluster1D >::const_iterator new_end = end;
82 
83 #ifdef FsmwClusterizer1DDebug
84 
85  cout << "New end at " << end->position().value() << endl;
86  cout << "stepsize " << stepsize << endl;
87 #endif
88 
89  // Old version: used the weights of just the end points
90  // double totalweight = begin->weight() + end->weight();
91 
92  // new version: sums up the weights of all points involved
93  // _including_ the "end" point
94  double totalweight = end->weight();
95  for ( typename std::vector< Cluster1D >::const_iterator w=begin; w!=end ; ++w )
96  {
97  totalweight+=w->weight();
98  };
99 
100  double div=fabs ( end->position().value() - begin->position().value() ) /
101  totalweight;
102 #ifdef FsmwClusterizer1DDebug
103 
104  cout << "Div at " << begin->position().value() << ":" << (end)->position().value()
105  << " = " << div << endl;
106 #endif
107 
108  for ( typename std::vector< Cluster1D >::const_iterator i = (begin + 1);
109  i!=(begin + size - stepsize + 1); ++i )
110  {
111  // FIXME wrong
112  // double tmpweight = i->weight() + (i+stepsize)->weight();
113  //
114  // new version: sums up the weights of all points in the interval
115  // _including_ the end point (i+stepsize)
116  double tmpweight = 0.;
117  for ( typename std::vector< Cluster1D >::const_iterator wt=i; wt!=(i+stepsize+1); ++wt )
118  {
119  tmpweight+=wt->weight();
120  };
121 
122  double tmpdiv = fabs( i->position().value() - (i+stepsize)->position().value() )
123  / tmpweight;
124 #ifdef FsmwClusterizer1DDebug
125 
126  cout << "Div at " << i->position().value() << ":" << (i+stepsize)->position().value()
127  << " = " << tmpdiv << endl;
128 #endif
129 
130  if ( tmpdiv < div)
131  {
132  new_begin= i;
133  new_end = i+stepsize;
134  div= tmpdiv;
135  };
136  };
137 #ifdef FsmwClusterizer1DDebug
138 
139  cout << "---- new interval: " << new_begin->position().value()
140  << ":" << new_end->position().value() << endl;
141 #endif
142 
143  begin = new_begin;
144  end = new_end;
145  if ( size < 4 )
146  break;
147  };
148 
149  std::pair < typename std::vector< Cluster1D >::const_iterator,
150  typename std::vector< Cluster1D >::const_iterator > ret ( begin, end );
151  return ret;
152 }
int i
Definition: DBlmapReader.cc:9
tuple ret
prodAgent to be discontinued
const double w
Definition: UKUtility.cc:23
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
static int position[264][3]
Definition: ReadPGInfo.cc:509
tuple cout
Definition: gather_cfg.py:145
tuple size
Write out results.