GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
AngularCorrelationSelector.h
Go to the documentation of this file.
1//////////////////////////////////////////////////////////
2// This class has been automatically generated on
3// Tue Oct 25 13:18:27 2016 by ROOT version 5.34/24
4// from TTree FragmentTree/FragmentTree
5// found on file: fragment07844_000.root
6//////////////////////////////////////////////////////////
7
8#ifndef AngularCorrelationSelector_h
9#define AngularCorrelationSelector_h
10
11#include "TChain.h"
12#include "TFile.h"
13
14#include "TH1.h"
15#include "TH2.h"
16#include "THnSparse.h"
17
18// Header file for the classes stored in the TTree if any.
19#include "TGriffin.h"
20#include "TSceptar.h"
21#include "TGRSISelector.h"
22
23// function to calculate angles (from LeanCorrelations), implemented at the end of this file
24std::vector<std::pair<double, int>> AngleCombinations(double distance = 110., bool folding = false,
25 bool addback = false);
26
28public:
31 std::vector<std::pair<double, int>> fAngleCombinations;
32 std::vector<std::pair<double, int>> fAngleCombinationsAddback; // with addback
33 std::map<double, int> fAngleMap;
34 std::map<double, int> fAngleMapAddback; // with addback
35
38
39 explicit AngularCorrelationSelector(TTree* /*tree*/ = nullptr) : TGRSISelector(), fGrif(nullptr), fScep(nullptr)
40 {
41 SetOutputPrefix("AngularCorrelation");
42 // calculate angle combinations
43 fAngleCombinations = AngleCombinations(110., false, false);
44 fAngleCombinationsAddback = AngleCombinations(110., false, true); // with addback
45 for(int i = 0; i < static_cast<int>(fAngleCombinations.size()); ++i) {
46 fAngleMap.insert(std::make_pair(fAngleCombinations[i].first, i));
47 }
48 for(int i = 0; i < static_cast<int>(fAngleCombinationsAddback.size()); ++i) {
49 fAngleMapAddback.insert(std::make_pair(fAngleCombinationsAddback[i].first, i));
50 }
51 }
52 virtual ~AngularCorrelationSelector() = default;
53 virtual Int_t Version() const { return 2; }
54 void CreateHistograms();
55 void FillHistograms();
56 void InitializeBranches(TTree* tree);
57
59};
60#endif
61
62#ifdef AngularCorrelationSelector_cxx
64{
65 if(tree == nullptr) return;
66 tree->SetBranchAddress("TGriffin", &fGrif);
67 if(tree->SetBranchAddress("TSceptar", &fScep) == TTree::kMissingBranch) {
68 fScep = new TSceptar;
69 }
70}
71
72#endif // #ifdef AngularCorrelationSelector_cxx
73
74std::vector<std::pair<double, int>> AngleCombinations(double distance, bool folding, bool addback)
75{
76 std::vector<std::pair<double, int>> result;
77 std::vector<std::pair<double, int>> grouped_result;
78 std::vector<double> angle;
79 for(int firstDet = 1; firstDet <= 16; ++firstDet) {
80 for(int firstCry = 0; firstCry < 4; ++firstCry) {
81 for(int secondDet = 1; secondDet <= 16; ++secondDet) {
82 for(int secondCry = 0; secondCry < 4; ++secondCry) {
83 if(firstDet == secondDet && firstCry == secondCry) {
84 continue;
85 }
86 if(!addback) {
87 angle.push_back(TGriffin::GetPosition(firstDet, firstCry, distance)
88 .Angle(TGriffin::GetPosition(secondDet, secondCry, distance)) *
89 180. / TMath::Pi());
90 }
91 if(addback) {
92 if(((TGriffin::GetPosition(firstDet, firstCry, distance)
93 .Angle(TGriffin::GetPosition(secondDet, secondCry, distance)) *
94 180. / TMath::Pi() >
95 18.786) &&
96 (TGriffin::GetPosition(firstDet, firstCry, distance)
97 .Angle(TGriffin::GetPosition(secondDet, secondCry, distance)) *
98 180. / TMath::Pi() <
99 18.788)) ||
100 ((TGriffin::GetPosition(firstDet, firstCry, distance)
101 .Angle(TGriffin::GetPosition(secondDet, secondCry, distance)) *
102 180. / TMath::Pi() >
103 26.6800) &&
104 (TGriffin::GetPosition(firstDet, firstCry, distance)
105 .Angle(TGriffin::GetPosition(secondDet, secondCry, distance)) *
106 180. / TMath::Pi() <
107 26.6915))) {
108 angle.push_back(18.7868);
109 } else {
110 angle.push_back(TGriffin::GetPosition(firstDet, firstCry, distance)
111 .Angle(TGriffin::GetPosition(secondDet, secondCry, distance)) *
112 180. / TMath::Pi());
113 }
114 }
115 if(folding && angle.back() > 90.) {
116 angle.back() = 180. - angle.back();
117 }
118 }
119 }
120 }
121 }
122
123 std::sort(angle.begin(), angle.end());
124 size_t r;
125 for(size_t a = 0; a < angle.size(); ++a) {
126 for(r = 0; r < result.size(); ++r) {
127 if(angle[a] >= result[r].first - 0.001 && angle[a] <= result[r].first + 0.001) {
128 (result[r].second)++;
129 break;
130 }
131 }
132 if(result.size() == 0 || r == result.size()) {
133 result.push_back(std::make_pair(angle[a], 1));
134 }
135 }
136
137 if(folding) { // if we fold we also want to group
138 std::vector<std::pair<double, int>> groupedResult;
139 for(size_t i = 0; i < result.size(); ++i) {
140 switch(i) {
141 case 0:
142 case 1: groupedResult.push_back(result[i]); break;
143 case 2:
144 case 4:
145 case 6:
146 if(i + 1 >= result.size()) {
147 std::cerr << "Error!" << std::endl;
148 }
149 groupedResult.push_back(
150 std::make_pair((result[i].first + result[i + 1].first) / 2., result[i].second + result[i + 1].second));
151 ++i;
152 break;
153 default:
154 groupedResult.push_back(std::make_pair((result[i].first + result[i + 1].first + result[i + 2].first) / 3.,
155 result[i].second + result[i + 1].second + result[i + 2].second));
156 i += 2;
157 break;
158 }
159 }
160 return groupedResult;
161 }
162
163 return result;
164}
std::vector< std::pair< double, int > > AngleCombinations(double distance=110., bool folding=false, bool addback=false)
std::vector< std::pair< double, int > > fAngleCombinationsAddback
void InitializeBranches(TTree *tree)
std::vector< std::pair< double, int > > fAngleCombinations
std::map< double, int > fAngleMapAddback
ClassDef(AngularCorrelationSelector, 1)
virtual ~AngularCorrelationSelector()=default
void SetOutputPrefix(const char *prefix)
static TVector3 GetPosition(int DetNbr, int CryNbr=5, double dist=110.0)
!
Definition TGriffin.cxx:501