CMS 3D CMS Logo

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

◆ fsmw()

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 51 of file FsmwClusterizer1D.h.

51  {
52  typedef Cluster1D<T> Cluster1D;
53  typename std::vector<Cluster1D>::const_iterator begin = values.begin();
54  typename std::vector<Cluster1D>::const_iterator end = values.end() - 1;
55 
56  while (true) {
57 #ifdef FsmwClusterizer1DDebug
58  cout << "Begin at " << begin->position().value() << endl;
59 #endif
60 
61  const int size = (int)(end - begin);
62 #ifdef FsmwClusterizer1DDebug
63 
64  cout << "Size " << size << endl;
65 #endif
66 
67  int stepsize = (int)floor((1 + size) * fraction);
68  if (stepsize == 0)
69  stepsize = 1;
70 #ifdef FsmwClusterizer1DDebug
71 
72  cout << "Old end at " << end->position().value() << endl;
73 #endif
74 
75  end = begin + stepsize;
76  typename std::vector<Cluster1D>::const_iterator new_begin = begin;
77  typename std::vector<Cluster1D>::const_iterator new_end = end;
78 
79 #ifdef FsmwClusterizer1DDebug
80 
81  cout << "New end at " << end->position().value() << endl;
82  cout << "stepsize " << stepsize << endl;
83 #endif
84 
85  // Old version: used the weights of just the end points
86  // double totalweight = begin->weight() + end->weight();
87 
88  // new version: sums up the weights of all points involved
89  // _including_ the "end" point
90  double totalweight = end->weight();
91  for (typename std::vector<Cluster1D>::const_iterator w = begin; w != end; ++w) {
92  totalweight += w->weight();
93  };
94 
95  double div = fabs(end->position().value() - begin->position().value()) / totalweight;
96 #ifdef FsmwClusterizer1DDebug
97 
98  cout << "Div at " << begin->position().value() << ":" << (end)->position().value() << " = " << div << endl;
99 #endif
100 
101  for (typename std::vector<Cluster1D>::const_iterator i = (begin + 1); i != (begin + size - stepsize + 1); ++i) {
102  // FIXME wrong
103  // double tmpweight = i->weight() + (i+stepsize)->weight();
104  //
105  // new version: sums up the weights of all points in the interval
106  // _including_ the end point (i+stepsize)
107  double tmpweight = 0.;
108  for (typename std::vector<Cluster1D>::const_iterator wt = i; wt != (i + stepsize + 1); ++wt) {
109  tmpweight += wt->weight();
110  };
111 
112  double tmpdiv = fabs(i->position().value() - (i + stepsize)->position().value()) / tmpweight;
113 #ifdef FsmwClusterizer1DDebug
114 
115  cout << "Div at " << i->position().value() << ":" << (i + stepsize)->position().value() << " = " << tmpdiv
116  << endl;
117 #endif
118 
119  if (tmpdiv < div) {
120  new_begin = i;
121  new_end = i + stepsize;
122  div = tmpdiv;
123  };
124  };
125 #ifdef FsmwClusterizer1DDebug
126 
127  cout << "---- new interval: " << new_begin->position().value() << ":" << new_end->position().value() << endl;
128 #endif
129 
130  begin = new_begin;
131  end = new_end;
132  if (size < 4)
133  break;
134  };
135 
136  std::pair<typename std::vector<Cluster1D>::const_iterator, typename std::vector<Cluster1D>::const_iterator> ret(
137  begin, end);
138  return ret;
139  }

References gather_cfg::cout, mps_fire::end, HLT_FULL_cff::fraction, mps_fire::i, createfilelist::int, position, runTheMatrix::ret, findQualityFiles::size, createBeamHaloJobs::stepsize, contentValuesCheck::values, and w.

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

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:543
mps_fire.i
i
Definition: mps_fire.py:428
Cluster1D
Definition: Cluster1D.h:13
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52823
w
const double w
Definition: UKUtility.cc:23
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
mps_fire.end
end
Definition: mps_fire.py:242
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
createfilelist.int
int
Definition: createfilelist.py:10
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
createBeamHaloJobs.stepsize
stepsize
Definition: createBeamHaloJobs.py:204