File indexing completed on 2024-04-06 12:27:23
0001 #include "DataFormats/ParticleFlowReco/interface/PFRecHitFraction.h"
0002 #include "RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h"
0003 #include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h"
0004 #include "CondTools/Hcal/interface/HcalPFCutsHandler.h"
0005
0006 class Basic2DClusterForEachSeed : public InitialClusteringStepBase {
0007 public:
0008 Basic2DClusterForEachSeed(const edm::ParameterSet& conf, edm::ConsumesCollector& cc)
0009 : InitialClusteringStepBase(conf, cc) {}
0010 ~Basic2DClusterForEachSeed() override = default;
0011
0012 void buildClusters(const edm::Handle<reco::PFRecHitCollection>&,
0013 const std::vector<bool>&,
0014 const std::vector<bool>&,
0015 reco::PFClusterCollection&,
0016 const HcalPFCuts*) override;
0017 };
0018
0019 DEFINE_EDM_PLUGIN(InitialClusteringStepFactory, Basic2DClusterForEachSeed, "Basic2DClusterForEachSeed");
0020
0021 void Basic2DClusterForEachSeed::buildClusters(const edm::Handle<reco::PFRecHitCollection>& input,
0022 const std::vector<bool>& rechitMask,
0023 const std::vector<bool>& seedable,
0024 reco::PFClusterCollection& output,
0025 const HcalPFCuts*) {
0026 auto const& hits = *input;
0027
0028
0029 reco::PFCluster cluster;
0030 for (unsigned int hit = 0; hit < hits.size(); ++hit) {
0031 if (!rechitMask[hit] || !seedable[hit])
0032 continue;
0033 cluster.reset();
0034
0035
0036 auto refhit = makeRefhit(input, hit);
0037 auto rhf = reco::PFRecHitFraction(refhit, 1.0);
0038
0039
0040 cluster.addRecHitFraction(rhf);
0041
0042
0043 const auto rh_energy = refhit->energy();
0044
0045
0046 cluster.setSeed(refhit->detId());
0047 cluster.setEnergy(rh_energy);
0048 cluster.setTime(refhit->time());
0049 cluster.setLayer(refhit->layer());
0050 cluster.setPosition(math::XYZPoint(refhit->position().x(), refhit->position().y(), refhit->position().z()));
0051 cluster.calculatePositionREP();
0052 cluster.setDepth(refhit->depth());
0053
0054 output.push_back(cluster);
0055
0056 }
0057 }