CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
PFMultiDepthClusterizer Class Referencefinal
Inheritance diagram for PFMultiDepthClusterizer:
PFClusterBuilderBase

Classes

class  ClusterLink
 

Public Member Functions

void buildClusters (const reco::PFClusterCollection &, const std::vector< bool > &, reco::PFClusterCollection &outclus, const HcalPFCuts *) override
 
B2DGPFoperator= (const B2DGPF &)=delete
 
 PFMultiDepthClusterizer (const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
 
 PFMultiDepthClusterizer (const B2DGPF &)=delete
 
void update (const edm::EventSetup &es) override
 
 ~PFMultiDepthClusterizer () override=default
 
- Public Member Functions inherited from PFClusterBuilderBase
std::ostream & operator<< (std::ostream &o) const
 
PFCBBoperator= (const PFCBB &)=delete
 
 PFClusterBuilderBase (const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
 
 PFClusterBuilderBase (const PFCBB &)=delete
 
void reset ()
 
virtual ~PFClusterBuilderBase ()=default
 

Private Types

typedef PFMultiDepthClusterizer B2DGPF
 

Private Member Functions

void absorbCluster (reco::PFCluster &, const reco::PFCluster &)
 
void calculateShowerShapes (const reco::PFClusterCollection &, std::vector< double > &, std::vector< double > &)
 
void expandCluster (reco::PFCluster &, unsigned int point, std::vector< bool > &mask, const reco::PFClusterCollection &, const std::vector< ClusterLink > &links)
 
std::vector< ClusterLinklink (const reco::PFClusterCollection &, const std::vector< double > &, const std::vector< double > &)
 
std::vector< ClusterLinkprune (std::vector< ClusterLink > &, std::vector< bool > &linkedClusters)
 

Private Attributes

std::unique_ptr< PFCPositionCalculatorBase_allCellsPosCalc
 
double nSigmaEta_
 
double nSigmaPhi_
 

Additional Inherited Members

- Public Types inherited from PFClusterBuilderBase
typedef PFCPositionCalculatorBase PosCalc
 
- Protected Attributes inherited from PFClusterBuilderBase
const float _minFractionToKeep
 
unsigned _nClustersFound
 
unsigned _nSeeds
 
std::unique_ptr< PosCalc_positionCalc
 

Detailed Description

Definition at line 16 of file PFMultiDepthClusterizer.cc.

Member Typedef Documentation

◆ B2DGPF

Definition at line 17 of file PFMultiDepthClusterizer.cc.

Constructor & Destructor Documentation

◆ PFMultiDepthClusterizer() [1/2]

PFMultiDepthClusterizer::PFMultiDepthClusterizer ( const edm::ParameterSet conf,
edm::ConsumesCollector cc 
)

Definition at line 81 of file PFMultiDepthClusterizer.cc.

References _allCellsPosCalc, gpuPixelDoublets::cc, get, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), nSigmaEta_, nSigmaPhi_, funct::pow(), and AlCaHLTBitMon_QueryRunRegistry::string.

82  : PFClusterBuilderBase(conf, cc) {
83  const auto& acConf = conf.getParameterSet("allCellsPositionCalc");
84  if (!acConf.empty()) {
85  const std::string& algoac = acConf.getParameter<std::string>("algoName");
86  if (!algoac.empty())
87  _allCellsPosCalc = PFCPositionCalculatorFactory::get()->create(algoac, acConf, cc);
88  }
89 
90  nSigmaEta_ = pow(conf.getParameter<double>("nSigmaEta"), 2);
91  nSigmaPhi_ = pow(conf.getParameter<double>("nSigmaPhi"), 2);
92 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
ParameterSet const & getParameterSet(std::string const &) const
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
PFClusterBuilderBase(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
#define get
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ ~PFMultiDepthClusterizer()

PFMultiDepthClusterizer::~PFMultiDepthClusterizer ( )
overridedefault

◆ PFMultiDepthClusterizer() [2/2]

PFMultiDepthClusterizer::PFMultiDepthClusterizer ( const B2DGPF )
delete

Member Function Documentation

◆ absorbCluster()

void PFMultiDepthClusterizer::absorbCluster ( reco::PFCluster main,
const reco::PFCluster added 
)
private

Definition at line 257 of file PFMultiDepthClusterizer.cc.

References StorageManager_cfg::e1, HLT_2024v14_cff::fraction, reco::PFCluster::recHitFractions(), and reco::CaloCluster::seed().

Referenced by expandCluster().

257  {
258  double e1 = 0.0;
259  double e2 = 0.0;
260 
261  //find seeds
262  for (const auto& fraction : main.recHitFractions())
263  if (fraction.recHitRef()->detId() == main.seed()) {
264  e1 = fraction.recHitRef()->energy();
265  }
266 
267  for (const auto& fraction : added.recHitFractions()) {
268  main.addRecHitFraction(fraction);
269  if (fraction.recHitRef()->detId() == added.seed()) {
270  e2 = fraction.recHitRef()->energy();
271  }
272  }
273  if (e2 > e1)
274  main.setSeed(added.seed());
275 }
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:219
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:65
Definition: main.py:1

◆ buildClusters()

void PFMultiDepthClusterizer::buildClusters ( const reco::PFClusterCollection input,
const std::vector< bool > &  seedable,
reco::PFClusterCollection outclus,
const HcalPFCuts hcalCuts 
)
overridevirtual

Implements PFClusterBuilderBase.

Definition at line 94 of file PFMultiDepthClusterizer.cc.

References _allCellsPosCalc, calculateShowerShapes(), expandCluster(), mps_fire::i, input, link(), electronStore::links, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, and prune().

97  {
98  std::vector<double> etaRMS2(input.size(), 0.0);
99  std::vector<double> phiRMS2(input.size(), 0.0);
100 
101  //We need to sort the clusters for smaller to larger depth
102  // for (unsigned int i=0;i<input.size();++i)
103  // printf(" cluster%f %f \n",input[i].depth(),input[i].energy());
104 
105  //calculate cluster shapes
106  calculateShowerShapes(input, etaRMS2, phiRMS2);
107 
108  //link
109  auto&& links = link(input, etaRMS2, phiRMS2);
110  // for (const auto& link: links)
111  // printf("link %d %d %f %f\n",link.from(),link.to(),link.dR(),link.dZ());
112 
113  std::vector<bool> mask(input.size(), false);
114  std::vector<bool> linked(input.size(), false);
115 
116  //prune
117  auto&& prunedLinks = prune(links, linked);
118 
119  //printf("Pruned links\n")
120  // for (const auto& link: prunedLinks)
121  // printf("link %d %d %f %f\n",link.from(),link.to(),link.dR(),link.dZ());
122 
123  //now we need to build clusters
124  for (unsigned int i = 0; i < input.size(); ++i) {
125  //if not masked
126  if (mask[i])
127  continue;
128  //if not linked just spit it out
129  if (!linked[i]) {
130  output.push_back(input[i]);
131  // printf("Added single cluster with energy =%f \n",input[i].energy());
132  mask[i] = true;
133  continue;
134  }
135 
136  //now business: if linked and not masked gather clusters
137  reco::PFCluster cluster = input[i];
138  mask[i] = true;
139  expandCluster(cluster, i, mask, input, prunedLinks);
140  _allCellsPosCalc->calculateAndSetPosition(cluster, hcalCuts);
141  output.push_back(cluster);
142  // printf("Added linked cluster with energy =%f\n",cluster.energy());
143  }
144 }
void calculateShowerShapes(const reco::PFClusterCollection &, std::vector< double > &, std::vector< double > &)
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
std::vector< ClusterLink > prune(std::vector< ClusterLink > &, std::vector< bool > &linkedClusters)
static std::string const input
Definition: EdmProvDump.cc:50
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
std::vector< ClusterLink > link(const reco::PFClusterCollection &, const std::vector< double > &, const std::vector< double > &)
Definition: output.py:1
void expandCluster(reco::PFCluster &, unsigned int point, std::vector< bool > &mask, const reco::PFClusterCollection &, const std::vector< ClusterLink > &links)

◆ calculateShowerShapes()

void PFMultiDepthClusterizer::calculateShowerShapes ( const reco::PFClusterCollection clusters,
std::vector< double > &  etaRMS2,
std::vector< double > &  phiRMS2 
)
private

Definition at line 146 of file PFMultiDepthClusterizer.cc.

References funct::abs(), bsc_activity_cfg::clusters, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::PFCluster::energy(), DivergingColor::frac, h, mps_fire::i, SiStripPI::max, reco::PFCluster::positionREP(), reco::PFCluster::recHitFractions(), and cuy::rep.

Referenced by buildClusters().

148  {
149  //shower shapes. here do not use the fractions
150 
151  for (unsigned int i = 0; i < clusters.size(); ++i) {
152  const reco::PFCluster& cluster = clusters[i];
153  double etaSum = 0.0;
154  double phiSum = 0.0;
155  auto const& crep = cluster.positionREP();
156  for (const auto& frac : cluster.recHitFractions()) {
157  auto const& h = *frac.recHitRef();
158  auto const& rep = h.positionREP();
159  etaSum += (frac.fraction() * h.energy()) * std::abs(rep.eta() - crep.eta());
160  phiSum += (frac.fraction() * h.energy()) * std::abs(deltaPhi(rep.phi(), crep.phi()));
161  }
162  //protection for single line : assign ~ tower
163  etaRMS2[i] = std::max(etaSum / cluster.energy(), 0.1);
164  etaRMS2[i] *= etaRMS2[i];
165  phiRMS2[i] = std::max(phiSum / cluster.energy(), 0.1);
166  phiRMS2[i] *= phiRMS2[i];
167  }
168 }
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:65
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:92
double energy() const
cluster energy
Definition: PFCluster.h:74
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
rep
Definition: cuy.py:1189
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ expandCluster()

void PFMultiDepthClusterizer::expandCluster ( reco::PFCluster cluster,
unsigned int  point,
std::vector< bool > &  mask,
const reco::PFClusterCollection clusters,
const std::vector< ClusterLink > &  links 
)
private

Definition at line 277 of file PFMultiDepthClusterizer.cc.

References absorbCluster(), bsc_activity_cfg::clusters, link(), electronStore::links, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, and point.

Referenced by buildClusters().

281  {
282  for (const auto& link : links) {
283  if (link.from() == point) {
284  //found link that starts from this guy if not masked absorb
285  if (!mask[link.from()]) {
286  absorbCluster(cluster, clusters[link.from()]);
287  mask[link.from()] = true;
288  }
289 
290  if (!mask[link.to()]) {
291  absorbCluster(cluster, clusters[link.to()]);
292  mask[link.to()] = true;
293  expandCluster(cluster, link.to(), mask, clusters, links);
294  }
295  }
296  if (link.to() == point) {
297  //found link that starts from this guy if not masked absorb
298  if (!mask[link.to()]) {
299  absorbCluster(cluster, clusters[link.to()]);
300  mask[link.to()] = true;
301  }
302 
303  if (!mask[link.from()]) {
304  absorbCluster(cluster, clusters[link.from()]);
305  mask[link.from()] = true;
306  expandCluster(cluster, link.from(), mask, clusters, links);
307  }
308  }
309  }
310 }
void absorbCluster(reco::PFCluster &, const reco::PFCluster &)
std::vector< ClusterLink > link(const reco::PFClusterCollection &, const std::vector< double > &, const std::vector< double > &)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void expandCluster(reco::PFCluster &, unsigned int point, std::vector< bool > &mask, const reco::PFClusterCollection &, const std::vector< ClusterLink > &links)

◆ link()

std::vector< PFMultiDepthClusterizer::ClusterLink > PFMultiDepthClusterizer::link ( const reco::PFClusterCollection clusters,
const std::vector< double > &  etaRMS2,
const std::vector< double > &  phiRMS2 
)
private

Definition at line 170 of file PFMultiDepthClusterizer.cc.

References funct::abs(), bsc_activity_cfg::clusters, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::PFCluster::depth(), PVValHelper::dz, reco::PFCluster::energy(), mps_fire::i, dqmiolumiharvest::j, electronStore::links, nSigmaEta_, nSigmaPhi_, and reco::PFCluster::positionREP().

Referenced by buildClusters(), and expandCluster().

171  {
172  std::vector<ClusterLink> links;
173  //loop on all pairs
174  for (unsigned int i = 0; i < clusters.size(); ++i)
175  for (unsigned int j = 0; j < clusters.size(); ++j) {
176  if (i == j)
177  continue;
178 
179  const reco::PFCluster& cluster1 = clusters[i];
180  const reco::PFCluster& cluster2 = clusters[j];
181 
182  // PFCluster depth stored as double but HCAL layer clusters have integral depths only
183  auto dz = (static_cast<int>(cluster2.depth()) - static_cast<int>(cluster1.depth()));
184 
185  //Do not link at the same layer and only link inside out!
186  if (dz <= 0)
187  continue;
188 
189  auto const& crep1 = cluster1.positionREP();
190  auto const& crep2 = cluster2.positionREP();
191 
192  auto deta = crep1.eta() - crep2.eta();
193  deta = deta * deta / (etaRMS2[i] + etaRMS2[j]);
194  auto dphi = deltaPhi(crep1.phi(), crep2.phi());
195  dphi = dphi * dphi / (phiRMS2[i] + phiRMS2[j]);
196 
197  // printf("Testing Link %d -> %d (%f %f %f %f ) \n",i,j,deta,dphi,cluster1.position().Eta()-cluster2.position().Eta(),deltaPhi(cluster1.position().Phi(),cluster2.position().Phi()));
198 
199  if ((deta < nSigmaEta_) & (dphi < nSigmaPhi_))
200  links.push_back(ClusterLink(i, j, deta + dphi, std::abs(dz), cluster1.energy() + cluster2.energy()));
201  }
202 
203  return links;
204 }
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:92
double depth() const
cluster depth
Definition: PFCluster.h:82
double energy() const
cluster energy
Definition: PFCluster.h:74
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ operator=()

B2DGPF& PFMultiDepthClusterizer::operator= ( const B2DGPF )
delete

◆ prune()

std::vector< PFMultiDepthClusterizer::ClusterLink > PFMultiDepthClusterizer::prune ( std::vector< ClusterLink > &  links,
std::vector< bool > &  linkedClusters 
)
private

Definition at line 206 of file PFMultiDepthClusterizer.cc.

References PFMultiDepthClusterizer::ClusterLink::dR(), PFMultiDepthClusterizer::ClusterLink::dZ(), PFMultiDepthClusterizer::ClusterLink::energy(), mps_fire::i, dqmiolumiharvest::j, electronStore::links, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::mask, and PFMultiDepthClusterizer::ClusterLink::to().

Referenced by buildClusters(), and dirstructure.Directory::prune().

207  {
208  std::vector<ClusterLink> goodLinks;
209  std::vector<bool> mask(links.size(), false);
210  if (links.empty())
211  return goodLinks;
212 
213  for (unsigned int i = 0; i < links.size() - 1; ++i) {
214  if (mask[i])
215  continue;
216  for (unsigned int j = i + 1; j < links.size(); ++j) {
217  if (mask[j])
218  continue;
219 
220  const ClusterLink& link1 = links[i];
221  const ClusterLink& link2 = links[j];
222 
223  if (link1.to() == link2.to()) { //found two links going to the same spot,kill one
224  //first prefer nearby layers
225  if (link1.dZ() < link2.dZ()) {
226  mask[j] = true;
227  } else if (link1.dZ() > link2.dZ()) {
228  mask[i] = true;
229  } else { //if same layer-pick based on transverse compatibility
230  if (link1.dR() < link2.dR()) {
231  mask[j] = true;
232  } else if (link1.dR() > link2.dR()) {
233  mask[i] = true;
234  } else {
235  //same distance as well -> can happen !!!!! Pick the highest SUME
236  if (link1.energy() < link2.energy())
237  mask[i] = true;
238  else
239  mask[j] = true;
240  }
241  }
242  }
243  }
244  }
245 
246  for (unsigned int i = 0; i < links.size(); ++i) {
247  if (mask[i])
248  continue;
249  goodLinks.push_back(links[i]);
250  linkedClusters[links[i].from()] = true;
251  linkedClusters[links[i].to()] = true;
252  }
253 
254  return goodLinks;
255 }

◆ update()

void PFMultiDepthClusterizer::update ( const edm::EventSetup es)
inlineoverridevirtual

Member Data Documentation

◆ _allCellsPosCalc

std::unique_ptr<PFCPositionCalculatorBase> PFMultiDepthClusterizer::_allCellsPosCalc
private

Definition at line 34 of file PFMultiDepthClusterizer.cc.

Referenced by buildClusters(), PFMultiDepthClusterizer(), and update().

◆ nSigmaEta_

double PFMultiDepthClusterizer::nSigmaEta_
private

Definition at line 35 of file PFMultiDepthClusterizer.cc.

Referenced by link(), and PFMultiDepthClusterizer().

◆ nSigmaPhi_

double PFMultiDepthClusterizer::nSigmaPhi_
private

Definition at line 36 of file PFMultiDepthClusterizer.cc.

Referenced by link(), and PFMultiDepthClusterizer().