75#include "TRestTrack3DAnalysisProcess.h"
79bool sortByValueDescending3D(
const std::pair<int, Double_t>& a,
const std::pair<int, Double_t>& b) {
80 return a.second > b.second;
85TRestTrack3DAnalysisProcess::TRestTrack3DAnalysisProcess() {
Initialize(); }
87TRestTrack3DAnalysisProcess::TRestTrack3DAnalysisProcess(
const char* configFilename) {
92TRestTrack3DAnalysisProcess::~TRestTrack3DAnalysisProcess() {
delete fTrackEvent; }
94void TRestTrack3DAnalysisProcess::LoadDefaultConfig() { SetTitle(
"Default config"); }
103void TRestTrack3DAnalysisProcess::LoadConfig(
const string& configFilename,
const string& name) {
118 map<int, Double_t> XYZ_Energy;
121 map<int, int> XYZ_NHits;
124 map<int, Double_t> XYZ_SigmaX;
125 map<int, Double_t> XYZ_SigmaY;
126 map<int, Double_t> XYZ_SigmaZ;
129 map<int, Double_t> XYZ_SkewXY;
130 map<int, Double_t> XYZ_SkewZ;
133 map<int, Double_t> XYZ_GaussSigmaX;
134 map<int, Double_t> XYZ_GaussSigmaY;
135 map<int, Double_t> XYZ_GaussSigmaZ;
138 map<int, Double_t> XYZ_Length;
140 map<int, Double_t> XYZ_Volume;
142 map<int, Double_t> XYZ_MeanX;
143 map<int, Double_t> XYZ_MeanY;
144 map<int, Double_t> XYZ_MeanZ;
147 Double_t XYZ_FirstSecondTracksDistance;
154 for (
int tck = 0; tck < fTrackEvent->GetNumberOfTracks(); tck++) {
155 if (!fTrackEvent->isTopLevel(tck))
continue;
160 XYZ_NHits[t->GetTrackID()] = t->GetNumberOfHits();
161 XYZ_Energy[t->GetTrackID()] = t->GetTrackEnergy();
162 XYZ_SigmaX[t->GetTrackID()] = t->GetHits()->
GetSigmaX();
163 XYZ_SigmaY[t->GetTrackID()] = t->GetHits()->
GetSigmaY();
164 XYZ_SigmaZ[t->GetTrackID()] = t->GetHits()->
GetSigmaZ2();
165 XYZ_GaussSigmaX[t->GetTrackID()] = t->GetHits()->
GetGaussSigmaX();
166 XYZ_GaussSigmaY[t->GetTrackID()] = t->GetHits()->
GetGaussSigmaY();
167 XYZ_GaussSigmaZ[t->GetTrackID()] = t->GetHits()->
GetGaussSigmaZ();
168 XYZ_Length[t->GetTrackID()] = t->GetLength();
169 XYZ_Volume[t->GetTrackID()] = t->GetVolume();
170 XYZ_MeanX[t->GetTrackID()] = t->GetMeanPosition().X();
171 XYZ_MeanY[t->GetTrackID()] = t->GetMeanPosition().Y();
172 XYZ_MeanZ[t->GetTrackID()] = t->GetMeanPosition().Z();
173 XYZ_SkewXY[t->GetTrackID()] = t->GetHits()->
GetSkewXY();
174 XYZ_SkewZ[t->GetTrackID()] = t->GetHits()->
GetSkewZ();
176 XYZ_NHits[t->GetTrackID()] = 0;
177 XYZ_Energy[t->GetTrackID()] = 0;
178 XYZ_SigmaX[t->GetTrackID()] = 0;
179 XYZ_SigmaY[t->GetTrackID()] = 0;
180 XYZ_SigmaZ[t->GetTrackID()] = 0;
181 XYZ_GaussSigmaX[t->GetTrackID()] = 0;
182 XYZ_GaussSigmaY[t->GetTrackID()] = 0;
183 XYZ_GaussSigmaZ[t->GetTrackID()] = 0;
184 XYZ_Length[t->GetTrackID()] = 0;
185 XYZ_Volume[t->GetTrackID()] = 0;
186 XYZ_MeanX[t->GetTrackID()] = 0;
187 XYZ_MeanY[t->GetTrackID()] = 0;
188 XYZ_MeanZ[t->GetTrackID()] = 0;
189 XYZ_SkewXY[t->GetTrackID()] = 0;
190 XYZ_SkewZ[t->GetTrackID()] = 0;
195 vector<pair<int, Double_t>> energies;
198 map<int, Double_t>::iterator it;
199 for (it = XYZ_Energy.begin(); it != XYZ_Energy.end(); it++) {
200 energies.emplace_back(make_pair(it->first, it->second));
204 sort(energies.begin(), energies.end(), sortByValueDescending3D);
207 if (fTrackEvent->GetNumberOfTracks() > 1) {
208 Double_t dX = 0, dY = 0, dZ = 0;
210 dX = abs(XYZ_MeanX[energies[0].first] - XYZ_MeanX[energies[1].first]);
211 dY = abs(XYZ_MeanY[energies[0].first] - XYZ_MeanY[energies[1].first]);
212 dZ = abs(XYZ_MeanZ[energies[0].first] - XYZ_MeanZ[energies[1].first]);
214 XYZ_FirstSecondTracksDistance = TMath::Sqrt(dX * dX + dY * dY + dZ * dZ);
216 XYZ_FirstSecondTracksDistance = 0;
245 if (!energies.empty()) {
247 int energies0FirstKey =
249 Double_t energies0SecondKey = energies[0].second;
268 (energies0SecondKey) / fTrackEvent->GetEnergy());
271 int energies1FirstKey = energies[1].first;
278 SetObservableValue(
"SecondMaxTrack_XYZ_GaussSigmaX", XYZ_GaussSigmaX[energies1FirstKey]);
279 SetObservableValue(
"SecondMaxTrack_XYZ_GaussSigmaY", XYZ_GaussSigmaY[energies1FirstKey]);
280 SetObservableValue(
"SecondMaxTrack_XYZ_GaussSigmaZ", XYZ_GaussSigmaZ[energies1FirstKey]);
289 Double_t energies1SecondKey = energies[1].second;
291 if (fTrackEvent->GetNumberOfTracks() > 2) {
293 (energies1SecondKey) / fTrackEvent->GetEnergy());
298 std::cerr <<
"Error: energies is empty. Some observables will not be set." << std::endl;
void SetObservableValue(const std::string &name, const T &value)
Set observable value for AnalysisTree.
A base class for any REST event.
Double_t GetSkewXY() const
It returns the 2-dimensional skewness on the XY-plane which is a measure of the hits distribution asy...
Double_t GetGaussSigmaX(Double_t error=150.0, Int_t nHitsMin=100000)
It computes the gaussian sigma in the X-coordinate. It adds a hit to the right and a hit to the left,...
Double_t GetSigmaX() const
It calculates the hits standard deviation in the X-coordinate.
Double_t GetGaussSigmaZ(Double_t error=150.0, Int_t nHitsMin=100000)
It computes the gaussian sigma in the Z-coordinate. It adds a hit to the right and a hit to the left,...
Double_t GetGaussSigmaY(Double_t error=150.0, Int_t nHitsMin=100000)
It computes the gaussian sigma in the Y-coordinate. It adds a hit to the right and a hit to the left,...
Double_t GetSigmaZ2() const
It returns the hits distribution variance on the Z-axis.
Double_t GetSkewZ() const
It returns the hits distribution skewness, or asymmetry on the Z-axis.
Double_t GetSigmaY() const
It calculates the hits standard deviation in the Y-coordinate.
An analysis REST process to extract valuable information from Track type of data.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
void Initialize() override
Making default settings.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void EndProcess() override
To be executed at the end of the run (outside event loop)
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.