CMS 3D CMS Logo

KDTreeLinkerBase.h
Go to the documentation of this file.
1 #ifndef KDTreeLinkerBase_h
2 #define KDTreeLinkerBase_h
3 
7 
8 #include <vector>
9 #include <map>
10 #include <set>
11 
12 using BlockEltSet = std::set<reco::PFBlockElement *>;
13 using RecHitSet = std::set<const reco::PFRecHit *>;
14 
15 using RecHit2BlockEltMap = std::map<const reco::PFRecHit *, BlockEltSet>;
16 using BlockElt2BlockEltMap = std::map<reco::PFBlockElement *, BlockEltSet>;
17 
19 {
20  public:
21  virtual ~KDTreeLinkerBase() {}
22 
24  _targetType = tgt;
25  }
26 
28  _fieldType = fld;
29  }
30 
32  return _targetType;
33  }
34 
36  return _fieldType;
37  }
38 
39  // Get/Set of the maximal size of the cristal (ECAL, HCAL,...) in phi/eta and
40  // X/Y. By default, thus value are set for the ECAL cristal.
41 
42  // Get/Set phi offset. See bellow in the description of phiOffset_ to understand
43  // the application.
44 
45  // Debug flag.
46  void setDebug(bool isDebug);
47 
48  // With this method, we create the list of elements that we want to link.
49  virtual void insertTargetElt(reco::PFBlockElement *target) = 0;
50 
51  // Here, we create the list of cluster that we want to link. From cluster
52  // and fraction, we will create a second list of rechits that will be used to
53  // build the KDTree.
54  virtual void insertFieldClusterElt(reco::PFBlockElement *cluster) = 0;
55 
56  // The KDTree building from rechits list.
57  virtual void buildTree() = 0;
58 
59  // Here we will iterate over all target elements. For each one, we will search the closest
60  // rechits in the KDTree, from rechits we will find the associated clusters and after that
61  // we will check the links between the target and all closest clusters.
62  virtual void searchLinks() = 0;
63 
64  // Here, we will store all target/cluster founded links in the PFBlockElement class
65  // of each target in the PFmultilinks field.
66  virtual void updatePFBlockEltWithLinks() = 0;
67 
68  // Here we free all allocated structures.
69  virtual void clear() = 0;
70 
71  // This method calls is the good order buildTree(), searchLinks(),
72  // updatePFBlockEltWithLinks() and clear()
73  inline void process()
74  {
75  buildTree();
76  searchLinks();
78  clear();
79  }
80 
81  protected:
82  // target and field
84  // Cristal maximal size. By default, thus value are set for the ECAL cristal.
85  float cristalPhiEtaMaxSize_ = 0.04;
86  float cristalXYMaxSize_ = 3.;
87 
88  // Usually, phi is between -Pi and +Pi. But phi space is circular, that's why an element
89  // with phi = 3.13 and another with phi = -3.14 are close. To solve this problem, during
90  // the kdtree building step, we duplicate some elements close enough to +Pi (resp -Pi) by
91  // substracting (adding) 2Pi. This field define the threshold of this operation.
92  float phiOffset_ = 0.25;
93 
94  // Debug boolean. Not used until now.
95  bool debug_ = false;
96 };
97 
98 
99 
100 
103 
104 #endif /* !KDTreeLinkerBase_h */
void setFieldType(const reco::PFBlockElement::Type &fld)
std::set< reco::PFBlockElement * > BlockEltSet
Abstract base class for a PFBlock element (track, cluster...)
virtual void updatePFBlockEltWithLinks()=0
edmplugin::PluginFactory< KDTreeLinkerBase *() > KDTreeLinkerFactory
reco::PFBlockElement::Type _fieldType
void setTargetType(const reco::PFBlockElement::Type &tgt)
std::map< const reco::PFRecHit *, BlockEltSet > RecHit2BlockEltMap
std::map< reco::PFBlockElement *, BlockEltSet > BlockElt2BlockEltMap
void setDebug(bool isDebug)
virtual void buildTree()=0
virtual void insertFieldClusterElt(reco::PFBlockElement *cluster)=0
virtual ~KDTreeLinkerBase()
const reco::PFBlockElement::Type & targetType() const
std::set< const reco::PFRecHit * > RecHitSet
virtual void clear()=0
const reco::PFBlockElement::Type & fieldType() const
virtual void searchLinks()=0
virtual void insertTargetElt(reco::PFBlockElement *target)=0
reco::PFBlockElement::Type _targetType