CMS 3D CMS Logo

PFBlockAlgo.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFProducer_PFBlockAlgo_h
2 #define RecoParticleFlow_PFProducer_PFBlockAlgo_h
3 
13 
14 #include <memory>
15 #include <string>
16 #include <unordered_map>
17 #include <vector>
18 
19 namespace std {
20  template<>
21  struct hash<std::pair<unsigned int,unsigned int> > {
22  typedef std::pair<unsigned int,unsigned int> arg_type;
23  typedef unsigned int value_type;
24  value_type operator()(const arg_type& arg) const {
25  return arg.first ^ (arg.second << 1);
26  }
27  };
28 }
29 
31 
36 class PFBlockAlgo {
37 
38  public:
39  // the element list should **always** be a list of (smart) pointers
40  typedef std::vector<std::unique_ptr<reco::PFBlockElement> > ElementList;
41  //for skipping ranges
42  typedef std::array<std::pair<unsigned int,unsigned int>,reco::PFBlockElement::kNBETypes> ElementRanges;
43 
44  PFBlockAlgo();
45 
46  ~PFBlockAlgo();
47 
48  void setLinkers(const std::vector<edm::ParameterSet>&);
49 
50  void setImporters(const std::vector<edm::ParameterSet>&,
52 
53  // update event setup info of all linkers
54  void updateEventSetup(const edm::EventSetup&);
55 
56  // run all of the importers and build KDtrees
57  void buildElements(const edm::Event&);
58 
60  reco::PFBlockCollection findBlocks();
61 
63  void setDebug( bool debug ) {debug_ = debug;}
64 
65  private:
66 
69  void packLinks(reco::PFBlock& block,
70  const std::unordered_map<std::pair<unsigned int,unsigned int>,double>& links) const;
71 
73  inline void link( const reco::PFBlockElement* el1,
74  const reco::PFBlockElement* el2,
75  double& dist) const;
76 
77  // the test elements will be transferred to the blocks
78  ElementList elements_;
79  ElementRanges ranges_;
80 
82  bool debug_;
83 
84  friend std::ostream& operator<<(std::ostream&, const PFBlockAlgo&);
85  bool useHO_;
86 
87  std::vector<std::unique_ptr<BlockElementImporterBase>> importers_;
88 
89  const std::unordered_map<std::string,reco::PFBlockElement::Type>
91  std::vector<std::unique_ptr<BlockElementLinkerBase>> linkTests_;
93 
94  std::vector<std::unique_ptr<KDTreeLinkerBase>> kdtrees_;
95 };
96 
97 #endif
Abstract base class for a PFBlock element (track, cluster...)
std::pair< unsigned int, unsigned int > arg_type
Definition: PFBlockAlgo.h:22
ElementList elements_
Definition: PFBlockAlgo.h:78
A arg
Definition: Factorize.h:38
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
Definition: PFBlockAlgo.h:40
Particle Flow Algorithm.
Definition: PFBlockAlgo.h:36
const std::unordered_map< std::string, reco::PFBlockElement::Type > elementTypes_
Definition: PFBlockAlgo.h:90
void setDebug(bool debug)
sets debug printout flag
Definition: PFBlockAlgo.h:63
std::vector< std::unique_ptr< KDTreeLinkerBase > > kdtrees_
Definition: PFBlockAlgo.h:94
std::vector< PFBlock > PFBlockCollection
collection of PFBlock objects
Definition: PFBlockFwd.h:11
std::ostream & operator<<(std::ostream &out, const std::tuple< Types... > &value)
Definition: Utilities.h:38
ElementRanges ranges_
Definition: PFBlockAlgo.h:79
std::vector< std::unique_ptr< BlockElementLinkerBase > > linkTests_
Definition: PFBlockAlgo.h:91
#define debug
Definition: HDRShower.cc:19
std::vector< std::unique_ptr< BlockElementImporterBase > > importers_
Definition: PFBlockAlgo.h:87
std::array< std::pair< unsigned int, unsigned int >, reco::PFBlockElement::kNBETypes > ElementRanges
Definition: PFBlockAlgo.h:42
value_type operator()(const arg_type &arg) const
Definition: PFBlockAlgo.h:24
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:82
Block of elements.
Definition: PFBlock.h:30