Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:24

0001 #include "DataFormats/FTLRecHit/interface/FTLUncalibratedRecHit.h"
0002 #include <cmath>
0003 #include <limits>
0004 
0005 FTLUncalibratedRecHit::FTLUncalibratedRecHit()
0006     : FTLUncalibratedRecHit(
0007           DetId(), 0, 0, {-1.f, -1.f}, {-1.f, -1.f}, -1.f, -1.f, -1.f, std::numeric_limits<unsigned char>::max()) {}
0008 
0009 FTLUncalibratedRecHit::FTLUncalibratedRecHit(const DetId& id,
0010                                              uint8_t row,
0011                                              uint8_t column,
0012                                              std::pair<float, float> ampl,
0013                                              std::pair<float, float> time,
0014                                              float timeError,
0015                                              float position,
0016                                              float positionError,
0017                                              unsigned char flags)
0018     : amplitude_(ampl),
0019       time_(time),
0020       timeError_(timeError),
0021       position_(position),
0022       positionError_(positionError),
0023       id_(id),
0024       row_(row),
0025       column_(column),
0026       flags_(flags) {}
0027 
0028 FTLUncalibratedRecHit::FTLUncalibratedRecHit(const DetId& id,
0029                                              std::pair<float, float> ampl,
0030                                              std::pair<float, float> time,
0031                                              float timeError,
0032                                              float position,
0033                                              float positionError,
0034                                              unsigned char flags)
0035     : FTLUncalibratedRecHit(id, 0, 0, ampl, time, timeError, position, positionError, flags) {}
0036 
0037 bool FTLUncalibratedRecHit::isSaturated() const { return FTLUncalibratedRecHit::checkFlag(kSaturated); }
0038 
0039 bool FTLUncalibratedRecHit::isTimeValid() const {
0040   if (timeError() < 0)
0041     return false;
0042   else
0043     return true;
0044 }
0045 
0046 bool FTLUncalibratedRecHit::isTimeErrorValid() const {
0047   if (!isTimeValid())
0048     return false;
0049   if (timeError() >= 10000)
0050     return false;
0051 
0052   return true;
0053 }
0054 
0055 void FTLUncalibratedRecHit::setFlagBit(FTLUncalibratedRecHit::Flags flag) {
0056   if (flag == kGood) {
0057     //then set all bits to zero;
0058     flags_ = 0;
0059     return;
0060   }
0061   // else set the flagbit
0062   flags_ |= 0x1 << flag;
0063 }
0064 
0065 bool FTLUncalibratedRecHit::checkFlag(FTLUncalibratedRecHit::Flags flag) const {
0066   if (flag == kGood) {
0067     if (!flags_)
0068       return true;
0069     else
0070       return false;
0071   }  // if all flags are unset, then hit is good
0072   return flags_ & (0x1 << flag);
0073 }