File indexing completed on 2024-04-06 12:04:09
0001 #include "DataFormats/FTLRecHit/interface/FTLRecHit.h"
0002 #include <cassert>
0003 #include <cmath>
0004 #include <limits>
0005
0006 namespace {
0007 constexpr float timereso_max = 10000;
0008 }
0009
0010 FTLRecHit::FTLRecHit()
0011 : FTLRecHit(DetId(), 0, 0, -1.f, -1.f, -1.f, -1.f, -1.f, std::numeric_limits<unsigned char>::max()) {}
0012
0013 FTLRecHit::FTLRecHit(const DetId& id,
0014 uint8_t row,
0015 uint8_t column,
0016 float energy,
0017 float time,
0018 float timeError,
0019 float position,
0020 float positionError,
0021 uint32_t flagBits)
0022 : id_(id),
0023 energy_(energy),
0024 time_(time),
0025 timeError_(timeError),
0026 position_(position),
0027 positionError_(positionError),
0028 row_(row),
0029 column_(column),
0030 flagBits_(flagBits) {}
0031
0032 FTLRecHit::FTLRecHit(
0033 const DetId& id, float energy, float time, float timeError, float position, float positionError, uint32_t flagBits)
0034 : FTLRecHit(id, 0, 0, energy, time, timeError, position, positionError, flagBits) {}
0035
0036 bool FTLRecHit::isTimeValid() const {
0037 if (timeError() < 0)
0038 return false;
0039 else
0040 return true;
0041 }
0042
0043 bool FTLRecHit::isTimeErrorValid() const {
0044 if (!isTimeValid())
0045 return false;
0046 if (timeError() >= timereso_max)
0047 return false;
0048
0049 return true;
0050 }
0051
0052
0053 bool FTLRecHit::checkFlags(const std::vector<int>& flagsvec) const {
0054 for (std::vector<int>::const_iterator flagPtr = flagsvec.begin(); flagPtr != flagsvec.end();
0055 ++flagPtr) {
0056 if (checkFlag(*flagPtr))
0057 return true;
0058 }
0059 return false;
0060 }
0061
0062 std::ostream& operator<<(std::ostream& s, const FTLRecHit& hit) {
0063 if (hit.detid().det() == DetId::Forward && hit.detid().subdetId() == FastTime)
0064 return s << MTDDetId(hit.detid()) << ": " << hit.energy() << " GeV, " << hit.time() << " ns";
0065 else
0066 return s << "FTLRecHit undefined subdetector";
0067 }