66#include "TRestGeant4VetoAnalysisProcess.h"
72TRestGeant4VetoAnalysisProcess::TRestGeant4VetoAnalysisProcess() {
Initialize(); }
74TRestGeant4VetoAnalysisProcess::TRestGeant4VetoAnalysisProcess(
const char* configFilename) {
81TRestGeant4VetoAnalysisProcess::~TRestGeant4VetoAnalysisProcess() {
delete fOutputEvent; }
120 fVetoVolumes.clear();
121 fVetoDetectorVolumes.clear();
122 fVetoDetectorBoundaryDirection.clear();
123 fVetoDetectorBoundaryPosition.clear();
125 if (fGeant4Metadata ==
nullptr) {
127 fGeant4Metadata = GetMetadata<TRestGeant4Metadata>();
129 if (fGeant4Metadata ==
nullptr) {
130 cerr <<
"TRestGeant4VetoAnalysisProcess::InitProcess: Geant4 metadata not found" << endl;
136 fVetoVolumes = geometryInfo.GetAllPhysicalVolumesMatchingExpression(fVetoVolumesExpression);
137 if (fVetoVolumes.empty()) {
138 const auto logicalVolumes =
139 geometryInfo.GetAllLogicalVolumesMatchingExpression(fVetoVolumesExpression);
140 for (
const auto& logicalVolume : logicalVolumes) {
141 for (
const auto& physicalVolume : geometryInfo.GetAllPhysicalVolumesFromLogical(logicalVolume)) {
142 fVetoVolumes.push_back(geometryInfo.GetAlternativeNameFromGeant4PhysicalName(physicalVolume));
146 if (fVetoVolumes.empty()) {
147 cerr <<
"TRestGeant4VetoAnalysisProcess::InitProcess: No veto volumes found" << endl;
152 if (!fVetoDetectorsExpression.IsNull()) {
153 fVetoDetectorVolumes = geometryInfo.GetAllPhysicalVolumesMatchingExpression(fVetoDetectorsExpression);
154 if (fVetoDetectorVolumes.empty()) {
155 const auto logicalVolumes =
156 geometryInfo.GetAllLogicalVolumesMatchingExpression(fVetoDetectorsExpression);
157 for (
const auto& logicalVolume : logicalVolumes) {
158 for (
const auto& physicalVolume :
159 geometryInfo.GetAllPhysicalVolumesFromLogical(logicalVolume)) {
160 fVetoDetectorVolumes.push_back(
161 geometryInfo.GetAlternativeNameFromGeant4PhysicalName(physicalVolume));
165 if (fVetoDetectorVolumes.empty()) {
166 cerr <<
"TRestGeant4VetoAnalysisProcess::InitProcess: No detector volumes found" << endl;
169 if (fVetoDetectorVolumes.size() != fVetoVolumes.size()) {
170 cerr <<
"TRestGeant4VetoAnalysisProcess::InitProcess: Number of detector volumes "
171 <<
"does not match number of veto volumes" << endl;
176 for (
unsigned int i = 0; i < fVetoDetectorVolumes.size(); i++) {
177 const auto& vetoName = fVetoVolumes[i];
178 const auto& vetoPosition = geometryInfo.GetPosition(vetoName);
180 const auto& vetoDetectorName = fVetoDetectorVolumes[i];
181 const auto& vetoDetectorPosition = geometryInfo.GetPosition(vetoDetectorName);
183 const auto distance = vetoDetectorPosition - vetoPosition;
184 const auto direction = distance.Unit();
186 fVetoDetectorBoundaryDirection[vetoName] = direction;
187 fVetoDetectorBoundaryPosition[vetoName] = vetoDetectorPosition - direction * fVetoDetectorOffsetSize;
325 fVetoVolumesExpression =
GetParameter(
"vetoVolumesExpression", fVetoVolumesExpression);
326 fVetoDetectorsExpression =
GetParameter(
"vetoDetectorsExpression", fVetoDetectorsExpression);
328 fVetoDetectorOffsetSize = GetDblParameterWithUnits(
"vetoDetectorOffset", fVetoDetectorOffsetSize);
329 fVetoLightAttenuation = GetDblParameterWithUnits(
"vetoLightAttenuation", fVetoLightAttenuation);
330 fVetoQuenchingFactor = GetDblParameterWithUnits(
"quenchingFactor", fVetoQuenchingFactor);
336 cout <<
"Veto volume expression: " << fVetoVolumesExpression << endl;
337 if (!fVetoDetectorsExpression.IsNull()) {
338 cout <<
"Veto detector expression: " << fVetoDetectorsExpression << endl;
339 cout <<
"Veto detector offset: " << fVetoDetectorOffsetSize << endl;
340 cout <<
"Veto light attenuation: " << fVetoLightAttenuation << endl;
342 cout <<
"Veto detector expression: not set" << endl;
344 cout <<
"Veto quenching factor: " << fVetoQuenchingFactor << endl;
348 if (fVetoVolumes.empty()) {
349 cout <<
"Process not initialized yet" << endl;
353 cout <<
"Number of veto volumes: " << fVetoVolumes.size() << endl;
354 cout <<
"Number of veto detector volumes: " << fVetoDetectorVolumes.size() << endl;
357 for (
unsigned int i = 0; i < fVetoVolumes.size(); i++) {
358 const auto& vetoName = fVetoVolumes[i];
359 const auto& vetoPosition = geometryInfo.GetPosition(vetoName);
361 cout << TString::Format(
" - Veto volume: %d - name: '%s' - position: %s mm", i, vetoName.Data(),
362 VectorToString(vetoPosition).c_str())
365 if (fVetoDetectorVolumes.empty()) {
369 const auto& vetoDetectorName = fVetoDetectorVolumes[i];
370 const auto& vetoDetectorPosition = geometryInfo.GetPosition(vetoDetectorName);
372 cout << TString::Format(
" Veto detector name: '%s' - position: %s mm", vetoDetectorName.Data(),
373 VectorToString(vetoDetectorPosition).c_str())
376 cout << TString::Format(
" Boundary position: %s mm - direction: %s",
377 VectorToString(fVetoDetectorBoundaryPosition.at(vetoName)).c_str(),
378 VectorToString(fVetoDetectorBoundaryDirection.at(vetoName)).c_str());
void BeginPrintProcess()
[name, cut range]
A base class for any REST event.
An event class to store geant4 generated event information.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
void EndProcess() override
Function to include required actions after all events have been processed.
void InitFromConfigFile() override
Function to read input parameters from the RML TRestGeant4VetoAnalysisProcess metadata section.
void Initialize() override
Function to initialize input/output event members and define the section name.
void InitProcess() override
Process initialization.