File indexing completed on 2024-04-06 12:27:27
0001 #ifndef RecoParticleFlow_PFProducer_PFBlockAlgo_h
0002 #define RecoParticleFlow_PFProducer_PFBlockAlgo_h
0003
0004 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
0005 #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
0006 #include "DataFormats/ParticleFlowReco/interface/PFBlockFwd.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/Framework/interface/ConsumesCollector.h"
0009 #include "RecoParticleFlow/PFProducer/interface/BlockElementImporterBase.h"
0010 #include "RecoParticleFlow/PFProducer/interface/BlockElementLinkerBase.h"
0011 #include "RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h"
0012 #include "DataFormats/Common/interface/OwnVector.h"
0013
0014 #include <memory>
0015 #include <string>
0016 #include <unordered_map>
0017 #include <vector>
0018
0019 namespace std {
0020 template <>
0021 struct hash<std::pair<unsigned int, unsigned int>> {
0022 typedef std::pair<unsigned int, unsigned int> arg_type;
0023 typedef unsigned int value_type;
0024 value_type operator()(const arg_type& arg) const { return arg.first ^ (arg.second << 1); }
0025 };
0026 }
0027
0028
0029
0030
0031
0032
0033
0034 class PFBlockAlgo {
0035 public:
0036
0037 typedef std::vector<std::unique_ptr<reco::PFBlockElement>> ElementList;
0038
0039 typedef std::array<std::pair<unsigned int, unsigned int>, reco::PFBlockElement::kNBETypes> ElementRanges;
0040
0041 PFBlockAlgo();
0042
0043 ~PFBlockAlgo();
0044
0045 void setLinkers(const std::vector<edm::ParameterSet>&);
0046
0047 void setImporters(const std::vector<edm::ParameterSet>&, edm::ConsumesCollector&);
0048
0049
0050 void updateEventSetup(const edm::EventSetup&);
0051
0052
0053 void buildElements(const edm::Event&);
0054
0055
0056 reco::PFBlockCollection findBlocks();
0057
0058
0059 void setDebug(bool debug) { debug_ = debug; }
0060
0061 private:
0062
0063
0064 void packLinks(reco::PFBlock& block,
0065 const std::unordered_map<std::pair<unsigned int, unsigned int>, double>& links) const;
0066
0067
0068 inline void link(const reco::PFBlockElement* el1, const reco::PFBlockElement* el2, double& dist) const;
0069
0070
0071 ElementList elements_;
0072 ElementRanges ranges_;
0073
0074
0075 bool debug_;
0076
0077 friend std::ostream& operator<<(std::ostream&, const PFBlockAlgo&);
0078 bool useHO_;
0079
0080 std::vector<std::unique_ptr<BlockElementImporterBase>> importers_;
0081
0082 const std::unordered_map<std::string, reco::PFBlockElement::Type> elementTypes_;
0083 std::vector<std::unique_ptr<BlockElementLinkerBase>> linkTests_;
0084 unsigned int linkTestSquare_[reco::PFBlockElement::kNBETypes][reco::PFBlockElement::kNBETypes];
0085
0086 std::vector<std::unique_ptr<KDTreeLinkerBase>> kdtrees_;
0087 };
0088
0089 #endif