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>
15 {
16 
17  const bool iDynamicPed = conf.getParameter<bool> ("dynamicPed");
18  const double iTS4Thresh = conf.getParameter<double> ("ts4Thresh");
19  const double chiSqSwitch = conf.getParameter<double> ("chiSqSwitch");
20 
21  const bool iApplyTimeSlew = conf.getParameter<bool> ("applyTimeSlew");
22 
23  const bool iCalculateArrivalTime = conf.getParameter<bool> ("calculateArrivalTime");
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, iTS4Thresh, chiSqSwitch, iApplyTimeSlew, HcalTimeSlew::Medium,
37  iCalculateArrivalTime, iMeanTime, iTimeSigmaHPD, iTimeSigmaSiPM,
38  iActiveBXs, iNMaxItersMin, iNMaxItersNNLS,
39  iDeltaChiSqThresh, iNnlsThresh);
40 
41  return corr;
42 }
43 
44 
45 static std::unique_ptr<PulseShapeFitOOTPileupCorrection>
47 {
48  const bool iPedestalConstraint = conf.getParameter<bool> ("applyPedConstraint");
49  const bool iTimeConstraint = conf.getParameter<bool> ("applyTimeConstraint");
50  const bool iAddPulseJitter = conf.getParameter<bool> ("applyPulseJitter");
51  const bool iApplyTimeSlew = conf.getParameter<bool> ("applyTimeSlew");
52  const double iTS4Min = conf.getParameter<double>("ts4Min");
53  const std::vector<double> iTS4Max = conf.getParameter<std::vector<double>>("ts4Max");
54  const double iPulseJitter = conf.getParameter<double>("pulseJitter");
55  const double iTimeMean = conf.getParameter<double>("meanTime");
56  const double iTimeSigHPD = conf.getParameter<double>("timeSigmaHPD");
57  const double iTimeSigSiPM = conf.getParameter<double>("timeSigmaSiPM");
58  const double iPedMean = conf.getParameter<double>("meanPed");
59  const double iTMin = conf.getParameter<double>("timeMin");
60  const double iTMax = conf.getParameter<double>("timeMax");
61  const std::vector<double> its4Chi2 = conf.getParameter<std::vector<double>>("ts4chi2");
62  const int iFitTimes = conf.getParameter<int> ("fitTimes");
63 
64  if (iTimeConstraint) assert(iTimeSigHPD);
65  if (iTimeConstraint) assert(iTimeSigSiPM);
66 
67  std::unique_ptr<PulseShapeFitOOTPileupCorrection> corr =
68  std::make_unique<PulseShapeFitOOTPileupCorrection>();
69 
70  corr->setPUParams(iPedestalConstraint, iTimeConstraint, iAddPulseJitter,
71  iApplyTimeSlew, iTS4Min, iTS4Max,
72  iPulseJitter,
73  iTimeMean,iTimeSigHPD, iTimeSigSiPM, iPedMean,
74  iTMin, iTMax, its4Chi2,
75  HcalTimeSlew::Medium, iFitTimes);
76 
77  return corr;
78 }
79 
80 
81 static std::unique_ptr<HcalDeterministicFit>
83 {
84  const bool iApplyTimeSlew = conf.getParameter<bool> ("applyTimeSlewM3");
85  const int iTimeSlewParsType = conf.getParameter<int> ("timeSlewParsType");
86  const double irespCorrM3 = conf.getParameter<double>("respCorrM3");
87 
88  std::unique_ptr<HcalDeterministicFit> fit = std::make_unique<HcalDeterministicFit>();
89 
90  fit->init( (HcalTimeSlew::ParaSource)iTimeSlewParsType,
91  HcalTimeSlew::Medium, iApplyTimeSlew,
92  irespCorrM3);
93 
94  return fit;
95 }
96 
97 
98 std::unique_ptr<AbsHBHEPhase1Algo>
100 {
101  std::unique_ptr<AbsHBHEPhase1Algo> algo;
102 
103  const std::string& className = ps.getParameter<std::string>("Class");
104 
105  if (className == "SimpleHBHEPhase1Algo")
106  {
107  std::unique_ptr<MahiFit> mahi;
108  std::unique_ptr<PulseShapeFitOOTPileupCorrection> m2;
109  std::unique_ptr<HcalDeterministicFit> detFit;
110 
111  // only run Mahi OR Method 2 but not both
112  if (ps.getParameter<bool>("useMahi") && ps.getParameter<bool>("useM2")) {
113  throw cms::Exception("ConfigurationError") <<
114  "SimpleHBHEPhase1Algo does not allow both Mahi and Method 2 to be turned on together.";
115  }
116  if (ps.getParameter<bool>("useMahi"))
117  mahi = parseHBHEMahiDescription(ps);
118  if (ps.getParameter<bool>("useM2"))
120  if (ps.getParameter<bool>("useM3"))
121  detFit = parseHBHEMethod3Description(ps);
122 
123  algo = std::unique_ptr<AbsHBHEPhase1Algo>(
124  new SimpleHBHEPhase1Algo(ps.getParameter<int> ("firstSampleShift"),
125  ps.getParameter<int> ("samplesToAdd"),
126  ps.getParameter<double>("correctionPhaseNS"),
127  ps.getParameter<double>("tdcTimeShift"),
128  ps.getParameter<bool> ("correctForPhaseContainment"),
129  ps.getParameter<bool> ("applyLegacyHBMCorrection"),
130  std::move(m2), std::move(detFit), std::move(mahi))
131  );
132  }
133 
134  return algo;
135 }
136 
137 
139 {
141 
142  desc.setAllowAnything();
143  desc.add<std::string>("Class", "SimpleHBHEPhase1Algo");
144  desc.add<bool>("useM2", false);
145  desc.add<bool>("useM3", true);
146  desc.add<bool>("useMahi", true);
147  desc.add<int>("firstSampleShift", 0);
148  desc.add<int>("samplesToAdd", 2);
149  desc.add<double>("correctionPhaseNS", 6.0);
150  desc.add<double>("tdcTimeShift", 0.0);
151  desc.add<bool>("correctForPhaseContainment", true);
152  desc.add<bool>("applyLegacyHBMCorrection", true);
153  desc.add<bool>("calculateArrivalTime", true);
154 
155  return desc;
156 }
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:30