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