File indexing completed on 2024-04-06 11:58:08
0001 #include "CalibCalorimetry/HcalAlgos/interface/HcalPulseContainmentCorrection.h"
0002 #include "CalibCalorimetry/HcalAlgos/src/HcalPulseContainmentAlgo.h"
0003 #include "CalibCalorimetry/HcalAlgos/interface/HcalPulseShape.h"
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "CalibCalorimetry/HcalAlgos/interface/genlkupmap.h"
0014
0015
0016
0017 HcalPulseContainmentCorrection::HcalPulseContainmentCorrection(int num_samples,
0018 float fixedphase_ns,
0019 bool phaseAsInSim,
0020 float max_fracerror,
0021 const HcalTimeSlew* hcalTimeSlew_delay) {
0022 HcalPulseContainmentAlgo corFalgo(num_samples, (double)fixedphase_ns, phaseAsInSim, hcalTimeSlew_delay);
0023
0024
0025
0026
0027
0028
0029 genlkupmap<HcalPulseContainmentAlgo>(1.0,
0030 200000.0f,
0031 max_fracerror,
0032 1.0,
0033 corFalgo,
0034 mCorFactors_);
0035 }
0036
0037
0038 HcalPulseContainmentCorrection::HcalPulseContainmentCorrection(const HcalPulseShape* shape,
0039 int num_samples,
0040 float fixedphase_ns,
0041 bool phaseAsInSim,
0042 float max_fracerror,
0043 const HcalTimeSlew* hcalTimeSlew_delay) {
0044 HcalPulseContainmentAlgo corFalgo(shape, num_samples, (double)fixedphase_ns, phaseAsInSim, hcalTimeSlew_delay);
0045 genlkupmap<HcalPulseContainmentAlgo>(1.0,
0046 200000.0f,
0047 max_fracerror,
0048 1.0,
0049 corFalgo,
0050 mCorFactors_);
0051 }
0052
0053 double HcalPulseContainmentCorrection::getCorrection(double fc_ampl) const {
0054 double correction;
0055
0056 std::map<double, double>::const_iterator fcupper, fclower;
0057
0058 fcupper = mCorFactors_.upper_bound(fc_ampl);
0059 fclower = fcupper;
0060 fclower--;
0061
0062 if (fcupper == mCorFactors_.end()) {
0063 correction = fclower->second;
0064 } else if (fcupper == mCorFactors_.begin()) {
0065 correction = fcupper->second;
0066 } else {
0067 if (fabs(fclower->first - fc_ampl) < fabs(fcupper->first - fc_ampl))
0068 correction = fclower->second;
0069 else
0070 correction = fcupper->second;
0071 }
0072
0073 #if 0
0074 char s[80];
0075 sprintf (s, "%7.1f (%8.5f %8.5f) (%8.5f %8.5f) %8.5f",
0076 fc_ampl,
0077 fclower->first, fclower->second,
0078 fcupper->first, fcupper->second,
0079 correction);
0080 cout << s << endl;
0081 #endif
0082
0083 return correction;
0084 }