Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:37

0001 /*! \class   TTCluster
0002  *  \brief   Class to store the L1 Track Trigger clusters
0003  *  \details After moving from SimDataFormats to DataFormats,
0004  *           the template structure of the class was maintained
0005  *           in order to accomodate any types other than Phase2TrackerDigis
0006  *           in case there is such a need in the future.
0007  *
0008  *  \author Nicola Pozzobon
0009  *  \author Emmanuele Salvati
0010  *  \date   2013, Jul 12
0011  *
0012  */
0013 
0014 #ifndef L1_TRACK_TRIGGER_CLUSTER_FORMAT_H
0015 #define L1_TRACK_TRIGGER_CLUSTER_FORMAT_H
0016 
0017 #include "DataFormats/Common/interface/Ref.h"
0018 #include "DataFormats/Common/interface/Ptr.h"
0019 #include "DataFormats/Common/interface/DetSet.h"
0020 #include "DataFormats/Common/interface/DetSetVector.h"
0021 #include "DataFormats/DetId/interface/DetId.h"
0022 #include "DataFormats/Phase2TrackerDigi/interface/Phase2TrackerDigi.h"
0023 #include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementPoint.h"
0024 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"  /// NOTE: this is needed even if it seems not
0025 
0026 template <typename T>
0027 class TTCluster {
0028 public:
0029   /// Constructors
0030   TTCluster();
0031   TTCluster(std::vector<T> aHits, DetId aDetId, unsigned int aStackMember, bool storeLocal);
0032 
0033   /// Destructor
0034   ~TTCluster();
0035 
0036   /// Data members:   getABC( ... )
0037   /// Helper methods: findABC( ... )
0038 
0039   /// Hits in the Cluster
0040   std::vector<T> getHits() const { return theHits; }
0041   void setHits(std::vector<T> aHits) { theHits = aHits; }
0042 
0043   /// Detector element
0044   DetId getDetId() const { return theDetId; }
0045   void setDetId(DetId aDetId) { theDetId = aDetId; }
0046   unsigned int getStackMember() const { return theStackMember; }
0047   void setStackMember(unsigned int aStackMember) { theStackMember = aStackMember; }
0048 
0049   /// Rows and columns to get rid of Digi collection
0050   std::vector<int> findRows() const;
0051   std::vector<int> findCols() const;
0052   void setCoordinates(std::vector<int> a, std::vector<int> b) {
0053     theRows = a;
0054     theCols = b;
0055   }
0056   std::vector<int> getRows() const { return theRows; }
0057   std::vector<int> getCols() const { return theCols; }
0058 
0059   /// Cluster width
0060   unsigned int findWidth() const;
0061 
0062   /// Single hit coordinates
0063   /// Average cluster coordinates
0064   MeasurementPoint findHitLocalCoordinates(unsigned int hitIdx) const;
0065   MeasurementPoint findAverageLocalCoordinates() const;
0066   MeasurementPoint findAverageLocalCoordinatesCentered() const;
0067 
0068   /// Information
0069   std::string print(unsigned int i = 0) const;
0070 
0071 private:
0072   /// Data members
0073   std::vector<T> theHits;
0074   DetId theDetId;
0075   unsigned int theStackMember;
0076 
0077   std::vector<int> theRows;
0078   std::vector<int> theCols;
0079 
0080 };  /// Close class
0081 
0082 /*! \brief   Implementation of methods
0083  *  \details Here, in the header file, the methods which do not depend
0084  *           on the specific type <T> that can fit the template.
0085  *           Other methods, with type-specific features, are implemented
0086  *           in the source file.
0087  */
0088 
0089 /// Default Constructor
0090 /// NOTE: to be used with setSomething(...) methods
0091 template <typename T>
0092 TTCluster<T>::TTCluster() {
0093   /// Set default data members
0094   theHits.clear();
0095   theDetId = 0;
0096   theStackMember = 0;
0097 
0098   theRows.clear();
0099   theCols.clear();
0100 }
0101 
0102 /// Another Constructor
0103 template <typename T>
0104 TTCluster<T>::TTCluster(std::vector<T> aHits, DetId aDetId, unsigned int aStackMember, bool storeLocal) {
0105   /// Set data members
0106   this->setHits(aHits);
0107   this->setDetId(aDetId);
0108   this->setStackMember(aStackMember);
0109 
0110   theRows.clear();
0111   theCols.clear();
0112   if (storeLocal) {
0113     this->setCoordinates(this->findRows(), this->findCols());
0114   }
0115 }
0116 
0117 /// Destructor
0118 template <typename T>
0119 TTCluster<T>::~TTCluster() {}
0120 
0121 /// Cluster width
0122 template <>
0123 unsigned int TTCluster<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::findWidth() const;
0124 
0125 /// Single hit coordinates
0126 /// Average cluster coordinates
0127 template <>
0128 MeasurementPoint TTCluster<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::findHitLocalCoordinates(
0129     unsigned int hitIdx) const;
0130 
0131 template <>
0132 MeasurementPoint
0133 TTCluster<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::findAverageLocalCoordinates() const;
0134 
0135 /// Operations with coordinates stored locally
0136 template <typename T>
0137 std::vector<int> TTCluster<T>::findRows() const {
0138   std::vector<int> temp;
0139   return temp;
0140 }
0141 
0142 template <typename T>
0143 std::vector<int> TTCluster<T>::findCols() const {
0144   std::vector<int> temp;
0145   return temp;
0146 }
0147 
0148 template <>
0149 std::vector<int> TTCluster<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::findRows() const;
0150 
0151 template <>
0152 std::vector<int> TTCluster<edm::Ref<edm::DetSetVector<Phase2TrackerDigi>, Phase2TrackerDigi> >::findCols() const;
0153 
0154 /// Information
0155 template <typename T>
0156 std::string TTCluster<T>::print(unsigned int i) const {
0157   std::string padding("");
0158   for (unsigned int j = 0; j != i; ++j) {
0159     padding += "\t";
0160   }
0161 
0162   std::stringstream output;
0163   output << padding << "TTCluster:\n";
0164   padding += '\t';
0165   output << padding << "DetId: " << theDetId.rawId() << '\n';
0166   output << padding << "member: " << theStackMember << ", cluster size: " << theHits.size() << '\n';
0167   return output.str();
0168 }
0169 
0170 template <typename T>
0171 std::ostream& operator<<(std::ostream& os, const TTCluster<T>& aTTCluster) {
0172   return (os << aTTCluster.print());
0173 }
0174 
0175 #endif