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 { return arg.first ^ (arg.second << 1); }
25  };
26 } // namespace std
27 
29 
34 class PFBlockAlgo {
35 public:
36  // the element list should **always** be a list of (smart) pointers
37  typedef std::vector<std::unique_ptr<reco::PFBlockElement>> ElementList;
38  //for skipping ranges
39  typedef std::array<std::pair<unsigned int, unsigned int>, reco::PFBlockElement::kNBETypes> ElementRanges;
40 
41  PFBlockAlgo();
42 
43  ~PFBlockAlgo();
44 
45  void setLinkers(const std::vector<edm::ParameterSet>&);
46 
47  void setImporters(const std::vector<edm::ParameterSet>&, edm::ConsumesCollector&);
48 
49  // update event setup info of all linkers
50  void updateEventSetup(const edm::EventSetup&);
51 
52  // run all of the importers and build KDtrees
53  void buildElements(const edm::Event&);
54 
57 
59  void setDebug(bool debug) { debug_ = debug; }
60 
61 private:
65  const std::unordered_map<std::pair<unsigned int, unsigned int>, double>& links) const;
66 
68  inline void link(const reco::PFBlockElement* el1, const reco::PFBlockElement* el2, double& dist) const;
69 
70  // the test elements will be transferred to the blocks
73 
75  bool debug_;
76 
77  friend std::ostream& operator<<(std::ostream&, const PFBlockAlgo&);
78  bool useHO_;
79 
80  std::vector<std::unique_ptr<BlockElementImporterBase>> importers_;
81 
82  const std::unordered_map<std::string, reco::PFBlockElement::Type> elementTypes_;
83  std::vector<std::unique_ptr<BlockElementLinkerBase>> linkTests_;
85 
86  std::vector<std::unique_ptr<KDTreeLinkerBase>> kdtrees_;
87 };
88 
89 #endif
Abstract base class for a PFBlock element (track, cluster...)
std::array< std::pair< unsigned int, unsigned int >, reco::PFBlockElement::kNBETypes > ElementRanges
Definition: PFBlockAlgo.h:39
friend std::ostream & operator<<(std::ostream &, const PFBlockAlgo &)
Definition: PFBlockAlgo.cc:324
ElementList elements_
Definition: PFBlockAlgo.h:71
A arg
Definition: Factorize.h:31
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
Definition: PFBlockAlgo.h:37
Particle Flow Algorithm.
Definition: PFBlockAlgo.h:34
void setDebug(bool debug)
sets debug printout flag
Definition: PFBlockAlgo.h:59
std::vector< std::unique_ptr< KDTreeLinkerBase > > kdtrees_
Definition: PFBlockAlgo.h:86
std::pair< unsigned int, unsigned int > arg_type
Definition: PFBlockAlgo.h:22
void updateEventSetup(const edm::EventSetup &)
Definition: PFBlockAlgo.cc:274
void setImporters(const std::vector< edm::ParameterSet > &, edm::ConsumesCollector &)
Definition: PFBlockAlgo.cc:123
void packLinks(reco::PFBlock &block, const std::unordered_map< std::pair< unsigned int, unsigned int >, double > &links) const
Definition: PFBlockAlgo.cc:216
std::vector< PFBlock > PFBlockCollection
collection of PFBlock objects
Definition: PFBlockFwd.h:10
void link(const reco::PFBlockElement *el1, const reco::PFBlockElement *el2, double &dist) const
check whether 2 elements are linked. Returns distance
Definition: PFBlockAlgo.cc:260
ElementRanges ranges_
Definition: PFBlockAlgo.h:72
value_type operator()(const arg_type &arg) const
Definition: PFBlockAlgo.h:24
std::vector< std::unique_ptr< BlockElementLinkerBase > > linkTests_
Definition: PFBlockAlgo.h:83
const std::unordered_map< std::string, reco::PFBlockElement::Type > elementTypes_
Definition: PFBlockAlgo.h:82
unsigned int linkTestSquare_[reco::PFBlockElement::kNBETypes][reco::PFBlockElement::kNBETypes]
Definition: PFBlockAlgo.h:84
#define debug
Definition: HDRShower.cc:19
std::vector< std::unique_ptr< BlockElementImporterBase > > importers_
Definition: PFBlockAlgo.h:80
reco::PFBlockCollection findBlocks()
build blocks
Definition: PFBlockAlgo.cc:138
void buildElements(const edm::Event &)
Definition: PFBlockAlgo.cc:283
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:75
void setLinkers(const std::vector< edm::ParameterSet > &)
Definition: PFBlockAlgo.cc:83
Block of elements.
Definition: PFBlock.h:26