Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CTPPSDigi_CTPPSDiamondDigi_h
0002 #define CTPPSDigi_CTPPSDiamondDigi_h
0003 
0004 /** \class CTPPSDiamondDigi
0005  *
0006  * Digi Class for CTPPS Timing Detector
0007  *
0008  *
0009  * \author Seyed Mohsen Etesami
0010  * March 2016
0011  */
0012 
0013 #include <cstdint>
0014 #include "DataFormats/CTPPSDigi/interface/HPTDCErrorFlags.h"
0015 
0016 class CTPPSDiamondDigi {
0017 public:
0018   CTPPSDiamondDigi(
0019       unsigned int ledgt_, unsigned int tedgt_, unsigned int threvolt, bool mhit_, unsigned short hptdcerror_);
0020   CTPPSDiamondDigi();
0021   ~CTPPSDiamondDigi(){};
0022 
0023   /// Digis are equal if they are have same  ledt and tedt, threshold voltage, multihit flag, hptdcerror flags
0024   bool operator==(const CTPPSDiamondDigi& digi) const;
0025 
0026   /// Return digi values number
0027 
0028   unsigned int leadingEdge() const { return ledgt; }
0029 
0030   unsigned int trailingEdge() const { return tedgt; }
0031 
0032   unsigned int thresholdVoltage() const { return threvolt; }
0033 
0034   bool multipleHit() const { return mhit; }
0035 
0036   HPTDCErrorFlags hptdcErrorFlags() const { return hptdcerror; }
0037 
0038   /// Set digi values
0039   inline void setLeadingEdge(unsigned int ledgt_) { ledgt = ledgt_; }
0040   inline void setTrailingEdge(unsigned int tedgt_) { tedgt = tedgt_; }
0041   inline void setThresholdVoltage(unsigned int threvolt_) { threvolt = threvolt_; }
0042   inline void setMultipleHit(bool mhit_) { mhit = mhit_; }
0043   inline void setHPTDCErrorFlags(const HPTDCErrorFlags& hptdcerror_) { hptdcerror = hptdcerror_; }
0044 
0045 private:
0046   // variable represents leading edge time
0047   unsigned int ledgt;
0048   // variable   represents trailing edge time
0049   unsigned int tedgt;
0050   // variable represents threshold voltage
0051   unsigned int threvolt;
0052   // variable represents multi-hit
0053   bool mhit;
0054   HPTDCErrorFlags hptdcerror;
0055 };
0056 
0057 #include <iostream>
0058 
0059 inline bool operator<(const CTPPSDiamondDigi& one, const CTPPSDiamondDigi& other) {
0060   if (one.leadingEdge() < other.leadingEdge())
0061     return true;
0062   if (one.leadingEdge() > other.leadingEdge())
0063     return false;
0064   if (one.trailingEdge() < other.trailingEdge())
0065     return true;
0066   if (one.trailingEdge() > other.trailingEdge())
0067     return false;
0068   if (one.multipleHit() < other.multipleHit())
0069     return true;
0070   if (one.multipleHit() > other.multipleHit())
0071     return false;
0072   if (one.hptdcErrorFlags().errorFlag() < other.hptdcErrorFlags().errorFlag())
0073     return true;
0074   if (one.hptdcErrorFlags().errorFlag() > other.hptdcErrorFlags().errorFlag())
0075     return false;
0076   if (one.thresholdVoltage() < other.thresholdVoltage())
0077     return true;
0078   if (one.thresholdVoltage() > other.thresholdVoltage())
0079     return false;
0080   return false;
0081 }
0082 
0083 inline std::ostream& operator<<(std::ostream& o, const CTPPSDiamondDigi& digi) {
0084   return o << " " << digi.leadingEdge() << " " << digi.trailingEdge() << " " << digi.thresholdVoltage() << " "
0085            << digi.multipleHit() << " " << digi.hptdcErrorFlags().errorFlag();
0086 }
0087 
0088 #endif