CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes | Static Private Attributes
LocalMaximumSeedFinder Class Referencefinal

#include <LocalMaximumSeedFinder.h>

Inheritance diagram for LocalMaximumSeedFinder:
SeedFinderBase

Public Member Functions

void findSeeds (const edm::Handle< reco::PFRecHitCollection > &input, const std::vector< bool > &mask, std::vector< bool > &seedable) override
 
 LocalMaximumSeedFinder (const edm::ParameterSet &conf)
 
 LocalMaximumSeedFinder (const LocalMaximumSeedFinder &)=delete
 
LocalMaximumSeedFinderoperator= (const LocalMaximumSeedFinder &)=delete
 
- Public Member Functions inherited from SeedFinderBase
const std::string & name () const
 
SeedFinderBaseoperator= (const SeedFinderBase &)=delete
 
 SeedFinderBase (const edm::ParameterSet &conf)
 
 SeedFinderBase (const SeedFinderBase &)=delete
 
virtual ~SeedFinderBase ()=default
 

Private Types

typedef std::tuple< std::vector< int >, std::vector< double >, std::vector< double > > I3tuple
 

Private Attributes

const std::unordered_map< std::string, int > _layerMap
 
const int _nNeighbours
 
std::array< I3tuple, 35 > _thresholds
 

Static Private Attributes

static int layerOffset = 15
 

Detailed Description

Definition at line 9 of file LocalMaximumSeedFinder.h.

Member Typedef Documentation

typedef std::tuple<std::vector<int>, std::vector<double> , std::vector<double> > LocalMaximumSeedFinder::I3tuple
private

Definition at line 24 of file LocalMaximumSeedFinder.h.

Constructor & Destructor Documentation

LocalMaximumSeedFinder::LocalMaximumSeedFinder ( const edm::ParameterSet conf)

Definition at line 14 of file LocalMaximumSeedFinder.cc.

References _layerMap, _thresholds, particleFlowClusterHBHE_cfi::depths, PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, mps_splice::entry, Exception, findSeeds(), PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, PFLayer::HCAL_ENDCAP, PFLayer::HF_EM, PFLayer::HF_HAD, mps_fire::i, createfilelist::int, layerOffset, PFLayer::NONE, PFLayer::PS1, PFLayer::PS2, muonDTDigis_cfi::pset, AlCaHLTBitMon_QueryRunRegistry::string, and particleFlowZeroSuppressionECAL_cff::thresholds.

14  :
15  SeedFinderBase(conf),
16  _nNeighbours(conf.getParameter<int>("nNeighbours")),
17  _layerMap({ {"PS2",(int)PFLayer::PS2},
18  {"PS1",(int)PFLayer::PS1},
19  {"ECAL_ENDCAP",(int)PFLayer::ECAL_ENDCAP},
20  {"ECAL_BARREL",(int)PFLayer::ECAL_BARREL},
21  {"NONE",(int)PFLayer::NONE},
22  {"HCAL_BARREL1",(int)PFLayer::HCAL_BARREL1},
23  {"HCAL_BARREL2_RING0",(int)PFLayer::HCAL_BARREL2},
24  // hack to deal with ring1 in HO
25  {"HCAL_BARREL2_RING1", 19},
26  {"HCAL_ENDCAP",(int)PFLayer::HCAL_ENDCAP},
27  {"HF_EM",(int)PFLayer::HF_EM},
28  {"HF_HAD",(int)PFLayer::HF_HAD} }) {
29  const std::vector<edm::ParameterSet>& thresholds =
30  conf.getParameterSetVector("thresholdsByDetector");
31  for( const auto& pset : thresholds ) {
32  const std::string& det = pset.getParameter<std::string>("detector");
33 
34  std::vector<int> depths;
35  std::vector<double> thresh_E;
36  std::vector<double> thresh_pT ;
37  std::vector<double> thresh_pT2;
38 
39  if (det==std::string("HCAL_BARREL1") || det==std::string("HCAL_ENDCAP")) {
40  depths = pset.getParameter<std::vector<int> >("depths");
41  thresh_E = pset.getParameter<std::vector<double> >("seedingThreshold");
42  thresh_pT = pset.getParameter<std::vector<double> >("seedingThresholdPt");
43  if(thresh_E.size()!=depths.size() || thresh_pT.size()!=depths.size()) {
44  throw cms::Exception("InvalidGatheringThreshold")
45  << "gatheringThresholds mismatch with the numbers of depths";
46  }
47  } else {
48  depths.push_back(0);
49  thresh_E.push_back(pset.getParameter<double>("seedingThreshold"));
50  thresh_pT.push_back(pset.getParameter<double>("seedingThresholdPt"));
51  }
52 
53  for(unsigned int i=0;i < thresh_pT.size();++i){
54  thresh_pT2.push_back(thresh_pT[i]*thresh_pT[i]);
55  }
56 
57  auto entry = _layerMap.find(det);
58  if( entry == _layerMap.end() ) {
59  throw cms::Exception("InvalidDetectorLayer")
60  << "Detector layer : " << det << " is not in the list of recognized"
61  << " detector layers!";
62  }
63 
64  _thresholds[entry->second+layerOffset]=
65  std::make_tuple(depths,thresh_E,thresh_pT2);
66  }
67 }
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
const std::unordered_map< std::string, int > _layerMap
std::array< I3tuple, 35 > _thresholds
SeedFinderBase(const edm::ParameterSet &conf)
LocalMaximumSeedFinder::LocalMaximumSeedFinder ( const LocalMaximumSeedFinder )
delete

Member Function Documentation

void LocalMaximumSeedFinder::findSeeds ( const edm::Handle< reco::PFRecHitCollection > &  input,
const std::vector< bool > &  mask,
std::vector< bool > &  seedable 
)
overridevirtual

Implements SeedFinderBase.

Definition at line 71 of file LocalMaximumSeedFinder.cc.

References _nNeighbours, _thresholds, funct::abs(), KineDebug3::count(), declareDynArray, egammaForCoreTracking_cff::depth, Exception, PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, PFLayer::HCAL_ENDCAP, mps_fire::i, training_settings::idx, initDynArray, createfilelist::int, layerOffset, LogDebug, eostools::move(), nhits, particleFlowZeroSuppressionECAL_cff::thresholds, and unInitDynArray.

Referenced by LocalMaximumSeedFinder().

73  {
74 
75  auto nhits = input->size();
76  initDynArray(bool,nhits,usable,true);
77  //need to run over energy sorted rechits
78  declareDynArray(float,nhits,energies);
79  unInitDynArray(int,nhits,qst); // queue storage
80  auto cmp = [&](int i, int j) { return energies[i] < energies[j]; };
81  std::priority_queue<int, DynArray<int>, decltype(cmp)> ordered_hits(cmp,std::move(qst));
82 
83  for( unsigned i = 0; i < nhits; ++i ) {
84  if( !mask[i] ) continue; // cannot seed masked objects
85  auto const & maybeseed = (*input)[i];
86  energies[i]=maybeseed.energy();
87  int seedlayer = (int)maybeseed.layer();
88  if( seedlayer == PFLayer::HCAL_BARREL2 &&
89  std::abs(maybeseed.positionREP().eta()) > 0.34 ) {
90  seedlayer = 19;
91  }
92  auto const & thresholds = _thresholds[seedlayer+layerOffset];
93 
94 
95  double thresholdE=0.;
96  double thresholdPT2=0.;
97 
98  for (unsigned int j=0; j<(std::get<2>(thresholds)).size(); ++j) {
99 
100  int depth=std::get<0>(thresholds)[j];
101  if( ( seedlayer == PFLayer::HCAL_BARREL1 && maybeseed.depth()== depth)
102  || ( seedlayer == PFLayer::HCAL_ENDCAP && maybeseed.depth()== depth)
103  || ( seedlayer != PFLayer::HCAL_BARREL1 && seedlayer != PFLayer::HCAL_ENDCAP)
104  ) { thresholdE=std::get<1>(thresholds)[j]; thresholdPT2=std::get<2>(thresholds)[j]; }
105 
106  }
107 
108  if( maybeseed.energy() < thresholdE ||
109  maybeseed.pt2() < thresholdPT2 ) usable[i] = false;
110  if( !usable[i] ) continue;
111  ordered_hits.push(i);
112 
113  }
114 
115 
116  while(!ordered_hits.empty() ) {
117  auto idx = ordered_hits.top();
118  ordered_hits.pop();
119  if( !usable[idx] ) continue;
120  //get the neighbours of this seed
121  auto const & maybeseed = (*input)[idx];
122  reco::PFRecHit::Neighbours myNeighbours;
123  switch( _nNeighbours ) {
124  case -1:
125  myNeighbours = maybeseed.neighbours();
126  break;
127  case 0: // for HF clustering
128  myNeighbours = _noNeighbours;
129  break;
130  case 4:
131  myNeighbours = maybeseed.neighbours4();
132  break;
133  case 8:
134  myNeighbours = maybeseed.neighbours8();
135  break;
136  default:
137  throw cms::Exception("InvalidConfiguration")
138  << "LocalMaximumSeedFinder only accepts nNeighbors = {-1,0,4,8}";
139  }
140  seedable[idx] = true;
141  for( auto neighbour : myNeighbours ) {
142  if( !mask[neighbour] ) continue;
143  if( energies[neighbour] > energies[idx] ) {
144 // std::cout << "how this can be?" << std::endl;
145  seedable[idx] = false;
146  break;
147  }
148  }
149  if( seedable[idx] ) {
150  for( auto neighbour : myNeighbours ) {
151  usable[neighbour] = false;
152  }
153  }
154  }
155 
156  LogDebug("LocalMaximumSeedFinder") << " found " << std::count(seedable.begin(),seedable.end(),true) << " seeds";
157 
158 }
#define LogDebug(id)
#define initDynArray(T, n, x, i)
Definition: DynArray.h:60
std::array< I3tuple, 35 > _thresholds
#define unInitDynArray(T, n, x)
Definition: DynArray.h:58
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define declareDynArray(T, n, x)
Definition: DynArray.h:59
def move(src, dest)
Definition: eostools.py:510
LocalMaximumSeedFinder& LocalMaximumSeedFinder::operator= ( const LocalMaximumSeedFinder )
delete

Member Data Documentation

const std::unordered_map<std::string,int> LocalMaximumSeedFinder::_layerMap
private

Definition at line 22 of file LocalMaximumSeedFinder.h.

Referenced by LocalMaximumSeedFinder().

const int LocalMaximumSeedFinder::_nNeighbours
private

Definition at line 20 of file LocalMaximumSeedFinder.h.

Referenced by findSeeds().

std::array<I3tuple, 35> LocalMaximumSeedFinder::_thresholds
private

Definition at line 26 of file LocalMaximumSeedFinder.h.

Referenced by findSeeds(), and LocalMaximumSeedFinder().

int LocalMaximumSeedFinder::layerOffset = 15
staticprivate

Definition at line 27 of file LocalMaximumSeedFinder.h.

Referenced by findSeeds(), and LocalMaximumSeedFinder().