CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Static Public Attributes | Protected Attributes | Private Types | Private Member Functions
VoronoiAlgorithm Class Reference

#include <VoronoiAlgorithm.h>

Classes

class  particle_t
 

Public Member Functions

void clear (void)
 
size_t nedge_pseudorapidity (void) const
 
std::vector< double > particle_area (void)
 
std::vector< std::set< size_t > > particle_incident (void)
 
std::vector< double > perp_fourier (void)
 
void push_back_particle (const double perp, const double pseudorapidity, const double azimuth, const unsigned int reduced_particle_flow_id)
 
std::vector< double > subtracted_equalized_perp (void)
 
std::vector< double > subtracted_unequalized_perp (void)
 
 VoronoiAlgorithm (const UECalibration *ue, const double dr_max, const std::pair< double, double > equalization_threshold=std::pair< double, double >(5.0, 35.0), const bool remove_nonpositive=true)
 
 ~VoronoiAlgorithm (void)
 

Static Public Attributes

static const size_t nfourier = 5
 
static const size_t nreduced_particle_flow_id = 3
 

Protected Attributes

std::vector< bool > _active
 
std::vector< double > _cms_ecal_edge_pseudorapidity
 
std::vector< double > _cms_hcal_edge_pseudorapidity
 
std::vector< double > _edge_pseudorapidity
 
std::pair< double, double > _equalization_threshold
 
event_t _event
 
std::vector< double > _feature
 
void * _lp_environment
 
void * _lp_problem
 
std::vector< size_t > _nblock_subtract
 
size_t _ncost
 
boost::multi_array< double, 4 > * _perp_fourier
 
double _positive_bound_scale
 
double _radial_distance_square_max
 
std::vector< std::pair< size_t,
size_t > > 
_recombine
 
std::vector< std::vector
< size_t > > 
_recombine_index
 
std::vector< double > _recombine_tie
 
std::vector< std::vector
< size_t > > 
_recombine_unsigned
 
bool _remove_nonpositive
 
bool _subtracted
 
const UECalibrationue
 

Private Types

typedef
CGAL::Delaunay_triangulation_2
< CGAL::Exact_predicates_inexact_constructions_kernel > 
delaunay_triangulation_t
 
typedef std::vector< particle_tevent_t
 
typedef
delaunay_triangulation_t::Point 
point_2d_t
 
typedef CGAL::Polygon_2
< CGAL::Exact_predicates_inexact_constructions_kernel > 
polygon_t
 
typedef
CGAL::Voronoi_diagram_2
< delaunay_triangulation_t,
CGAL::Delaunay_triangulation_adaptation_traits_2
< delaunay_triangulation_t >
, CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2
< delaunay_triangulation_t > > 
voronoi_diagram_t
 

Private Member Functions

void allocate (void)
 
void deallocate (void)
 
void equalize (void)
 
void event_fourier (void)
 
void feature_extract (void)
 
void initialize_geometry (void)
 
void lp_populate (void *lp_problem)
 
void recombine_link (void)
 
void remove_nonpositive (void)
 
void subtract_if_necessary (void)
 
void subtract_momentum (void)
 
void voronoi_area_incident (void)
 

Detailed Description

Definition at line 18 of file VoronoiAlgorithm.h.

Member Typedef Documentation

typedef CGAL::Delaunay_triangulation_2< CGAL::Exact_predicates_inexact_constructions_kernel> VoronoiAlgorithm::delaunay_triangulation_t
private

Definition at line 23 of file VoronoiAlgorithm.h.

typedef std::vector<particle_t> VoronoiAlgorithm::event_t
private

Definition at line 48 of file VoronoiAlgorithm.h.

Definition at line 24 of file VoronoiAlgorithm.h.

typedef CGAL::Polygon_2< CGAL::Exact_predicates_inexact_constructions_kernel> VoronoiAlgorithm::polygon_t
private

Definition at line 59 of file VoronoiAlgorithm.h.

typedef CGAL::Voronoi_diagram_2< delaunay_triangulation_t, CGAL::Delaunay_triangulation_adaptation_traits_2< delaunay_triangulation_t>, CGAL:: Delaunay_triangulation_caching_degeneracy_removal_policy_2< delaunay_triangulation_t> > VoronoiAlgorithm::voronoi_diagram_t
private

Definition at line 56 of file VoronoiAlgorithm.h.

Constructor & Destructor Documentation

VoronoiAlgorithm::VoronoiAlgorithm ( const UECalibration ue,
const double  dr_max,
const std::pair< double, double >  equalization_threshold = std::pair<double, double>(5.0, 35.0),
const bool  remove_nonpositive = true 
)

Definition at line 1842 of file VoronoiAlgorithm.cc.

References _edge_pseudorapidity, allocate(), initialize_geometry(), and nedge_pseudorapidity().

1848  _equalization_threshold(equalization_threshold),
1849  _radial_distance_square_max(dr_max * dr_max),
1850  _positive_bound_scale(0.2),
1851  _subtracted(false),
1852  ue(ue_)
1853  {
1855 
1856  static const size_t nedge_pseudorapidity = 15 + 1;
1857  static const double edge_pseudorapidity[nedge_pseudorapidity] = {
1858  -5.191, -2.650, -2.043, -1.740, -1.479, -1.131, -0.783, -0.522, 0.522, 0.783, 1.131, 1.479, 1.740, 2.043, 2.650, 5.191
1859  };
1860 
1861  _edge_pseudorapidity = std::vector<double>(
1862  edge_pseudorapidity,
1863  edge_pseudorapidity + nedge_pseudorapidity);
1864  allocate();
1865  }
double _positive_bound_scale
void remove_nonpositive(void)
std::vector< double > _edge_pseudorapidity
void initialize_geometry(void)
const UECalibration * ue
double _radial_distance_square_max
std::pair< double, double > _equalization_threshold
size_t nedge_pseudorapidity(void) const
VoronoiAlgorithm::~VoronoiAlgorithm ( void  )

Definition at line 1867 of file VoronoiAlgorithm.cc.

References deallocate().

1868  {
1869  deallocate();
1870  }

Member Function Documentation

void VoronoiAlgorithm::allocate ( void  )
private

Definition at line 942 of file VoronoiAlgorithm.cc.

References _edge_pseudorapidity, _perp_fourier, nfourier, and nreduced_particle_flow_id.

Referenced by VoronoiAlgorithm().

943  {
944  _perp_fourier = new boost::multi_array<double, 4>(
945  boost::extents[_edge_pseudorapidity.size() - 1]
947  }
std::vector< double > _edge_pseudorapidity
static const size_t nreduced_particle_flow_id
static const size_t nfourier
boost::multi_array< double, 4 > * _perp_fourier
void VoronoiAlgorithm::clear ( void  )

Clears the list of unsubtracted particles

Definition at line 1894 of file VoronoiAlgorithm.cc.

References _event, and _subtracted.

Referenced by VoronoiBackgroundProducer::produce().

1895  {
1896  _event.clear();
1897  _subtracted = false;
1898  }
void VoronoiAlgorithm::deallocate ( void  )
private

Definition at line 948 of file VoronoiAlgorithm.cc.

References _perp_fourier.

Referenced by ~VoronoiAlgorithm().

949  {
950  delete _perp_fourier;
951  }
boost::multi_array< double, 4 > * _perp_fourier
void VoronoiAlgorithm::equalize ( void  )
private

Definition at line 1783 of file VoronoiAlgorithm.cc.

References _event, _lp_environment, _nblock_subtract, _ncost, _recombine, plotBeamSpotDB::first, relval_2017::k, lp_populate(), pi, recombine_link(), edm::second(), and x.

Referenced by subtract_if_necessary().

1784  {
1785  bpmpd_problem_t lp_problem = reinterpret_cast<bpmpd_environment_t *>(_lp_environment)->problem();
1786 
1787  recombine_link();
1788  lp_populate(&lp_problem);
1789  lp_problem.optimize();
1790 
1791  int solution_status;
1792  double objective_value;
1793  std::vector<double> x;
1794  std::vector<double> pi;
1795 
1796  lp_problem.solve(solution_status, objective_value,
1797  x, pi);
1798 
1799  for (size_t k = _ncost; k < x.size(); k++) {
1800  if (_event[_recombine[k - _ncost].first].
1801  momentum_perp_subtracted < 0 &&
1803  momentum_perp_subtracted >= 0 && x[k] >= 0) {
1804  _event[_recombine[k - _ncost].first].
1805  momentum_perp_subtracted += x[k];
1806  _event[_recombine[k - _ncost].second].
1807  momentum_perp_subtracted -= x[k];
1808  }
1809  }
1810  for (size_t k = 0; k < _event.size(); k++) {
1811  if (_nblock_subtract[k] != 0 &&
1812  x[_nblock_subtract[k]] >= 0) {
1813  _event[k].momentum_perp_subtracted -=
1814  x[_nblock_subtract[k]];
1815  }
1816  }
1817  }
const Double_t pi
U second(std::pair< T, U > const &p)
void lp_populate(void *lp_problem)
std::vector< std::pair< size_t, size_t > > _recombine
std::vector< size_t > _nblock_subtract
void VoronoiAlgorithm::event_fourier ( void  )
private

Definition at line 952 of file VoronoiAlgorithm.cc.

References _edge_pseudorapidity, _event, _perp_fourier, funct::cos(), lumiContext::fill, relval_2017::k, cmsLHEtoEOSManager::l, nfourier, and funct::sin().

Referenced by subtract_if_necessary().

953  {
954  std::fill(_perp_fourier->data(),
955  _perp_fourier->data() +
956  _perp_fourier->num_elements(),
957  0);
958 
959  for (std::vector<particle_t>::const_iterator iterator =
960  _event.begin();
961  iterator != _event.end(); iterator++) {
962  const unsigned int reduced_id =
963  iterator->reduced_particle_flow_id;
964 
965  for (size_t k = 1; k < _edge_pseudorapidity.size();
966  k++) {
967  if (iterator->momentum.Eta() >=
968  _edge_pseudorapidity[k - 1] &&
969  iterator->momentum.Eta() <
971  const double azimuth =
972  iterator->momentum.Phi();
973 
974  for (size_t l = 0; l < nfourier; l++) {
975  (*_perp_fourier)[k - 1][reduced_id]
976  [l][0] +=
977  iterator->momentum.Pt() *
978  cos(l * azimuth);
979  (*_perp_fourier)[k - 1][reduced_id]
980  [l][1] +=
981  iterator->momentum.Pt() *
982  sin(l * azimuth);
983  }
984  }
985  }
986  }
987  }
string fill
Definition: lumiContext.py:319
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< double > _edge_pseudorapidity
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static const size_t nfourier
boost::multi_array< double, 4 > * _perp_fourier
void VoronoiAlgorithm::feature_extract ( void  )
private

Definition at line 988 of file VoronoiAlgorithm.cc.

References _edge_pseudorapidity, _feature, j, relval_2017::k, nfourier, nreduced_particle_flow_id, pileupReCalc_HLTpaths::scale, and mathSSE::sqrt().

Referenced by subtract_if_necessary().

989  {
990  const size_t nfeature = 2 * nfourier - 1;
991 
992  _feature.resize(nfeature);
993 
994  // Scale factor to get 95% of the coefficient below 1.0
995  // (where however one order of magnitude tolerance is
996  // acceptable). This is valid for nfourier < 18 (where
997  // interference behavior with the HF geometry starts to
998  // appear)
999 
1000  std::vector<double> scale(nfourier, 1.0 / 200.0);
1001 
1002  if (nfourier >= 1) {
1003  scale[0] = 1.0 / 5400.0;
1004  }
1005  if (nfourier >= 2) {
1006  scale[1] = 1.0 / 130.0;
1007  }
1008  if (nfourier >= 3) {
1009  scale[2] = 1.0 / 220.0;
1010  }
1011 
1012  const size_t index_edge_end =
1013  _edge_pseudorapidity.size() - 2;
1014 
1015  _feature[0] = 0;
1016  for (size_t j = 0; j < nreduced_particle_flow_id; j++) {
1017  _feature[0] += scale[0] *
1018  ((*_perp_fourier)[0 ][j][0][0] +
1019  (*_perp_fourier)[index_edge_end][j][0][0]);
1020  }
1021 
1022  for (size_t k = 1; k < nfourier; k++) {
1023  _feature[2 * k - 1] = 0;
1024  for (size_t j = 0; j < nreduced_particle_flow_id; j++) {
1025  _feature[2 * k - 1] += scale[k] *
1026  ((*_perp_fourier)[0 ][j][k][0] +
1027  (*_perp_fourier)[index_edge_end][j][k][0]);
1028  }
1029  _feature[2 * k] = 0;
1030  for (size_t j = 0; j < nreduced_particle_flow_id; j++) {
1031  _feature[2 * k] += scale[k] *
1032  ((*_perp_fourier)[0 ][j][k][1] +
1033  (*_perp_fourier)[index_edge_end][j][k][1]);
1034  }
1035  }
1036 
1037 
1038 #if 0
1039  const double event_plane = atan2(_feature[4], _feature[3]);
1040  const double v2 =
1041  sqrt(_feature[3] * _feature[3] +
1042  _feature[4] * _feature[4]) / _feature[0];
1043 #endif
1044  }
std::vector< double > _edge_pseudorapidity
T sqrt(T t)
Definition: SSEVec.h:18
static const size_t nreduced_particle_flow_id
static const size_t nfourier
int j
Definition: DBlmapReader.cc:9
std::vector< double > _feature
void VoronoiAlgorithm::initialize_geometry ( void  )
private

Definition at line 908 of file VoronoiAlgorithm.cc.

References _cms_ecal_edge_pseudorapidity, _cms_hcal_edge_pseudorapidity, and i.

Referenced by VoronoiAlgorithm().

909  {
910  static const size_t ncms_hcal_edge_pseudorapidity = 82 + 1;
911  static const double cms_hcal_edge_pseudorapidity[
912  ncms_hcal_edge_pseudorapidity] = {
913  -5.191, -4.889, -4.716, -4.538, -4.363, -4.191, -4.013,
914  -3.839, -3.664, -3.489, -3.314, -3.139, -2.964, -2.853,
915  -2.650, -2.500, -2.322, -2.172, -2.043, -1.930, -1.830,
916  -1.740, -1.653, -1.566, -1.479, -1.392, -1.305, -1.218,
917  -1.131, -1.044, -0.957, -0.879, -0.783, -0.696, -0.609,
918  -0.522, -0.435, -0.348, -0.261, -0.174, -0.087,
919  0.000,
920  0.087, 0.174, 0.261, 0.348, 0.435, 0.522, 0.609,
921  0.696, 0.783, 0.879, 0.957, 1.044, 1.131, 1.218,
922  1.305, 1.392, 1.479, 1.566, 1.653, 1.740, 1.830,
923  1.930, 2.043, 2.172, 2.322, 2.500, 2.650, 2.853,
924  2.964, 3.139, 3.314, 3.489, 3.664, 3.839, 4.013,
925  4.191, 4.363, 4.538, 4.716, 4.889, 5.191
926  };
927 
928  _cms_hcal_edge_pseudorapidity = std::vector<double>(
929  cms_hcal_edge_pseudorapidity,
930  cms_hcal_edge_pseudorapidity +
931  ncms_hcal_edge_pseudorapidity);
932 
933  static const size_t ncms_ecal_edge_pseudorapidity = 344 + 1;
934 
935  for (size_t i = 0; i < ncms_ecal_edge_pseudorapidity; i++) {
937  i * (2 * 2.9928 /
938  (ncms_ecal_edge_pseudorapidity - 1)) -
939  2.9928);
940  }
941  }
int i
Definition: DBlmapReader.cc:9
std::vector< double > _cms_ecal_edge_pseudorapidity
std::vector< double > _cms_hcal_edge_pseudorapidity
void VoronoiAlgorithm::lp_populate ( void *  lp_problem)
private

Definition at line 1414 of file VoronoiAlgorithm.cc.

References _active, _equalization_threshold, _event, _nblock_subtract, _ncost, _positive_bound_scale, _recombine_index, _recombine_tie, _recombine_unsigned, alignCSCRings::e, cond::serialization::equal(), i, infinity, M_PI, bookConverter::max, min(), nedge_pseudorapidity(), AlCaHLTBitMon_ParallelJobs::p, jetcorrextractor::sign(), and puppiForMET_cff::weight.

Referenced by equalize().

1415  {
1416  bpmpd_problem_t *p = reinterpret_cast<bpmpd_problem_t *>(lp_problem);
1417 
1418  // The minimax problem is transformed into the LP notation
1419  // using the cost variable trick:
1420  //
1421  // Minimize c
1422  // Subject to:
1423  // c + sum_l t_kl + n_k >= 0 for negative cells n_k
1424  // c - sum_k t_kl + p_l >= 0 for positive cells p_l
1425 
1426  // Common LP mistakes during code development and their
1427  // CPLEX errors when running CPLEX in data checking mode:
1428  //
1429  // Error 1201 (column index ... out of range): Bad column
1430  // indexing, usually index_column out of bound for the
1431  // cost variables.
1432  //
1433  // Error 1222 (duplicate entry): Forgetting to increment
1434  // index_row, or index_column out of bound for the cost
1435  // variables.
1436 
1437  p->set_objective_sense(bpmpd_problem_t::minimize);
1438 
1439  // Rows (RHS of the constraints) of the LP problem
1440 
1441  static const size_t nsector_azimuth = 12;
1442 
1443  // Approximatively 2 pi / nsector_azimuth segmentation of
1444  // the CMS HCAL granularity
1445 
1446  static const size_t ncms_hcal_edge_pseudorapidity = 19 + 1;
1447  static const double cms_hcal_edge_pseudorapidity[
1448  ncms_hcal_edge_pseudorapidity] = {
1449  -5.191, -4.538, -4.013,
1450  -3.489, -2.853, -2.322, -1.830, -1.305, -0.783, -0.261,
1451  0.261, 0.783, 1.305, 1.830, 2.322, 2.853, 3.489,
1452  4.013, 4.538, 5.191
1453  };
1454 
1455  size_t nedge_pseudorapidity;
1456  const double *edge_pseudorapidity;
1457 
1458  nedge_pseudorapidity = ncms_hcal_edge_pseudorapidity;
1459  edge_pseudorapidity = cms_hcal_edge_pseudorapidity;
1460 
1461  const size_t nsuperblock = (nedge_pseudorapidity - 2) *
1462  nsector_azimuth;
1463 
1464  size_t index_row = 0;
1465  for (size_t index_pseudorapidity = 0;
1466  index_pseudorapidity < nedge_pseudorapidity - 2;
1467  index_pseudorapidity++) {
1468  for (size_t index_azimuth = 0;
1469  index_azimuth < nsector_azimuth - 1;
1470  index_azimuth++) {
1471  const size_t index_column =
1472  index_pseudorapidity * nsector_azimuth +
1473  index_azimuth;
1474  p->push_back_row(
1475  bpmpd_problem_t::greater_equal, 0);
1476  p->push_back_coefficient(
1477  index_row, index_column, 1);
1478  p->push_back_coefficient(
1479  index_row, nsuperblock + index_column, -1);
1480  index_row++;
1481  p->push_back_row(
1482  bpmpd_problem_t::greater_equal, 0);
1483  p->push_back_coefficient(
1484  index_row, index_column, 1);
1485  p->push_back_coefficient(
1486  index_row, nsuperblock + index_column + 1, -1);
1487  index_row++;
1488  p->push_back_row(
1489  bpmpd_problem_t::greater_equal, 0);
1490  p->push_back_coefficient(
1491  index_row, index_column, 1);
1492  p->push_back_coefficient(
1493  index_row,
1494  nsuperblock + index_column + nsector_azimuth, -1);
1495  index_row++;
1496  p->push_back_row(
1497  bpmpd_problem_t::greater_equal, 0);
1498  p->push_back_coefficient(
1499  index_row, index_column, 1);
1500  p->push_back_coefficient(
1501  index_row,
1502  nsuperblock + index_column + nsector_azimuth + 1,
1503  -1);
1504  index_row++;
1505  }
1506  const size_t index_column =
1507  index_pseudorapidity * nsector_azimuth +
1508  nsector_azimuth - 1;
1509  p->push_back_row(
1510  bpmpd_problem_t::greater_equal, 0);
1511  p->push_back_coefficient(
1512  index_row, index_column, 1);
1513  p->push_back_coefficient(
1514  index_row, nsuperblock + index_column, -1);
1515  index_row++;
1516  p->push_back_row(
1517  bpmpd_problem_t::greater_equal, 0);
1518  p->push_back_coefficient(
1519  index_row, index_column, 1);
1520  p->push_back_coefficient(
1521  index_row,
1522  nsuperblock + index_column - (nsector_azimuth - 1),
1523  -1);
1524  index_row++;
1525  p->push_back_row(
1526  bpmpd_problem_t::greater_equal, 0);
1527  p->push_back_coefficient(
1528  index_row, index_column, 1);
1529  p->push_back_coefficient(
1530  index_row,
1531  nsuperblock + index_column + nsector_azimuth, -1);
1532  index_row++;
1533  p->push_back_row(
1534  bpmpd_problem_t::greater_equal, 0);
1535  p->push_back_coefficient(
1536  index_row, index_column, 1);
1537  p->push_back_coefficient(
1538  index_row,
1539  nsuperblock + index_column + nsector_azimuth -
1540  (nsector_azimuth - 1),
1541  -1);
1542  index_row++;
1543  }
1544 
1545  const size_t nstaggered_block =
1546  (nedge_pseudorapidity - 1) * nsector_azimuth;
1547  const size_t nblock = nsuperblock + 2 * nstaggered_block;
1548 
1549  _nblock_subtract = std::vector<size_t>(_event.size(), 0);
1550 
1551  std::vector<size_t>
1552  positive_index(_event.size(), _event.size());
1553  size_t positive_count = 0;
1554 
1555  for (std::vector<particle_t>::const_iterator iterator =
1556  _event.begin();
1557  iterator != _event.end(); iterator++) {
1558  if (iterator->momentum_perp_subtracted >= 0) {
1559  positive_index[iterator - _event.begin()] =
1560  positive_count;
1561  positive_count++;
1562  }
1563  }
1564 
1565  _ncost = nblock + positive_count;
1566 
1567  const double sum_unequalized_0 = _equalization_threshold.first;
1568  const double sum_unequalized_1 = (2.0 / 3.0) * _equalization_threshold.first + (1.0 / 3.0) * _equalization_threshold.second;
1569  const double sum_unequalized_2 = (1.0 / 3.0) * _equalization_threshold.first + (2.0 / 3.0) * _equalization_threshold.second;
1570  const double sum_unequalized_3 = _equalization_threshold.second;
1571 
1572  std::vector<particle_t>::const_iterator
1573  iterator_particle = _event.begin();
1574  std::vector<bool>::const_iterator iterator_active =
1575  _active.begin();
1576  std::vector<std::vector<size_t> >::const_iterator
1577  iterator_recombine_index_outer =
1578  _recombine_index.begin();
1579  std::vector<std::vector<size_t> >::const_iterator
1580  iterator_recombine_unsigned_outer =
1581  _recombine_unsigned.begin();
1582  size_t index_column_max = _ncost - 1;
1583  for (; iterator_particle != _event.end();
1584  iterator_particle++, iterator_active++,
1585  iterator_recombine_index_outer++,
1586  iterator_recombine_unsigned_outer++) {
1587  if (*iterator_active) {
1588  int index_pseudorapidity = -1;
1589 
1591  for (size_t i = 1; i < nedge_pseudorapidity; i++) {
1592  if (iterator_particle->momentum.Eta() >= edge_pseudorapidity[i - 1] &&
1593  iterator_particle->momentum.Eta() < edge_pseudorapidity[i]) {
1594  index_pseudorapidity = i - 1;
1595  }
1596  }
1597 
1598  const int index_azimuth = floor(
1599  (iterator_particle->momentum.Phi() + M_PI) *
1600  ((nsector_azimuth >> 1) / M_PI));
1601 
1602  if (index_pseudorapidity != -1) {
1603  // p_i - sum t - u = c_i
1604  // or: c_i + u + sum_t = p_i
1605  // n_i + sum t - u <= 0
1606  // or: u - sum_t >= n_i
1607 
1608  // Inequality RHS
1609  p->push_back_row(
1610  iterator_particle->momentum_perp_subtracted >= 0 ?
1612  bpmpd_problem_t::greater_equal,
1613  iterator_particle->momentum_perp_subtracted);
1614 
1615  // Energy transfer coefficients t_kl
1616  const double sign = iterator_particle->momentum_perp_subtracted >= 0 ? 1 : -1;
1617  const size_t index_column_block_subtract =
1618  nsuperblock +
1619  (nedge_pseudorapidity - 1) * nsector_azimuth +
1620  index_pseudorapidity * nsector_azimuth +
1621  index_azimuth;
1622 
1623  _nblock_subtract[iterator_particle - _event.begin()] =
1624  index_column_block_subtract;
1625 
1626  if (iterator_particle->momentum_perp_subtracted >= 0) {
1627  const size_t index_column_cost =
1628  nblock + positive_index[iterator_particle - _event.begin()];
1629 
1630  p->push_back_coefficient(
1631  index_row, index_column_cost, 1);
1632  index_column_max =
1633  std::max(index_column_max, index_column_cost);
1634  }
1635  p->push_back_coefficient(
1636  index_row, index_column_block_subtract, 1);
1637  index_column_max =
1638  std::max(index_column_max, index_column_block_subtract);
1639 
1640  for (std::vector<size_t>::const_iterator
1641  iterator_recombine_index_inner =
1642  iterator_recombine_index_outer->begin();
1643  iterator_recombine_index_inner !=
1644  iterator_recombine_index_outer->end();
1645  iterator_recombine_index_inner++) {
1646  const size_t index_column =
1647  *iterator_recombine_index_inner +
1648  _ncost;
1649 
1650  p->push_back_coefficient(
1651  index_row, index_column, sign);
1652  index_column_max =
1653  std::max(index_column_max, index_column);
1654  }
1655  index_row++;
1656 
1657  const size_t index_column_block =
1658  nsuperblock +
1659  index_pseudorapidity * nsector_azimuth +
1660  index_azimuth;
1661 
1662  // sum_R c_i - o_i >= -d
1663  // or: d + sum_R c_i >= o_i
1664  // sum_R c_i - o_i <= d
1665  // or: d - sum_R c_i >= -o_i
1666 
1667  double sum_unequalized;
1668 
1669  sum_unequalized = 0;
1670  for (std::vector<size_t>::const_iterator
1671  iterator_recombine_unsigned_inner =
1672  iterator_recombine_unsigned_outer->begin();
1673  iterator_recombine_unsigned_inner !=
1674  iterator_recombine_unsigned_outer->end();
1675  iterator_recombine_unsigned_inner++) {
1676  sum_unequalized +=
1677  _event[*iterator_recombine_unsigned_inner].momentum_perp_subtracted;
1678  }
1679  sum_unequalized = std::max(0.0, sum_unequalized);
1680 
1681  if (sum_unequalized >= sum_unequalized_3 ||
1682  (sum_unequalized >= sum_unequalized_2 &&
1683  (iterator_particle - _event.begin()) % 2 == 0) ||
1684  (sum_unequalized >= sum_unequalized_1 &&
1685  (iterator_particle - _event.begin()) % 4 == 0) ||
1686  (sum_unequalized >= sum_unequalized_0 &&
1687  (iterator_particle - _event.begin()) % 8 == 0)) {
1688 
1689  const double weight = sum_unequalized *
1690  std::min(1.0, std::max(1e-3,
1691  iterator_particle->area));
1692 
1693  if (weight > 0) {
1694  p->push_back_row(
1695  bpmpd_problem_t::greater_equal,
1696  sum_unequalized);
1697 
1698  p->push_back_coefficient(
1699  index_row, index_column_block, 1.0 / weight);
1700 
1701  for (std::vector<size_t>::const_iterator
1702  iterator_recombine_unsigned_inner =
1703  iterator_recombine_unsigned_outer->begin();
1704  iterator_recombine_unsigned_inner !=
1705  iterator_recombine_unsigned_outer->end();
1706  iterator_recombine_unsigned_inner++) {
1707  if (_event[*iterator_recombine_unsigned_inner].momentum_perp_subtracted >= 0) {
1708  const size_t index_column_cost =
1709  nblock +
1710  positive_index[*iterator_recombine_unsigned_inner];
1711 
1712  p->push_back_coefficient(
1713  index_row, index_column_cost, 1);
1714  index_column_max =
1715  std::max(index_column_max, index_column_cost);
1716  }
1717  }
1718  index_row++;
1719 
1720  p->push_back_row(
1721  bpmpd_problem_t::greater_equal,
1722  -sum_unequalized);
1723 
1724  p->push_back_coefficient(
1725  index_row, index_column_block, _positive_bound_scale / weight);
1726 
1727  for (std::vector<size_t>::const_iterator iterator_recombine_unsigned_inner = iterator_recombine_unsigned_outer->begin();
1728  iterator_recombine_unsigned_inner != iterator_recombine_unsigned_outer->end();
1729  iterator_recombine_unsigned_inner++) {
1730  if (_event[*iterator_recombine_unsigned_inner].momentum_perp_subtracted >= 0) {
1731  const size_t index_column_cost =
1732  nblock +
1733  positive_index[*iterator_recombine_unsigned_inner];
1734 
1735  p->push_back_coefficient(
1736  index_row, index_column_cost, -1);
1737  index_column_max =
1738  std::max(index_column_max, index_column_cost);
1739  }
1740  }
1741  index_row++;
1742  }
1743 
1744  }
1745 
1746  }
1747  }
1748  }
1749 
1750  // Epsilon that breaks the degeneracy, in the same units
1751  // as the pT of the event (i.e. GeV)
1752  static const double epsilon_degeneracy = 1e-2;
1753 
1754  // Columns (variables and the objective coefficients) of
1755  // the LP problem
1756  //
1757  // Cost variables (objective coefficient 1)
1758  for (size_t i = 0; i < nsuperblock; i++) {
1759  p->push_back_column(
1761  }
1762  for (size_t i = nsuperblock; i < nsuperblock + nstaggered_block; i++) {
1763  p->push_back_column(
1765  }
1766  for (size_t i = nsuperblock + nstaggered_block; i < nsuperblock + 2 * nstaggered_block; i++) {
1767  p->push_back_column(
1769  }
1770  for (size_t i = nsuperblock + 2 * nstaggered_block; i < _ncost; i++) {
1771  p->push_back_column(
1773  }
1774  //fprintf(stderr, "%s:%d: %lu %lu\n", __FILE__, __LINE__, index_column_max, recombine_tie.size());
1775  // Energy transfer coefficients t_kl (objective
1776  // coefficient 0 + epsilon)
1777  for (size_t i = _ncost; i <= index_column_max; i++) {
1778  p->push_back_column(
1779  epsilon_degeneracy * _recombine_tie[i - _ncost],
1781  }
1782  }
std::vector< bool > _active
std::vector< std::vector< size_t > > _recombine_index
int i
Definition: DBlmapReader.cc:9
double sign(double x)
double _positive_bound_scale
std::vector< double > _recombine_tie
bool equal(const T &first, const T &second)
Definition: Equal.h:34
const double infinity
std::vector< size_t > _nblock_subtract
T min(T a, T b)
Definition: MathUtil.h:58
#define M_PI
std::vector< std::vector< size_t > > _recombine_unsigned
std::pair< double, double > _equalization_threshold
size_t nedge_pseudorapidity(void) const
size_t VoronoiAlgorithm::nedge_pseudorapidity ( void  ) const

Definition at line 1992 of file VoronoiAlgorithm.cc.

References _edge_pseudorapidity.

Referenced by lp_populate(), and VoronoiAlgorithm().

1993  {
1994  return _edge_pseudorapidity.size();
1995  }
std::vector< double > _edge_pseudorapidity
std::vector< double > VoronoiAlgorithm::particle_area ( void  )

Returns the area in the Voronoi diagram diagram occupied by a given particle

Returns
vector of area

Definition at line 1938 of file VoronoiAlgorithm.cc.

References _event, runTheMatrix::ret, and subtract_if_necessary().

Referenced by VoronoiBackgroundProducer::produce().

1939  {
1941 
1942  std::vector<double> ret;
1943 
1944  for (std::vector<particle_t>::const_iterator iterator =
1945  _event.begin();
1946  iterator != _event.end(); iterator++) {
1947  ret.push_back(iterator->area);
1948  }
1949 
1950  return ret;
1951  }
tuple ret
prodAgent to be discontinued
void subtract_if_necessary(void)
std::vector< std::set< size_t > > VoronoiAlgorithm::particle_incident ( void  )

Returns the incident particles in the Delaunay diagram (particles that has a given particle as the nearest neighbor)

Returns
vector of sets of incident particles indices, using the original indexing

Definition at line 1960 of file VoronoiAlgorithm.cc.

References _event, alignCSCRings::e, runTheMatrix::ret, and subtract_if_necessary().

1961  {
1963 
1964  std::vector<std::set<size_t> > ret;
1965 
1966  for (std::vector<particle_t>::const_iterator
1967  iterator_outer = _event.begin();
1968  iterator_outer != _event.end(); iterator_outer++) {
1969  std::set<size_t> e;
1970 
1971  for (std::set<std::vector<particle_t>::iterator>::
1972  const_iterator iterator_inner =
1973  iterator_outer->incident.begin();
1974  iterator_inner != iterator_outer->incident.begin();
1975  iterator_inner++) {
1976  e.insert(*iterator_inner - _event.begin());
1977  }
1978  ret.push_back(e);
1979  }
1980 
1981  return ret;
1982  }
tuple ret
prodAgent to be discontinued
void subtract_if_necessary(void)
std::vector< double > VoronoiAlgorithm::perp_fourier ( void  )

Definition at line 1983 of file VoronoiAlgorithm.cc.

References _perp_fourier, and subtract_if_necessary().

Referenced by VoronoiBackgroundProducer::produce().

1984  {
1986 
1987  return std::vector<double>(
1988  _perp_fourier->data(),
1989  _perp_fourier->data() +
1990  _perp_fourier->num_elements());
1991  }
void subtract_if_necessary(void)
boost::multi_array< double, 4 > * _perp_fourier
void VoronoiAlgorithm::push_back_particle ( const double  perp,
const double  pseudorapidity,
const double  azimuth,
const unsigned int  reduced_particle_flow_id 
)

Add a new unsubtracted particle to the current event

Parameters
[in]perptransverse momentum
[in]pseudorapiditypseudorapidity
[in]azimuthazimuth
[in]reduced_particle_flow_idreduced particle flow ID, between 0 and 2 (inclusive)

Definition at line 1881 of file VoronoiAlgorithm.cc.

References _event, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by VoronoiBackgroundProducer::produce().

1885  {
1886  math::PtEtaPhiELorentzVector p(perp, pseudorapidity, azimuth, NAN);
1887 
1888  p.SetE(p.P());
1889  _event.push_back(particle_t(p, reduced_particle_flow_id));
1890  }
PtEtaPhiELorentzVectorD PtEtaPhiELorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:27
T perp() const
Magnitude of transverse component.
void VoronoiAlgorithm::recombine_link ( void  )
private

Definition at line 1286 of file VoronoiAlgorithm.cc.

References _active, _event, _radial_distance_square_max, _recombine, _recombine_index, _recombine_tie, _recombine_unsigned, begin, i, and j.

Referenced by equalize().

1287  {
1288  boost::multi_array<double, 2> radial_distance_square(
1289  boost::extents[_event.size()][_event.size()]);
1290 
1291  for (std::vector<particle_t>::const_iterator
1292  iterator_outer = _event.begin();
1293  iterator_outer != _event.end(); iterator_outer++) {
1294  radial_distance_square
1295  [iterator_outer - _event.begin()]
1296  [iterator_outer - _event.begin()] = 0;
1297 
1298  for (std::vector<particle_t>::const_iterator
1299  iterator_inner = _event.begin();
1300  iterator_inner != iterator_outer;
1301  iterator_inner++) {
1302  const double deta = iterator_outer->momentum.Eta() -
1303  iterator_inner->momentum.Eta();
1304  const double dphi = angular_range_reduce(
1305  iterator_outer->momentum.Phi() -
1306  iterator_inner->momentum.Phi());
1307 
1308  radial_distance_square
1309  [iterator_outer - _event.begin()]
1310  [iterator_inner - _event.begin()] =
1311  deta * deta + dphi * dphi;
1312  radial_distance_square
1313  [iterator_inner - _event.begin()]
1314  [iterator_outer - _event.begin()] =
1315  radial_distance_square
1316  [iterator_outer - _event.begin()]
1317  [iterator_inner - _event.begin()];
1318  }
1319  }
1320 
1321  _active.clear();
1322 
1323  for (std::vector<particle_t>::const_iterator
1324  iterator_outer = _event.begin();
1325  iterator_outer != _event.end(); iterator_outer++) {
1326  double incident_area_sum = iterator_outer->area;
1327 
1328  for (std::set<std::vector<particle_t>::iterator>::
1329  const_iterator iterator_inner =
1330  iterator_outer->incident.begin();
1331  iterator_inner !=
1332  iterator_outer->incident.end();
1333  iterator_inner++) {
1334  incident_area_sum += (*iterator_inner)->area;
1335  }
1336  _active.push_back(incident_area_sum < 2.0);
1337  }
1338 
1339  _recombine.clear();
1340  _recombine_index = std::vector<std::vector<size_t> >(
1341  _event.size(), std::vector<size_t>());
1342  _recombine_unsigned = std::vector<std::vector<size_t> >(
1343  _event.size(), std::vector<size_t>());
1344  _recombine_tie.clear();
1345 
1346  // 36 cells corresponds to ~ 3 layers, note that for
1347  // hexagonal tiling, cell in proximity = 3 * layer *
1348  // (layer + 1)
1349  static const size_t npair_max = 36;
1350 
1351  for (size_t i = 0; i < _event.size(); i++) {
1352  for (size_t j = 0; j < _event.size(); j++) {
1353  const bool active_i_j = _active[i] && _active[j];
1354  const size_t incident_count =
1355  _event[i].incident.count(_event.begin() + j) +
1356  _event[j].incident.count(_event.begin() + i);
1357 
1358  if (active_i_j &&
1359  (radial_distance_square[i][j] <
1361  incident_count > 0)) {
1362  _recombine_unsigned[i].push_back(j);
1363  }
1364  }
1365 
1366  if (_event[i].momentum_perp_subtracted < 0) {
1367  std::vector<double> radial_distance_square_list;
1368 
1369  for (std::vector<size_t>::const_iterator iterator =
1371  iterator != _recombine_unsigned[i].end();
1372  iterator++) {
1373  const size_t j = *iterator;
1374 
1375  if (_event[j].momentum_perp_subtracted > 0) {
1376  radial_distance_square_list.push_back(
1377  radial_distance_square[i][j]);
1378  }
1379  }
1380 
1381  double radial_distance_square_max_equalization_cut =
1383 
1384  if (radial_distance_square_list.size() >= npair_max) {
1385  std::sort(radial_distance_square_list.begin(),
1386  radial_distance_square_list.end());
1387  radial_distance_square_max_equalization_cut =
1388  radial_distance_square_list[npair_max - 1];
1389  }
1390 
1391  for (std::vector<size_t>::const_iterator iterator =
1393  iterator != _recombine_unsigned[i].end();
1394  iterator++) {
1395  const size_t j = *iterator;
1396 
1397  if (_event[j].momentum_perp_subtracted > 0 &&
1398  radial_distance_square[i][j] <
1399  radial_distance_square_max_equalization_cut) {
1400  _recombine_index[j].push_back(
1401  _recombine.size());
1402  _recombine_index[i].push_back(
1403  _recombine.size());
1404  _recombine.push_back(
1405  std::pair<size_t, size_t>(i, j));
1406  _recombine_tie.push_back(
1407  radial_distance_square[i][j] /
1409  }
1410  }
1411  }
1412  }
1413  }
std::vector< bool > _active
std::vector< std::vector< size_t > > _recombine_index
int i
Definition: DBlmapReader.cc:9
std::vector< double > _recombine_tie
std::vector< std::pair< size_t, size_t > > _recombine
int j
Definition: DBlmapReader.cc:9
double _radial_distance_square_max
std::vector< std::vector< size_t > > _recombine_unsigned
#define begin
Definition: vmac.h:30
void VoronoiAlgorithm::remove_nonpositive ( void  )
private

Definition at line 1818 of file VoronoiAlgorithm.cc.

References _event, and bookConverter::max.

Referenced by subtract_if_necessary().

1819  {
1820  for (std::vector<particle_t>::iterator iterator =
1821  _event.begin();
1822  iterator != _event.end(); iterator++) {
1823  iterator->momentum_perp_subtracted = std::max(
1824  0.0, iterator->momentum_perp_subtracted);
1825  }
1826  }
void VoronoiAlgorithm::subtract_if_necessary ( void  )
private
void VoronoiAlgorithm::subtract_momentum ( void  )
private

Definition at line 1136 of file VoronoiAlgorithm.cc.

References _cms_ecal_edge_pseudorapidity, _cms_hcal_edge_pseudorapidity, _edge_pseudorapidity, _event, _feature, funct::cos(), create_public_lumi_plots::exp, j, cmsLHEtoEOSManager::l, visualization-live-secondInstance_cfg::m, M_PI, gen::n, nfourier, nreduced_particle_flow_id, connectstrParser::o, AlCaHLTBitMon_ParallelJobs::p, funct::sin(), ue, UECalibration::ue_interpolation_pf0, UECalibration::ue_interpolation_pf1, UECalibration::ue_interpolation_pf2, and UECalibration::ue_predictor_pf.

Referenced by subtract_if_necessary().

1137  {
1138  for (std::vector<particle_t>::iterator iterator =
1139  _event.begin();
1140  iterator != _event.end(); iterator++) {
1141  int predictor_index = -1;
1142  int interpolation_index = -1;
1143  double density = 0;
1144  double pred_0 = 0;
1145 
1146  for (size_t l = 1; l < _edge_pseudorapidity.size(); l++) {
1147  if (iterator->momentum.Eta() >=
1148  _edge_pseudorapidity[l - 1] &&
1149  iterator->momentum.Eta() <
1151  predictor_index = l - 1;
1152  }
1153  }
1154 
1155  for (size_t j = 0; j < nreduced_particle_flow_id; j++) {
1156  if (j == 2) {
1157  // HCAL
1158  for (size_t l = 1;
1159  l < _cms_hcal_edge_pseudorapidity.size(); l++) {
1160  if (iterator->momentum.Eta() >=
1162  iterator->momentum.Eta() <
1164  interpolation_index = l - 1;
1165  }
1166  }
1167  }
1168  else {
1169  // Tracks or ECAL clusters
1170  for (size_t l = 1;
1171  l < _cms_ecal_edge_pseudorapidity.size(); l++) {
1172  if (iterator->momentum.Eta() >=
1174  iterator->momentum.Eta() <
1176  interpolation_index = l - 1;
1177  }
1178  }
1179  }
1180 
1181  if (predictor_index >= 0 && interpolation_index >= 0) {
1182  // Calculate the aggregated prediction and
1183  // interpolation for the pseudorapidity segment
1184 
1185  const double azimuth = iterator->momentum.Phi();
1186  const float (*p)[2][82] =
1187 #ifdef STANDALONE
1188  ue_predictor_pf[j][predictor_index]
1189 #else // STANDALONE
1190  ue->ue_predictor_pf[j][predictor_index]
1191 #endif // STANDALONE
1192  ;
1193  double pred = 0;
1194 
1195  for (size_t l = 0; l < nfourier; l++) {
1196  const size_t norder = l == 0 ? 9 : 1;
1197 
1198  for (size_t m = 0; m < 2; m++) {
1199  float u = p[l][m][0];
1200 
1201  for (size_t n = 0; n < 2 * nfourier - 1; n++) {
1202  if ((l == 0 && n == 0) || (l == 2 && (n == 3 || n == 4))) {
1203  u += p[l][m][9 * n + 1] * _feature[n];
1204  for (size_t o = 2; o < norder + 1; o++) {
1205  u += p[l][m][9 * n + o] *
1206  hermite_h_normalized(
1207  2 * o - 1, _feature[n]) *
1208  exp(-_feature[n] * _feature[n]);
1209  }
1210  }
1211  }
1212 
1213  pred += u * (l == 0 ? 1.0 : 2.0) *
1214  (m == 0 ? cos(l * azimuth) :
1215  sin(l * azimuth));
1216  if (l == 0 && m == 0) {
1217  pred_0 += u /
1218  (2.0 * M_PI *
1219  (_edge_pseudorapidity[predictor_index + 1] -
1220  _edge_pseudorapidity[predictor_index]));
1221  }
1222  }
1223  }
1224 
1225  double interp = 0;
1226 
1227 #ifdef STANDALONE
1228  if (j == 0) {
1229  interp =
1230  ue_interpolation_pf0[predictor_index][
1231  interpolation_index];
1232  }
1233  else if (j == 1) {
1234  interp =
1235  ue_interpolation_pf1[predictor_index][
1236  interpolation_index];
1237  }
1238  else if (j == 2) {
1239  interp =
1240  ue_interpolation_pf2[predictor_index][
1241  interpolation_index];
1242  }
1243 #else // STANDALONE
1244  if (j == 0) {
1245  interp =
1246  ue->ue_interpolation_pf0[predictor_index][
1247  interpolation_index];
1248  }
1249  else if (j == 1) {
1250  interp =
1251  ue->ue_interpolation_pf1[predictor_index][
1252  interpolation_index];
1253  }
1254  else if (j == 2) {
1255  interp =
1256  ue->ue_interpolation_pf2[predictor_index][
1257  interpolation_index];
1258  }
1259 #endif // STANDALONE
1260  // Interpolate down to the finely binned
1261  // pseudorapidity
1262 
1263  density += pred /
1264  (2.0 * M_PI *
1265  (_edge_pseudorapidity[predictor_index + 1] -
1266  _edge_pseudorapidity[predictor_index])) *
1267  interp;
1268  }
1269  }
1270 
1271  if (std::isfinite(iterator->area) && density >= 0) {
1272  // Subtract the PF candidate by density times
1273  // Voronoi cell area
1274  iterator->momentum_perp_subtracted =
1275  iterator->momentum.Pt() -
1276  density * iterator->area;
1277  }
1278  else {
1279  iterator->momentum_perp_subtracted =
1280  iterator->momentum.Pt();
1281  }
1282  iterator->momentum_perp_subtracted_unequalized =
1283  iterator->momentum_perp_subtracted;
1284  }
1285  }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< double > _edge_pseudorapidity
const UECalibration * ue
std::vector< double > _cms_ecal_edge_pseudorapidity
static const size_t nreduced_particle_flow_id
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static const size_t nfourier
int j
Definition: DBlmapReader.cc:9
std::vector< double > _feature
#define M_PI
float ue_interpolation_pf0[15][344]
float ue_predictor_pf[3][15][5][2][82]
std::vector< double > _cms_hcal_edge_pseudorapidity
float ue_interpolation_pf1[15][344]
float ue_interpolation_pf2[15][82]
std::vector< double > VoronoiAlgorithm::subtracted_equalized_perp ( void  )

Returns the transverse momenta of the subtracted particles

Returns
vector of transverse momenta

Definition at line 1904 of file VoronoiAlgorithm.cc.

References _event, runTheMatrix::ret, and subtract_if_necessary().

Referenced by VoronoiBackgroundProducer::produce().

1905  {
1907 
1908  std::vector<double> ret;
1909 
1910  for (std::vector<particle_t>::const_iterator iterator =
1911  _event.begin();
1912  iterator != _event.end(); iterator++) {
1913  ret.push_back(iterator->momentum_perp_subtracted);
1914  }
1915 
1916  return ret;
1917  }
tuple ret
prodAgent to be discontinued
void subtract_if_necessary(void)
std::vector< double > VoronoiAlgorithm::subtracted_unequalized_perp ( void  )

Definition at line 1918 of file VoronoiAlgorithm.cc.

References _event, runTheMatrix::ret, and subtract_if_necessary().

Referenced by VoronoiBackgroundProducer::produce().

1919  {
1921 
1922  std::vector<double> ret;
1923 
1924  for (std::vector<particle_t>::const_iterator iterator =
1925  _event.begin();
1926  iterator != _event.end(); iterator++) {
1927  ret.push_back(iterator->momentum_perp_subtracted_unequalized);
1928  }
1929 
1930  return ret;
1931  }
tuple ret
prodAgent to be discontinued
void subtract_if_necessary(void)
void VoronoiAlgorithm::voronoi_area_incident ( void  )
private

Definition at line 1045 of file VoronoiAlgorithm.cc.

References _event, patZpeak::handle, edm::eventsetup::heterocontainer::insert(), relval_2017::k, M_PI, NULL, AlCaHLTBitMon_ParallelJobs::p, and mps_fire::result.

Referenced by subtract_if_necessary().

1046  {
1047  // Make the Voronoi diagram
1048 
1049  voronoi_diagram_t diagram;
1050 
1051  // Reverse Voronoi face lookup
1052 #ifdef HAVE_SPARSEHASH
1053  // The "empty" or default value of the hash table
1054  const voronoi_diagram_t::Face face_empty;
1055  google::dense_hash_map<voronoi_diagram_t::Face_handle,
1056  size_t, hash<voronoi_diagram_t::Face_handle> >
1057  face_index;
1058 
1059  face_index.set_empty_key(face_empty);
1060 #else // HAVE_SPARSEHASH
1061  std::map<voronoi_diagram_t::Face_handle, size_t>
1062  face_index;
1063 #endif // HAVE_SPARSEHASH
1064 
1065  for (std::vector<particle_t>::const_iterator iterator =
1066  _event.begin();
1067  iterator != _event.end(); iterator++) {
1068  // Make two additional replicas with azimuth +/- 2 pi
1069  // (and use only the middle) to mimick the azimuthal
1070  // cyclicity
1071  for (int k = -1; k <= 1; k++) {
1072  const point_2d_t p(
1073  iterator->momentum.Eta(),
1074  iterator->momentum.Phi() +
1075  k * (2 * M_PI));
1076  const voronoi_diagram_t::Face_handle handle =
1077  diagram.insert(p);
1078 
1079  face_index[handle] = iterator - _event.begin();
1080  }
1081  }
1082 
1083  // Extract the Voronoi cells as polygon and calculate the
1084  // area associated with individual particles
1085 
1086  for (std::vector<particle_t>::iterator iterator =
1087  _event.begin();
1088  iterator != _event.end(); iterator++) {
1089  const voronoi_diagram_t::Locate_result result =
1090  diagram.locate(*iterator);
1091  const voronoi_diagram_t::Face_handle *face =
1092  boost::get<voronoi_diagram_t::Face_handle>(
1093  &result);
1094  double polygon_area;
1095 
1096  if (face != NULL) {
1097  voronoi_diagram_t::Ccb_halfedge_circulator
1098  circulator_start = (*face)->outer_ccb();
1099  bool unbounded = false;
1100  polygon_t polygon;
1101 
1102  voronoi_diagram_t::Ccb_halfedge_circulator
1103  circulator = circulator_start;
1104 
1105  // Circle around the edges and extract the polygon
1106  // vertices
1107  do {
1108  if (circulator->has_target()) {
1109  polygon.push_back(
1110  circulator->target()->point());
1111  _event[face_index[*face]].incident.
1112  insert(
1113  _event.begin() +
1114  face_index[circulator->twin()->
1115  face()]);
1116  }
1117  else {
1118  unbounded = true;
1119  break;
1120  }
1121  }
1122  while (++circulator != circulator_start);
1123  if (unbounded) {
1124  polygon_area = INFINITY;
1125  }
1126  else {
1127  polygon_area = polygon.area();
1128  }
1129  }
1130  else {
1131  polygon_area = NAN;
1132  }
1133  iterator->area = fabs(polygon_area);
1134  }
1135  }
CGAL::Voronoi_diagram_2< delaunay_triangulation_t, CGAL::Delaunay_triangulation_adaptation_traits_2< delaunay_triangulation_t >, CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2< delaunay_triangulation_t > > voronoi_diagram_t
#define NULL
Definition: scimark2.h:8
tuple result
Definition: mps_fire.py:95
delaunay_triangulation_t::Point point_2d_t
tuple handle
Definition: patZpeak.py:22
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
#define M_PI
CGAL::Polygon_2< CGAL::Exact_predicates_inexact_constructions_kernel > polygon_t

Member Data Documentation

std::vector<bool> VoronoiAlgorithm::_active
protected

Definition at line 75 of file VoronoiAlgorithm.h.

Referenced by lp_populate(), and recombine_link().

std::vector<double> VoronoiAlgorithm::_cms_ecal_edge_pseudorapidity
protected

Definition at line 66 of file VoronoiAlgorithm.h.

Referenced by initialize_geometry(), and subtract_momentum().

std::vector<double> VoronoiAlgorithm::_cms_hcal_edge_pseudorapidity
protected

Definition at line 65 of file VoronoiAlgorithm.h.

Referenced by initialize_geometry(), and subtract_momentum().

std::vector<double> VoronoiAlgorithm::_edge_pseudorapidity
protected
std::pair<double, double> VoronoiAlgorithm::_equalization_threshold
protected

Definition at line 68 of file VoronoiAlgorithm.h.

Referenced by lp_populate().

event_t VoronoiAlgorithm::_event
protected
std::vector<double> VoronoiAlgorithm::_feature
protected

Definition at line 74 of file VoronoiAlgorithm.h.

Referenced by feature_extract(), and subtract_momentum().

void* VoronoiAlgorithm::_lp_environment
protected

Definition at line 82 of file VoronoiAlgorithm.h.

Referenced by equalize().

void* VoronoiAlgorithm::_lp_problem
protected

Definition at line 83 of file VoronoiAlgorithm.h.

std::vector<size_t> VoronoiAlgorithm::_nblock_subtract
protected

Definition at line 81 of file VoronoiAlgorithm.h.

Referenced by equalize(), and lp_populate().

size_t VoronoiAlgorithm::_ncost
protected

Definition at line 80 of file VoronoiAlgorithm.h.

Referenced by equalize(), and lp_populate().

boost::multi_array<double, 4>* VoronoiAlgorithm::_perp_fourier
protected

Definition at line 73 of file VoronoiAlgorithm.h.

Referenced by allocate(), deallocate(), event_fourier(), and perp_fourier().

double VoronoiAlgorithm::_positive_bound_scale
protected

Definition at line 70 of file VoronoiAlgorithm.h.

Referenced by lp_populate().

double VoronoiAlgorithm::_radial_distance_square_max
protected

Definition at line 69 of file VoronoiAlgorithm.h.

Referenced by recombine_link().

std::vector<std::pair<size_t, size_t> > VoronoiAlgorithm::_recombine
protected

Definition at line 76 of file VoronoiAlgorithm.h.

Referenced by equalize(), and recombine_link().

std::vector<std::vector<size_t> > VoronoiAlgorithm::_recombine_index
protected

Definition at line 77 of file VoronoiAlgorithm.h.

Referenced by lp_populate(), and recombine_link().

std::vector<double> VoronoiAlgorithm::_recombine_tie
protected

Definition at line 79 of file VoronoiAlgorithm.h.

Referenced by lp_populate(), and recombine_link().

std::vector<std::vector<size_t> > VoronoiAlgorithm::_recombine_unsigned
protected

Definition at line 78 of file VoronoiAlgorithm.h.

Referenced by lp_populate(), and recombine_link().

bool VoronoiAlgorithm::_remove_nonpositive
protected

Definition at line 67 of file VoronoiAlgorithm.h.

Referenced by subtract_if_necessary().

bool VoronoiAlgorithm::_subtracted
protected

Definition at line 71 of file VoronoiAlgorithm.h.

Referenced by clear(), and subtract_if_necessary().

const size_t VoronoiAlgorithm::nfourier = 5
static

Definition at line 62 of file VoronoiAlgorithm.h.

Referenced by allocate(), event_fourier(), feature_extract(), and subtract_momentum().

const size_t VoronoiAlgorithm::nreduced_particle_flow_id = 3
static

Definition at line 61 of file VoronoiAlgorithm.h.

Referenced by allocate(), feature_extract(), and subtract_momentum().

const UECalibration* VoronoiAlgorithm::ue
protected

Definition at line 85 of file VoronoiAlgorithm.h.

Referenced by subtract_momentum().