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
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)) { iNGaps++; }
57 }
58
59 return iNGaps;
60}
61// -------------------------------------------------------------------------
62
63
64// ----- Get the index of the first gap --------------------------------
66{
67 for (int32_t iGapBit = 0; iGapBit < std::numeric_limits<uint16_t>::digits; iGapBit++) {
68 if (fGapMask & (0x1 << iGapBit)) { return iGapBit; }
69 }
70
71 return -1;
72}
73// -------------------------------------------------------------------------
74
75
76// ----- Get the index of the last gap ---------------------------------
78{
79 int32_t iLastGap(-1);
80
81 for (int32_t iGapBit = 0; iGapBit < std::numeric_limits<uint16_t>::digits; iGapBit++) {
82 if (fGapMask & (0x1 << iGapBit)) { iLastGap = iGapBit; }
83 }
84
85 return iLastGap;
86}
87// -------------------------------------------------------------------------
88
89
90// ----- Add one gap to the gap mask -----------------------------------
91void CbmTofPoint::SetGap(int32_t iGap)
92{
93 assert(0 <= iGap && std::numeric_limits<uint16_t>::digits > iGap);
94 fGapMask |= 0x1 << iGap;
95}
96// -------------------------------------------------------------------------
97
98
99// ----- String output -------------------------------------------------
101{
102 stringstream ss;
103 ss << "STofPoint: track ID " << fTrackID << ", detector ID " << fDetectorID << "\n";
104 ss << " Position (" << fX << ", " << fY << ", " << fZ << ") cm \n";
105 ss << " Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV \n";
106 ss << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV \n";
107 ss << " Number of cells " << fNofCells << ", gap mask "
108 << std::bitset<std::numeric_limits<uint16_t>::digits>(fGapMask) << endl;
109 return ss.str();
110}
111// -------------------------------------------------------------------------
112
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.