NAIA  1.1.1
Rich.cpp
Go to the documentation of this file.
1 #include "Containers/Rich.h"
2 
3 namespace NAIA {
4 
5 const std::string RichBase::BranchName = "RichBaseData";
6 const std::string RichPlus::BranchName = "RichPlusData";
7 
8 void RichBaseData::Clear() { m_beta.clear(); }
9 void RichBaseData::Dump() const {}
10 
12  if (!m_beta.empty()) {
13  return m_beta[0].hasBetaLIP;
14  }
15 
16  return false;
17 }
18 
19 bool RichBaseData::IsNaF() const {
20  if (!m_beta.empty()) {
21  return m_beta[0].isNaF;
22  }
23 
24  return false;
25 }
26 
28  if (!m_beta.empty()) {
29  return m_beta[0].beta;
30  }
31 
32  return {};
33 }
34 
36  if (!m_beta.empty()) {
37  return m_beta[0].ebeta;
38  }
39 
40  return {};
41 }
42 
43 std::array<float, 2> RichBaseData::GetTrackEmissionPoint() const {
44  if (!m_beta.empty()) {
45  return m_beta[0].Pos;
46  }
47 
48  return {};
49 }
50 
52  if (!m_beta.empty() && m_beta[0].beta.size() > 1) {
53  return std::fabs(m_beta[0].beta.at(Rich::BetaType::CIEMAT) - m_beta[0].beta.at(Rich::BetaType::LIP));
54  }
55 
56  return std::numeric_limits<double>::max();
57 }
58 
59 double RichBaseData::BetaConsistencyTof(const TofBaseData &tofData) const {
60  if (!m_beta.empty() && ContainsKeys(m_beta[0].beta, Rich::BetaType::CIEMAT) &&
62  return std::fabs(m_beta[0].beta.at(Rich::BetaType::CIEMAT) - tofData.Beta.at(Tof::BetaType::BetaH));
63  }
64 
65  return std::numeric_limits<double>::max();
66 }
67 
69  if (m_beta.empty())
70  return -1;
71  float x = m_beta[0].Pos[0];
72  float y = m_beta[0].Pos[1];
73  constexpr int grid_side_length = 11;
74  constexpr int n_tiles = grid_side_length * grid_side_length;
75  constexpr double tile_width = 0.1 + 11.5;
76 
77  if (std::fabs(x) < tile_width * 1.5 && std::fabs(y) < tile_width * 1.5)
78  return 121;
79 
80  int nx = int(x / tile_width + 5.5);
81  int ny = int(y / tile_width + 5.5);
82  int t = ny * grid_side_length + nx;
83  return t > n_tiles ? -1 : t;
84 }
85 
87 
88  if (m_beta.empty())
89  return false;
90 
91  float x = m_beta[0].Pos[0];
92  float y = m_beta[0].Pos[1];
93 
94  static constexpr int nbadtiles = 7; // tiles with bad beta reconstruction
95  static constexpr std::array<int, nbadtiles> kbadtile = {3, 7, 12, 20, 87, 100, 108};
96 
97  // mdb: Cut particles that are on the outer edge of the aerogel, esp if they fall on small tiles (?)
98  // aerogel external border (r**2)
99  static constexpr float cut_aerogelexternalborder = 3422.25;
100  static constexpr std::array<float, 2> cut_aerogelborder = {28.5, 29.5};
101 
102  // mdb: Also cut particles that fall close to the NaF/aerogel border
103  // aerogel/NaF border ([0]=NaF, [1]=aerogel)
104  static constexpr std::array<float, 2> cut_aerogel_nafborder = {17., 19.};
105 
106  // clang-format off
107  // Bad aerogel regions (from TWiki)
108  static constexpr int npos = 9;
109  static constexpr float xpos[npos] = { -2., 20., -29., 30, 16, 30., -30., -10., 12.};
110  static constexpr float xw[npos] = { 2., 2., 1., 2., 2., 2., 2., 2., 2.};
111  static constexpr float ypos[npos] = {-60., -42., -18., 16, 22, 38., 40., 56., 56.};
112  static constexpr float yw[npos] = { 2., 2., 2., 2., 2., 1.5, 2., 1.5, 2.};
113  // clang-format on
114 
115  if (geom == RingGeom::Borders) {
116  if (IsNaF()) {
117  if (std::max(std::fabs(x), std::fabs(y)) > cut_aerogel_nafborder[0])
118  return false;
119  } else {
120  if (std::max(std::fabs(x), std::fabs(y)) < cut_aerogel_nafborder[1])
121  return false;
122  if (x * x + y * y > cut_aerogelexternalborder)
123  return false;
124  }
125  } else if (geom == RingGeom::BadAglTiles) {
126  for (int kbad = 0; kbad < nbadtiles; kbad++) {
127  if (GetTileIndex() == kbadtile[kbad])
128  return false;
129  }
130  } else if (geom == RingGeom::AglTilesEdge) {
131  if (std::max(std::fabs(x), std::fabs(y)) > cut_aerogelborder[0] &&
132  std::max(std::fabs(x), std::fabs(y)) < cut_aerogelborder[1])
133  return false;
134  } else if (geom == RingGeom::BadAglRegions) {
135  for (int i = 0; i < npos; i++) {
136  bool isx = (x > (xpos[i]) && x < (xpos[i] + xw[i]));
137  bool isy = (y > (ypos[i]) && y < (ypos[i] + yw[i]));
138  if (isx && isy)
139  return false;
140  }
141  }
142  return true;
143 }
144 
145 //=======================================
146 void RichPlusData::Clear() { m_data.clear(); }
147 void RichPlusData::Dump() const {}
148 
149 } // namespace NAIA
NAIA::RichBaseData::GetBetaError
RichBetaVariable< float > GetBetaError() const
Get the Beta error.
Definition: Rich.cpp:35
NAIA::RichBaseData::RingGeom
RingGeom
Definition: Rich.h:40
NAIA::RichBetaVariable
std::map< Rich::BetaType, T > RichBetaVariable
Definition: Rich.h:29
Rich.h
Rich container class description.
NAIA::RichBaseData::Clear
void Clear()
Clear container content.
Definition: Rich.cpp:8
NAIA::RichBaseData::Dump
void Dump() const
Dump on screen container content.
Definition: Rich.cpp:9
NAIA::RichPlusData::Dump
void Dump() const
Dump on screen container content.
Definition: Rich.cpp:147
NAIA
Definition: Event.h:13
NAIA::ContainsKeys
std::enable_if< std::is_convertible< Key, size_t >::value, bool >::type ContainsKeys(const std::array< T, N > &container, Key key)
Definition: Utils.hpp:53
NAIA::Rich::CIEMAT
@ CIEMAT
Definition: Utils.h:419
NAIA::RichPlusData::m_data
std::vector< RichAdditionalData > m_data
Definition: Rich.h:249
NAIA::Tof::BetaH
@ BetaH
IHEP reconstruction.
Definition: Utils.h:352
NAIA::RichBaseData::BetaConsistency
double BetaConsistency() const
Get the estimator for beta consistency between CIEMAT and LIP reconstructions.
Definition: Rich.cpp:51
NAIA::RichBase::BranchName
static const std::string BranchName
Definition: Rich.h:165
NAIA::RichBaseData::IsNaF
bool IsNaF() const
Returns true if the radiator is NaF; false if it is AGL.
Definition: Rich.cpp:19
NAIA::RichBaseData::RingGeomTest
bool RingGeomTest(RingGeom geom=RingGeom::Borders) const
Checks if the track impact point on the radiator falls on the on the edge of the radiator (absolute o...
Definition: Rich.cpp:86
NAIA::Rich::LIP
@ LIP
Definition: Utils.h:422
NAIA::RichPlusData::Clear
void Clear()
Clear container content.
Definition: Rich.cpp:146
NAIA::TofBaseData
Container class for base Tof info.
Definition: Tof.h:46
NAIA::RichBaseData::GetTrackEmissionPoint
std::array< float, 2 > GetTrackEmissionPoint() const
Get the Track emmission point.
Definition: Rich.cpp:43
NAIA::RichBaseData::HasBetaLIP
bool HasBetaLIP() const
Returns true if Standalone LIP beta measurement is available.
Definition: Rich.cpp:11
NAIA::RichBaseData::GetBeta
RichBetaVariable< float > GetBeta() const
Get the Beta measurements.
Definition: Rich.cpp:27
NAIA::RichBaseData::BetaConsistencyTof
double BetaConsistencyTof(const TofBaseData &tofData) const
Get the estimator for beta consistency between Rich and Tof.
Definition: Rich.cpp:59
NAIA::RichBaseData::GetTileIndex
int GetTileIndex() const
Get the ID of the radiator tile where the ring is generated.
Definition: Rich.cpp:68
NAIA::TofBaseData::Beta
TofBetaVariable< float > Beta
Beta measurement, one for each type. See Tof::BetaType for list of types.
Definition: Tof.h:49
NAIA::RichPlus::BranchName
static const std::string BranchName
Definition: Rich.h:264
NAIA::RichBaseData::m_beta
std::vector< RichBaseDataR > m_beta
Definition: Rich.h:150