16 #define INIT_ENTRY(name) {#name,name}
43 for(
const auto& conf : confs ) {
48 size_t split = linkTypeStr.find(
':');
49 if( split == std::string::npos ) {
51 <<
"\"" << linkTypeStr <<
"\" is not a valid link type definition."
52 <<
" This string should have the form \"linkFrom:linkTo\"";
54 std::string link1(prefix+linkTypeStr.substr(0,split));
55 std::string link2(prefix+linkTypeStr.substr(split+1,std::string::npos));
58 <<
"One of \"" << link1 <<
"\" or \"" << link2
59 <<
"\" are invalid block element types!";
68 const bool useKDTree = conf.getParameter<
bool>(
"useKDTree");
81 for(
const auto& conf : confs ) {
94 cout<<
"~PFBlockAlgo - number of remaining elements: "
102 for(
const auto& kdtree :
_kdtrees ) {
115 cout<<
" PFBlockAlgo::findBlocks() ----------------------"<<endl;
116 cout<<
" element "<<**ie<<endl;
117 cout<<
" creating new block"<<endl;
138 std::unordered_map<std::pair<size_t,size_t>,
PFBlockLink>& links,
140 if( elems.size() == 0 )
return elems.begin();
141 ElementList::iterator scan_upper(elems.begin()), search_lower(elems.begin()),
142 scan_lower(elems.begin());
143 ++scan_upper; ++search_lower;
151 scan_upper = search_lower;
154 for(
auto comp = scan_lower;
comp != scan_upper; ++
comp ) {
160 std::partition(search_lower,elems.end(),
166 linktype, linktest, dist );
169 const unsigned lidx = ((*comp)->type() <
a->type() ?
172 const unsigned uidx = ((*comp)->type() >=
a->type() ?
176 links.emplace( std::make_pair(lidx,uidx),
187 scan_lower = scan_upper;
188 }
while( search_lower != scan_upper );
190 return elems.erase(elems.begin(),scan_upper);
195 const std::unordered_map<std::pair<size_t,size_t>,
PFBlockLink>& links )
const {
201 unsigned elsize = els.
size();
203 for(
unsigned i1=0; i1<elsize; ++i1 ) {
204 for(
unsigned i2=0; i2<i1; ++i2 ) {
213 = PFBlock::LINKTEST_RECHIT;
217 const auto link_itr = links.find(std::make_pair(i2,i1));
218 if( link_itr != links.end() ) {
219 dist = link_itr->second.dist();
220 linktest = link_itr->second.test();
227 if (bTestLink)
link( & els[i1], & els[i2], linktype, linktest, dist);
234 cout <<
"Setting link between elements " << i1 <<
" and " << i2
235 <<
" of dist =" << dist <<
" computed from link test "
252 const unsigned index = rowsize*
std::max(type1,type2) +
std::min(type1,type2);
265 double& dist)
const {
268 linktest = PFBlock::LINKTEST_RECHIT;
272 const unsigned index = rowsize*
std::max(type1,type2) +
std::min(type1,type2);
274 std::cout <<
" PFBlockAlgo links type1 " << type1
275 <<
" type2 " << type2 << std::endl;
284 importer->updateEventSetup(es);
293 for(
const auto& importer : _importers ) {
303 for (ElementList::iterator it =
elements_.begin();
305 for(
const auto& kdtree : _kdtrees ) {
306 if( (*it)->type() == kdtree->targetType() ) {
307 kdtree->insertTargetElt(it->get());
309 if( (*it)->type() == kdtree->fieldType() ) {
310 kdtree->insertFieldClusterElt(it->get());
318 if(! out)
return out;
320 out<<
"====== Particle Flow Block Algorithm ======= ";
322 out<<
"number of unassociated elements : "<<a.
elements_.size()<<endl;
327 out<<
"\t"<<**ie <<endl;
333 const std::auto_ptr< reco::PFBlockCollection >&
blocks
337 out<<
"blocks already transfered"<<endl;
340 out<<
"number of blocks : "<<blocks->size()<<endl;
344 ib != blocks->end(); ++
ib) {
const std::auto_ptr< reco::PFBlockCollection > & blocks() const
Abstract base class for a PFBlock element (track, cluster...)
std::vector< LinkTestPtr > _linkTests
const std::unordered_map< std::string, reco::PFBlockElement::Type > _elementTypes
ElementList::const_iterator IEC
IE associate(ElementList &elems, std::unordered_map< std::pair< size_t, size_t >, PFBlockLink > &links, reco::PFBlock &)
const edm::OwnVector< reco::PFBlockElement > & elements() const
std::auto_ptr< reco::PFBlockCollection > blocks_
const LinkData & linkData() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
ElementList::iterator IE
define these in *Fwd files in DataFormats/ParticleFlowReco?
void setLink(unsigned i1, unsigned i2, double dist, LinkData &linkData, LinkTest test=LINKTEST_RECHIT) const
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
Container::value_type value_type
void addElement(reco::PFBlockElement *element)
void link(const reco::PFBlockElement *el1, const reco::PFBlockElement *el2, PFBlockLink::Type &linktype, reco::PFBlock::LinkTest &linktest, double &dist) const
check whether 2 elements are linked. Returns distance and linktype
void packLinks(reco::PFBlock &block, const std::unordered_map< std::pair< size_t, size_t >, PFBlockLink > &links) const
std::vector< KDTreePtr > _kdtrees
void updateEventSetup(const edm::EventSetup &)
void setImporters(const std::vector< edm::ParameterSet > &, edm::ConsumesCollector &)
std::vector< PFBlock > PFBlockCollection
collection of PFBlock objects
reco::PFBlockCollection::const_iterator IBC
bool linkPrefilter(const reco::PFBlockElement *last, const reco::PFBlockElement *next) const
Avoid to check links when not useful.
void findBlocks()
build blocks
Type
possible types. WARNING: have a look at PFBlockElement
volatile std::atomic< bool > shutdown_flag false
void buildElements(const edm::Event &)
bool debug_
if true, debug printouts activated
void setLinkers(const std::vector< edm::ParameterSet > &)
T get(const Candidate &c)
std::vector< ImporterPtr > _importers