Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-10 02:34:31

0001 /*! \class   TTStub
0002  *  \brief   Class to store the L1 Track Trigger stubs
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 Andrew W. Rose
0009  *  \author Nicola Pozzobon
0010  *  \date   2013, Jul 12
0011  *
0012  */
0013 
0014 #ifndef L1_TRACK_TRIGGER_STUB_FORMAT_H
0015 #define L1_TRACK_TRIGGER_STUB_FORMAT_H
0016 
0017 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0018 #include "DataFormats/L1TrackTrigger/interface/TTCluster.h"
0019 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0020 
0021 template <typename T>
0022 class TTStub {
0023 public:
0024   /// Constructors
0025   TTStub();
0026   TTStub(DetId aDetId);
0027 
0028   /// Destructor
0029   ~TTStub();
0030 
0031   /// Data members:   aBc( ... )
0032   /// Helper methods: findAbc( ... )
0033 
0034   /// Clusters composing the Stub -- see https://twiki.cern.ch/twiki/bin/viewauth/CMS/SLHCTrackerTriggerSWTools#TTCluster
0035 
0036   /// Returns the permanent references of the cluster in the sensor stack identified by hitStackMember
0037   /// which should be either 0 or 1 for the innermost and outermost sensor, respectively
0038   const edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> >& clusterRef(unsigned int hitStackMember) const;
0039 
0040   /// Add a cluster reference, depending on which stack member it is on (inner = 0, outer = 1)
0041   void addClusterRef(edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> > aTTCluster);
0042 
0043   /// Detector element
0044   DetId getDetId() const { return theDetId; }
0045   void setDetId(DetId aDetId) { theDetId = aDetId; }
0046 
0047   /// Trigger information; see, e.g., TTStubAlgorithm_official::PatternHitCorrelation for definitions
0048   /// Values are passed back from there via the TTStubBuilder, be careful to choose the right one.
0049   /// In particular note the difference between values passed as "full" strip units (i.e. the strip
0050   /// number or difference between strip numbers) and "half" strip units, which have a 2X finer granularity.
0051 
0052   /// RawBend() [rename of getTriggerDisplacement()]: In FULL strip units!
0053   /// Returns the relative displacement between the two cluster centroids, i.e.
0054   /// the difference between average row coordinates in inner and outer stack member,
0055   /// in terms of outer member pitch (if both pitches are the same, this is just the coordinate difference).
0056   /// Flag for rejected stubs: +500 if rejected by FE, +1000 if rejected by CIC chip.
0057   double rawBend() const;
0058 
0059   /// setRawBend [rename of setTriggerDisplacement()]: In HALF strip units!
0060   /// Sets relative displacement between the two cluster centroids, as above.
0061   /// Flag for rejected stubs: +500 if rejected by FE, +1000 if rejected by CIC chip.
0062   /// NB: Should probably only be used in TTStubBuilder or very similar.
0063   void setRawBend(int aDisplacement);
0064 
0065   /// BendOffset() [rename of getTriggerOffset()]: In FULL strip units!
0066   /// Returns the correction offset calculated while accepting/rejecting the stub
0067   /// Offset is the projection of a straight line from the beam-spot through the innermost hit
0068   /// to the outermost stack member, again in terms of outer member pitch.  It is calculated
0069   /// taking the centre of the module at (NROWS/2)-0.5.
0070 
0071   double bendOffset() const;
0072 
0073   /// setBendOffset() [rename of setTriggerOffset()]: In HALF strip units!
0074   /// Again restricted to builder code.
0075   void setBendOffset(int anOffset);
0076 
0077   /// set whether this is a PS module or not;
0078   void setModuleTypePS(bool isPSModule);
0079 
0080   /// check if a PS module
0081   bool moduleTypePS() const;
0082 
0083   /// CBC3-style trigger information
0084   /// for sake of simplicity, these methods are
0085   /// slightly out of the ABC(...)/findABC(...) rule
0086 
0087   /// InnerClusterPosition() [rename of getTriggerPosition()]: In FULL strip units!
0088   /// Returns the average local x coordinate of hits in the inner stack member
0089   double innerClusterPosition() const;
0090 
0091   /// BendFE(): In FULL-STRIP units from FE! Rename of getTriggerBend()
0092   double bendFE() const;
0093 
0094   /// BendBE(): In FULL-STRIP units! Reduced resolution from BE boards.  Rename of getHardwareBend()
0095   double bendBE() const;
0096 
0097   ///  setBendBE(): In HALF-STRIP units!  Reduced resolution in BE boards.  Rename of setHardwareBend()
0098   void setBendBE(float aBend);
0099 
0100   /// Print Stub information for debugging purposes
0101   std::string print(unsigned int i = 0) const;
0102 
0103 private:
0104   /// Data members
0105   DetId theDetId;
0106   edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> > theClusterRef0;
0107   edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> > theClusterRef1;
0108   int theDisplacement;
0109   int theOffset;
0110   float theBendBE;
0111   bool thePSModule;
0112 
0113   static constexpr float dummyBend = 999999;  // Dumy value should be away from potential bends
0114 };                                            /// Close class
0115 
0116 /*! \brief   Implementation of methods
0117  *  \details Here, in the header file, the methods which do not depend
0118  *           on the specific type <T> that can fit the template.
0119  *           Other methods, with type-specific features, are implemented
0120  *           in the source file.
0121  */
0122 
0123 /// Default Constructor
0124 template <typename T>
0125 TTStub<T>::TTStub() {
0126   /// Set default data members
0127   theDetId = 0;
0128   theDisplacement = dummyBend;
0129   theOffset = 0;
0130   theBendBE = dummyBend;
0131 }
0132 
0133 /// Another Constructor using a given DetId
0134 template <typename T>
0135 TTStub<T>::TTStub(DetId aDetId) {
0136   /// Set data members
0137   this->setDetId(aDetId);
0138 
0139   /// Set default data members
0140   theDisplacement = dummyBend;
0141   theOffset = 0;
0142   theBendBE = dummyBend;
0143 }
0144 
0145 /// Destructor
0146 template <typename T>
0147 TTStub<T>::~TTStub() {}
0148 
0149 template <typename T>
0150 const edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> >& TTStub<T>::clusterRef(
0151     unsigned int hitStackMember) const {
0152   return (hitStackMember == 0) ? theClusterRef0 : theClusterRef1;
0153 }
0154 
0155 template <typename T>
0156 void TTStub<T>::addClusterRef(edm::Ref<edmNew::DetSetVector<TTCluster<T> >, TTCluster<T> > aTTCluster) {
0157   if (aTTCluster->getStackMember() == 0)
0158     theClusterRef0 = aTTCluster;
0159   else if (aTTCluster->getStackMember() == 1)
0160     theClusterRef1 = aTTCluster;
0161 }
0162 
0163 /// Trigger info
0164 template <typename T>
0165 double TTStub<T>::rawBend() const {
0166   return 0.5 * theDisplacement;
0167 }
0168 
0169 template <typename T>
0170 void TTStub<T>::setRawBend(int aDisplacement) {
0171   theDisplacement = aDisplacement;
0172 }
0173 
0174 template <typename T>
0175 double TTStub<T>::bendOffset() const {
0176   return 0.5 * theOffset;
0177 }
0178 
0179 template <typename T>
0180 void TTStub<T>::setBendOffset(int anOffset) {
0181   theOffset = anOffset;
0182 }
0183 
0184 template <typename T>
0185 void TTStub<T>::setBendBE(float aBend) {
0186   theBendBE = aBend;
0187 }
0188 
0189 template <typename T>
0190 void TTStub<T>::setModuleTypePS(bool isPSModule) {
0191   thePSModule = isPSModule;
0192 }  // set whether this is a PS module or not;
0193 template <typename T>
0194 bool TTStub<T>::moduleTypePS() const {
0195   return thePSModule;
0196 }  // check if a PS module
0197 template <typename T>
0198 double TTStub<T>::innerClusterPosition() const {
0199   return this->clusterRef(0)->findAverageLocalCoordinates().x();  //CBC3-style trigger info
0200 }
0201 
0202 template <typename T>
0203 double TTStub<T>::bendFE() const {
0204   if (theDisplacement == dummyBend)
0205     return theDisplacement;
0206 
0207   return 0.5 * (theDisplacement - theOffset);
0208 }
0209 
0210 template <typename T>
0211 double TTStub<T>::bendBE() const {
0212   if (theBendBE == dummyBend)
0213     return this->bendFE();  // If not set make it transparent
0214 
0215   return theBendBE;
0216 }
0217 
0218 /// Information
0219 template <typename T>
0220 std::string TTStub<T>::print(unsigned int i) const {
0221   std::string padding("");
0222   for (unsigned int j = 0; j != i; ++j) {
0223     padding += "\t";
0224   }
0225 
0226   std::stringstream output;
0227   output << padding << "TTStub:\n";
0228   padding += '\t';
0229   output << padding << "DetId: " << theDetId.rawId() << ", position: " << this->innerClusterPosition();
0230   output << ", bend: " << this->bendFE() << '\n';
0231   output << ", hardware bend: " << this->bendBE() << '\n';
0232   output << padding << "cluster 0: address: " << theClusterRef0.get();
0233   output << ", cluster size: " << theClusterRef0->getHits().size() << '\n';
0234   output << padding << "cluster 1: address: " << theClusterRef1.get();
0235   output << ", cluster size: " << theClusterRef1->getHits().size() << '\n';
0236   return output.str();
0237 }
0238 
0239 template <typename T>
0240 std::ostream& operator<<(std::ostream& os, const TTStub<T>& aTTStub) {
0241   return (os << aTTStub.print());
0242 }
0243 
0244 #endif