R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandCluster.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
14#include "R3BNeulandCluster.h"
15#include "R3BNeulandHit.h"
16#include <Math/Vector3Dfwd.h>
17#include <Rtypes.h>
18#include <RtypesCore.h>
19#include <algorithm>
20#include <cstdlib>
21#include <iostream>
22#include <numeric>
23#include <ostream>
24#include <stdexcept>
25
27{
28 auto min = std::min_element(fHits.cbegin(),
29 fHits.cend(),
30 [](const R3BNeulandHit& a, const R3BNeulandHit& b)
31 { return a.GetPosition().Z() < b.GetPosition().Z(); });
32 if (min == fHits.end())
33 {
34 throw std::logic_error("R3BNeulandCluster::GetFirstHit(): Cluster has no Hits!");
35 }
36 return *min;
37}
38
40{
41 auto min = std::min_element(fHits.cbegin(),
42 fHits.cend(),
43 [](const R3BNeulandHit& a, const R3BNeulandHit& b) { return a.GetT() < b.GetT(); });
44 if (min == fHits.end())
45 {
46 throw std::logic_error("R3BNeulandCluster::GetFirstHit(): Cluster has no Hits!");
47 }
48 return *min;
49}
50
52{
53 auto max = std::max_element(fHits.cbegin(),
54 fHits.cend(),
55 [](const R3BNeulandHit& a, const R3BNeulandHit& b) { return a.GetT() < b.GetT(); });
56 if (max == fHits.end())
57 {
58 throw std::logic_error("R3BNeulandCluster::GetLastHit(): Cluster has no Hits!");
59 }
60 return *max;
61}
62
64{
65 auto max = std::max_element(fHits.cbegin(),
66 fHits.cend(),
67 [](const R3BNeulandHit& a, const R3BNeulandHit& b) { return a.GetE() < b.GetE(); });
68 if (max == fHits.end())
69 {
70 throw std::logic_error("R3BNeulandCluster::GetLastHit(): Cluster has no Hits!");
71 }
72 return *max;
73}
74
76{
77 return std::accumulate(
78 fHits.begin(), fHits.end(), 0., [](const Double_t sum, const R3BNeulandHit& hit) { return sum + hit.GetE(); });
79}
80
81Double_t R3BNeulandCluster::GetT() const { return GetFirstHit().GetT(); }
82
83auto R3BNeulandCluster::GetPosition() const -> ROOT::Math::XYZVector { return GetFirstHit().GetPosition(); };
84
85auto R3BNeulandCluster::GetEnergyCentroid() const -> ROOT::Math::XYZVector
86{
87 // analog to Geometrical Centroid \vec{c} = \frac{\sum_i (\vec{r}_{i} \cdot V_i)}{\sum_i V_i}
88 const auto centroid = std::accumulate(fHits.cbegin(),
89 fHits.cend(),
90 ROOT::Math::XYZVector(),
91 [](const ROOT::Math::XYZVector& cluster, const R3BNeulandHit& hit)
92 { return cluster + (hit.GetPosition() * hit.GetE()); });
93 return centroid * (1. / GetE());
94}
95
96auto R3BNeulandCluster::GetEnergyMoment() const -> Double_t
97{
98 const ROOT::Math::XYZVector centroid = GetEnergyCentroid();
99 Double_t mom = std::accumulate(fHits.cbegin(),
100 fHits.cend(),
101 0.,
102 [&](const Double_t cluster, const R3BNeulandHit& hit)
103 { return cluster + ((hit.GetPosition() - centroid).r() * hit.GetE()); });
104 return mom / GetE();
105}
106
107Double_t R3BNeulandCluster::GetRCluster(Double_t beta) const
108{
109 // Equation 4.2 in TDR (Page 55).
110 return std::abs(beta - GetBeta()) / GetE();
111}
112
113Double_t R3BNeulandCluster::GetRECluster(Double_t ekin) const { return std::abs(ekin - GetEToF()) / GetE(); }
114
115std::ostream& operator<<(std::ostream& os, const R3BNeulandCluster& cluster)
116{
117 os << "R3BNeulandCluster: NeuLAND Cluster with size " << cluster.GetSize() << std::endl;
118 if (cluster.GetSize() > 0)
119 {
120 os << " Sum Energy: " << cluster.GetE() << std::endl
121 << " FirstHit: " << cluster.GetFirstHit() << " LastHit: " << cluster.GetLastHit();
122 }
123 return os;
124}
125
126void R3BNeulandCluster::Print(const Option_t*) const { std::cout << *this; }
127
ClassImp(R3B::Neuland::Cal2HitPar)
std::ostream & operator<<(std::ostream &os, const R3BNeulandCluster &cluster)
auto GetEToF() const -> double
void Print(const Option_t *) const override
auto GetForemostHit() const -> R3BNeulandHit
auto GetT() const -> double
auto GetBeta() const -> double
auto GetFirstHit() const -> R3BNeulandHit
std::vector< R3BNeulandHit > fHits
auto GetRECluster(double ekin) const -> double
auto GetSize() const -> std::size_t
auto GetEnergyCentroid() const -> ROOT::Math::XYZVector
auto GetMaxEnergyHit() const -> R3BNeulandHit
auto GetPosition() const -> ROOT::Math::XYZVector
auto GetLastHit() const -> R3BNeulandHit
auto GetRCluster(double beta) const -> double
auto GetE() const -> double
auto GetEnergyMoment() const -> double