NAIA  1.0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Tof.cpp
Go to the documentation of this file.
1 #include "fmt/format.h"
2 
3 #include "Containers/Tof.h"
4 
5 namespace NAIA {
6 const std::string TofBase::BranchName = "TofBaseData";
7 const std::string TofPlus::BranchName = "TofPlusData";
8 const std::string TofBaseStandalone::BranchName = "TofBaseDataSt";
9 const std::string TofPlusStandalone::BranchName = "TofPlusDataSt";
10 
12  Beta.clear();
13  Charge.clear();
14 
15  m_pointAndDir.clear();
16 }
17 
19  Chi2Coo = Chi2Time = 0;
20 
23 
24  BetaPattern.clear();
25  LayerGoodPathl.clear();
26  LayerCharge.clear();
27  LayerEdep.clear();
28  NClusters.clear();
29  AverageEdep.clear();
30  AverageDTime.clear();
31 }
32 
33 TVector3 TofBaseData::InterpolateAtZ(float z) const {
34  // not elegant, but who cares
35  float dxdz = m_pointAndDir.at(1)[0] / m_pointAndDir.at(1)[2];
36  float dydz = m_pointAndDir.at(1)[1] / m_pointAndDir.at(1)[2];
37 
38  TVector3 result{m_pointAndDir.at(0)};
39  result[0] += dxdz * (z - result[2]);
40  result[1] += dydz * (z - result[2]);
41  result[2] = z;
42 
43  return result;
44 }
45 
46 void TofBaseData::Dump() const {
47  fmt::print("{:=^120} \n", " TofBaseData ");
48 
49  if (!Beta.empty()) {
50  fmt::print("{:<32}", " ");
51  for (auto bType : Tof::betaTypes) {
52  fmt::print("{:>15} ", Tof::betaNames[bType]);
53  }
54  fmt::print("\n");
55  fmt::print(" {:<30} = ", "Beta");
56  for (auto bType : Tof::betaTypes) {
57  fmt::print("{:> 15.4f} ", ContainsKeys(Beta, bType) ? Beta.at(bType) : 0);
58  }
59  fmt::print("\n");
60  }
61 
62  if (!Charge.empty()) {
63  fmt::print("{:<32}", " ");
64  for (auto cType : Tof::recoTypes) {
65  fmt::print("{:>15} ", Tof::recoNames[cType]);
66  }
67  fmt::print("\n");
68  fmt::print(" {:<30} = ", "Charge");
69  for (auto cType : Tof::recoTypes) {
70  fmt::print("{:> 15.4f} ", ContainsKeys(Charge, cType) ? Charge.at(cType) : 0);
71  }
72  fmt::print("\n");
73  fmt::print(" {:<30} = ", "ChargeNoPL");
74  for (auto cType : Tof::recoTypes) {
75  fmt::print("{:> 15.4f} ", ContainsKeys(ChargeNoPL, cType) ? ChargeNoPL.at(cType) : 0);
76  }
77  fmt::print("\n");
78  }
79 }
80 
81 void TofPlusData::Dump() const {
82  fmt::print("{:=^120} \n", " TofPlusData ");
83 
84  fmt::print("{:^15} {:^15} {:^15} {:^15} {:^15} {:^30}\n", "Chi2Coo", "Chi2Time", "NTrkClusters", "NBetaClusters",
85  "NChargeClusters", "ChargeLikelihoodEst (prob)");
86  fmt::print("{:^15} {:^15} {:^15} {:^15} {:^15} {:^30}\n", Chi2Coo, Chi2Time, NTrkClusters, NBetaClusters,
87  NChargeClusters, fmt::format("{} ({})", ChargeLikelihoodEst, ChargeLikelihoodProb));
88 
89  if (!BetaPattern.empty()) {
90  fmt::print("{:<32}", "Beta type");
91  for (auto bType : Tof::betaTypes) {
92  fmt::print("{:>15} ", Tof::betaNames[bType]);
93  }
94  fmt::print("\n");
95  fmt::print(" {:<30} = ", "BetaPattern");
96  for (auto bType : Tof::betaTypes) {
97  fmt::print("{:> 15} ", ContainsKeys(BetaPattern, bType) ? BetaPattern.at(bType) : 0);
98  }
99  fmt::print("\n");
100  }
101 
102  if (!LayerGoodPathl.empty()) {
103  fmt::print("{:-^120}\n", "");
104  fmt::print("{:<32} {:>15} {:>15} {:>15}\n", " ", "LayerGoodPathl", "LayerCharge", "LayerEdep");
105  for (size_t iLayer = 0; iLayer < LayerGoodPathl.size(); iLayer++) {
106  auto LayerChargeV = ContainsKeys(LayerCharge, iLayer) ? LayerCharge.at(iLayer) : 0;
107  auto LayerEdepV = ContainsKeys(LayerEdep, iLayer) ? LayerEdep.at(iLayer) : 0;
108  fmt::print(" - {:<28} = {:>15} {:> 15.4f} {:> 15.4f}\n", fmt::format("Layer {}", iLayer), LayerGoodPathl[iLayer],
109  LayerChargeV, LayerEdepV);
110  }
111  }
112 
113  if (!NClusters.empty()) {
114  fmt::print("{:-^120}\n", "");
115  fmt::print("{:<32} {:>15} {:>15} {:>15}\n", " ", "NClusters", "AverageDTime", "AverageEdep");
116  for (size_t iLayer = 0; iLayer < LayerGoodPathl.size(); iLayer++) {
118  fmt::print(" - {:<28} = {:>15} {:> 15.4f} {:> 15.4f}\n", fmt::format("Layer {} (On Time)", iLayer),
123  fmt::print(" - {:<28} = {:>15} {:> 15.4f} {:> 15.4f}\n", fmt::format("Layer {} (Off Time)", iLayer),
127  }
128  }
129 
130  fmt::print("{:-^120}\n", "");
131 }
132 
133 } // namespace NAIA
TofBetaVariable< float > Beta
Beta measurement, one for each type. See Tof::BetaType for list of types.
Definition: Tof.h:49
float ChargeLikelihoodEst
Likelihood estimation of the event discrete charge.
Definition: Tof.h:125
void Dump() const
Dump on screen container content.
Definition: Tof.cpp:81
LayerVariable< TofClusterTypeVariable< unsigned int > > NClusters
Number of tof clusters on each layer both on-time or off-time (far from trigger). See Tof::BetaCluste...
Definition: Tof.h:132
LayerVariable< TofClusterTypeVariable< float > > AverageDTime
Average delta-t for tof clusters on each layer. See Tof::BetaClusterType for list of cluster types...
Definition: Tof.h:133
constexpr std::array< BetaType, numBetaTypes > betaTypes
Definition: Utils.h:353
LayerVariable< float > LayerEdep
Energy deposition in each tof layer.
Definition: Tof.h:131
short NChargeClusters
Total number of clusters used for charge estimation.
Definition: Tof.h:123
TofChargeVariable< float > ChargeNoPL
Charge measurement obtained using every layer, regardless of GoodPathl. One for each type...
Definition: Tof.h:51
float ChargeLikelihoodProb
Likelihood probability of the event discrete charge estimation.
Definition: Tof.h:126
TofBetaVariable< short > BetaPattern
Tof layer pattern used for the beta reconstruction (for each beta type). See Tof::BetaType for list o...
Definition: Tof.h:128
short NTrkClusters
Total number of clusters matching Tracker track.
Definition: Tof.h:121
float Chi2Coo
Tof clusters spatial reconstruction normalized chi-square. The tof cluster residuals are computed w...
Definition: Tof.h:118
static const std::string BranchName
Definition: Tof.h:184
void Clear()
Clear container content.
Definition: Tof.cpp:11
constexpr std::array< ChargeType, numChargeTypes > recoTypes
Definition: Utils.h:340
static const std::string BranchName
Definition: Tof.h:212
LayerVariable< TofClusterTypeVariable< float > > AverageEdep
Average cluster energy deposition on each tof layer. See Tof::BetaClusterType for list of cluster typ...
Definition: Tof.h:134
static const std::array< std::string, numChargeTypes > recoNames
Definition: Utils.h:342
TVector3 InterpolateAtZ(float z) const
Get Tof track interpolation at given height.
Definition: Tof.cpp:33
short NBetaClusters
Total number of clusters used for beta estimation.
Definition: Tof.h:122
void Dump() const
Dump on screen container content.
Definition: Tof.cpp:46
void Clear()
Clear container content.
Definition: Tof.cpp:18
TofChargeVariable< float > Charge
Charge measurement obtained using only layers for which GoodPathl is true. One for each type...
Definition: Tof.h:50
std::vector< bool > LayerGoodPathl
Pathlength check for each tof layer. False if the track crosses a paddle edge, or if this is the stan...
Definition: Tof.h:129
Tof container class description.
float Chi2Time
Tof clusters temporal reconstruction normalized chi-square. (Good luck finding out how this is comput...
Definition: Tof.h:119
std::vector< TVector3 > m_pointAndDir
Definition: Tof.h:101
static const std::string BranchName
Definition: Tof.h:198
static const std::string BranchName
Definition: Tof.h:169
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
LayerVariable< float > LayerCharge
Charge estimation for each tof layer.
Definition: Tof.h:130
static const std::array< std::string, numBetaTypes > betaNames
Definition: Utils.h:355