CMS 3D CMS Logo

Basic2DGenericTopoClusterizer.cc
Go to the documentation of this file.
3 
4 #ifdef PFLOW_DEBUG
5 #define LOGVERB(x) edm::LogVerbatim(x)
6 #define LOGWARN(x) edm::LogWarning(x)
7 #define LOGERR(x) edm::LogError(x)
8 #define LOGDRESSED(x) edm::LogInfo(x)
9 #else
10 #define LOGVERB(x) LogTrace(x)
11 #define LOGWARN(x) edm::LogWarning(x)
12 #define LOGERR(x) edm::LogError(x)
13 #define LOGDRESSED(x) LogDebug(x)
14 #endif
15 
18  const std::vector<bool>& rechitMask,
19  const std::vector<bool>& seedable,
21  auto const & hits = *input;
22  std::vector<bool> used(hits.size(),false);
23  std::vector<unsigned int> seeds;
24 
25  // get the seeds and sort them descending in energy
26  seeds.reserve(hits.size());
27  for( unsigned int i = 0; i < hits.size(); ++i ) {
28  if( !rechitMask[i] || !seedable[i] || used[i] ) continue;
29  seeds.emplace_back(i);
30  }
31  // maxHeap would be better
32  std::sort(seeds.begin(),seeds.end(),
33  [&](unsigned int i, unsigned int j) { return hits[i].energy()>hits[j].energy();});
34 
36  for( auto seed : seeds ) {
37  if( !rechitMask[seed] || !seedable[seed] || used[seed] ) continue;
38  temp.reset();
39  buildTopoCluster(input,rechitMask,seed,used,temp);
40  if( !temp.recHitFractions().empty() ) output.push_back(temp);
41  }
42 }
43 
46  const std::vector<bool>& rechitMask,
47  unsigned int kcell,
48  std::vector<bool>& used,
49  reco::PFCluster& topocluster) {
50  auto const & cell = (*input)[kcell];
51  int cell_layer = (int)cell.layer();
52  if( cell_layer == PFLayer::HCAL_BARREL2 &&
53  std::abs(cell.positionREP().eta()) > 0.34 ) {
54  cell_layer *= 100;
55  }
56 
57  auto const& thresholds = _thresholds.find(cell_layer)->second;
58  double thresholdE=0.;
59  double thresholdPT2=0.;
60 
61  for (unsigned int j=0; j<(std::get<1>(thresholds)).size(); ++j) {
62  int depth=std::get<0>(thresholds)[j];
63 
64  if( ( cell_layer == PFLayer::HCAL_BARREL1 && cell.depth()== depth)
65  || ( cell_layer == PFLayer::HCAL_ENDCAP && cell.depth()== depth)
66  || ( cell_layer != PFLayer::HCAL_BARREL1 && cell_layer != PFLayer::HCAL_ENDCAP )
67  ) { thresholdE=std::get<1>(thresholds)[j]; thresholdPT2=std::get<2>(thresholds)[j]; }
68 
69  }
70 
71  if( cell.energy() < thresholdE ||
72  cell.pt2() < thresholdPT2 ) {
73  LOGDRESSED("GenericTopoCluster::buildTopoCluster()")
74  << "RecHit " << cell.detId() << " with enegy "
75  << cell.energy() << " GeV was rejected!." << std::endl;
76  return;
77  }
78 
79 
80  auto k = kcell;
81  used[k] = true;
82  auto ref = makeRefhit(input,k);
83  topocluster.addRecHitFraction(reco::PFRecHitFraction(ref, 1.0));
84 
85  auto const & neighbours =
86  ( _useCornerCells ? cell.neighbours8() : cell.neighbours4() );
87 
88  for( auto nb : neighbours ) {
89  if( used[nb] || !rechitMask[nb] ) {
90  LOGDRESSED("GenericTopoCluster::buildTopoCluster()")
91  << " RecHit " << cell.detId() << "\'s"
92  << " neighbor RecHit " << input->at(nb).detId()
93  << " with enegy "
94  << input->at(nb).energy() << " GeV was rejected!"
95  << " Reasons : " << used[nb] << " (used) "
96  << !rechitMask[nb] << " (masked)." << std::endl;
97  continue;
98  }
99  buildTopoCluster(input,rechitMask,nb,used,topocluster);
100  }
101 }
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
void buildClusters(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const std::vector< bool > &, reco::PFClusterCollection &) override
void buildTopoCluster(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, unsigned int, std::vector< bool > &, reco::PFCluster &)
std::unordered_map< int, I3tuple > _thresholds
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
static std::string const input
Definition: EdmProvDump.cc:45
reco::PFRecHitRef makeRefhit(const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int k[5][pyjets_maxn]
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:91
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
#define LOGDRESSED(x)