CMS 3D CMS Logo

parseHFPhase1AlgoDescription.cc
Go to the documentation of this file.
1 #include <cfloat>
2 
5 
6 // Phase 1 HF reco algorithm headers
9 
10 std::unique_ptr<AbsHFPhase1Algo>
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  const float minChargeForUndershoot =
33  ps.getParameter<double>("minChargeForUndershoot");
34  const float minChargeForOvershoot =
35  ps.getParameter<double>("minChargeForOvershoot");
36 
38  const unsigned sz = sizeof(energyWeights)/sizeof(energyWeights[0][0]);
39 
40  if (energyWeightsVec.size() == sz)
41  {
42  std::pair<float,float> tlimits[2];
43  if (isHFSimpleTimeCheck)
44  {
45  // Must specify the time limits explicitly for this algorithm
46  const std::vector<double>& tlimitsVec =
47  ps.getParameter<std::vector<double> >("tlimits");
48  if (tlimitsVec.size() == 4)
49  {
50  tlimits[0] = std::pair<float,float>(tlimitsVec[0], tlimitsVec[1]);
51  tlimits[1] = std::pair<float,float>(tlimitsVec[2], tlimitsVec[3]);
52  }
53  else
54  return algo;
55  }
56  else
57  {
58  // Use "all pass" time limits values, just in case
59  tlimits[0] = std::pair<float,float>(-FLT_MAX, FLT_MAX);
60  tlimits[1] = tlimits[0];
61  }
62 
63  // Same order of elements as in the natural C array mapping
64  float* to = &energyWeights[0][0];
65  for (unsigned i=0; i<sz; ++i)
66  to[i] = energyWeightsVec[i];
67 
68  // Create the algorithm object
69  if (isHFSimpleTimeCheck)
70  algo = std::unique_ptr<AbsHFPhase1Algo>(
71  new HFSimpleTimeCheck(tlimits, energyWeights, soiPhase,
72  timeShift, triseIfNoTDC, tfallIfNoTDC,
73  minChargeForUndershoot, minChargeForOvershoot,
74  rejectAllFailures));
75  else
76  algo = std::unique_ptr<AbsHFPhase1Algo>(
77  new HFFlexibleTimeCheck(tlimits, energyWeights, soiPhase,
78  timeShift, triseIfNoTDC, tfallIfNoTDC,
79  minChargeForUndershoot, minChargeForOvershoot,
80  rejectAllFailures));
81  }
82  }
83 
84  return algo;
85 }
86 
88 {
90 
91  std::vector<double> allPass{-10000.0, 10000.0, -10000.0, 10000.0};
92  desc.add<std::vector<double> >("tlimits", allPass);
93  desc.add<std::vector<double> >("energyWeights");
94  desc.add<unsigned>("soiPhase", 1U);
95  desc.add<double>("timeShift", 0.0);
96  desc.add<double>("triseIfNoTDC", -100.0);
97  desc.add<double>("tfallIfNoTDC", -101.0);
98  desc.add<double>("minChargeForUndershoot", 1.0e10);
99  desc.add<double>("minChargeForOvershoot", 1.0e10);
100 
101  desc.ifValue(edm::ParameterDescription<std::string>("Class", "HFSimpleTimeCheck", true),
102  "HFSimpleTimeCheck" >> edm::ParameterDescription<bool>("rejectAllFailures", false, true) or
103  "HFFlexibleTimeCheck" >> edm::ParameterDescription<bool>("rejectAllFailures", true, true));
104 
105  return desc;
106 }
T getParameter(std::string const &) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T > > cases)
std::unique_ptr< AbsHFPhase1Algo > parseHFPhase1AlgoDescription(const edm::ParameterSet &ps)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::string className(const T &t)
Definition: ClassName.h:30
edm::ParameterSetDescription fillDescriptionForParseHFPhase1AlgoDescription()