CMS 3D CMS Logo

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