CMS 3D CMS Logo

InitialClusteringStepBase.h
Go to the documentation of this file.
1 #ifndef __InitialClusteringStepBase_H__
2 #define __InitialClusteringStepBase_H__
3 
13 
14 #include <string>
15 #include <iostream>
16 #include <unordered_map>
17 #include <tuple>
18 
19 namespace edm {
20  class Event;
21  class EventSetup;
22 } // namespace edm
23 
25 
28 
29 public:
31  : _nSeeds(0),
32  _nClustersFound(0),
33  _layerMap({{"PS2", (int)PFLayer::PS2},
34  {"PS1", (int)PFLayer::PS1},
35  {"ECAL_ENDCAP", (int)PFLayer::ECAL_ENDCAP},
36  {"ECAL_BARREL", (int)PFLayer::ECAL_BARREL},
37  {"NONE", (int)PFLayer::NONE},
38  {"HCAL_BARREL1", (int)PFLayer::HCAL_BARREL1},
39  {"HCAL_BARREL2_RING0", (int)PFLayer::HCAL_BARREL2},
40  {"HCAL_BARREL2_RING1", 100 * (int)PFLayer::HCAL_BARREL2},
41  {"HCAL_ENDCAP", (int)PFLayer::HCAL_ENDCAP},
42  {"HF_EM", (int)PFLayer::HF_EM},
43  {"HF_HAD", (int)PFLayer::HF_HAD},
44  {"HGCAL", (int)PFLayer::HGCAL}}),
45  _algoName(conf.getParameter<std::string>("algoName")) {
46  const std::vector<edm::ParameterSet>& thresholds = conf.getParameterSetVector("thresholdsByDetector");
47  for (const auto& pset : thresholds) {
48  const std::string& det = pset.getParameter<std::string>("detector");
49 
50  std::vector<int> depths;
51  std::vector<double> thresh_E;
52  std::vector<double> thresh_pT;
53  std::vector<double> thresh_pT2;
54 
55  if (det == std::string("HCAL_BARREL1") || det == std::string("HCAL_ENDCAP")) {
56  depths = pset.getParameter<std::vector<int> >("depths");
57  thresh_E = pset.getParameter<std::vector<double> >("gatheringThreshold");
58  thresh_pT = pset.getParameter<std::vector<double> >("gatheringThresholdPt");
59  if (thresh_E.size() != depths.size() || thresh_pT.size() != depths.size()) {
60  throw cms::Exception("InvalidGatheringThreshold")
61  << "gatheringThresholds mismatch with the numbers of depths";
62  }
63  } else {
64  depths.push_back(0);
65  thresh_E.push_back(pset.getParameter<double>("gatheringThreshold"));
66  thresh_pT.push_back(pset.getParameter<double>("gatheringThresholdPt"));
67  }
68 
69  for (unsigned int i = 0; i < thresh_pT.size(); ++i) {
70  thresh_pT2.push_back(thresh_pT[i] * thresh_pT[i]);
71  }
72 
73  auto entry = _layerMap.find(det);
74  if (entry == _layerMap.end()) {
75  throw cms::Exception("InvalidDetectorLayer")
76  << "Detector layer : " << det << " is not in the list of recognized"
77  << " detector layers!";
78  }
79  _thresholds.emplace(_layerMap.find(det)->second, std::make_tuple(depths, thresh_E, thresh_pT2));
80  }
81  }
82  virtual ~InitialClusteringStepBase() = default;
83  // get rid of things we should never use...
84  InitialClusteringStepBase(const ICSB&) = delete;
85  ICSB& operator=(const ICSB&) = delete;
86 
87  virtual void update(const edm::EventSetup&) {}
88 
89  virtual void updateEvent(const edm::Event&) {}
90 
92  const std::vector<bool>& mask, // mask flags
93  const std::vector<bool>& seeds, // seed flags
94  reco::PFClusterCollection&, //output
95  const HcalPFCuts*) = 0;
96 
97  std::ostream& operator<<(std::ostream& o) const {
98  o << "InitialClusteringStep with algo \"" << _algoName << "\" located " << _nSeeds << " seeds and built "
99  << _nClustersFound << " clusters from those seeds. ";
100  return o;
101  }
102 
103  void reset() { _nSeeds = _nClustersFound = 0; }
104 
105 protected:
107  return reco::PFRecHitRef(h, i);
108  }
109  unsigned _nSeeds, _nClustersFound; // basic performance information
110  const std::unordered_map<std::string, int> _layerMap;
111 
112  typedef std::tuple<std::vector<int>, std::vector<double>, std::vector<double> > I3tuple;
113  std::unordered_map<int, I3tuple> _thresholds;
114 
115 private:
117 };
118 
119 std::ostream& operator<<(std::ostream& o, const InitialClusteringStepBase& a);
120 
124 
125 #endif
const std::unordered_map< std::string, int > _layerMap
reco::PFRecHitRef makeRefhit(const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
std::ostream & operator<<(std::ostream &o) const
InitialClusteringStepBase ICSB
virtual void updateEvent(const edm::Event &)
InitialClusteringStepBase(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
edm::Ref< PFRecHitCollection > PFRecHitRef
persistent reference to PFRecHit objects
Definition: PFRecHitFwd.h:15
edmplugin::PluginFactory< InitialClusteringStepBase *(const edm::ParameterSet &, edm::ConsumesCollector &)> InitialClusteringStepFactory
virtual void update(const edm::EventSetup &)
virtual void buildClusters(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &mask, const std::vector< bool > &seeds, reco::PFClusterCollection &, const HcalPFCuts *)=0
std::tuple< std::vector< int >, std::vector< double >, std::vector< double > > I3tuple
std::ostream & operator<<(std::ostream &o, const InitialClusteringStepBase &a)
ICSB & operator=(const ICSB &)=delete
HLT enums.
double a
Definition: hdecay.h:121
virtual ~InitialClusteringStepBase()=default
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::unordered_map< int, I3tuple > _thresholds