CMS 3D CMS Logo

FTLRecHit.cc
Go to the documentation of this file.
3 #include <cassert>
4 #include <cmath>
5 #include <limits>
6 
7 namespace {
8  constexpr float timereso_max = 10000;
9 }
10 
12  : id_(DetId()),
13  energy_(-1.f),
14  time_(-1.f),
15  timeError_(-1.f),
16  row_(0),
17  column_(0),
18  flagBits_(std::numeric_limits<unsigned char>::max()) {}
19 
20 FTLRecHit::FTLRecHit(const DetId& id, float energy, float time, float timeError, uint32_t flagBits)
21  : id_(id), energy_(energy), time_(time), timeError_(timeError), row_(0), column_(0), flagBits_(flagBits) {}
22 
24  const DetId& id, uint8_t row, uint8_t column, float energy, float time, float timeError, uint32_t flagBits)
25  : id_(id), energy_(energy), time_(time), timeError_(timeError), row_(row), column_(column), flagBits_(flagBits) {}
26 
27 bool FTLRecHit::isTimeValid() const {
28  if (timeError() < 0)
29  return false;
30  else
31  return true;
32 }
33 
35  if (!isTimeValid())
36  return false;
37  if (timeError() >= timereso_max)
38  return false;
39 
40  return true;
41 }
42 
44 bool FTLRecHit::checkFlags(const std::vector<int>& flagsvec) const {
45  for (std::vector<int>::const_iterator flagPtr = flagsvec.begin(); flagPtr != flagsvec.end();
46  ++flagPtr) { // check if one of the flags is up
47  if (checkFlag(*flagPtr))
48  return true;
49  }
50  return false;
51 }
52 
53 std::ostream& operator<<(std::ostream& s, const FTLRecHit& hit) {
54  if (hit.detid().det() == DetId::Forward && hit.detid().subdetId() == FastTime)
55  return s << FastTimeDetId(hit.detid()) << ": " << hit.energy() << " GeV, " << hit.time() << " ns";
56  else
57  return s << "FTLRecHit undefined subdetector";
58 }
int row() const
Definition: FTLRecHit.h:54
const DetId & detid() const
Definition: FTLRecHit.h:50
bool checkFlag(int flag) const
check if the flag is true
Definition: FTLRecHit.h:71
unsigned char flagBits_
store rechit condition (see Flags enum) in a bit-wise way
Definition: FTLRecHit.h:82
uint8_t column_
Definition: FTLRecHit.h:79
float timeError() const
Definition: FTLRecHit.h:63
float energy() const
get the id
Definition: FTLRecHit.h:46
std::ostream & operator<<(std::ostream &s, const FTLRecHit &hit)
Definition: FTLRecHit.cc:53
float time_
Definition: FTLRecHit.h:78
bool isTimeErrorValid() const
Definition: FTLRecHit.cc:34
bool checkFlags(const std::vector< int > &flagsvec) const
check if one of the flags in a set is true
Definition: FTLRecHit.cc:44
float time() const
Definition: FTLRecHit.h:57
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
double f[11][100]
float timeError_
Definition: FTLRecHit.h:78
int column() const
Definition: FTLRecHit.h:55
float energy_
Definition: FTLRecHit.h:78
DetId id_
Definition: FTLRecHit.h:77
Definition: DetId.h:17
uint8_t row_
Definition: FTLRecHit.h:79
bool isTimeValid() const
Definition: FTLRecHit.cc:27
#define constexpr
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46