NAIA
 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 
22  ChargeLikelihood = 0;
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  }
74 }
75 
76 void TofPlusData::Dump() const {
77  fmt::print("{:=^120} \n", " TofPlusData ");
78 
79  fmt::print("{:^15} {:^15} {:^15} {:^15} {:^15} {:^15}\n", "Chi2Coo", "Chi2Time", "NTrkClusters", "NBetaClusters",
80  "NChargeClusters", "ChargeLikelihood");
81  fmt::print("{:^15} {:^15} {:^15} {:^15} {:^15} {:^15}\n", Chi2Coo, Chi2Time, NTrkClusters, NBetaClusters,
83 
84  if (!BetaPattern.empty()) {
85  fmt::print("{:<32}", "Beta type");
86  for (auto bType : Tof::betaTypes) {
87  fmt::print("{:>15} ", Tof::betaNames[bType]);
88  }
89  fmt::print("\n");
90  fmt::print(" {:<30} = ", "BetaPattern");
91  for (auto bType : Tof::betaTypes) {
92  fmt::print("{:> 15} ", ContainsKeys(BetaPattern, bType) ? BetaPattern.at(bType) : 0);
93  }
94  fmt::print("\n");
95  }
96 
97  if (!LayerGoodPathl.empty()) {
98  fmt::print("{:-^120}\n", "");
99  fmt::print("{:<32} {:>15} {:>15} {:>15}\n", " ", "LayerGoodPathl", "LayerCharge", "LayerEdep");
100  for (size_t iLayer = 0; iLayer < LayerGoodPathl.size(); iLayer++) {
101  auto LayerEdepV = ContainsKeys(LayerEdep, iLayer) ? LayerEdep.at(iLayer) : 0;
102  fmt::print(" - {:<28} = {:>15} {:> 15.4f} {:> 15.4f}\n", fmt::format("Layer {}", iLayer), LayerGoodPathl[iLayer],
103  LayerCharge[iLayer], LayerEdepV);
104  }
105  }
106 
107  if (!NClusters.empty()) {
108  fmt::print("{:-^120}\n", "");
109  fmt::print("{:<32} {:>15} {:>15} {:>15}\n", " ", "NClusters", "AverageDTime", "AverageEdep");
110  for (size_t iLayer = 0; iLayer < LayerGoodPathl.size(); iLayer++) {
112  fmt::print(" - {:<28} = {:>15} {:> 15.4f} {:> 15.4f}\n", fmt::format("Layer {} (On Time)", iLayer),
117  fmt::print(" - {:<28} = {:>15} {:> 15.4f} {:> 15.4f}\n", fmt::format("Layer {} (Off Time)", iLayer),
121  }
122  }
123 
124  fmt::print("{:-^120}\n", "");
125 }
126 
127 } // namespace NAIA
TofBetaVariable< float > Beta
Beta measurement, one for each type. See Tof::BetaType for list of types.
Definition: Tof.h:48
void Dump() const
Dump on screen container content.
Definition: Tof.cpp:76
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:128
float ChargeLikelihood
Likelihood probability of the discrete charge estimation.
Definition: Tof.h:122
LayerVariable< TofClusterTypeVariable< float > > AverageDTime
Average delta-t for tof clusters on each layer. See Tof::BetaClusterType for list of cluster types...
Definition: Tof.h:129
constexpr std::array< BetaType, numBetaTypes > betaTypes
Definition: Utils.h:346
LayerVariable< float > LayerEdep
Energy deposition in each tof layer.
Definition: Tof.h:127
short NChargeClusters
Total number of clusters used for charge estimation.
Definition: Tof.h:120
TofBetaVariable< short > BetaPattern
Tof layer pattern used for the beta reconstruction (for each beta type). See Tof::BetaType for list o...
Definition: Tof.h:124
short NTrkClusters
Total number of clusters matching Tracker track.
Definition: Tof.h:118
float Chi2Coo
Tof clusters spatial reconstruction normalized chi-square. The tof cluster residuals are computed w...
Definition: Tof.h:115
static const std::string BranchName
Definition: Tof.h:180
void Clear()
Clear container content.
Definition: Tof.cpp:11
constexpr std::array< ChargeType, numChargeTypes > recoTypes
Definition: Utils.h:333
static const std::string BranchName
Definition: Tof.h:208
std::vector< float > LayerCharge
Charge estimation for each tof layer.
Definition: Tof.h:126
LayerVariable< TofClusterTypeVariable< float > > AverageEdep
Average cluster energy deposition on each tof layer. See Tof::BetaClusterType for list of cluster typ...
Definition: Tof.h:130
static const std::array< std::string, numChargeTypes > recoNames
Definition: Utils.h:335
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:119
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, one for each type. See Tof::ChargeType for list of types.
Definition: Tof.h:49
std::vector< bool > LayerGoodPathl
Pathlength check for each tof layer. False if the track (or the cluster line-fit in case of standalon...
Definition: Tof.h:125
Tof container class description.
float Chi2Time
Tof clusters temporal reconstruction normalized chi-square. (Good luck finding out how this is comput...
Definition: Tof.h:116
std::vector< TVector3 > m_pointAndDir
Definition: Tof.h:98
static const std::string BranchName
Definition: Tof.h:194
std::enable_if< std::is_convertible< T, Key >::value, bool >::type ContainsKeys(const std::map< Key, Value > &container, T key)
Definition: Utils.hpp:69
static const std::string BranchName
Definition: Tof.h:165
static const std::array< std::string, numBetaTypes > betaNames
Definition: Utils.h:348