CMS 3D CMS Logo

GenericSimClusterMapper.cc
Go to the documentation of this file.
8 
11 
12 public:
14  : InitialClusteringStepBase(conf, cc) {
15  _simClusterToken = cc.consumes<SimClusterCollection>(conf.getParameter<edm::InputTag>("simClusterSrc"));
16  }
17  ~GenericSimClusterMapper() override = default;
18  GenericSimClusterMapper(const B2DGT&) = delete;
19  B2DGT& operator=(const B2DGT&) = delete;
20 
21  void updateEvent(const edm::Event&) final;
22 
24  const std::vector<bool>&,
25  const std::vector<bool>&,
26  reco::PFClusterCollection&) override;
27 
28 private:
31 };
32 
34 
35 #ifdef PFLOW_DEBUG
36 #define LOGVERB(x) edm::LogVerbatim(x)
37 #define LOGWARN(x) edm::LogWarning(x)
38 #define LOGERR(x) edm::LogError(x)
39 #define LOGDRESSED(x) edm::LogInfo(x)
40 #else
41 #define LOGVERB(x) LogTrace(x)
42 #define LOGWARN(x) edm::LogWarning(x)
43 #define LOGERR(x) edm::LogError(x)
44 #define LOGDRESSED(x) LogDebug(x)
45 #endif
46 
48 
50  const std::vector<bool>& rechitMask,
51  const std::vector<bool>& seedable,
53  const SimClusterCollection& simClusters = *_simClusterH;
54  auto const& hits = *input;
55 
56  // for quick indexing back to hit energy
57  std::unordered_map<uint32_t, size_t> detIdToIndex(hits.size());
58  for (uint32_t i = 0; i < hits.size(); ++i) {
59  detIdToIndex[hits[i].detId()] = i;
60  auto ref = makeRefhit(input, i);
61  }
62 
63  for (const auto& sc : simClusters) {
64  output.emplace_back();
65  reco::PFCluster& back = output.back();
67  double energy = 0.0, highest_energy = 0.0;
68  auto hitsAndFractions = sc.hits_and_fractions();
69  for (const auto& hAndF : hitsAndFractions) {
70  auto itr = detIdToIndex.find(hAndF.first);
71  if (itr == detIdToIndex.end())
72  continue; // hit wasn't saved in reco
73  auto ref = makeRefhit(input, itr->second);
74  const double hit_energy = hAndF.second * ref->energy();
75  energy += hit_energy;
76  back.addRecHitFraction(reco::PFRecHitFraction(ref, hAndF.second));
77  if (hit_energy > highest_energy || highest_energy == 0.0) {
78  highest_energy = hit_energy;
79  seed = ref;
80  }
81  }
82  if (!back.hitsAndFractions().empty()) {
83  back.setSeed(seed->detId());
84  back.setEnergy(energy);
86  } else {
87  back.setSeed(-1);
88  back.setEnergy(0.f);
89  }
90  }
91 }
GenericSimClusterMapper
Definition: GenericSimClusterMapper.cc:9
reco::PFClusterCollection
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
reco::CaloCluster::setSeed
void setSeed(const DetId &id)
Definition: CaloCluster.h:146
SimClusterCollection
std::vector< SimCluster > SimClusterCollection
Definition: SimClusterFwd.h:8
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
InitialClusteringStepBase.h
MessageLogger.h
GenericSimClusterMapper::operator=
B2DGT & operator=(const B2DGT &)=delete
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
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
GenericSimClusterMapper::B2DGT
GenericSimClusterMapper B2DGT
Definition: GenericSimClusterMapper.cc:10
edm::EDGetTokenT< SimClusterCollection >
reco::CaloCluster::setCorrectedEnergy
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:137
GenericSimClusterMapper::GenericSimClusterMapper
GenericSimClusterMapper(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
Definition: GenericSimClusterMapper.cc:13
edm::Handle< reco::PFRecHitCollection >
edm::Ref
Definition: AssociativeIterator.h:58
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
SimCluster.h
GenericSimClusterMapper::updateEvent
void updateEvent(const edm::Event &) final
Definition: GenericSimClusterMapper.cc:47
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
GenericSimClusterMapper::_simClusterH
edm::Handle< SimClusterCollection > _simClusterH
Definition: GenericSimClusterMapper.cc:30
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
GenericSimClusterMapper::_simClusterToken
edm::EDGetTokenT< SimClusterCollection > _simClusterToken
Definition: GenericSimClusterMapper.cc:29
edm::ParameterSet
Definition: ParameterSet.h:47
InitialClusteringStepBase
Definition: InitialClusteringStepBase.h:24
Event.h
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
GenericSimClusterMapper::buildClusters
void buildClusters(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const std::vector< bool > &, reco::PFClusterCollection &) override
Definition: GenericSimClusterMapper.cc:49
edmplugin::PluginFactory
Definition: PluginFactory.h:34
SimClusterFwd.h
cc
PFRecHitFraction.h
reco::PFCluster::addRecHitFraction
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:33
reco::CaloCluster::setEnergy
void setEnergy(double energy)
Definition: CaloCluster.h:136
HGCalDetId.h
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
reco::PFCluster
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
GenericSimClusterMapper::~GenericSimClusterMapper
~GenericSimClusterMapper() override=default
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45