REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestTrackPointLikeAnalysisProcess.cxx
1
10
11#include "TRestTrackPointLikeAnalysisProcess.h"
12
13using namespace std;
14
16
17TRestTrackPointLikeAnalysisProcess::TRestTrackPointLikeAnalysisProcess() { Initialize(); }
18
19TRestTrackPointLikeAnalysisProcess::TRestTrackPointLikeAnalysisProcess(const char* configFilename) {
20 Initialize();
21
22 if (LoadConfigFromFile(configFilename)) LoadDefaultConfig();
23}
24
25TRestTrackPointLikeAnalysisProcess::~TRestTrackPointLikeAnalysisProcess() {}
26
27void TRestTrackPointLikeAnalysisProcess::LoadDefaultConfig() { SetTitle("Default config"); }
28
30 SetSectionName(this->ClassName());
31 SetLibraryVersion(LIBRARY_VERSION);
32
33 fTrackEvent = nullptr;
34}
35
36void TRestTrackPointLikeAnalysisProcess::LoadConfig(string configFilename) {
37 if (LoadConfigFromFile(configFilename)) LoadDefaultConfig();
38
39 // fReadout = new TRestDetectorReadout( configFilename.c_str() );
40}
41
42void TRestTrackPointLikeAnalysisProcess::InitProcess() { TRestEventProcess::ReadObservables(); }
43
45 fTrackEvent = (TRestTrackEvent*)inputEvent;
46
47 Int_t nTracks = fTrackEvent->GetNumberOfTracks();
48 Int_t nTotalHits = fTrackEvent->GetTotalHits();
49
50 Double_t totEnergy = 0;
51 Double_t maxTrackEnergy = 0;
52
53 Double_t totLength = 0;
54 Double_t maxTrackLength = 0;
55
56 Int_t maxNumberHits = 0;
57
58 Int_t maxIndex = 0;
59
60 for (int tck = 0; tck < fTrackEvent->GetNumberOfTracks(); tck++) {
61 Double_t trackEnergy = fTrackEvent->GetTrack(tck)->GetEnergy();
62 if (trackEnergy > maxTrackEnergy) {
63 maxTrackEnergy = trackEnergy;
64 maxIndex = tck;
65 }
66 totEnergy += trackEnergy;
67
68 Double_t trackLength = fTrackEvent->GetTrack(tck)->GetTrackLength();
69 if (trackLength > maxTrackLength) maxTrackLength = trackLength;
70 totLength += trackLength;
71
72 Int_t numberHits = fTrackEvent->GetTrack(tck)->GetVolumeHits()->GetNumberOfHits();
73 if (numberHits > maxNumberHits) maxNumberHits = numberHits;
74 }
75
76 Double_t totSize = 0;
77 Double_t maxClusterSize = 0;
78
79 for (unsigned int cl = 0; cl < fTrackEvent->GetTrack(maxIndex)->GetVolumeHits()->GetNumberOfHits();
80 cl++) {
81 Double_t clusterSize = fTrackEvent->GetTrack(maxIndex)->GetVolumeHits()->GetClusterSize(cl);
82 if (clusterSize > maxClusterSize) maxClusterSize = clusterSize;
83 totSize += clusterSize;
84 }
85
86 Double_t clusterEnergyBalance = maxTrackEnergy / totEnergy;
87 Double_t clusterLengthBalance = maxTrackLength / totLength;
88 Double_t hitsBalance = maxNumberHits / nTotalHits;
89 Double_t clusterSizeBalance = maxClusterSize / totSize;
90
91 // A new value for each observable is added
92 SetObservableValue("nTracks", nTracks); // Total number of tracks of the event
93 SetObservableValue("nTotalHits", nTotalHits); // Total number of hits of the event
94 SetObservableValue("totalEnergy", totEnergy); // Total number of hits of the event
95 SetObservableValue("clusterEnergyBalance", clusterEnergyBalance); // cluster energy balance
96 SetObservableValue("clusterLengthBalance", clusterLengthBalance); // cluster length balance
97 SetObservableValue("hitsBalance", hitsBalance); // cluster number of hits balance
98 SetObservableValue("size", totSize); // size of the track with more energy
99 SetObservableValue("sizeBalance", clusterSizeBalance); // size balance
100
101 return fTrackEvent;
102}
103
105 // Function to be executed once at the end of the process
106 // (after all events have been processed)
107
108 // Start by calling the EndProcess function of the abstract class.
109 // Comment this if you don't want it.
110 // TRestEventProcess::EndProcess();
111}
112
void SetObservableValue(const std::string &name, const T &value)
Set observable value for AnalysisTree.
A base class for any REST event.
Definition: TRestEvent.h:38
Int_t LoadConfigFromFile(const std::string &configFilename, const std::string &sectionName="")
Give the file name, find out the corresponding section. Then call the main starter.
void SetLibraryVersion(TString version)
Set the library version of this metadata class.
void SetSectionName(std::string sName)
set the section name, clear the section content
void EndProcess() override
To be executed at the end of the run (outside event loop)
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void Initialize() override
Making default settings.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)