14 template <
class T_algo>
20 std::map<double,double>& m_ylookup)
22 std::pair<double,double> thisxy, lastxy, laststoredxy;
23 std::pair<double,double> minxy = algoObject.calcpair(smin);
24 std::pair<double,double> maxxy = algoObject.calcpair(smax);
26 double slope = maxxy.second - minxy.second;
27 slope = (slope >= 0.0) ? 1.0 : -1.0;
29 double sstep = min_sstep;
31 for (
double s=smin; lastxy.first<smax;
s += sstep) {
33 thisxy = algoObject.calcpair(
s);
35 double fracerror = slope*(thisxy.second - laststoredxy.second)/ thisxy.second;
36 double fracchange = slope*(thisxy.second - lastxy.second)/ thisxy.second;
38 bool store_cur_pair =
false;
39 bool store_prev_pair =
false;
43 sprintf(str,
"%7.1f %7.1f (%8.3f %8.4f) %8.5f %8.5f",
44 s, sstep, thisxy.first, thisxy.second, fracerror, fracchange);
49 store_cur_pair =
true;
51 else if ((fracerror > 2*max_fracerror) ||
52 (thisxy.first > smax) ) {
53 if (sstep > min_sstep) {
56 sstep =
std::max(0.5*sstep, min_sstep);
62 else if (lastxy.second == laststoredxy.second) {
63 store_cur_pair =
true;
68 edm::LogWarning(
"HcalPulseContainmentCorrection::genlkupmap") <<
" fractional error max exceeded";
71 store_prev_pair =
true;
74 fracerror = slope*(thisxy.second - lastxy.second)/ thisxy.second;
76 if (fracerror > 2*max_fracerror) {
77 store_cur_pair =
true;
82 edm::LogWarning(
"HcalPulseContainmentCorrection::genlkupmap") <<
" fractional error max exceeded";
86 else if ((fracerror < 1.9*max_fracerror) &&
87 (fracchange < 0.1*max_fracerror) &&
88 (thisxy.first < 0.99 * smax) ) {
93 if (thisxy.first > smax)
94 store_cur_pair =
true;
96 if (store_prev_pair) {
97 m_ylookup[lastxy.first] = lastxy.second;
98 laststoredxy = lastxy;
100 if (store_cur_pair) {
101 m_ylookup[thisxy.first] = thisxy.second;
102 laststoredxy = thisxy;
108 sprintf(str,
" %c %c",
109 store_cur_pair ?
'C' :
' ',
110 store_prev_pair ?
'P' :
' ');
125 double fixedphase_ns);
127 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 T & max(const T &a, const T &b)
RecoFCcorFactorAlgo(int num_samples, double fixedphase_ns)
perl if(1 lt scalar(@::datatypes))