Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:29

0001 #include <cfloat>
0002 
0003 #include "RecoLocalCalo/HcalRecAlgos/interface/parseHFPhase1AlgoDescription.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 
0006 // Phase 1 HF reco algorithm headers
0007 #include "RecoLocalCalo/HcalRecAlgos/interface/HFSimpleTimeCheck.h"
0008 #include "RecoLocalCalo/HcalRecAlgos/interface/HFFlexibleTimeCheck.h"
0009 
0010 std::unique_ptr<AbsHFPhase1Algo> parseHFPhase1AlgoDescription(const edm::ParameterSet& ps) {
0011   std::unique_ptr<AbsHFPhase1Algo> algo;
0012 
0013   const std::string& className = ps.getParameter<std::string>("Class");
0014 
0015   const bool isHFSimpleTimeCheck = className == "HFSimpleTimeCheck";
0016   if (isHFSimpleTimeCheck || className == "HFFlexibleTimeCheck") {
0017     const std::vector<double>& energyWeightsVec = ps.getParameter<std::vector<double> >("energyWeights");
0018     const unsigned soiPhase = ps.getParameter<unsigned>("soiPhase");
0019     const float timeShift = ps.getParameter<double>("timeShift");
0020     const float triseIfNoTDC = ps.getParameter<double>("triseIfNoTDC");
0021     const float tfallIfNoTDC = ps.getParameter<double>("tfallIfNoTDC");
0022     const bool rejectAllFailures = ps.getParameter<bool>("rejectAllFailures");
0023     const float minChargeForUndershoot = ps.getParameter<double>("minChargeForUndershoot");
0024     const float minChargeForOvershoot = ps.getParameter<double>("minChargeForOvershoot");
0025     const bool alwaysCalculateQAsymmetry = ps.getParameter<bool>("alwaysCalculateQAsymmetry");
0026 
0027     float energyWeights[2 * HFAnodeStatus::N_POSSIBLE_STATES - 1][2];
0028     const unsigned sz = sizeof(energyWeights) / sizeof(energyWeights[0][0]);
0029 
0030     if (energyWeightsVec.size() == sz) {
0031       std::pair<float, float> tlimits[2];
0032       if (isHFSimpleTimeCheck) {
0033         // Must specify the time limits explicitly for this algorithm
0034         const std::vector<double>& tlimitsVec = ps.getParameter<std::vector<double> >("tlimits");
0035         if (tlimitsVec.size() == 4) {
0036           tlimits[0] = std::pair<float, float>(tlimitsVec[0], tlimitsVec[1]);
0037           tlimits[1] = std::pair<float, float>(tlimitsVec[2], tlimitsVec[3]);
0038         } else
0039           return algo;
0040       } else {
0041         // Use "all pass" time limits values, just in case
0042         tlimits[0] = std::pair<float, float>(-FLT_MAX, FLT_MAX);
0043         tlimits[1] = tlimits[0];
0044       }
0045 
0046       // Same order of elements as in the natural C array mapping
0047       float* to = &energyWeights[0][0];
0048       for (unsigned i = 0; i < sz; ++i)
0049         to[i] = energyWeightsVec[i];
0050 
0051       // Create the algorithm object
0052       if (isHFSimpleTimeCheck)
0053         algo = std::unique_ptr<AbsHFPhase1Algo>(new HFSimpleTimeCheck(tlimits,
0054                                                                       energyWeights,
0055                                                                       soiPhase,
0056                                                                       timeShift,
0057                                                                       triseIfNoTDC,
0058                                                                       tfallIfNoTDC,
0059                                                                       minChargeForUndershoot,
0060                                                                       minChargeForOvershoot,
0061                                                                       rejectAllFailures,
0062                                                                       alwaysCalculateQAsymmetry));
0063       else
0064         algo = std::unique_ptr<AbsHFPhase1Algo>(new HFFlexibleTimeCheck(tlimits,
0065                                                                         energyWeights,
0066                                                                         soiPhase,
0067                                                                         timeShift,
0068                                                                         triseIfNoTDC,
0069                                                                         tfallIfNoTDC,
0070                                                                         minChargeForUndershoot,
0071                                                                         minChargeForOvershoot,
0072                                                                         rejectAllFailures,
0073                                                                         alwaysCalculateQAsymmetry));
0074     }
0075   }
0076 
0077   return algo;
0078 }
0079 
0080 edm::ParameterSetDescription fillDescriptionForParseHFPhase1AlgoDescription() {
0081   edm::ParameterSetDescription desc;
0082 
0083   std::vector<double> allPass{-10000.0, 10000.0, -10000.0, 10000.0};
0084   desc.add<std::vector<double> >("tlimits", allPass);
0085   desc.add<std::vector<double> >("energyWeights");
0086   desc.add<unsigned>("soiPhase", 1U);
0087   desc.add<double>("timeShift", 0.0);
0088   desc.add<double>("triseIfNoTDC", -100.0);
0089   desc.add<double>("tfallIfNoTDC", -101.0);
0090   desc.add<double>("minChargeForUndershoot", 1.0e10);
0091   desc.add<double>("minChargeForOvershoot", 1.0e10);
0092   desc.add<bool>("alwaysCalculateQAsymmetry", true);
0093 
0094   desc.ifValue(edm::ParameterDescription<std::string>("Class", "HFSimpleTimeCheck", true),
0095                "HFSimpleTimeCheck" >> edm::ParameterDescription<bool>("rejectAllFailures", false, true) or
0096                    "HFFlexibleTimeCheck" >> edm::ParameterDescription<bool>("rejectAllFailures", true, true));
0097 
0098   return desc;
0099 }