Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:00

0001 /*! \class   TTClusterAlgorithm_neighbor
0002  *  \brief   Class for "neighbor" algorithm to be used
0003  *           in TTClusterBuilder
0004  *  \details This is a greedy clustering to be
0005  *           used for diagnostic purposes, which
0006  *           will make clusters as large as
0007  *           possible by including all contiguous
0008  *           hits in a single cluster.
0009  *           After moving from SimDataFormats to DataFormats,
0010  *           the template structure of the class was maintained
0011  *           in order to accomodate any types other than PixelDigis
0012  *           in case there is such a need in the future.
0013  *
0014  *  \author Kristofer Henriksson
0015  *  \date   2013, Jul 15
0016  *
0017  */
0018 
0019 #ifndef CLUSTERING_ALGORITHM_NEIGHBOR_H
0020 #define CLUSTERING_ALGORITHM_NEIGHBOR_H
0021 
0022 #include "FWCore/Framework/interface/EventSetup.h"
0023 #include "FWCore/Framework/interface/ESHandle.h"
0024 #include "FWCore/Framework/interface/ModuleFactory.h"
0025 #include "FWCore/Framework/interface/ESProducer.h"
0026 
0027 #include "L1Trigger/TrackTrigger/interface/TTClusterAlgorithm.h"
0028 #include "L1Trigger/TrackTrigger/interface/TTClusterAlgorithmRecord.h"
0029 
0030 #include <string>
0031 #include <cstdlib>
0032 #include <map>
0033 
0034 template <typename T>
0035 class TTClusterAlgorithm_neighbor : public TTClusterAlgorithm<T> {
0036 private:
0037   /// Data members
0038   /// Other stuff
0039 
0040 public:
0041   /// Constructor
0042   TTClusterAlgorithm_neighbor() : TTClusterAlgorithm<T>(__func__) {}
0043 
0044   /// Destructor
0045   ~TTClusterAlgorithm_neighbor() override {}
0046 
0047   /// Clustering operations
0048   void Cluster(std::vector<std::vector<T> >& output, const std::vector<T>& input) const override;
0049 
0050   /// Needed for neighbours
0051   bool isANeighbor(const T& center, const T& mayNeigh) const;
0052   void addNeighbors(std::vector<T>& cluster,
0053                     const std::vector<T>& input,
0054                     unsigned int start,
0055                     std::vector<bool>& masked) const;
0056 
0057 };  /// Close class
0058 
0059 /*! \brief   Implementation of methods
0060  *  \details Here, in the header file, the methods which do not depend
0061  *           on the specific type <T> that can fit the template.
0062  *           Other methods, with type-specific features, are implemented
0063  *           in the source file.
0064  */
0065 
0066 /// Clustering operations
0067 template <>
0068 void TTClusterAlgorithm_neighbor<Ref_Phase2TrackerDigi_>::Cluster(
0069     std::vector<std::vector<Ref_Phase2TrackerDigi_> >& output, const std::vector<Ref_Phase2TrackerDigi_>& input) const;
0070 
0071 /// Check if the hit is a neighbour
0072 template <>
0073 bool TTClusterAlgorithm_neighbor<Ref_Phase2TrackerDigi_>::isANeighbor(const Ref_Phase2TrackerDigi_& center,
0074                                                                       const Ref_Phase2TrackerDigi_& mayNeigh) const;
0075 
0076 /// Add neighbours to the cluster
0077 template <>
0078 void TTClusterAlgorithm_neighbor<Ref_Phase2TrackerDigi_>::addNeighbors(std::vector<Ref_Phase2TrackerDigi_>& cluster,
0079                                                                        const std::vector<Ref_Phase2TrackerDigi_>& input,
0080                                                                        unsigned int startVal,
0081                                                                        std::vector<bool>& used) const;
0082 
0083 /*! \class   ES_TTClusterAlgorithm_neighbor
0084  *  \brief   Class to declare the algorithm to the framework
0085  *
0086  *  \author Kristofer Henriksson
0087  *  \date   2013, Jul 15
0088  *
0089  */
0090 
0091 template <typename T>
0092 class ES_TTClusterAlgorithm_neighbor : public edm::ESProducer {
0093 private:
0094   /// Data members
0095 
0096 public:
0097   /// Constructor
0098   ES_TTClusterAlgorithm_neighbor(const edm::ParameterSet& p) { setWhatProduced(this); }
0099 
0100   /// Destructor
0101   ~ES_TTClusterAlgorithm_neighbor() override {}
0102 
0103   /// Implement the producer
0104   std::unique_ptr<TTClusterAlgorithm<T> > produce(const TTClusterAlgorithmRecord& record) {
0105     TTClusterAlgorithm<T>* TTClusterAlgo = new TTClusterAlgorithm_neighbor<T>();
0106 
0107     return std::unique_ptr<TTClusterAlgorithm<T> >(TTClusterAlgo);
0108   }
0109 
0110 };  /// Close class
0111 
0112 #endif