CMS 3D CMS Logo

PFClusterParamsESProducer.cc
Go to the documentation of this file.
12 
13 #include <array>
14 
16 
18  public:
20  constexpr static uint32_t kMaxDepth_barrel = 4;
21  constexpr static uint32_t kMaxDepth_endcap = 7;
22  product = std::make_shared<reco::PFClusterParamsHostCollection>(std::max(kMaxDepth_barrel, kMaxDepth_endcap),
24  auto view = product->view();
25 
26  // seedFinder
27  auto const& sfConf = iConfig.getParameterSet("seedFinder");
28  view.nNeigh() = sfConf.getParameter<int>("nNeighbours");
29  auto const& seedFinderConfs = sfConf.getParameterSetVector("thresholdsByDetector");
30  for (auto const& pset : seedFinderConfs) {
31  auto const& det = pset.getParameter<std::string>("detector");
32  auto seedPt2Threshold = std::pow(pset.getParameter<double>("seedingThresholdPt"), 2.);
33  auto const& thresholds = pset.getParameter<std::vector<double>>("seedingThreshold");
34  if (det == "HCAL_BARREL1") {
35  if (thresholds.size() != kMaxDepth_barrel)
36  throw cms::Exception("Configuration") << "Invalid size (" << thresholds.size() << " != " << kMaxDepth_barrel
37  << ") for \"\" vector of det = \"" << det << "\"";
38  view.seedPt2ThresholdHB() = seedPt2Threshold;
39  for (size_t idx = 0; idx < thresholds.size(); ++idx) {
40  view.seedEThresholdHB_vec()[idx] = thresholds[idx];
41  }
42  } else if (det == "HCAL_ENDCAP") {
43  if (thresholds.size() != kMaxDepth_endcap)
44  throw cms::Exception("Configuration") << "Invalid size (" << thresholds.size() << " != " << kMaxDepth_endcap
45  << ") for \"\" vector of det = \"" << det << "\"";
46  view.seedPt2ThresholdHE() = seedPt2Threshold;
47  for (size_t idx = 0; idx < thresholds.size(); ++idx) {
48  view.seedEThresholdHE_vec()[idx] = thresholds[idx];
49  }
50  } else {
51  throw cms::Exception("Configuration") << "Unknown detector when parsing seedFinder: " << det;
52  }
53  }
54 
55  // initialClusteringStep
56  auto const& initConf = iConfig.getParameterSet("initialClusteringStep");
57  auto const& topoThresholdConf = initConf.getParameterSetVector("thresholdsByDetector");
58  for (auto const& pset : topoThresholdConf) {
59  auto const& det = pset.getParameter<std::string>("detector");
60  auto const& thresholds = pset.getParameter<std::vector<double>>("gatheringThreshold");
61  if (det == "HCAL_BARREL1") {
62  if (thresholds.size() != kMaxDepth_barrel)
63  throw cms::Exception("Configuration") << "Invalid size (" << thresholds.size() << " != " << kMaxDepth_barrel
64  << ") for \"\" vector of det = \"" << det << "\"";
65  for (size_t idx = 0; idx < thresholds.size(); ++idx) {
66  view.topoEThresholdHB_vec()[idx] = thresholds[idx];
67  }
68  } else if (det == "HCAL_ENDCAP") {
69  if (thresholds.size() != kMaxDepth_endcap)
70  throw cms::Exception("Configuration") << "Invalid size (" << thresholds.size() << " != " << kMaxDepth_endcap
71  << ") for \"\" vector of det = \"" << det << "\"";
72  for (size_t idx = 0; idx < thresholds.size(); ++idx) {
73  view.topoEThresholdHE_vec()[idx] = thresholds[idx];
74  }
75  } else {
76  throw cms::Exception("Configuration") << "Unknown detector when parsing initClusteringStep: " << det;
77  }
78  }
79 
80  // pfClusterBuilder
81  auto const& pfClusterPSet = iConfig.getParameterSet("pfClusterBuilder");
82  view.showerSigma2() = std::pow(pfClusterPSet.getParameter<double>("showerSigma"), 2.);
83  view.minFracToKeep() = pfClusterPSet.getParameter<double>("minFractionToKeep");
84  view.minFracTot() = pfClusterPSet.getParameter<double>("minFracTot");
85  view.maxIterations() = pfClusterPSet.getParameter<unsigned int>("maxIterations");
86  view.excludeOtherSeeds() = pfClusterPSet.getParameter<bool>("excludeOtherSeeds");
87  view.stoppingTolerance() = pfClusterPSet.getParameter<double>("stoppingTolerance");
88  auto const& pcPSet = pfClusterPSet.getParameterSet("positionCalc");
89  view.minFracInCalc() = pcPSet.getParameter<double>("minFractionInCalc");
90  view.minAllowedNormalization() = pcPSet.getParameter<double>("minAllowedNormalization");
91 
92  auto const& recHitEnergyNormConf = pfClusterPSet.getParameterSetVector("recHitEnergyNorms");
93  for (auto const& pset : recHitEnergyNormConf) {
94  auto const& recHitNorms = pset.getParameter<std::vector<double>>("recHitEnergyNorm");
95  auto const& det = pset.getParameter<std::string>("detector");
96  if (det == "HCAL_BARREL1") {
97  if (recHitNorms.size() != kMaxDepth_barrel)
98  throw cms::Exception("Configuration")
99  << "Invalid size (" << recHitNorms.size() << " != " << kMaxDepth_barrel
100  << ") for \"\" vector of det = \"" << det << "\"";
101  for (size_t idx = 0; idx < recHitNorms.size(); ++idx) {
102  view.recHitEnergyNormInvHB_vec()[idx] = 1. / recHitNorms[idx];
103  }
104  } else if (det == "HCAL_ENDCAP") {
105  if (recHitNorms.size() != kMaxDepth_endcap)
106  throw cms::Exception("Configuration")
107  << "Invalid size (" << recHitNorms.size() << " != " << kMaxDepth_endcap
108  << ") for \"\" vector of det = \"" << det << "\"";
109  for (size_t idx = 0; idx < recHitNorms.size(); ++idx) {
110  view.recHitEnergyNormInvHE_vec()[idx] = 1. / recHitNorms[idx];
111  }
112  } else {
113  throw cms::Exception("Configuration") << "Unknown detector when parsing recHitEnergyNorms: " << det;
114  }
115  }
116 
117  auto const& barrelTimeResConf = pfClusterPSet.getParameterSet("timeResolutionCalcBarrel");
118  view.barrelTimeResConsts_corrTermLowE() = barrelTimeResConf.getParameter<double>("corrTermLowE");
119  view.barrelTimeResConsts_threshLowE() = barrelTimeResConf.getParameter<double>("threshLowE");
120  view.barrelTimeResConsts_noiseTerm() = barrelTimeResConf.getParameter<double>("noiseTerm");
121  view.barrelTimeResConsts_constantTermLowE2() =
122  std::pow(barrelTimeResConf.getParameter<double>("constantTermLowE"), 2.);
123  view.barrelTimeResConsts_noiseTermLowE() = barrelTimeResConf.getParameter<double>("noiseTermLowE");
124  view.barrelTimeResConsts_threshHighE() = barrelTimeResConf.getParameter<double>("threshHighE");
125  view.barrelTimeResConsts_constantTerm2() = std::pow(barrelTimeResConf.getParameter<double>("constantTerm"), 2.);
126  view.barrelTimeResConsts_resHighE2() =
127  std::pow(view.barrelTimeResConsts_noiseTerm() / view.barrelTimeResConsts_threshHighE(), 2.) +
128  view.barrelTimeResConsts_constantTerm2();
129 
130  auto const& endcapTimeResConf = pfClusterPSet.getParameterSet("timeResolutionCalcEndcap");
131  view.endcapTimeResConsts_corrTermLowE() = endcapTimeResConf.getParameter<double>("corrTermLowE");
132  view.endcapTimeResConsts_threshLowE() = endcapTimeResConf.getParameter<double>("threshLowE");
133  view.endcapTimeResConsts_noiseTerm() = endcapTimeResConf.getParameter<double>("noiseTerm");
134  view.endcapTimeResConsts_constantTermLowE2() =
135  std::pow(endcapTimeResConf.getParameter<double>("constantTermLowE"), 2.);
136  view.endcapTimeResConsts_noiseTermLowE() = endcapTimeResConf.getParameter<double>("noiseTermLowE");
137  view.endcapTimeResConsts_threshHighE() = endcapTimeResConf.getParameter<double>("threshHighE");
138  view.endcapTimeResConsts_constantTerm2() = std::pow(endcapTimeResConf.getParameter<double>("constantTerm"), 2.);
139  view.endcapTimeResConsts_resHighE2() =
140  std::pow(view.endcapTimeResConsts_noiseTerm() / view.endcapTimeResConsts_threshHighE(), 2.) +
141  view.endcapTimeResConsts_constantTerm2();
142 
143  setWhatProduced(this);
144  }
145 
148  {
149  auto const psetName = "seedFinder";
151  foo.add<int>("nNeighbours", 4);
152  {
154  validator.add<std::string>("detector", "");
155  validator.add<std::vector<double>>("seedingThreshold", {});
156  validator.add<double>("seedingThresholdPt", 0.);
157  std::vector<edm::ParameterSet> vDefaults(2);
158  vDefaults[0].addParameter<std::string>("detector", "HCAL_BARREL1");
159  vDefaults[0].addParameter<std::vector<double>>("seedingThreshold", {0.125, 0.25, 0.35, 0.35});
160  vDefaults[0].addParameter<double>("seedingThresholdPt", 0.);
161  vDefaults[1].addParameter<std::string>("detector", "HCAL_ENDCAP");
162  vDefaults[1].addParameter<std::vector<double>>("seedingThreshold",
163  {0.1375, 0.275, 0.275, 0.275, 0.275, 0.275, 0.275});
164  vDefaults[1].addParameter<double>("seedingThresholdPt", 0.);
165  foo.addVPSet("thresholdsByDetector", validator, vDefaults);
166  }
167  psetDesc.add(psetName, foo);
168  }
169  {
170  auto const psetName = "initialClusteringStep";
172  {
174  validator.add<std::string>("detector", "");
175  validator.add<std::vector<double>>("gatheringThreshold", {});
176  std::vector<edm::ParameterSet> vDefaults(2);
177  vDefaults[0].addParameter<std::string>("detector", "HCAL_BARREL1");
178  vDefaults[0].addParameter<std::vector<double>>("gatheringThreshold", {0.1, 0.2, 0.3, 0.3});
179  vDefaults[1].addParameter<std::string>("detector", "HCAL_ENDCAP");
180  vDefaults[1].addParameter<std::vector<double>>("gatheringThreshold", {0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2});
181  foo.addVPSet("thresholdsByDetector", validator, vDefaults);
182  }
183  psetDesc.add(psetName, foo);
184  }
185  {
186  auto const psetName = "pfClusterBuilder";
188  foo.add<unsigned int>("maxIterations", 50);
189  foo.add<double>("minFracTot", 1e-20);
190  foo.add<double>("minFractionToKeep", 1e-7);
191  foo.add<bool>("excludeOtherSeeds", true);
192  foo.add<double>("showerSigma", 10.);
193  foo.add<double>("stoppingTolerance", 1e-8);
194  {
196  validator.add<std::string>("detector", "");
197  validator.add<std::vector<double>>("recHitEnergyNorm", {});
198  std::vector<edm::ParameterSet> vDefaults(2);
199  vDefaults[0].addParameter<std::string>("detector", "HCAL_BARREL1");
200  vDefaults[0].addParameter<std::vector<double>>("recHitEnergyNorm", {0.1, 0.2, 0.3, 0.3});
201  vDefaults[1].addParameter<std::string>("detector", "HCAL_ENDCAP");
202  vDefaults[1].addParameter<std::vector<double>>("recHitEnergyNorm", {0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2});
203  foo.addVPSet("recHitEnergyNorms", validator, vDefaults);
204  }
205  {
207  bar.add<double>("minFractionInCalc", 1e-9);
208  bar.add<double>("minAllowedNormalization", 1e-9);
209  foo.add("positionCalc", bar);
210  }
211  {
213  bar.add<double>("corrTermLowE", 0.);
214  bar.add<double>("threshLowE", 6.);
215  bar.add<double>("noiseTerm", 21.86);
216  bar.add<double>("constantTermLowE", 4.24);
217  bar.add<double>("noiseTermLowE", 8.);
218  bar.add<double>("threshHighE", 15.);
219  bar.add<double>("constantTerm", 2.82);
220  foo.add("timeResolutionCalcBarrel", bar);
221  }
222  {
224  bar.add<double>("corrTermLowE", 0.);
225  bar.add<double>("threshLowE", 6.);
226  bar.add<double>("noiseTerm", 21.86);
227  bar.add<double>("constantTermLowE", 4.24);
228  bar.add<double>("noiseTermLowE", 8.);
229  bar.add<double>("threshHighE", 15.);
230  bar.add<double>("constantTerm", 2.82);
231  foo.add("timeResolutionCalcEndcap", bar);
232  }
233  psetDesc.add(psetName, foo);
234  }
235 
236  descriptions.addWithDefaultLabel(psetDesc);
237  }
238 
239  std::shared_ptr<reco::PFClusterParamsHostCollection> produce(JobConfigurationGPURecord const& iRecord) {
240  return product;
241  }
242 
243  private:
244  std::shared_ptr<reco::PFClusterParamsHostCollection> product;
245  };
246 
247 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
248 
249 DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(PFClusterParamsESProducer);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::shared_ptr< reco::PFClusterParamsHostCollection > produce(JobConfigurationGPURecord const &iRecord)
ParameterSet const & getParameterSet(std::string const &) const
std::shared_ptr< reco::PFClusterParamsHostCollection > product
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
alpaka::DevCpu const & host()
Definition: host.h:26
auto setWhatProduced(T *iThis, edm::es::Label const &label={})
Definition: ESProducer.h:40
VParameterSet const & getParameterSetVector(std::string const &name) const
#define DEFINE_FWK_EVENTSETUP_ALPAKA_MODULE(type)
Definition: ModuleFactory.h:17
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29