CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
16 namespace {
17  bool greaterByEnergy(const std::pair<unsigned,double>& a,
18  const std::pair<unsigned,double>& b) {
19  return a.second > b.second;
20  }
21 }
22 
25  const std::vector<bool>& rechitMask,
26  const std::vector<bool>& seedable,
28  std::vector<bool> used(input->size(),false);
29  std::vector<std::pair<unsigned,double> > seeds;
30 
31  // get the seeds and sort them descending in energy
32  seeds.reserve(input->size());
33  for( unsigned i = 0; i < input->size(); ++i ) {
34  if( !rechitMask[i] || !seedable[i] || used[i] ) continue;
35  std::pair<unsigned,double> val = std::make_pair(i,input->at(i).energy());
36  auto pos = std::upper_bound(seeds.begin(),seeds.end(),val,greaterByEnergy);
37  seeds.insert(pos,val);
38  }
39 
41  for( const auto& idx_e : seeds ) {
42  const int seed = idx_e.first;
43  if( !rechitMask[seed] || !seedable[seed] || used[seed] ) continue;
44  temp.reset();
45  buildTopoCluster(input,rechitMask,makeRefhit(input,seed),used,temp);
46  if( temp.recHitFractions().size() ) output.push_back(temp);
47  }
48 }
49 
52  const std::vector<bool>& rechitMask,
53  const reco::PFRecHitRef& cell,
54  std::vector<bool>& used,
55  reco::PFCluster& topocluster) {
56  int cell_layer = (int)cell->layer();
57  if( cell_layer == PFLayer::HCAL_BARREL2 &&
58  std::abs(cell->positionREP().eta()) > 0.34 ) {
59  cell_layer *= 100;
60  }
61  const std::pair<double,double>& thresholds =
62  _thresholds.find(cell_layer)->second;
63  if( cell->energy() < thresholds.first ||
64  cell->pt2() < thresholds.second ) {
65  LOGDRESSED("GenericTopoCluster::buildTopoCluster()")
66  << "RecHit " << cell->detId() << " with enegy "
67  << cell->energy() << " GeV was rejected!." << std::endl;
68  return;
69  }
70 
71  used[cell.key()] = true;
72  topocluster.addRecHitFraction(reco::PFRecHitFraction(cell, 1.0));
73 
74  const reco::PFRecHitRefVector& neighbours =
75  ( _useCornerCells ? cell->neighbours8() : cell->neighbours4() );
76 
77  for( const reco::PFRecHitRef nb : neighbours ) {
78  if( used[nb.key()] || !rechitMask[nb.key()] ) {
79  LOGDRESSED("GenericTopoCluster::buildTopoCluster()")
80  << " RecHit " << cell->detId() << "\'s"
81  << " neighbor RecHit " << input->at(nb.key()).detId()
82  << " with enegy "
83  << input->at(nb.key()).energy() << " GeV was rejected!"
84  << " Reasons : " << used[nb.key()] << " (used) "
85  << !rechitMask[nb.key()] << " (masked)." << std::endl;
86  continue;
87  }
88  buildTopoCluster(input,rechitMask,nb,used,topocluster);
89  }
90 }
int i
Definition: DBlmapReader.cc:9
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
dictionary thresholds
Definition: fff_deleter.py:273
void buildClusters(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const std::vector< bool > &, reco::PFClusterCollection &)
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
static std::string const input
Definition: EdmProvDump.cc:44
reco::PFRecHitRef makeRefhit(const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void buildTopoCluster(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const reco::PFRecHitRef &, std::vector< bool > &, reco::PFCluster &)
void reset()
resets clusters parameters
Definition: PFCluster.cc:36
key_type key() const
Accessor for product key.
Definition: Ref.h:266
double b
Definition: hdecay.h:120
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:56
double a
Definition: hdecay.h:121
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:69
#define LOGDRESSED(x)
std::unordered_map< int, std::pair< double, double > > _thresholds