|
|
#include <HGCalImagingAlgo.h>
|
double | calculateDistanceToHigher (std::vector< KDNode > &) const |
|
double | calculateEnergyWithFraction (const std::vector< KDNode > &, const std::vector< double > &) |
|
double | calculateLocalDensity (std::vector< KDNode > &, KDTree &, const unsigned int) const |
|
math::XYZPoint | calculatePosition (std::vector< KDNode > &) const |
|
math::XYZPoint | calculatePositionWithFraction (const std::vector< KDNode > &, const std::vector< double > &) |
|
double | distance (const Hexel &pt1, const Hexel &pt2) const |
|
double | distance2 (const Hexel &pt1, const Hexel &pt2) const |
|
int | findAndAssignClusters (std::vector< KDNode > &, KDTree &, double, KDTreeBox< 2 > &, const unsigned int, std::vector< std::vector< KDNode >> &) const |
|
std::vector< unsigned > | findLocalMaximaInCluster (const std::vector< KDNode > &) |
|
void | setDensity (const std::vector< KDNode > &nd) |
|
void | shareEnergy (const std::vector< KDNode > &, const std::vector< unsigned > &, std::vector< std::vector< double >> &) |
|
std::vector< size_t > | sort_by_delta (const std::vector< KDNode > &v) const |
|
Definition at line 31 of file HGCalImagingAlgo.h.
◆ KDNode
◆ KDTree
◆ Point
◆ HGCalImagingAlgo()
◆ ~HGCalImagingAlgo()
HGCalImagingAlgo::~HGCalImagingAlgo |
( |
| ) |
|
|
inlineoverride |
◆ calculateDistanceToHigher()
double HGCalImagingAlgo::calculateDistanceToHigher |
( |
std::vector< KDNode > & |
nd | ) |
const |
|
private |
◆ calculateEnergyWithFraction()
double HGCalImagingAlgo::calculateEnergyWithFraction |
( |
const std::vector< KDNode > & |
hits, |
|
|
const std::vector< double > & |
fractions |
|
) |
| |
|
private |
◆ calculateLocalDensity()
double HGCalImagingAlgo::calculateLocalDensity |
( |
std::vector< KDNode > & |
nd, |
|
|
KDTree & |
lp, |
|
|
const unsigned int |
layer |
|
) |
| const |
|
private |
Definition at line 262 of file HGCalImagingAlgo.cc.
263 double maxdensity = 0.;
274 for (
unsigned int i = 0;
i < nd.size(); ++
i) {
277 nd[
i].dims[0] - delta_c, nd[
i].dims[0] + delta_c, nd[
i].dims[1] - delta_c, nd[
i].dims[1] + delta_c);
278 std::vector<Hexel>
found;
279 lp.search(search_box,
found);
280 const unsigned int found_size =
found.size();
281 for (
unsigned int j = 0;
j < found_size;
j++) {
283 nd[
i].data.rho +=
found[
j].weight;
References data, HLT_FULL_cff::distance, newFWLiteAna::found, mps_fire::i, dqmiolumiharvest::j, SiStripPI::max, and KDTreeLinkerAlgo< DATA, DIM >::search().
◆ calculatePosition()
Definition at line 196 of file HGCalImagingAlgo.cc.
197 float total_weight = 0.f;
201 unsigned int v_size =
v.size();
202 unsigned int maxEnergyIndex = 0;
203 float maxEnergyValue = 0;
207 for (
unsigned int i = 0;
i < v_size;
i++) {
208 if (
v[
i].
data.weight > maxEnergyValue) {
209 maxEnergyValue =
v[
i].data.weight;
220 std::vector<unsigned int> innerIndices;
221 for (
unsigned int i = 0;
i < v_size;
i++) {
223 innerIndices.push_back(
i);
225 float rhEnergy =
v[
i].data.weight;
226 total_weight += rhEnergy;
230 x +=
v[
i].data.x * rhEnergy;
231 y +=
v[
i].data.y * rhEnergy;
237 if (thick != -1 && total_weight != 0.) {
238 float total_weight_log = 0.f;
241 for (
auto idx : innerIndices) {
242 float rhEnergy =
v[
idx].data.weight;
246 x_log +=
v[
idx].data.x * Wi;
247 y_log +=
v[
idx].data.y * Wi;
248 total_weight_log += Wi;
250 total_weight = total_weight_log;
255 if (total_weight != 0.) {
256 auto inv_tot_weight = 1. / total_weight;
References data, mps_fire::i, heavyIonCSV_trainingSettings::idx, dqm-mbProfile::log, SiStripPI::max, and findQualityFiles::v.
◆ calculatePositionWithFraction()
math::XYZPoint HGCalImagingAlgo::calculatePositionWithFraction |
( |
const std::vector< KDNode > & |
hits, |
|
|
const std::vector< double > & |
fractions |
|
) |
| |
|
private |
◆ computeThreshold()
void HGCalImagingAlgo::computeThreshold |
( |
| ) |
|
◆ distance()
double HGCalImagingAlgo::distance |
( |
const Hexel & |
pt1, |
|
|
const Hexel & |
pt2 |
|
) |
| const |
|
inlineprivate |
◆ distance2()
double HGCalImagingAlgo::distance2 |
( |
const Hexel & |
pt1, |
|
|
const Hexel & |
pt2 |
|
) |
| const |
|
inlineprivate |
◆ fillPSetDescription()
Definition at line 88 of file HGCalImagingAlgo.h.
89 iDesc.
add<std::vector<double>>(
"thresholdW0", {2.9, 2.9, 2.9});
90 iDesc.
add<std::vector<double>>(
"positionDeltaRho_c", {1.3, 1.3, 1.3});
91 iDesc.
add<std::vector<double>>(
"deltac",
97 iDesc.
add<
bool>(
"dependSensor",
true);
98 iDesc.
add<
double>(
"ecut", 3.0);
99 iDesc.
add<
double>(
"kappa", 9.0);
101 iDesc.
add<std::vector<double>>(
"dEdXweights", {});
102 iDesc.
add<std::vector<double>>(
"thicknessCorrection", {});
103 iDesc.
add<std::vector<double>>(
"fcPerMip", {});
104 iDesc.
add<
double>(
"fcPerEle", 0.0);
106 descNestedNoises.
add<std::vector<double>>(
"values", {});
109 descNestedNoiseMIP.
add<
bool>(
"scaleByDose",
false);
110 descNestedNoiseMIP.add<
double>(
"scaleByDoseFactor", 1.);
114 descNestedNoiseMIP.
add<
double>(
"noise_MIP", 1. / 100.);
References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.
◆ findAndAssignClusters()
int HGCalImagingAlgo::findAndAssignClusters |
( |
std::vector< KDNode > & |
nd, |
|
|
KDTree & |
lp, |
|
|
double |
maxdensity, |
|
|
KDTreeBox< 2 > & |
bounds, |
|
|
const unsigned int |
layer, |
|
|
std::vector< std::vector< KDNode >> & |
clustersOnLayer |
|
) |
| const |
|
private |
Definition at line 344 of file HGCalImagingAlgo.cc.
355 unsigned int nClustersOnLayer = 0;
367 const unsigned int nd_size = nd.size();
368 for (
unsigned int i = 0;
i < nd_size; ++
i) {
369 if (nd[ds[
i]].
data.delta < delta_c)
372 float rho_c =
kappa_ * nd[ds[
i]].data.sigmaNoise;
373 if (nd[ds[
i]].
data.rho < rho_c)
376 }
else if (nd[ds[
i]].
data.rho *
kappa_ < maxdensity)
379 nd[ds[
i]].data.clusterIndex = nClustersOnLayer;
381 std::cout <<
"Adding new cluster with index " << nClustersOnLayer << std::endl;
382 std::cout <<
"Cluster center is hit " << ds[
i] << std::endl;
389 if (nClustersOnLayer == 0)
390 return nClustersOnLayer;
395 for (
unsigned int oi = 1; oi < nd_size; ++oi) {
396 unsigned int i = rs[oi];
397 int ci = nd[
i].data.clusterIndex;
399 nd[
i].data.clusterIndex = nd[nd[
i].data.nearestHigher].data.clusterIndex;
407 std::cout <<
"resizing cluster vector by " << nClustersOnLayer << std::endl;
409 clustersOnLayer.resize(nClustersOnLayer);
413 std::vector<double> rho_b(nClustersOnLayer, 0.);
415 lp.build(nd, bounds);
418 for (
unsigned int i = 0;
i < nd_size; ++
i) {
419 int ci = nd[
i].data.clusterIndex;
420 bool flag_isolated =
true;
423 nd[
i].dims[0] - delta_c, nd[
i].dims[0] + delta_c, nd[
i].dims[1] - delta_c, nd[
i].dims[1] + delta_c);
424 std::vector<Hexel>
found;
425 lp.search(search_box,
found);
427 const unsigned int found_size =
found.size();
428 for (
unsigned int j = 0;
j < found_size;
j++) {
430 if (
found[
j].clusterIndex != -1) {
432 if (dist < delta_c &&
found[
j].clusterIndex != ci) {
434 nd[
i].data.isBorder =
true;
440 if (dist < delta_c && dist != 0. &&
found[
j].clusterIndex == ci) {
444 flag_isolated =
false;
449 nd[
i].data.isBorder =
true;
453 if (nd[
i].
data.isBorder && rho_b[ci] < nd[
i].data.rho)
454 rho_b[ci] = nd[
i].data.rho;
459 for (
unsigned int i = 0;
i < nd_size; ++
i) {
460 int ci = nd[
i].data.clusterIndex;
462 if (nd[
i].
data.rho <= rho_b[ci])
463 nd[
i].data.isHalo =
true;
464 clustersOnLayer[ci].push_back(nd[
i]);
466 std::cout <<
"Pushing hit " <<
i <<
" into cluster with index " << ci << std::endl;
473 std::cout <<
"moving cluster offset by " << nClustersOnLayer << std::endl;
475 return nClustersOnLayer;
References KDTreeLinkerAlgo< DATA, DIM >::build(), KDTreeLinkerAlgo< DATA, DIM >::clear(), gather_cfg::cout, data, HLT_FULL_cff::distance, newFWLiteAna::found, mps_fire::i, dqmiolumiharvest::j, KDTreeLinkerAlgo< DATA, DIM >::search(), and hgcal_clustering::sorted_indices().
◆ findLocalMaximaInCluster()
std::vector< unsigned > HGCalImagingAlgo::findLocalMaximaInCluster |
( |
const std::vector< KDNode > & |
cluster | ) |
|
|
private |
◆ getClusters()
Implements HGCalClusteringAlgoBase.
Definition at line 119 of file HGCalImagingAlgo.cc.
121 std::vector<std::pair<DetId, float>> thisCluster;
123 for (
unsigned int i = 0;
i < clsOnLayer.size(); ++
i) {
134 std::vector<std::vector<double>> fractions;
141 for (
unsigned isub = 0; isub < fractions.size(); ++isub) {
142 double effective_hits = 0.0;
146 for (
unsigned ihit = 0; ihit < fractions[isub].size(); ++ihit) {
147 const double fraction = fractions[isub][ihit];
150 thisCluster.emplace_back(clsOnLayer[
i][ihit].
data.detid,
fraction);
155 std::cout <<
"\t******** NEW CLUSTER (SHARING) ********" << std::endl;
156 std::cout <<
"\tEff. No. of cells = " << effective_hits << std::endl;
160 std::cout <<
"\t*****************************" << std::endl;
171 for (
auto &it : clsOnLayer[
i]) {
172 energy += it.data.isHalo ? 0. : it.data.weight;
174 thisCluster.emplace_back(it.data.detid, (it.data.isHalo ? 0.f : 1.f));
177 std::cout <<
"******** NEW CLUSTER (HGCIA) ********" << std::endl;
179 std::cout <<
"No. of cells = " << clsOnLayer[
i].size() << std::endl;
183 std::cout <<
"*****************************" << std::endl;
References AlignmentPI::calculatePosition(), gather_cfg::cout, data, reco::CaloID::DET_HGCAL_ENDCAP, HLTEgPhaseIITestSequence_cff::doSharing, MillePedeFileConverter_cfg::e, HCALHighEnergyHPDFilter_cfi::energy, HLT_FULL_cff::fraction, mps_fire::i, hgcal_clustering::max_index(), position, and InitialStep_cff::seeds.
◆ getDensity()
Density HGCalImagingAlgo::getDensity |
( |
| ) |
|
|
overridevirtual |
◆ getEventSetupPerAlgorithm()
void HGCalImagingAlgo::getEventSetupPerAlgorithm |
( |
const edm::EventSetup & |
es | ) |
|
|
overridevirtual |
◆ makeClusters()
void HGCalImagingAlgo::makeClusters |
( |
| ) |
|
|
overridevirtual |
◆ populate()
◆ reset()
void HGCalImagingAlgo::reset |
( |
void |
| ) |
|
|
inlineoverridevirtual |
◆ setDensity()
void HGCalImagingAlgo::setDensity |
( |
const std::vector< KDNode > & |
nd | ) |
|
|
private |
◆ shareEnergy()
void HGCalImagingAlgo::shareEnergy |
( |
const std::vector< KDNode > & |
incluster, |
|
|
const std::vector< unsigned > & |
seeds, |
|
|
std::vector< std::vector< double >> & |
outclusters |
|
) |
| |
|
private |
Definition at line 531 of file HGCalImagingAlgo.cc.
534 std::vector<bool> isaseed(incluster.size(),
false);
536 outclusters.resize(
seeds.size());
537 std::vector<Point> centroids(
seeds.size());
538 std::vector<double> energies(
seeds.size());
540 if (
seeds.size() == 1) {
541 outclusters[0].clear();
542 outclusters[0].resize(incluster.size(), 1.0);
549 for (
unsigned i = 0;
i <
seeds.size(); ++
i) {
557 for (
unsigned i = 0;
i <
seeds.size(); ++
i) {
558 outclusters[
i].resize(incluster.size(), 0.0);
559 for (
unsigned j = 0;
j < incluster.size(); ++
j) {
561 outclusters[
i][
j] = 1.0;
563 energies[
i] = incluster[
j].data.weight;
572 const unsigned iterMax = 50;
575 const auto numberOfSeeds =
seeds.size();
576 auto toleranceScaling = numberOfSeeds > 2 ? (numberOfSeeds - 1) * (numberOfSeeds - 1) : 1;
577 std::vector<Point> prevCentroids;
578 std::vector<double>
frac(numberOfSeeds), dist2(numberOfSeeds);
580 for (
unsigned i = 0;
i < incluster.size(); ++
i) {
581 const Hexel &ihit = incluster[
i].data;
583 for (
unsigned j = 0;
j < numberOfSeeds; ++
j) {
585 double d2 = (
std::pow(ihit.x - centroids[
j].x(), 2.0) +
std::pow(ihit.y - centroids[
j].y(), 2.0) +
586 std::pow(ihit.z - centroids[
j].z(), 2.0)) /
592 }
else if (isaseed[
i]) {
602 for (
unsigned j = 0;
j < numberOfSeeds; ++
j) {
604 outclusters[
j][
i] =
frac[
j] / fracTot;
606 outclusters[
j][
i] = 0.0;
614 centroids.resize(numberOfSeeds);
616 for (
unsigned i = 0;
i < numberOfSeeds; ++
i) {
620 const double delta2 = (prevCentroids[
i] - centroids[
i]).
perp2();
References data, change_name::diff, MillePedeFileConverter_cfg::e, JetChargeProducer_cfi::exp, DivergingColor::frac, HLT_FULL_cff::fraction, mps_fire::i, dqmiolumiharvest::j, SiStripPI::max, HLT_FULL_cff::minFracTot, eostools::move(), perp2(), funct::pow(), InitialStep_cff::seeds, mathSSE::sqrt(), HLT_FULL_cff::stoppingTolerance, HGCalImagingAlgo::Hexel::x, HGCalImagingAlgo::Hexel::y, and HGCalImagingAlgo::Hexel::z.
◆ sort_by_delta()
std::vector<size_t> HGCalImagingAlgo::sort_by_delta |
( |
const std::vector< KDNode > & |
v | ) |
const |
|
inlineprivate |
◆ clusters_v_
◆ dEdXweights_
std::vector<double> HGCalImagingAlgo::dEdXweights_ |
|
private |
◆ density_
◆ dependSensor_
bool HGCalImagingAlgo::dependSensor_ |
|
private |
◆ ecut_
double HGCalImagingAlgo::ecut_ |
|
private |
◆ fcPerEle_
double HGCalImagingAlgo::fcPerEle_ |
|
private |
◆ fcPerMip_
std::vector<double> HGCalImagingAlgo::fcPerMip_ |
|
private |
◆ initialized_
bool HGCalImagingAlgo::initialized_ |
|
private |
◆ kappa_
double HGCalImagingAlgo::kappa_ |
|
private |
◆ layerClustersPerLayer_
std::vector<std::vector<std::vector<KDNode> > > HGCalImagingAlgo::layerClustersPerLayer_ |
|
private |
◆ maxpos_
std::vector<std::array<float, 2> > HGCalImagingAlgo::maxpos_ |
|
private |
◆ minpos_
std::vector<std::array<float, 2> > HGCalImagingAlgo::minpos_ |
|
private |
◆ noiseMip_
double HGCalImagingAlgo::noiseMip_ |
|
private |
◆ nonAgedNoises_
std::vector<double> HGCalImagingAlgo::nonAgedNoises_ |
|
private |
◆ points_
std::vector<std::vector<KDNode> > HGCalImagingAlgo::points_ |
|
private |
◆ positionDeltaRho_c_
std::vector<double> HGCalImagingAlgo::positionDeltaRho_c_ |
|
private |
◆ sigma2_
double HGCalImagingAlgo::sigma2_ |
|
private |
◆ sigmaNoise_
std::vector<std::vector<double> > HGCalImagingAlgo::sigmaNoise_ |
|
private |
◆ thicknessCorrection_
std::vector<double> HGCalImagingAlgo::thicknessCorrection_ |
|
private |
◆ thresholds_
std::vector<std::vector<double> > HGCalImagingAlgo::thresholds_ |
|
private |
◆ thresholdW0_
std::vector<double> HGCalImagingAlgo::thresholdW0_ |
|
private |
◆ vecDeltas_
std::vector<double> HGCalImagingAlgo::vecDeltas_ |
|
private |
std::vector< std::vector< double > > thresholds_
double calculateEnergyWithFraction(const std::vector< KDNode > &, const std::vector< double > &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< size_t > sorted_indices(const std::vector< T > &v)
std::vector< double > fcPerMip_
constexpr float energy() const
VerbosityLevel verbosity_
std::vector< std::array< float, 2 > > minpos_
T getUntrackedParameter(std::string const &, T const &) const
std::vector< unsigned > findLocalMaximaInCluster(const std::vector< KDNode > &)
constexpr const DetId & detid() const
std::vector< double > thicknessCorrection_
std::vector< double > positionDeltaRho_c_
unsigned int lastLayerEE_
std::vector< reco::BasicCluster > clusters_v_
unsigned int firstLayerBH_
double distance2(const Hexel &pt1, const Hexel &pt2) const
HGCalClusteringAlgoBase(VerbosityLevel v, reco::CaloCluster::AlgoId algo)
math::XYZPoint calculatePositionWithFraction(const std::vector< KDNode > &, const std::vector< double > &)
std::vector< std::vector< double > > sigmaNoise_
std::vector< std::array< float, 2 > > maxpos_
std::vector< double > thresholdW0_
double distance(const Hexel &pt1, const Hexel &pt2) const
reco::CaloCluster::AlgoId algoId_
std::vector< size_t > sort_by_delta(const std::vector< KDNode > &v) const
int findAndAssignClusters(std::vector< KDNode > &, KDTree &, double, KDTreeBox< 2 > &, const unsigned int, std::vector< std::vector< KDNode >> &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Structure Point Contains parameters of Gaussian fits to DMRs.
std::vector< std::vector< KDNode > > points_
XYZPointD XYZPoint
point in space with cartesian internal representation
hgcal::RecHitTools rhtools_
std::vector< double > vecDeltas_
std::vector< double > dEdXweights_
double calculateDistanceToHigher(std::vector< KDNode > &) const
static int position[264][3]
void setDensity(const std::vector< KDNode > &nd)
T perp2() const
Squared magnitude of transverse component.
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
double calculateLocalDensity(std::vector< KDNode > &, KDTree &, const unsigned int) const
std::vector< std::vector< std::vector< KDNode > > > layerClustersPerLayer_
size_t max_index(const std::vector< T > &v)
void shareEnergy(const std::vector< KDNode > &, const std::vector< unsigned > &, std::vector< std::vector< double >> &)
T getParameter(std::string const &) const
char data[epos_bytes_allocation]
std::vector< double > nonAgedNoises_
Power< A, B >::type pow(const A &a, const B &b)
math::XYZPoint calculatePosition(std::vector< KDNode > &) const
KDTreeLinkerAlgo< Hexel > KDTree