CMS 3D CMS Logo

Namespaces | Functions
parseHFPhase1AlgoDescription.h File Reference
#include <memory>
#include "RecoLocalCalo/HcalRecAlgos/interface/AbsHFPhase1Algo.h"

Go to the source code of this file.

Namespaces

 edm
 HLT enums.
 

Functions

std::unique_ptr< AbsHFPhase1AlgoparseHFPhase1AlgoDescription (const edm::ParameterSet &ps)
 

Function Documentation

std::unique_ptr<AbsHFPhase1Algo> parseHFPhase1AlgoDescription ( const edm::ParameterSet ps)

Definition at line 11 of file parseHFPhase1AlgoDescription.cc.

References patPFMETCorrections_cff::algo, className(), HFPhase1Reconstructor_cfi::energyWeights, edm::ParameterSet::getParameter(), mps_fire::i, HFAnodeStatus::N_POSSIBLE_STATES, hcalLocalRecoNZS_cff::rejectAllFailures, HFPhase1Reconstructor_cfi::soiPhase, AlCaHLTBitMon_QueryRunRegistry::string, HFPhase1Reconstructor_cfi::tfallIfNoTDC, ctppsDiamondRecHits_cfi::timeShift, HFPhase1Reconstructor_cfi::tlimits, and HFPhase1Reconstructor_cfi::triseIfNoTDC.

12 {
13  std::unique_ptr<AbsHFPhase1Algo> algo;
14 
15  const std::string& className = ps.getParameter<std::string>("Class");
16 
17  const bool isHFSimpleTimeCheck = className == "HFSimpleTimeCheck";
18  if (isHFSimpleTimeCheck || className == "HFFlexibleTimeCheck")
19  {
20  const std::vector<double>& energyWeightsVec =
21  ps.getParameter<std::vector<double> >("energyWeights");
22  const unsigned soiPhase =
23  ps.getParameter<unsigned>("soiPhase");
24  const float timeShift =
25  ps.getParameter<double>("timeShift");
26  const float triseIfNoTDC =
27  ps.getParameter<double>("triseIfNoTDC");
28  const float tfallIfNoTDC =
29  ps.getParameter<double>("tfallIfNoTDC");
30  const bool rejectAllFailures =
31  ps.getParameter<bool>("rejectAllFailures");
32 
34  const unsigned sz = sizeof(energyWeights)/sizeof(energyWeights[0][0]);
35 
36  if (energyWeightsVec.size() == sz)
37  {
38  std::pair<float,float> tlimits[2];
39  if (isHFSimpleTimeCheck)
40  {
41  // Must specify the time limits explicitly for this algorithm
42  const std::vector<double>& tlimitsVec =
43  ps.getParameter<std::vector<double> >("tlimits");
44  if (tlimitsVec.size() == 4)
45  {
46  tlimits[0] = std::pair<float,float>(tlimitsVec[0], tlimitsVec[1]);
47  tlimits[1] = std::pair<float,float>(tlimitsVec[2], tlimitsVec[3]);
48  }
49  else
50  return algo;
51  }
52  else
53  {
54  // Use "all pass" time limits values, just in case
55  tlimits[0] = std::pair<float,float>(-FLT_MAX, FLT_MAX);
56  tlimits[1] = tlimits[0];
57  }
58 
59  // Same order of elements as in the natural C array mapping
60  float* to = &energyWeights[0][0];
61  for (unsigned i=0; i<sz; ++i)
62  to[i] = energyWeightsVec[i];
63 
64  // Create the algorithm object
65  if (isHFSimpleTimeCheck)
66  algo = std::unique_ptr<AbsHFPhase1Algo>(
67  new HFSimpleTimeCheck(tlimits, energyWeights, soiPhase,
68  timeShift, triseIfNoTDC, tfallIfNoTDC,
69  rejectAllFailures));
70  else
71  algo = std::unique_ptr<AbsHFPhase1Algo>(
72  new HFFlexibleTimeCheck(tlimits, energyWeights, soiPhase,
73  timeShift, triseIfNoTDC, tfallIfNoTDC,
74  rejectAllFailures));
75  }
76  }
77 
78  return algo;
79 }
T getParameter(std::string const &) const
std::string className(const T &t)
Definition: ClassName.h:30