17 #include "TRestGeant4BlobAnalysisProcess.h"
23 TRestGeant4BlobAnalysisProcess::TRestGeant4BlobAnalysisProcess() { Initialize(); }
25 TRestGeant4BlobAnalysisProcess::TRestGeant4BlobAnalysisProcess(
const char* configFilename) {
28 if (LoadConfigFromFile(configFilename)) LoadDefaultConfig();
31 TRestGeant4BlobAnalysisProcess::~TRestGeant4BlobAnalysisProcess() {
delete fG4Event; }
33 void TRestGeant4BlobAnalysisProcess::LoadDefaultConfig() { SetTitle(
"Default config"); }
36 SetSectionName(this->ClassName());
37 SetLibraryVersion(LIBRARY_VERSION);
43 void TRestGeant4BlobAnalysisProcess::LoadConfig(
const string& configFilename,
const string& name) {
44 if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
48 std::vector<string> fObservables;
49 fObservables = TRestEventProcess::ReadObservables();
51 for (
unsigned int i = 0; i < fObservables.size(); i++) {
52 if (fObservables[i].find(
"Q1_R") != string::npos) fQ1_Observables.push_back(fObservables[i]);
53 if (fObservables[i].find(
"Q2_R") != string::npos) fQ2_Observables.push_back(fObservables[i]);
56 for (
unsigned int i = 0; i < fQ1_Observables.size(); i++) {
57 Double_t r1 = atof(fQ1_Observables[i].substr(4, fQ1_Observables[i].length() - 4).c_str());
58 fQ1_Radius.push_back(r1);
61 for (
unsigned int i = 0; i < fQ2_Observables.size(); i++) {
62 Double_t r2 = atof(fQ2_Observables[i].substr(4, fQ2_Observables[i].length() - 4).c_str());
63 fQ2_Radius.push_back(r2);
66 fG4Metadata = GetMetadata<TRestGeant4Metadata>();
76 Double_t xBlob1 = 0, yBlob1 = 0, zBlob1 = 0;
77 Double_t xBlob2 = 0, yBlob2 = 0, zBlob2 = 0;
79 for (
unsigned int tck = 0; tck < fG4Event->GetNumberOfTracks(); tck++) {
80 const auto& track = fG4Event->GetTrack(tck);
81 if (track.GetParentID() == 0) {
82 if (track.GetParticleName() !=
"e-") {
83 cout <<
"TRestGeant4BlobAnalysis Warning. Primary particle is not an "
86 cout <<
"Skipping." << endl;
90 if (track.GetNumberOfHits() == 0) {
91 cout <<
"REST. FindG4Blobs WARNING. A primary electron with no hits "
94 cout <<
"Skipping." << endl;
99 cout <<
"TRestGeant4BlobAnalysis Warning. More than 2 e- primaries "
105 Int_t nHits = track.GetNumberOfHits();
108 xBlob1 = track.GetHits().GetX(nHits - 1);
109 yBlob1 = track.GetHits().GetY(nHits - 1);
110 zBlob1 = track.GetHits().GetZ(nHits - 1);
112 xBlob2 = track.GetHits().GetX(nHits - 1);
113 yBlob2 = track.GetHits().GetY(nHits - 1);
114 zBlob2 = track.GetHits().GetZ(nHits - 1);
122 cout <<
"REST. FindG4Blobs ERROR. Blobs != 2. Blobs found " << nBlobs << endl;
129 if (fabs(zBlob1) < fabs(zBlob2)) {
147 SetObservableValue(
"x1", x1);
149 SetObservableValue(
"y1", y1);
151 SetObservableValue(
"z1", z1);
153 SetObservableValue(
"x2", x2);
155 SetObservableValue(
"y2", y2);
157 SetObservableValue(
"z2", z2);
159 Double_t deltaX = xBlob1 - xBlob2;
160 Double_t deltaY = yBlob1 - yBlob2;
161 Double_t deltaZ = zBlob1 - zBlob2;
163 Double_t blobDistance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
164 blobDistance = TMath::Sqrt(blobDistance);
166 SetObservableValue(
"distance", blobDistance);
171 for (
unsigned int n = 0; n < fQ1_Observables.size(); n++) {
174 SetObservableValue(fQ1_Observables[n], q);
177 for (
unsigned int n = 0; n < fQ2_Observables.size(); n++) {
180 SetObservableValue(fQ2_Observables[n], q);
A base class for any REST event.
void Initialize() override
Making default settings.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
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.
An event class to store geant4 generated event information.
It saves a 3-coordinate position and an energy for each punctual deposition.
Double_t GetEnergyInSphere(const TVector3 &pos0, Double_t radius) const
It determines the total energy contained in a sphere with position pos0 for a given spherical radius.