CMS 3D CMS Logo

PFClusterFromHGCalTrackster.cc
Go to the documentation of this file.
7 
9 public:
11  : InitialClusteringStepBase(conf, cc) {
12  filterByTracksterPID_ = conf.getParameter<bool>("filterByTracksterPID");
13  pid_threshold_ = conf.getParameter<double>("pid_threshold");
14  filter_on_categories_ = conf.getParameter<std::vector<int> >("filter_on_categories");
15 
16  tracksterToken_ = cc.consumes<std::vector<ticl::Trackster> >(conf.getParameter<edm::InputTag>("tracksterSrc"));
18  }
19 
23 
24  void updateEvent(const edm::Event&) final;
25 
27  const std::vector<bool>&,
28  const std::vector<bool>&,
29  reco::PFClusterCollection&) override;
30 
31 private:
34  std::vector<int> filter_on_categories_;
35 
38 
41 };
42 
44 
46  ev.getByToken(tracksterToken_, trackstersH_);
47  ev.getByToken(clusterToken_, clusterH_);
48 }
49 
51  const std::vector<bool>& rechitMask,
52  const std::vector<bool>& seedable,
54  auto const& hits = *input;
55 
56  const auto& tracksters = *trackstersH_;
57  const auto& clusters = *clusterH_;
58 
59  // for quick indexing back to hit energy
60  std::unordered_map<uint32_t, size_t> detIdToIndex(hits.size());
61  for (uint32_t i = 0; i < hits.size(); ++i) {
62  detIdToIndex[hits[i].detId()] = i;
63  }
64 
65  for (const auto& tst : tracksters) {
66  // Skip empty tracksters
67  if (tst.vertices().empty()) {
68  continue;
69  }
70  // Filter using trackster PID
72  float probTotal = 0.0f;
73  for (int cat : filter_on_categories_) {
74  probTotal += tst.id_probabilities(cat);
75  }
76  if (probTotal < pid_threshold_) {
77  continue;
78  }
79  }
80 
81  DetId seed;
82  double energy = 0.0, highest_energy = 0.0;
83  output.emplace_back();
84  reco::PFCluster& back = output.back();
85 
86  std::vector<std::pair<DetId, float> > hitsAndFractions;
87  int iLC = 0;
88  std::for_each(std::begin(tst.vertices()), std::end(tst.vertices()), [&](unsigned int lcId) {
89  const auto fraction = 1.f / tst.vertex_multiplicity(iLC++);
90  for (const auto& cell : clusters[lcId].hitsAndFractions()) {
91  hitsAndFractions.emplace_back(cell.first, cell.second * fraction);
92  }
93  });
94 
95  for (const auto& hAndF : hitsAndFractions) {
96  auto itr = detIdToIndex.find(hAndF.first);
97  if (itr == detIdToIndex.end()) {
98  continue; // hit wasn't saved in reco
99  }
100  auto ref = makeRefhit(input, itr->second);
101  assert(ref->detId() == hAndF.first.rawId());
102  const double hit_energy = hAndF.second * ref->energy();
103  energy += hit_energy;
104  back.addRecHitFraction(reco::PFRecHitFraction(ref, hAndF.second));
105  // TODO: the following logic to identify the seed of a cluster
106  // could be appropriate for the Run2 Ecal Calorimetric
107  // detector, but could be wrong for the HGCal one. This has to
108  // be reviewd.
109  if (hit_energy > highest_energy || highest_energy == 0.0) {
110  highest_energy = hit_energy;
111  seed = ref->detId();
112  }
113  } // end of hitsAndFractions
114 
115  if (!back.hitsAndFractions().empty()) {
116  back.setSeed(seed);
117  back.setEnergy(energy);
119  } else {
120  back.setSeed(0);
121  back.setEnergy(0.f);
122  }
123  } // end of loop over hgcalTracksters (3D)
124 }
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
PFClusterFromHGCalTrackster::trackstersH_
edm::Handle< std::vector< ticl::Trackster > > trackstersH_
Definition: PFClusterFromHGCalTrackster.cc:37
PFClusterFromHGCalTrackster::PFClusterFromHGCalTrackster
PFClusterFromHGCalTrackster(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
Definition: PFClusterFromHGCalTrackster.cc:10
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
InitialClusteringStepBase.h
MessageLogger.h
Trackster.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PFClusterFromHGCalTrackster::~PFClusterFromHGCalTrackster
~PFClusterFromHGCalTrackster() override
Definition: PFClusterFromHGCalTrackster.cc:20
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
edm::EDGetTokenT
Definition: EDGetToken.h:33
PFClusterFromHGCalTrackster::operator=
PFClusterFromHGCalTrackster & operator=(const PFClusterFromHGCalTrackster &)=delete
reco::CaloCluster::setCorrectedEnergy
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:137
eostools.cat
def cat(path)
Definition: eostools.py:401
PFClusterFromHGCalTrackster::tracksterToken_
edm::EDGetTokenT< std::vector< ticl::Trackster > > tracksterToken_
Definition: PFClusterFromHGCalTrackster.cc:36
cms::cuda::assert
assert(be >=bs)
PFClusterFromHGCalTrackster::filter_on_categories_
std::vector< int > filter_on_categories_
Definition: PFClusterFromHGCalTrackster.cc:34
PFClusterFromHGCalTrackster::clusterToken_
edm::EDGetTokenT< reco::CaloClusterCollection > clusterToken_
Definition: PFClusterFromHGCalTrackster.cc:39
edm::Handle< reco::PFRecHitCollection >
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
DetId
Definition: DetId.h:17
PFClusterFromHGCalTrackster::pid_threshold_
float pid_threshold_
Definition: PFClusterFromHGCalTrackster.cc:33
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52823
reco::CaloClusterCollection
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
Definition: CaloClusterFwd.h:19
mps_fire.end
end
Definition: mps_fire.py:242
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
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
edmplugin::PluginFactory
Definition: PluginFactory.h:34
PFClusterFromHGCalTrackster
Definition: PFClusterFromHGCalTrackster.cc:8
PFClusterFromHGCalTrackster::filterByTracksterPID_
bool filterByTracksterPID_
Definition: PFClusterFromHGCalTrackster.cc:32
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
PFClusterFromHGCalTrackster::updateEvent
void updateEvent(const edm::Event &) final
Definition: PFClusterFromHGCalTrackster.cc:45
PFClusterFromHGCalTrackster::clusterH_
edm::Handle< reco::CaloClusterCollection > clusterH_
Definition: PFClusterFromHGCalTrackster.cc:40
PFClusterFromHGCalTrackster::buildClusters
void buildClusters(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const std::vector< bool > &, reco::PFClusterCollection &) override
Definition: PFClusterFromHGCalTrackster.cc:50
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45