CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PFClusterFromHGCalTrackster Class Reference
Inheritance diagram for PFClusterFromHGCalTrackster:
InitialClusteringStepBase

Public Member Functions

void buildClusters (const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const std::vector< bool > &, reco::PFClusterCollection &, const HcalPFCuts *) override
 
PFClusterFromHGCalTracksteroperator= (const PFClusterFromHGCalTrackster &)=delete
 
 PFClusterFromHGCalTrackster (const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
 
 PFClusterFromHGCalTrackster (const PFClusterFromHGCalTrackster &)=delete
 
void updateEvent (const edm::Event &) final
 
 ~PFClusterFromHGCalTrackster () override
 
- Public Member Functions inherited from InitialClusteringStepBase
 InitialClusteringStepBase (const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
 
 InitialClusteringStepBase (const ICSB &)=delete
 
std::ostream & operator<< (std::ostream &o) const
 
ICSBoperator= (const ICSB &)=delete
 
void reset ()
 
virtual void update (const edm::EventSetup &)
 
virtual ~InitialClusteringStepBase ()=default
 

Private Attributes

edm::Handle< reco::CaloClusterCollectionclusterH_
 
edm::EDGetTokenT< reco::CaloClusterCollectionclusterToken_
 
std::vector< int > filter_on_categories_
 
std::vector< int > filter_on_iterations_
 
bool filterByTracksterIteration_
 
bool filterByTracksterPID_
 
float pid_threshold_
 
edm::Handle< std::vector< ticl::Trackster > > trackstersH_
 
edm::EDGetTokenT< std::vector< ticl::Trackster > > tracksterToken_
 

Additional Inherited Members

- Protected Types inherited from InitialClusteringStepBase
typedef std::tuple< std::vector< int >, std::vector< double >, std::vector< double > > I3tuple
 
- Protected Member Functions inherited from InitialClusteringStepBase
reco::PFRecHitRef makeRefhit (const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
 
- Protected Attributes inherited from InitialClusteringStepBase
const std::unordered_map< std::string, int > _layerMap
 
unsigned _nClustersFound
 
unsigned _nSeeds
 
std::unordered_map< int, I3tuple_thresholds
 

Detailed Description

Definition at line 10 of file PFClusterFromHGCalTrackster.cc.

Constructor & Destructor Documentation

◆ PFClusterFromHGCalTrackster() [1/2]

PFClusterFromHGCalTrackster::PFClusterFromHGCalTrackster ( const edm::ParameterSet conf,
edm::ConsumesCollector cc 
)
inline

Definition at line 12 of file PFClusterFromHGCalTrackster.cc.

References gpuPixelDoublets::cc, clusterToken_, filter_on_categories_, filter_on_iterations_, filterByTracksterIteration_, filterByTracksterPID_, edm::ParameterSet::getParameter(), pid_threshold_, and tracksterToken_.

13  : InitialClusteringStepBase(conf, cc) {
14  filterByTracksterPID_ = conf.getParameter<bool>("filterByTracksterPID");
15  filterByTracksterIteration_ = conf.getParameter<bool>("filterByTracksterIteration");
16  pid_threshold_ = conf.getParameter<double>("pid_threshold");
17  filter_on_categories_ = conf.getParameter<std::vector<int> >("filter_on_categories");
18  filter_on_iterations_ = conf.getParameter<std::vector<int> >("filter_on_iterations");
19 
20  tracksterToken_ = cc.consumes<std::vector<ticl::Trackster> >(conf.getParameter<edm::InputTag>("tracksterSrc"));
22  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::EDGetTokenT< reco::CaloClusterCollection > clusterToken_
InitialClusteringStepBase(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
std::vector< CaloCluster > CaloClusterCollection
collection of CaloCluster objects
edm::EDGetTokenT< std::vector< ticl::Trackster > > tracksterToken_

◆ ~PFClusterFromHGCalTrackster()

PFClusterFromHGCalTrackster::~PFClusterFromHGCalTrackster ( )
inlineoverride

Definition at line 24 of file PFClusterFromHGCalTrackster.cc.

24 {}

◆ PFClusterFromHGCalTrackster() [2/2]

PFClusterFromHGCalTrackster::PFClusterFromHGCalTrackster ( const PFClusterFromHGCalTrackster )
delete

Member Function Documentation

◆ buildClusters()

void PFClusterFromHGCalTrackster::buildClusters ( const edm::Handle< reco::PFRecHitCollection > &  input,
const std::vector< bool > &  rechitMask,
const std::vector< bool > &  seedable,
reco::PFClusterCollection output,
const HcalPFCuts  
)
overridevirtual

Implements InitialClusteringStepBase.

Definition at line 57 of file PFClusterFromHGCalTrackster.cc.

References reco::PFCluster::addRecHitFraction(), cms::cuda::assert(), eostools::cat(), clusterH_, bsc_activity_cfg::clusters, hcalRecHitTable_cff::energy, f, filter_on_categories_, filter_on_iterations_, filterByTracksterIteration_, filterByTracksterPID_, spr::find(), HLT_2024v13_cff::fraction, hfClusterShapes_cfi::hits, reco::CaloCluster::hitsAndFractions(), mps_fire::i, input, InitialClusteringStepBase::makeRefhit(), pid_threshold_, fileCollector::seed, reco::CaloCluster::setCorrectedEnergy(), reco::CaloCluster::setEnergy(), reco::CaloCluster::setSeed(), and trackstersH_.

61  {
62  auto const& hits = *input;
63 
64  const auto& tracksters = *trackstersH_;
65  const auto& clusters = *clusterH_;
66 
67  // for quick indexing back to hit energy
68  std::unordered_map<uint32_t, size_t> detIdToIndex(hits.size());
69  for (uint32_t i = 0; i < hits.size(); ++i) {
70  detIdToIndex[hits[i].detId()] = i;
71  }
72 
73  for (const auto& tst : tracksters) {
74  // Skip empty tracksters
75  if (tst.vertices().empty()) {
76  continue;
77  }
78  // Filter using trackster PID
80  float probTotal = 0.0f;
81  for (int cat : filter_on_categories_) {
82  probTotal += tst.id_probabilities(cat);
83  }
84  if (probTotal < pid_threshold_) {
85  continue;
86  }
87  }
88 
90  std::find(filter_on_iterations_.begin(), filter_on_iterations_.end(), tst.ticlIteration()) ==
91  filter_on_iterations_.end()) {
92  continue;
93  }
94 
95  DetId seed;
96  double energy = 0.0, highest_energy = 0.0;
97  output.emplace_back();
98  reco::PFCluster& back = output.back();
99 
100  std::vector<std::pair<DetId, float> > hitsAndFractions;
101  int iLC = 0;
102  std::for_each(std::begin(tst.vertices()), std::end(tst.vertices()), [&](unsigned int lcId) {
103  const auto fraction = 1.f / tst.vertex_multiplicity(iLC++);
104  for (const auto& cell : clusters[lcId].hitsAndFractions()) {
105  hitsAndFractions.emplace_back(cell.first, cell.second * fraction);
106  }
107  });
108 
109  for (const auto& hAndF : hitsAndFractions) {
110  auto itr = detIdToIndex.find(hAndF.first);
111  if (itr == detIdToIndex.end()) {
112  continue; // hit wasn't saved in reco
113  }
114  auto ref = makeRefhit(input, itr->second);
115  assert(ref->detId() == hAndF.first.rawId());
116  const double hit_energy = hAndF.second * ref->energy();
117  energy += hit_energy;
118  back.addRecHitFraction(reco::PFRecHitFraction(ref, hAndF.second));
119  // TODO: the following logic to identify the seed of a cluster
120  // could be appropriate for the Run2 Ecal Calorimetric
121  // detector, but could be wrong for the HGCal one. This has to
122  // be reviewd.
123  if (hit_energy > highest_energy || highest_energy == 0.0) {
124  highest_energy = hit_energy;
125  seed = ref->detId();
126  }
127  } // end of hitsAndFractions
128 
129  if (!back.hitsAndFractions().empty()) {
130  back.setSeed(seed);
131  back.setEnergy(energy);
133  } else {
134  back.setSeed(0);
135  back.setEnergy(0.f);
136  }
137  } // end of loop over hgcalTracksters (3D)
138 }
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
reco::PFRecHitRef makeRefhit(const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
edm::Handle< reco::CaloClusterCollection > clusterH_
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
void setEnergy(double energy)
Definition: CaloCluster.h:136
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:50
void setSeed(const DetId &id)
Definition: CaloCluster.h:146
def cat(path)
Definition: eostools.py:401
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:137
double f[11][100]
Definition: DetId.h:17
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:33
Definition: output.py:1
edm::Handle< std::vector< ticl::Trackster > > trackstersH_

◆ operator=()

PFClusterFromHGCalTrackster& PFClusterFromHGCalTrackster::operator= ( const PFClusterFromHGCalTrackster )
delete

◆ updateEvent()

void PFClusterFromHGCalTrackster::updateEvent ( const edm::Event ev)
finalvirtual

Reimplemented from InitialClusteringStepBase.

Definition at line 52 of file PFClusterFromHGCalTrackster.cc.

References clusterH_, clusterToken_, makeMEIFBenchmarkPlots::ev, trackstersH_, and tracksterToken_.

52  {
53  ev.getByToken(tracksterToken_, trackstersH_);
54  ev.getByToken(clusterToken_, clusterH_);
55 }
edm::Handle< reco::CaloClusterCollection > clusterH_
edm::EDGetTokenT< reco::CaloClusterCollection > clusterToken_
edm::Handle< std::vector< ticl::Trackster > > trackstersH_
edm::EDGetTokenT< std::vector< ticl::Trackster > > tracksterToken_

Member Data Documentation

◆ clusterH_

edm::Handle<reco::CaloClusterCollection> PFClusterFromHGCalTrackster::clusterH_
private

Definition at line 47 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and updateEvent().

◆ clusterToken_

edm::EDGetTokenT<reco::CaloClusterCollection> PFClusterFromHGCalTrackster::clusterToken_
private

Definition at line 46 of file PFClusterFromHGCalTrackster.cc.

Referenced by PFClusterFromHGCalTrackster(), and updateEvent().

◆ filter_on_categories_

std::vector<int> PFClusterFromHGCalTrackster::filter_on_categories_
private

Definition at line 40 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ filter_on_iterations_

std::vector<int> PFClusterFromHGCalTrackster::filter_on_iterations_
private

Definition at line 41 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ filterByTracksterIteration_

bool PFClusterFromHGCalTrackster::filterByTracksterIteration_
private

Definition at line 38 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ filterByTracksterPID_

bool PFClusterFromHGCalTrackster::filterByTracksterPID_
private

Definition at line 37 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ pid_threshold_

float PFClusterFromHGCalTrackster::pid_threshold_
private

Definition at line 39 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ trackstersH_

edm::Handle<std::vector<ticl::Trackster> > PFClusterFromHGCalTrackster::trackstersH_
private

Definition at line 44 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and updateEvent().

◆ tracksterToken_

edm::EDGetTokenT<std::vector<ticl::Trackster> > PFClusterFromHGCalTrackster::tracksterToken_
private

Definition at line 43 of file PFClusterFromHGCalTrackster.cc.

Referenced by PFClusterFromHGCalTrackster(), and updateEvent().