CMS 3D CMS Logo

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