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 
17  const std::vector<bool>& rechitMask,
18  const std::vector<bool>& seedable,
20  auto const& hits = *input;
21  std::vector<bool> used(hits.size(), false);
22  std::vector<unsigned int> seeds;
23 
24  // get the seeds and sort them descending in energy
25  seeds.reserve(hits.size());
26  for (unsigned int i = 0; i < hits.size(); ++i) {
27  if (!rechitMask[i] || !seedable[i] || used[i])
28  continue;
29  seeds.emplace_back(i);
30  }
31  // maxHeap would be better
32  std::sort(
33  seeds.begin(), seeds.end(), [&](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])
38  continue;
39  temp.reset();
40  buildTopoCluster(input, rechitMask, seed, used, temp);
41  if (!temp.recHitFractions().empty())
42  output.push_back(temp);
43  }
44 }
45 
47  const std::vector<bool>& rechitMask,
48  unsigned int kcell,
49  std::vector<bool>& used,
50  reco::PFCluster& topocluster) {
51  auto const& cell = (*input)[kcell];
52  int cell_layer = (int)cell.layer();
53  if (cell_layer == PFLayer::HCAL_BARREL2 && 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];
68  thresholdPT2 = std::get<2>(thresholds)[j];
69  }
70  }
71 
72  if (cell.energy() < thresholdE || cell.pt2() < thresholdPT2) {
73  LOGDRESSED("GenericTopoCluster::buildTopoCluster()")
74  << "RecHit " << cell.detId() << " with enegy " << cell.energy() << " GeV was rejected!." << std::endl;
75  return;
76  }
77 
78  auto k = kcell;
79  used[k] = true;
80  auto ref = makeRefhit(input, k);
81  topocluster.addRecHitFraction(reco::PFRecHitFraction(ref, 1.0));
82 
83  auto const& neighbours = (_useCornerCells ? cell.neighbours8() : cell.neighbours4());
84 
85  for (auto nb : neighbours) {
86  if (used[nb] || !rechitMask[nb]) {
87  LOGDRESSED("GenericTopoCluster::buildTopoCluster()")
88  << " RecHit " << cell.detId() << "\'s"
89  << " neighbor RecHit " << input->at(nb).detId() << " with enegy " << input->at(nb).energy()
90  << " GeV was rejected!"
91  << " Reasons : " << used[nb] << " (used) " << !rechitMask[nb] << " (masked)." << std::endl;
92  continue;
93  }
94  buildTopoCluster(input, rechitMask, nb, used, topocluster);
95  }
96 }
reco::PFClusterCollection
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
Basic2DGenericTopoClusterizer::buildTopoCluster
void buildTopoCluster(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, unsigned int, std::vector< bool > &, reco::PFCluster &)
Definition: Basic2DGenericTopoClusterizer.cc:46
particleFlowZeroSuppressionECAL_cff.thresholds
thresholds
Definition: particleFlowZeroSuppressionECAL_cff.py:31
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
InitialClusteringStepBase::_thresholds
std::unordered_map< int, I3tuple > _thresholds
Definition: InitialClusteringStepBase.h:110
reco::PFRecHitFraction
Fraction of a PFRecHit (rechits can be shared between several PFCluster's)
Definition: PFRecHitFraction.h:18
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
PFLayer::HCAL_ENDCAP
Definition: PFLayer.h:37
edm::Handle
Definition: AssociativeIterator.h:50
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
Basic2DGenericTopoClusterizer::_useCornerCells
const bool _useCornerCells
Definition: Basic2DGenericTopoClusterizer.h:23
InitialClusteringStepBase::makeRefhit
reco::PFRecHitRef makeRefhit(const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
Definition: InitialClusteringStepBase.h:103
fileCollector.seed
seed
Definition: fileCollector.py:127
PFLayer::HCAL_BARREL2
Definition: PFLayer.h:36
PFLayer::HCAL_BARREL1
Definition: PFLayer.h:35
LOGDRESSED
#define LOGDRESSED(x)
Definition: Basic2DGenericTopoClusterizer.cc:13
dqmdumpme.k
k
Definition: dqmdumpme.py:60
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
InitialStep_cff.seeds
seeds
Definition: InitialStep_cff.py:230
createfilelist.int
int
Definition: createfilelist.py:10
Basic2DGenericTopoClusterizer.h
reco::PFCluster::addRecHitFraction
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:33
reco::PFCluster
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
Basic2DGenericTopoClusterizer::buildClusters
void buildClusters(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const std::vector< bool > &, reco::PFClusterCollection &) override
Definition: Basic2DGenericTopoClusterizer.cc:16
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443