CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/RecoParticleFlow/PFProducer/interface/KDTreeLinkerTools.h

Go to the documentation of this file.
00001 #ifndef KDTreeLinkerTools_h
00002 #define KDTreeLinkerTools_h
00003 
00004 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h"
00005 #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
00006 
00007 #include <map>
00008 #include <set>
00009 
00010 typedef std::set<reco::PFBlockElement*>                         BlockEltSet; 
00011 typedef std::set<const reco::PFRecHit*>                         RecHitSet;
00012 
00013 typedef std::map<const reco::PFRecHit*, BlockEltSet>            RecHit2BlockEltMap;
00014 typedef std::map<reco::PFBlockElement*, BlockEltSet>            BlockElt2BlockEltMap;
00015 
00016 
00017 // Box structure used to define 2D field.
00018 // It's used in KDTree building step to divide the detector
00019 // space (ECAL, HCAL...) and in searching step to create a bounding
00020 // box around the demanded point (Track collision point, PS projection...).
00021 struct KDTreeBox
00022 {
00023   double dim1min, dim1max;
00024   double dim2min, dim2max;
00025   
00026   public:
00027 
00028   KDTreeBox(double d1min, double d1max, 
00029             double d2min, double d2max)
00030     : dim1min (d1min), dim1max(d1max)
00031     , dim2min (d2min), dim2max(d2max)
00032   {}
00033 
00034   KDTreeBox()
00035     : dim1min (0), dim1max(0)
00036     , dim2min (0), dim2max(0)
00037   {}
00038 };
00039 
00040   
00041 // Data stored in each KDTree node.
00042 // The dim1/dim2 fields are usually the duplication of some PFRecHit values
00043 // (eta/phi or x/y). But in some situations, phi field is shifted by +-2.Pi
00044 struct KDTreeNodeInfo 
00045 {
00046   const reco::PFRecHit *ptr;
00047   double dim1;
00048   double dim2;
00049   
00050   public:
00051   KDTreeNodeInfo()
00052     : ptr(0)
00053   {}
00054   
00055   KDTreeNodeInfo(const reco::PFRecHit   *rhptr,
00056                  double                 d1,
00057                  double                 d2)
00058     : ptr(rhptr), dim1(d1), dim2(d2)
00059   {}  
00060 };
00061 
00062 
00063 // KDTree node.
00064 struct KDTreeNode
00065 {
00066   // Data
00067   KDTreeNodeInfo rh;
00068   
00069   // Right/left sons.
00070   KDTreeNode *left, *right;
00071   
00072   // Region bounding box.
00073   KDTreeBox region;
00074   
00075   public:
00076   KDTreeNode()
00077     : left(0), right(0)
00078   {}
00079   
00080   void setAttributs(const KDTreeBox&            regionBox,
00081                     const KDTreeNodeInfo&       rhinfo) 
00082   {
00083     rh = rhinfo;
00084     region = regionBox;
00085   }
00086   
00087   void setAttributs(const KDTreeBox&   regionBox) 
00088   {
00089     region = regionBox;
00090   }
00091 };
00092 
00093 
00094 
00095 #endif