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 
11 FTLRecHit::FTLRecHit() : id_(DetId()), energy_(-1.f), time_(-1.f), timeError_(-1.f), row_(0), column_(0), flagBits_(std::numeric_limits<unsigned char>::max())
12 {}
13 
14 FTLRecHit::FTLRecHit(const DetId& id, float energy, float time, float timeError, uint32_t flagBits) :
15  id_(id), energy_(energy), time_(time), timeError_(timeError), row_(0), column_(0), flagBits_(flagBits)
16 {}
17 
18 FTLRecHit::FTLRecHit(const DetId& id, uint8_t row, uint8_t column, float energy,
19  float time, float timeError, uint32_t flagBits) :
20  id_(id), energy_(energy), time_(time), timeError_(timeError), row_(row), column_(column), flagBits_(flagBits)
21 {}
22 
23 bool FTLRecHit::isTimeValid() const {
24  if(timeError() < 0)
25  return false;
26  else
27  return true;
28 }
29 
31  if(!isTimeValid())
32  return false;
33  if(timeError() >= timereso_max)
34  return false;
35 
36  return true;
37 }
38 
40 bool FTLRecHit::checkFlags(const std::vector<int>& flagsvec ) const {
41 
42  for (std::vector<int>::const_iterator flagPtr = flagsvec.begin();
43  flagPtr!= flagsvec.end(); ++flagPtr) { // check if one of the flags is up
44  if (checkFlag(*flagPtr)) return true;
45  }
46  return false;
47 }
48 
49 
50 std::ostream& operator<<(std::ostream& s, const FTLRecHit& hit) {
51  if (hit.detid().det() == DetId::Forward && hit.detid().subdetId() == FastTime)
52  return s << FastTimeDetId(hit.detid()) << ": " << hit.energy() << " GeV, " << hit.time() << " ns";
53  else
54  return s << "FTLRecHit undefined subdetector" ;
55 }
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:84
uint8_t column_
Definition: FTLRecHit.h:81
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:50
float time_
Definition: FTLRecHit.h:80
bool isTimeErrorValid() const
Definition: FTLRecHit.cc:30
bool checkFlags(const std::vector< int > &flagsvec) const
check if one of the flags in a set is true
Definition: FTLRecHit.cc:40
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:41
double f[11][100]
float timeError_
Definition: FTLRecHit.h:80
int column() const
Definition: FTLRecHit.h:55
float energy_
Definition: FTLRecHit.h:80
DetId id_
Definition: FTLRecHit.h:79
Definition: DetId.h:18
uint8_t row_
Definition: FTLRecHit.h:81
bool isTimeValid() const
Definition: FTLRecHit.cc:23
#define constexpr
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39