Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:14

0001 #include <cfloat>
0002 
0003 #include "CondTools/Hcal/interface/make_HFPhase1PMTParams.h"
0004 
0005 #include "CondFormats/HcalObjects/interface/HcalDetIdTransform.h"
0006 #include "CondFormats/HcalObjects/interface/HcalConstFunctor.h"
0007 #include "CondFormats/HcalObjects/interface/HcalPiecewiseLinearFunctor.h"
0008 #include "CondFormats/HcalObjects/interface/HcalLinearCompositionFunctor.h"
0009 
0010 #if BOOST_VERSION < 105600 || BOOST_VERSION > 105800
0011 #ifdef BAD_BOOST_VERSION
0012 #undef BAD_BOOST_VERSION
0013 #endif
0014 #else
0015 #define BAD_BOOST_VERSION
0016 #endif
0017 
0018 std::unique_ptr<HFPhase1PMTParams> make_HFPhase1PMTParams_test() {
0019   typedef std::pair<double, double> P;
0020 
0021   // Create HFPhase1PMTData configuration for testing
0022   // cut visualization code. Note that the cut values
0023   // used are absolutely not realistic.
0024   HFPhase1PMTData::Cuts cuts;
0025 
0026   const double minCharge0 = 10.0;
0027   const double minCharge1 = 20.0;
0028   const double minChargeAsymm = 30.0;
0029 
0030   std::vector<P> pts;
0031   pts.push_back(P(minCharge0, 10.0));
0032   pts.push_back(P(10.0 * minCharge0, 12.0));
0033   pts.push_back(P(20.0 * minCharge0, 13.0));
0034   cuts[HFPhase1PMTData::T_0_MIN] = std::shared_ptr<AbsHcalFunctor>(new HcalPiecewiseLinearFunctor(pts, false, false));
0035 
0036   pts.clear();
0037   pts.push_back(P(minCharge0, 20.0));
0038   pts.push_back(P(10.0 * minCharge0, 18.0));
0039   pts.push_back(P(20.0 * minCharge0, 17.0));
0040   cuts[HFPhase1PMTData::T_0_MAX] = std::shared_ptr<AbsHcalFunctor>(new HcalPiecewiseLinearFunctor(pts, false, false));
0041 
0042 #ifdef BAD_BOOST_VERSION
0043   pts.clear();
0044   pts.push_back(P(minCharge0, 10.0 - 2.0));
0045   pts.push_back(P(10.0 * minCharge0, 12.0 - 2.0));
0046   pts.push_back(P(20.0 * minCharge0, 13.0 - 2.0));
0047   cuts[HFPhase1PMTData::T_1_MIN] = std::shared_ptr<AbsHcalFunctor>(new HcalPiecewiseLinearFunctor(pts, false, false));
0048 #else
0049   cuts[HFPhase1PMTData::T_1_MIN] =
0050       std::shared_ptr<AbsHcalFunctor>(new HcalLinearCompositionFunctor(cuts[HFPhase1PMTData::T_0_MIN], 1.0, -2.0));
0051 #endif
0052 
0053 #ifdef BAD_BOOST_VERSION
0054   pts.clear();
0055   pts.push_back(P(minCharge0, 20.0 + 2.0));
0056   pts.push_back(P(10.0 * minCharge0, 18.0 + 2.0));
0057   pts.push_back(P(20.0 * minCharge0, 17.0 + 2.0));
0058   cuts[HFPhase1PMTData::T_1_MAX] = std::shared_ptr<AbsHcalFunctor>(new HcalPiecewiseLinearFunctor(pts, false, false));
0059 #else
0060   cuts[HFPhase1PMTData::T_1_MAX] =
0061       std::shared_ptr<AbsHcalFunctor>(new HcalLinearCompositionFunctor(cuts[HFPhase1PMTData::T_0_MAX], 1.0, 2.0));
0062 #endif
0063 
0064   pts.clear();
0065   pts.push_back(P(5.0 * minChargeAsymm, 2.0));
0066   pts.push_back(P(10.0 * minChargeAsymm, 1.0));
0067   cuts[HFPhase1PMTData::ASYMM_MAX] = std::shared_ptr<AbsHcalFunctor>(new HcalPiecewiseLinearFunctor(pts, false, false));
0068 
0069 #ifdef BAD_BOOST_VERSION
0070   pts.clear();
0071   pts.push_back(P(5.0 * minChargeAsymm, -2.0));
0072   pts.push_back(P(10.0 * minChargeAsymm, -1.0));
0073   cuts[HFPhase1PMTData::ASYMM_MIN] = std::shared_ptr<AbsHcalFunctor>(new HcalPiecewiseLinearFunctor(pts, false, false));
0074 #else
0075   cuts[HFPhase1PMTData::ASYMM_MIN] =
0076       std::shared_ptr<AbsHcalFunctor>(new HcalLinearCompositionFunctor(cuts[HFPhase1PMTData::ASYMM_MAX], -1.0, 0.0));
0077 #endif
0078 
0079   std::unique_ptr<HFPhase1PMTData> defaultItem(new HFPhase1PMTData(cuts, minCharge0, minCharge1, minChargeAsymm));
0080 
0081   // Other parts needed to create HFPhase1PMTParams
0082   const unsigned detIdTransformCode = HcalDetIdTransform::RAWID;
0083   HcalIndexLookup lookup;
0084   HcalItemColl<HFPhase1PMTData> coll;
0085 
0086   HcalDetId id(HcalForward, 29, 5, 1);
0087   lookup.add(HcalDetIdTransform::transform(id, detIdTransformCode), 0);
0088 
0089 #ifdef BAD_BOOST_VERSION
0090   pts.clear();
0091   pts.push_back(P(5.0 * minChargeAsymm, -2.0 + 1.0));
0092   pts.push_back(P(10.0 * minChargeAsymm, -1.0 + 1.0));
0093   cuts[HFPhase1PMTData::ASYMM_MIN] = std::shared_ptr<AbsHcalFunctor>(new HcalPiecewiseLinearFunctor(pts, false, false));
0094 #else
0095   cuts[HFPhase1PMTData::ASYMM_MIN] =
0096       std::shared_ptr<AbsHcalFunctor>(new HcalLinearCompositionFunctor(cuts[HFPhase1PMTData::ASYMM_MAX], -1.0, 1.0));
0097 #endif
0098 
0099   std::unique_ptr<HFPhase1PMTData> firstItem(new HFPhase1PMTData(cuts, minCharge0, minCharge1, minChargeAsymm));
0100   coll.push_back(std::move(firstItem));
0101 
0102   return std::unique_ptr<HFPhase1PMTParams>(
0103       new HFPhase1PMTParams(coll, lookup, detIdTransformCode, std::move(defaultItem)));
0104 }