GRSISort "v4.1.1.0"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TGriffinAngles.h
Go to the documentation of this file.
1#ifndef TGRIFFINANGLES_H
2#define TGRIFFINANGLES_H
3
4/** \addtogroup Analysis
5 * @{
6 */
7
8////////////////////////////////////////////////////////////////////////////////
9///
10/// \class TGriffinAngles
11///
12/// This class provides the number of angles, their values, and the index a
13/// specific angle is at, as well as how many combinations contribute to this
14/// angle.
15/// It is meant to be used for the angular correlation analysis.
16///
17////////////////////////////////////////////////////////////////////////////////
18
19#include <set>
20#include <map>
21#include <functional>
22#include <cmath>
23
24#include "TCollection.h"
25#include "TNamed.h"
26#include "TGraphErrors.h"
27
28#include "Globals.h"
29
30class TGriffinAngles : public TNamed {
31public:
32 explicit TGriffinAngles(double distance = 145., bool folding = false, bool grouping = false, bool addback = true);
33 TGriffinAngles(const TGriffinAngles&) = default;
34 TGriffinAngles(TGriffinAngles&&) noexcept = default;
35 TGriffinAngles& operator=(const TGriffinAngles&) = default;
36 TGriffinAngles& operator=(TGriffinAngles&&) noexcept = default;
37 ~TGriffinAngles() = default;
38
39 double Distance() const { return fDistance; }
40 bool Folding() const { return fFolding; }
41 bool Grouping() const { return fGrouping; }
42 bool Addback() const { return fAddback; }
43
44 int Index(double angle);
45 int NumberOfAngles() const { return fAngles.size(); }
46 double Angle(int index) const
47 {
48 auto it = fAngles.begin();
49 std::advance(it, index);
50 return *it;
51 }
52 double AverageAngle(int index) const;
53 int Count(double angle)
54 {
55 /// If the angle is in our map, report how often it exists, otherwise return zero.
56 if(fAngleCount.count(static_cast<int>(std::round(angle / fRounding))) == 1) { return fAngleCount.at(static_cast<int>(std::round(angle / fRounding))); }
57 return 0;
58 }
59
60 void FoldOrGroup(TGraphErrors* z0, TGraphErrors* z2, TGraphErrors* z4, bool verbose = false) const;
61 std::set<double>::iterator begin() const { return fAngles.begin(); }
62 std::set<double>::iterator end() const { return fAngles.end(); }
63
64 void ApplyFolding(bool grouping = false);
65 std::vector<int> FoldedAndGroupedIndices(int index) const { return fFoldedAndGroupedIndices.at(index); }
66
67 bool ExcludeDetector(int detector) const;
68 bool ExcludeCrystal(int detector, int crystal) const;
69
70 void Print(Option_t* = "") const override;
71
72 Long64_t Merge(TCollection* list)
73 {
74 for(auto* griffinAngles : *list) { Add(static_cast<TGriffinAngles*>(griffinAngles)); }
75 return 0;
76 }
77
78 static double Rounding() { return fRounding; }
79 static void Rounding(const double& val) { fRounding = val; }
80
81 static EVerbosity Verbosity() { return fVerbosity; }
82 static void Verbosity(const EVerbosity& val) { fVerbosity = val; }
83
84private:
85 void Add(TGriffinAngles* griffinAngles);
86
87 static EVerbosity fVerbosity; ///< verbosity level
88 double fDistance{145.}; ///< distance of detector from center of array in mmm
89 bool fFolding{false}; ///< flag indicating whether we fold our distribution around 90 degree
90 bool fGrouping{false}; ///< flag indicating whether we group close angles together
91 bool fAddback{true}; ///< flag indicating whether we use addback
92 static double fRounding; ///< we consider any angles whose difference is less than this to be equal
93 std::vector<int> fExcludedDetectors; ///< list of detectors that are excluded in calculating the angles
94 std::vector<int> fExcludedCrystals; ///< list of crystals that are excluded in calculating the angles, the crystals are numbered as 4*(det-1)+cry, so start at 0 and go up to 63
95 std::vector<int> fCustomGrouping; ///< list of custom groups
96 std::set<double> fAngles; ///< set of unique angles, when grouping is used, the largest angle of the group is used!
97 std::map<double, int> fAngleMap; ///< Maps angles to indices. This is fairly straight forward without grouping, but if grouping is used multiple angles can be mapped to the same index.
98 std::map<int, int> fAngleCount; ///< Maps angles (divided by rounding and cast to integers) to number of combinations contributing to it.
99 std::vector<std::vector<int>> fFoldedAndGroupedIndices; ///< this gives for each folded (and grouped) index the list of original indices contained
100
101 /// \cond CLASSIMP
102 ClassDefOverride(TGriffinAngles, 6) // NOLINT(readability-else-after-return)
103 /// \endcond
104};
105/*! @} */
106#endif
EVerbosity
Definition Globals.h:141
void Add(TGriffinAngles *griffinAngles)
std::set< double > fAngles
set of unique angles, when grouping is used, the largest angle of the group is used!
static void Rounding(const double &val)
TGriffinAngles(TGriffinAngles &&) noexcept=default
Long64_t Merge(TCollection *list)
std::vector< int > FoldedAndGroupedIndices(int index) const
bool Addback() const
void ApplyFolding(bool grouping=false)
bool Grouping() const
static double fRounding
we consider any angles whose difference is less than this to be equal
void FoldOrGroup(TGraphErrors *z0, TGraphErrors *z2, TGraphErrors *z4, bool verbose=false) const
bool ExcludeDetector(int detector) const
bool fGrouping
flag indicating whether we group close angles together
double Distance() const
std::set< double >::iterator end() const
std::vector< int > fCustomGrouping
list of custom groups
bool Folding() const
void Print(Option_t *="") const override
double fDistance
distance of detector from center of array in mmm
bool fFolding
flag indicating whether we fold our distribution around 90 degree
bool fAddback
flag indicating whether we use addback
int NumberOfAngles() const
TGriffinAngles(double distance=145., bool folding=false, bool grouping=false, bool addback=true)
std::vector< std::vector< int > > fFoldedAndGroupedIndices
this gives for each folded (and grouped) index the list of original indices contained
TGriffinAngles(const TGriffinAngles &)=default
double Angle(int index) const
static void Verbosity(const EVerbosity &val)
int Index(double angle)
std::map< int, int > fAngleCount
Maps angles (divided by rounding and cast to integers) to number of combinations contributing to it.
static EVerbosity Verbosity()
std::vector< int > fExcludedDetectors
list of detectors that are excluded in calculating the angles
std::map< double, int > fAngleMap
Maps angles to indices. This is fairly straight forward without grouping, but if grouping is used mul...
static EVerbosity fVerbosity
verbosity level
std::vector< int > fExcludedCrystals
list of crystals that are excluded in calculating the angles, the crystals are numbered as 4*(det-1)+...
static double Rounding()
std::set< double >::iterator begin() const
bool ExcludeCrystal(int detector, int crystal) const
int Count(double angle)
double AverageAngle(int index) const