5#ifndef PARTICLESINCONETOOLS_IPARTICLELOOKUPTABLE_H
6#define PARTICLESINCONETOOLS_IPARTICLELOOKUPTABLE_H
55 void addEntry(
int i, std::vector< const T* >& output )
const;
84 unsigned int size = particles.size();
85 for(
unsigned int i=0; i<size;++i ){
93 if(
vec.empty() )
continue;
94 std::stable_sort(
vec.begin(),
vec.end(),[&](
int i,
int j) { return (*m_container)[i]->eta() < (*m_container)[j]->eta(); });
103 template<
class T>
template<
class O>
110 auto compEta1 = [&](
int i,
double val ) {
return (*
m_container)[i]->eta() < val; };
111 auto compEta2 = [&](
double val,
int i ) {
return val < (*m_container)[i]->eta(); };
118 std::vector< std::pair<int,int> > ranges;
119 if( indexMin > indexMax ) {
120 ranges.push_back( std::make_pair(0,indexMax) );
121 ranges.push_back( std::make_pair(indexMin,
m_nphiBins-1) );
123 ranges.push_back( std::make_pair(indexMin,indexMax) );
126 float dr2Cut = dr*dr;
129 for(
auto& range : ranges ){
130 indexMin = range.first;
131 indexMax = range.second;
132 for( ; indexMin <= indexMax; ++indexMin ){
135 auto it_min = std::lower_bound (tps.begin(),tps.end(),
eta-dr,compEta1 );
136 auto it_max = std::upper_bound (it_min,tps.end(),
eta+dr,compEta2 );
139 for( ;it_min!=it_max;++it_min ){
140 const T* entry = (*m_container)[*it_min];
141 float deta =
eta- entry->eta();
143 float dr2 = deta*deta + dphi*dphi;
145 if( dr2 < dr2Cut )
addEntry( *it_min, output );
Scalar eta() const
pseudorapidity method
std::vector< size_t > vec
An STL vector of pointers that by default owns its pointed-to elements.
ElementLink implementation for ROOT usage.
void addEntry(int i, std::vector< ElementLink< DataVector< T > > > &output) const
add an entry into a vector of ElementLinks
const DataVector< CaloCluster > * m_container
float phiInRange(float phi) const
hepler function to ensure phi is within +-Pi
bool iParticlesInCone(float eta, float phi, float dr, O &output) const
collect IParticles in a given cone
void addEntry(int i, std::vector< const T * > &output) const
add an entry into a vector of pointers
bool isInitialized() const
return whether table is initialized
static constexpr float m_2PI
int phiIndex(float phi) const
calculate phi index for a given phi
IParticlesLookUpTable(unsigned int nbins=50, float minPt=1e-3)
constructor taking the desired binsize
void init(const DataVector< T > &particles)
initialize the look up table with an iParticle container
std::vector< std::vector< int > > m_phiBinnedLookUpTable
void clear()
clear the look up table
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
setRcore setEtHad setFside pt