CbmRoot
CbmTofPoint.cxx
Go to the documentation of this file.
1 
8 #include "CbmTofPoint.h"
9 
10 #include <FairMCPoint.h> // for FairMCPoint
11 
12 #include <TVector3.h> // for TVector3
13 
14 #include <bitset> // for bitset
15 #include <cassert> // for assert
16 #include <limits> // for numeric_limits, numeric_limits<>::digits
17 #include <sstream> // for operator<<, basic_ostream, stringstream
18 #include <string> // for char_traits
19 
20 using std::endl;
21 using std::string;
22 using std::stringstream;
23 
24 
25 // ----- Default constructor -------------------------------------------
26 CbmTofPoint::CbmTofPoint() : FairMCPoint(), fNofCells(0), fGapMask(0) {}
27 // -------------------------------------------------------------------------
28 
29 
30 // ----- Standard constructor ------------------------------------------
32  Int_t detID,
33  TVector3 pos,
34  TVector3 mom,
35  Double_t tof,
36  Double_t length,
37  Double_t eLoss)
38  : FairMCPoint(trackID, detID, pos, mom, tof, length, eLoss)
39  , fNofCells(0)
40  , fGapMask(0) {}
41 // -------------------------------------------------------------------------
42 
43 
44 // ----- Destructor ----------------------------------------------------
46 // -------------------------------------------------------------------------
47 
48 
49 // ----- Get the number of gaps ----------------------------------------
50 Int_t CbmTofPoint::GetNGaps() const {
51  Int_t iNGaps(0);
52 
53  for (Int_t iGapBit = 0; iGapBit < std::numeric_limits<UShort_t>::digits;
54  iGapBit++) {
55  if (fGapMask & (0x1 << iGapBit)) { iNGaps++; }
56  }
57 
58  return iNGaps;
59 }
60 // -------------------------------------------------------------------------
61 
62 
63 // ----- Get the index of the first gap --------------------------------
64 Int_t CbmTofPoint::GetFirstGap() const {
65  for (Int_t iGapBit = 0; iGapBit < std::numeric_limits<UShort_t>::digits;
66  iGapBit++) {
67  if (fGapMask & (0x1 << iGapBit)) { return iGapBit; }
68  }
69 
70  return -1;
71 }
72 // -------------------------------------------------------------------------
73 
74 
75 // ----- Get the index of the last gap ---------------------------------
76 Int_t CbmTofPoint::GetLastGap() const {
77  Int_t iLastGap(-1);
78 
79  for (Int_t iGapBit = 0; iGapBit < std::numeric_limits<UShort_t>::digits;
80  iGapBit++) {
81  if (fGapMask & (0x1 << iGapBit)) { iLastGap = iGapBit; }
82  }
83 
84  return iLastGap;
85 }
86 // -------------------------------------------------------------------------
87 
88 
89 // ----- Add one gap to the gap mask -----------------------------------
90 void CbmTofPoint::SetGap(Int_t iGap) {
91  assert(0 <= iGap && std::numeric_limits<UShort_t>::digits > iGap);
92  fGapMask |= 0x1 << iGap;
93 }
94 // -------------------------------------------------------------------------
95 
96 
97 // ----- String output -------------------------------------------------
98 string CbmTofPoint::ToString() const {
99  stringstream ss;
100  ss << "STofPoint: track ID " << fTrackID << ", detector ID " << fDetectorID
101  << "\n";
102  ss << " Position (" << fX << ", " << fY << ", " << fZ << ") cm \n";
103  ss << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV \n";
104  ss << " Time " << fTime << " ns, Length " << fLength
105  << " cm, Energy loss " << fELoss * 1.0e06 << " keV \n";
106  ss << " Number of cells " << fNofCells << ", gap mask "
107  << std::bitset<std::numeric_limits<UShort_t>::digits>(fGapMask) << endl;
108  return ss.str();
109 }
110 // -------------------------------------------------------------------------
111 
CbmTofPoint::fNofCells
Int_t fNofCells
Definition: CbmTofPoint.h:130
CbmTofPoint::~CbmTofPoint
virtual ~CbmTofPoint()
Destructor.
Definition: CbmTofPoint.cxx:45
CbmTofPoint::ToString
virtual std::string ToString() const
String representation of the object. @value String representation of the object.
Definition: CbmTofPoint.cxx:98
CbmTofPoint::GetLastGap
Int_t GetLastGap() const
Index of last traversed gap @value Last gap index.
Definition: CbmTofPoint.cxx:76
CbmTofPoint::fGapMask
UShort_t fGapMask
Number of cells traversed.
Definition: CbmTofPoint.h:131
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmTofPoint::GetNGaps
Int_t GetNGaps() const
Number of traversed gaps @value Number of traversed gaps.
Definition: CbmTofPoint.cxx:50
CbmTofPoint::CbmTofPoint
CbmTofPoint()
Default constructor.
Definition: CbmTofPoint.cxx:26
CbmTofPoint::SetGap
void SetGap(Int_t iGap)
Set a gap in the gap mask.
Definition: CbmTofPoint.cxx:90
CbmTofPoint.h
CbmTofPoint::GetFirstGap
Int_t GetFirstGap() const
Index of first traversed gap @value First gap index.
Definition: CbmTofPoint.cxx:64
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
CbmTofPoint
Geometric intersection of a MC track with a TOFb detector.
Definition: CbmTofPoint.h:40