CMS 3D CMS Logo

parseHBHEPhase1AlgoDescription.cc
Go to the documentation of this file.
1 #include <cassert>
2 
6 
9 
10 // Phase 1 HBHE reco algorithm headers
12 
13 static std::unique_ptr<MahiFit> parseHBHEMahiDescription(const edm::ParameterSet& conf) {
14  const bool iDynamicPed = conf.getParameter<bool>("dynamicPed");
15  const double iTS4Thresh = conf.getParameter<double>("ts4Thresh");
16  const double chiSqSwitch = conf.getParameter<double>("chiSqSwitch");
17 
18  const bool iApplyTimeSlew = conf.getParameter<bool>("applyTimeSlew");
19 
20  const bool iCalculateArrivalTime = conf.getParameter<bool>("calculateArrivalTime");
21  const double iMeanTime = conf.getParameter<double>("meanTime");
22  const double iTimeSigmaHPD = conf.getParameter<double>("timeSigmaHPD");
23  const double iTimeSigmaSiPM = conf.getParameter<double>("timeSigmaSiPM");
24 
25  const std::vector<int> iActiveBXs = conf.getParameter<std::vector<int>>("activeBXs");
26  const int iNMaxItersMin = conf.getParameter<int>("nMaxItersMin");
27  const int iNMaxItersNNLS = conf.getParameter<int>("nMaxItersNNLS");
28  const double iDeltaChiSqThresh = conf.getParameter<double>("deltaChiSqThresh");
29  const double iNnlsThresh = conf.getParameter<double>("nnlsThresh");
30 
31  std::unique_ptr<MahiFit> corr = std::make_unique<MahiFit>();
32 
33  corr->setParameters(iDynamicPed,
34  iTS4Thresh,
35  chiSqSwitch,
36  iApplyTimeSlew,
38  iCalculateArrivalTime,
39  iMeanTime,
40  iTimeSigmaHPD,
41  iTimeSigmaSiPM,
42  iActiveBXs,
43  iNMaxItersMin,
44  iNMaxItersNNLS,
45  iDeltaChiSqThresh,
46  iNnlsThresh);
47 
48  return corr;
49 }
50 
51 static std::unique_ptr<PulseShapeFitOOTPileupCorrection> parseHBHEMethod2Description(const edm::ParameterSet& conf) {
52  const bool iPedestalConstraint = conf.getParameter<bool>("applyPedConstraint");
53  const bool iTimeConstraint = conf.getParameter<bool>("applyTimeConstraint");
54  const bool iAddPulseJitter = conf.getParameter<bool>("applyPulseJitter");
55  const bool iApplyTimeSlew = conf.getParameter<bool>("applyTimeSlew");
56  const double iTS4Min = conf.getParameter<double>("ts4Min");
57  const std::vector<double> iTS4Max = conf.getParameter<std::vector<double>>("ts4Max");
58  const double iPulseJitter = conf.getParameter<double>("pulseJitter");
59  const double iTimeMean = conf.getParameter<double>("meanTime");
60  const double iTimeSigHPD = conf.getParameter<double>("timeSigmaHPD");
61  const double iTimeSigSiPM = conf.getParameter<double>("timeSigmaSiPM");
62  const double iPedMean = conf.getParameter<double>("meanPed");
63  const double iTMin = conf.getParameter<double>("timeMin");
64  const double iTMax = conf.getParameter<double>("timeMax");
65  const std::vector<double> its4Chi2 = conf.getParameter<std::vector<double>>("ts4chi2");
66  const int iFitTimes = conf.getParameter<int>("fitTimes");
67 
68  if (iTimeConstraint)
69  assert(iTimeSigHPD);
70  if (iTimeConstraint)
71  assert(iTimeSigSiPM);
72 
73  std::unique_ptr<PulseShapeFitOOTPileupCorrection> corr = std::make_unique<PulseShapeFitOOTPileupCorrection>();
74 
75  corr->setPUParams(iPedestalConstraint,
76  iTimeConstraint,
77  iAddPulseJitter,
78  iApplyTimeSlew,
79  iTS4Min,
80  iTS4Max,
81  iPulseJitter,
82  iTimeMean,
83  iTimeSigHPD,
84  iTimeSigSiPM,
85  iPedMean,
86  iTMin,
87  iTMax,
88  its4Chi2,
90  iFitTimes);
91 
92  return corr;
93 }
94 
95 static std::unique_ptr<HcalDeterministicFit> parseHBHEMethod3Description(const edm::ParameterSet& conf) {
96  const bool iApplyTimeSlew = conf.getParameter<bool>("applyTimeSlewM3");
97  const int iTimeSlewParsType = conf.getParameter<int>("timeSlewParsType");
98  const double irespCorrM3 = conf.getParameter<double>("respCorrM3");
99 
100  std::unique_ptr<HcalDeterministicFit> fit = std::make_unique<HcalDeterministicFit>();
101 
102  fit->init((HcalTimeSlew::ParaSource)iTimeSlewParsType, HcalTimeSlew::Medium, iApplyTimeSlew, irespCorrM3);
103 
104  return fit;
105 }
106 
107 std::unique_ptr<AbsHBHEPhase1Algo> parseHBHEPhase1AlgoDescription(const edm::ParameterSet& ps) {
108  std::unique_ptr<AbsHBHEPhase1Algo> algo;
109 
110  const std::string& className = ps.getParameter<std::string>("Class");
111 
112  if (className == "SimpleHBHEPhase1Algo") {
113  std::unique_ptr<MahiFit> mahi;
114  std::unique_ptr<PulseShapeFitOOTPileupCorrection> m2;
115  std::unique_ptr<HcalDeterministicFit> detFit;
116 
117  // only run Mahi OR Method 2 but not both
118  if (ps.getParameter<bool>("useMahi") && ps.getParameter<bool>("useM2")) {
119  throw cms::Exception("ConfigurationError")
120  << "SimpleHBHEPhase1Algo does not allow both Mahi and Method 2 to be turned on together.";
121  }
122  if (ps.getParameter<bool>("useMahi"))
123  mahi = parseHBHEMahiDescription(ps);
124  if (ps.getParameter<bool>("useM2"))
126  if (ps.getParameter<bool>("useM3"))
127  detFit = parseHBHEMethod3Description(ps);
128 
129  algo =
130  std::unique_ptr<AbsHBHEPhase1Algo>(new SimpleHBHEPhase1Algo(ps.getParameter<int>("firstSampleShift"),
131  ps.getParameter<int>("samplesToAdd"),
132  ps.getParameter<double>("correctionPhaseNS"),
133  ps.getParameter<double>("tdcTimeShift"),
134  ps.getParameter<bool>("correctForPhaseContainment"),
135  ps.getParameter<bool>("applyLegacyHBMCorrection"),
136  std::move(m2),
137  std::move(detFit),
138  std::move(mahi)));
139  }
140 
141  return algo;
142 }
143 
146 
147  desc.setAllowAnything();
148  desc.add<std::string>("Class", "SimpleHBHEPhase1Algo");
149  desc.add<bool>("useM2", false);
150  desc.add<bool>("useM3", true);
151  desc.add<bool>("useMahi", true);
152  desc.add<int>("firstSampleShift", 0);
153  desc.add<int>("samplesToAdd", 2);
154  desc.add<double>("correctionPhaseNS", 6.0);
155  desc.add<double>("tdcTimeShift", 0.0);
156  desc.add<bool>("correctForPhaseContainment", true);
157  desc.add<bool>("applyLegacyHBMCorrection", true);
158  desc.add<bool>("calculateArrivalTime", false);
159 
160  return desc;
161 }
T getParameter(std::string const &) const
void setAllowAnything()
allow any parameter label/value pairs
std::unique_ptr< AbsHBHEPhase1Algo > parseHBHEPhase1AlgoDescription(const edm::ParameterSet &ps)
static std::unique_ptr< PulseShapeFitOOTPileupCorrection > parseHBHEMethod2Description(const edm::ParameterSet &conf)
edm::ParameterSetDescription fillDescriptionForParseHBHEPhase1Algo()
ParameterDescriptionBase * add(U const &iLabel, T const &value)
JetCorrectorParameters corr
Definition: classes.h:5
static std::unique_ptr< MahiFit > parseHBHEMahiDescription(const edm::ParameterSet &conf)
static std::unique_ptr< HcalDeterministicFit > parseHBHEMethod3Description(const edm::ParameterSet &conf)
def move(src, dest)
Definition: eostools.py:511
std::string className(const T &t)
Definition: ClassName.h:31