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
PFBlockAlgo::buildElements
void buildElements(const edm::Event &)
Definition: PFBlockAlgo.cc:286
PFBlockAlgo::debug_
bool debug_
if true, debug printouts activated
Definition: PFBlockAlgo.h:75
cond::hash
Definition: Time.h:19
reco::PFBlock
Block of elements.
Definition: PFBlock.h:26
PFBlockAlgo::ElementRanges
std::array< std::pair< unsigned int, unsigned int >, reco::PFBlockElement::kNBETypes > ElementRanges
Definition: PFBlockAlgo.h:39
PFBlockAlgo::ElementList
std::vector< std::unique_ptr< reco::PFBlockElement > > ElementList
Definition: PFBlockAlgo.h:37
PFBlockAlgo::setDebug
void setDebug(bool debug)
sets debug printout flag
Definition: PFBlockAlgo.h:59
PFBlockAlgo::operator<<
friend std::ostream & operator<<(std::ostream &, const PFBlockAlgo &)
Definition: PFBlockAlgo.cc:327
debug
#define debug
Definition: HDRShower.cc:19
BlockElementImporterBase.h
KDTreeLinkerBase.h
PFBlockElement.h
PFBlockAlgo::link
void link(const reco::PFBlockElement *el1, const reco::PFBlockElement *el2, double &dist) const
check whether 2 elements are linked. Returns distance
Definition: PFBlockAlgo.cc:263
PFBlockAlgo::elements_
ElementList elements_
Definition: PFBlockAlgo.h:71
PFBlockAlgo::~PFBlockAlgo
~PFBlockAlgo()
Definition: PFBlockAlgo.cc:134
PFBlockAlgo::kdtrees_
std::vector< std::unique_ptr< KDTreeLinkerBase > > kdtrees_
Definition: PFBlockAlgo.h:86
reco::PFBlockCollection
std::vector< PFBlock > PFBlockCollection
collection of PFBlock objects
Definition: PFBlockFwd.h:10
std::hash< std::pair< unsigned int, unsigned int > >::operator()
value_type operator()(const arg_type &arg) const
Definition: PFBlockAlgo.h:24
PFBlockAlgo::linkTests_
std::vector< std::unique_ptr< BlockElementLinkerBase > > linkTests_
Definition: PFBlockAlgo.h:83
PFBlockAlgo::elementTypes_
const std::unordered_map< std::string, reco::PFBlockElement::Type > elementTypes_
Definition: PFBlockAlgo.h:82
PFBlockAlgo::linkTestSquare_
unsigned int linkTestSquare_[reco::PFBlockElement::kNBETypes][reco::PFBlockElement::kNBETypes]
Definition: PFBlockAlgo.h:84
PFBlockAlgo::useHO_
bool useHO_
Definition: PFBlockAlgo.h:78
PFBlockAlgo::setImporters
void setImporters(const std::vector< edm::ParameterSet > &, edm::ConsumesCollector &)
Definition: PFBlockAlgo.cc:126
std::hash< std::pair< unsigned int, unsigned int > >::arg_type
std::pair< unsigned int, unsigned int > arg_type
Definition: PFBlockAlgo.h:22
PFBlockAlgo::ranges_
ElementRanges ranges_
Definition: PFBlockAlgo.h:72
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
edm::EventSetup
Definition: EventSetup.h:57
PFBlockAlgo
Particle Flow Algorithm.
Definition: PFBlockAlgo.h:34
std::hash< std::pair< unsigned int, unsigned int > >::value_type
unsigned int value_type
Definition: PFBlockAlgo.h:23
PFBlockAlgo::findBlocks
reco::PFBlockCollection findBlocks()
build blocks
Definition: PFBlockAlgo.cc:141
PFBlockAlgo::updateEventSetup
void updateEventSetup(const edm::EventSetup &)
Definition: PFBlockAlgo.cc:277
reco::PFBlockElement
Abstract base class for a PFBlock element (track, cluster...)
Definition: PFBlockElement.h:26
PFBlockFwd.h
PFBlockAlgo::packLinks
void packLinks(reco::PFBlock &block, const std::unordered_map< std::pair< unsigned int, unsigned int >, double > &links) const
Definition: PFBlockAlgo.cc:219
PFBlock.h
std
Definition: JetResolutionObject.h:76
reco::PFBlockElement::kNBETypes
Definition: PFBlockElement.h:44
electronStore.links
links
Definition: electronStore.py:149
BlockElementLinkerBase.h
PFBlockAlgo::importers_
std::vector< std::unique_ptr< BlockElementImporterBase > > importers_
Definition: PFBlockAlgo.h:80
funct::arg
A arg
Definition: Factorize.h:31
ConsumesCollector.h
ParameterSet.h
OwnVector.h
PFBlockAlgo::PFBlockAlgo
PFBlockAlgo()
Definition: PFBlockAlgo.cc:71
edm::Event
Definition: Event.h:73
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
PFBlockAlgo::setLinkers
void setLinkers(const std::vector< edm::ParameterSet > &)
Definition: PFBlockAlgo.cc:86