6 #include <boost/scoped_ptr.hpp>
16 template <
class T_algo>
22 std::map<double,double>& m_ylookup)
24 std::pair<double,double> thisxy, lastxy, laststoredxy;
25 std::pair<double,double> minxy = algoObject.calcpair(smin);
26 std::pair<double,double> maxxy = algoObject.calcpair(smax);
28 double slope = maxxy.second - minxy.second;
29 slope = (slope >= 0.0) ? 1.0 : -1.0;
31 double sstep = min_sstep;
33 for (
double s=smin; lastxy.first<smax;
s += sstep) {
35 thisxy = algoObject.calcpair(
s);
37 double fracerror = slope*(thisxy.second - laststoredxy.second)/ thisxy.second;
38 double fracchange = slope*(thisxy.second - lastxy.second)/ thisxy.second;
40 bool store_cur_pair =
false;
41 bool store_prev_pair =
false;
45 sprintf(str,
"%7.1f %7.1f (%8.3f %8.4f) %8.5f %8.5f",
46 s, sstep, thisxy.first, thisxy.second, fracerror, fracchange);
51 store_cur_pair =
true;
53 else if ((fracerror > 2*max_fracerror) ||
54 (thisxy.first > smax) ) {
55 if (sstep > min_sstep) {
58 sstep =
std::max(0.5*sstep, min_sstep);
64 else if (lastxy.second == laststoredxy.second) {
65 store_cur_pair =
true;
73 store_prev_pair =
true;
76 fracerror = slope*(thisxy.second - lastxy.second)/ thisxy.second;
78 if (fracerror > 2*max_fracerror) {
79 store_cur_pair =
true;
88 else if ((fracerror < 1.9*max_fracerror) &&
89 (fracchange < 0.1*max_fracerror) &&
90 (thisxy.first < 0.99 * smax) ) {
95 if (thisxy.first > smax)
96 store_cur_pair =
true;
98 if (store_prev_pair) {
99 m_ylookup[lastxy.first] = lastxy.second;
100 laststoredxy = lastxy;
102 if (store_cur_pair) {
103 m_ylookup[thisxy.first] = thisxy.second;
104 laststoredxy = thisxy;
110 sprintf(str,
" %c %c",
111 store_cur_pair ?
'C' :
' ',
112 store_prev_pair ?
'P' :
' ');
127 double fixedphase_ns);
128 std::pair<double,double>
calcpair(
double);
std::pair< double, double > calcpair(double)
static const double slope[3]
void genlkupmap(double smin, double smax, double max_fracerror, double min_sstep, T_algo &algoObject, std::map< double, double > &m_ylookup)
double integrationwindowns_
const boost::scoped_ptr< HcalShapeIntegrator > integrator_
const T & max(const T &a, const T &b)
RecoFCcorFactorAlgo(int num_samples, double fixedphase_ns)
perl if(1 lt scalar(@::datatypes))