test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
genlkupmap.h File Reference
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CalibCalorimetry/HcalAlgos/interface/HcalShapeIntegrator.h"
#include <algorithm>
#include <cmath>
#include <iostream>
#include <boost/scoped_ptr.hpp>

Go to the source code of this file.

Classes

class  RecoFCcorFactorAlgo< S >
 

Functions

template<class T_algo >
void genlkupmap (double smin, double smax, double max_fracerror, double min_sstep, T_algo &algoObject, std::map< double, double > &m_ylookup)
 

Function Documentation

template<class T_algo >
void genlkupmap ( double  smin,
double  smax,
double  max_fracerror,
double  min_sstep,
T_algo &  algoObject,
std::map< double, double > &  m_ylookup 
)

Definition at line 17 of file genlkupmap.h.

References gather_cfg::cout, reco::if(), bookConverter::max, alignCSCRings::s, and slope.

23 {
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);
27 
28  double slope = maxxy.second - minxy.second;
29  slope = (slope >= 0.0) ? 1.0 : -1.0;
30 
31  double sstep = min_sstep;
32 
33  for (double s=smin; lastxy.first<smax; s += sstep) {
34 
35  thisxy = algoObject.calcpair(s);
36 
37  double fracerror = slope*(thisxy.second - laststoredxy.second)/ thisxy.second;
38  double fracchange = slope*(thisxy.second - lastxy.second)/ thisxy.second;
39 
40  bool store_cur_pair = false;
41  bool store_prev_pair = false;
42 
43 #if 0
44  char str[80];
45  sprintf(str, "%7.1f %7.1f (%8.3f %8.4f) %8.5f %8.5f",
46  s, sstep, thisxy.first, thisxy.second, fracerror, fracchange);
47  cout << str;
48 #endif
49 
50  if (s == smin) {
51  store_cur_pair = true;
52  }
53  else if ((fracerror > 2*max_fracerror) ||
54  (thisxy.first > smax) ) {
55  if (sstep > min_sstep) {
56  // possibly overstepped the next entry, back up and reduce the step size
57  s -= sstep;
58  sstep = std::max(0.5*sstep, min_sstep);
59 #if 0
60  cout << endl;
61 #endif
62  continue;
63  }
64  else if (lastxy.second == laststoredxy.second) {
65  store_cur_pair = true;
66 
67  // current step size is too big for the max allowed fractional error,
68  // store current value and issue a warning.
69  //
70  // edm::LogWarning("HcalPulseContainmentCorrection::genlkupmap") << " fractional error max exceeded";
71  }
72  else {
73  store_prev_pair = true;
74 
75  // re-evaluate current yval with prev yval.
76  fracerror = slope*(thisxy.second - lastxy.second)/ thisxy.second;
77 
78  if (fracerror > 2*max_fracerror) {
79  store_cur_pair = true;
80 
81  // current step size is too big for the max allowed fractional error,
82  // store current value and issue a warning.
83  //
84  // edm::LogWarning("HcalPulseContainmentCorrection::genlkupmap") << " fractional error max exceeded";
85  }
86  }
87  }
88  else if ((fracerror < 1.9*max_fracerror) &&
89  (fracchange < 0.1*max_fracerror) &&
90  (thisxy.first < 0.99 * smax) ) {
91  // adapt step size to reduce iterations
92  sstep *= 2.0;
93  }
94 
95  if (thisxy.first > smax)
96  store_cur_pair = true;
97 
98  if (store_prev_pair) {
99  m_ylookup[lastxy.first] = lastxy.second;
100  laststoredxy = lastxy;
101  }
102  if (store_cur_pair) {
103  m_ylookup[thisxy.first] = thisxy.second;
104  laststoredxy = thisxy;
105  }
106 
107  lastxy = thisxy;
108 
109 #if 0
110  sprintf(str, " %c %c",
111  store_cur_pair ? 'C' : ' ',
112  store_prev_pair ? 'P' : ' ');
113  cout << str << endl;
114 #endif
115 
116  }
117 
118 }
static const double slope[3]
if(dp >Float(M_PI)) dp-
tuple cout
Definition: gather_cfg.py:145