Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:15

0001 #ifndef RecoParticleFlow_PFAlgo_PFBlock_h
0002 #define RecoParticleFlow_PFAlgo_PFBlock_h
0003 
0004 #include <map>
0005 #include <iostream>
0006 
0007 /* #include "boost/graph/adjacency_matrix.hpp" */
0008 
0009 // #include "DataFormats/ParticleFlowReco/interface/PFBlockLink.h"
0010 #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
0011 // #include "DataFormats/ParticleFlowReco/interface/PFBlockParticle.h"
0012 #include "DataFormats/Common/interface/OwnVector.h"
0013 
0014 namespace reco {
0015 
0016   /// \brief Block of elements
0017   /*!
0018     \author Colin Bernet
0019     \date January 2006
0020 
0021     A PFBlock is: 
0022     - a set of topologically connected elements.
0023     - a set of links between these elements
0024   */
0025 
0026   class PFBlock {
0027   public:
0028     struct Link {
0029       Link() : distance(-1), test(0) {}
0030       Link(float d, char t) : distance(d), test(t) {}
0031       float distance;
0032       char test;
0033     };
0034 
0035     typedef edm::OwnVector<reco::PFBlockElement>::const_iterator IE;
0036     /*     typedef std::vector< reco::PFBlockLink >::const_iterator IL; */
0037 
0038     // typedef std::vector< std::vector<double> > LinkData;
0039     typedef std::map<unsigned int, Link> LinkData;
0040 
0041     enum LinkTest { LINKTEST_RECHIT, LINKTEST_NLINKTEST, LINKTEST_ALL };
0042 
0043     PFBlock() {}
0044     // PFBlock(const PFBlock& other);
0045 
0046     /// add an element to the current PFBlock
0047     /// the block will keep a copy.
0048     void addElement(reco::PFBlockElement* element);
0049 
0050     void bookLinkData();
0051 
0052     /// makes the correspondance between a 2d element matrix and
0053     /// the 1D vector which is the most compact way to store the matrix
0054     bool matrix2vector(unsigned i, unsigned j, unsigned& index) const;
0055 
0056     /// set a link between elements of indices i1 and i2, of "distance" dist
0057     /// the link is set in the linkData vector provided as an argument.
0058     /// As indicated by the 'const' statement, 'this' is not modified.
0059     void setLink(unsigned i1, unsigned i2, double dist, LinkData& linkData, LinkTest test = LINKTEST_RECHIT) const;
0060 
0061     /// lock an element ( unlink it from the others )
0062     /// Colin: this function is misleading
0063     /// void lock(unsigned i, LinkData& linkData ) const;
0064 
0065     /// fills a map with the elements associated to element i.
0066     /// elements are sorted by increasing distance.
0067     /// if specified, only the elements of type "type" will be considered
0068     /// if specified, only the link calculated from a certain "test" will
0069     /// be considered: distance test, etc..
0070     void associatedElements(unsigned i,
0071                             const LinkData& linkData,
0072                             std::multimap<double, unsigned>& sortedAssociates,
0073                             reco::PFBlockElement::Type type = PFBlockElement::NONE,
0074                             LinkTest test = LINKTEST_RECHIT) const;
0075 
0076     /// \return distance of link
0077     double dist(unsigned ie1, unsigned ie2, const LinkData& linkData, LinkTest test) const {
0078       return dist(ie1, ie2, linkData);
0079     }
0080 
0081     /// \return distance of link
0082     double dist(unsigned ie1, unsigned ie2, const LinkData& linkData) const;
0083 
0084     /// \return elements
0085     const edm::OwnVector<reco::PFBlockElement>& elements() const { return elements_; }
0086 
0087     /// \return link data
0088     const LinkData& linkData() const { return linkData_; }
0089 
0090     /// \return link data
0091     LinkData& linkData() { return linkData_; }
0092 
0093   private:
0094     /// \return size of linkData_, calculated from the number of elements
0095     unsigned linkDataSize() const;
0096 
0097     /// link data (permanent)
0098     LinkData linkData_;
0099 
0100     /// all elements
0101     edm::OwnVector<reco::PFBlockElement> elements_;
0102   };
0103 
0104   std::ostream& operator<<(std::ostream& out, const PFBlock& co);
0105 
0106 }  // namespace reco
0107 
0108 #endif