Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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