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