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 &) 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 8 of file PFClusterFromHGCalTrackster.cc.

Constructor & Destructor Documentation

◆ PFClusterFromHGCalTrackster() [1/2]

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

Definition at line 10 of file PFClusterFromHGCalTrackster.cc.

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

11  : InitialClusteringStepBase(conf, cc) {
12  filterByTracksterPID_ = conf.getParameter<bool>("filterByTracksterPID");
13  filterByTracksterIteration_ = conf.getParameter<bool>("filterByTracksterIteration");
14  pid_threshold_ = conf.getParameter<double>("pid_threshold");
15  filter_on_categories_ = conf.getParameter<std::vector<int> >("filter_on_categories");
16  filter_on_iterations_ = conf.getParameter<std::vector<int> >("filter_on_iterations");
17 
18  tracksterToken_ = cc.consumes<std::vector<ticl::Trackster> >(conf.getParameter<edm::InputTag>("tracksterSrc"));
20  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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 22 of file PFClusterFromHGCalTrackster.cc.

22 {}

◆ 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 
)
overridevirtual

Implements InitialClusteringStepBase.

Definition at line 54 of file PFClusterFromHGCalTrackster.cc.

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

57  {
58  auto const& hits = *input;
59 
60  const auto& tracksters = *trackstersH_;
61  const auto& clusters = *clusterH_;
62 
63  // for quick indexing back to hit energy
64  std::unordered_map<uint32_t, size_t> detIdToIndex(hits.size());
65  for (uint32_t i = 0; i < hits.size(); ++i) {
66  detIdToIndex[hits[i].detId()] = i;
67  }
68 
69  for (const auto& tst : tracksters) {
70  // Skip empty tracksters
71  if (tst.vertices().empty()) {
72  continue;
73  }
74  // Filter using trackster PID
76  float probTotal = 0.0f;
77  for (int cat : filter_on_categories_) {
78  probTotal += tst.id_probabilities(cat);
79  }
80  if (probTotal < pid_threshold_) {
81  continue;
82  }
83  }
84 
86  std::find(filter_on_iterations_.begin(), filter_on_iterations_.end(), tst.ticlIteration()) ==
87  filter_on_iterations_.end()) {
88  continue;
89  }
90 
91  DetId seed;
92  double energy = 0.0, highest_energy = 0.0;
93  output.emplace_back();
94  reco::PFCluster& back = output.back();
95 
96  std::vector<std::pair<DetId, float> > hitsAndFractions;
97  int iLC = 0;
98  std::for_each(std::begin(tst.vertices()), std::end(tst.vertices()), [&](unsigned int lcId) {
99  const auto fraction = 1.f / tst.vertex_multiplicity(iLC++);
100  for (const auto& cell : clusters[lcId].hitsAndFractions()) {
101  hitsAndFractions.emplace_back(cell.first, cell.second * fraction);
102  }
103  });
104 
105  for (const auto& hAndF : hitsAndFractions) {
106  auto itr = detIdToIndex.find(hAndF.first);
107  if (itr == detIdToIndex.end()) {
108  continue; // hit wasn't saved in reco
109  }
110  auto ref = makeRefhit(input, itr->second);
111  assert(ref->detId() == hAndF.first.rawId());
112  const double hit_energy = hAndF.second * ref->energy();
113  energy += hit_energy;
114  back.addRecHitFraction(reco::PFRecHitFraction(ref, hAndF.second));
115  // TODO: the following logic to identify the seed of a cluster
116  // could be appropriate for the Run2 Ecal Calorimetric
117  // detector, but could be wrong for the HGCal one. This has to
118  // be reviewd.
119  if (hit_energy > highest_energy || highest_energy == 0.0) {
120  highest_energy = hit_energy;
121  seed = ref->detId();
122  }
123  } // end of hitsAndFractions
124 
125  if (!back.hitsAndFractions().empty()) {
126  back.setSeed(seed);
127  back.setEnergy(energy);
129  } else {
130  back.setSeed(0);
131  back.setEnergy(0.f);
132  }
133  } // end of loop over hgcalTracksters (3D)
134 }
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
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 49 of file PFClusterFromHGCalTrackster.cc.

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

49  {
50  ev.getByToken(tracksterToken_, trackstersH_);
51  ev.getByToken(clusterToken_, clusterH_);
52 }
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 44 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and updateEvent().

◆ clusterToken_

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

Definition at line 43 of file PFClusterFromHGCalTrackster.cc.

Referenced by PFClusterFromHGCalTrackster(), and updateEvent().

◆ filter_on_categories_

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

Definition at line 37 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ filter_on_iterations_

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

Definition at line 38 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ filterByTracksterIteration_

bool PFClusterFromHGCalTrackster::filterByTracksterIteration_
private

Definition at line 35 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ filterByTracksterPID_

bool PFClusterFromHGCalTrackster::filterByTracksterPID_
private

Definition at line 34 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ pid_threshold_

float PFClusterFromHGCalTrackster::pid_threshold_
private

Definition at line 36 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and PFClusterFromHGCalTrackster().

◆ trackstersH_

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

Definition at line 41 of file PFClusterFromHGCalTrackster.cc.

Referenced by buildClusters(), and updateEvent().

◆ tracksterToken_

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

Definition at line 40 of file PFClusterFromHGCalTrackster.cc.

Referenced by PFClusterFromHGCalTrackster(), and updateEvent().