CMS 3D CMS Logo

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