62#include "TRestGeant4ToDetectorHitsProcess.h"
102 SetTitle(
"Default config");
104 cout <<
"Geant4 to hits metadata not found. Loading default values" << endl;
145 }
else if (
GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Warning)
146 cout <<
"TRestGeant4ToDetectorHitsProcess. volume name : " << userVolume
147 <<
" not found and will not be added." << endl;
153 for (
size_t i = 0; i <
fVolumeId.size(); i++) {
154 RESTDebug <<
"TRestGeant4ToDetectorHitsProcess. Volume id : " <<
fVolumeId[i]
158 RESTDebug <<
"Active volumes available in TRestGeant4Metadata" <<
RESTendl;
159 RESTDebug <<
"-------------------------------------------" <<
RESTendl;
165 RESTDebug <<
"TRestGeant4HitsProcess volumes enabled in RML : ";
166 RESTDebug <<
"-------------------------------------------" <<
RESTendl;
172 RESTDebug <<
" - " << volume <<
RESTendl;
178 RESTWarning <<
"TRestGeant4ToDetectorHitsProcess. Not all volumes were properly identified!"
182 RESTDebug <<
"TRestGeant4HitsProcess volumes identified : ";
183 RESTDebug <<
"---------------------------------------" <<
RESTendl;
189 RESTDebug <<
" - " << volume <<
RESTendl;
204 cout <<
"------ TRestGeant4ToDetectorHitsProcess --- Printing Input Event --- START ----" << endl;
206 cout <<
"------ TRestGeant4ToDetectorHitsProcess --- Printing Input Event ---- END ----" << endl;
219 const auto& hits = track.GetHits();
220 for (
unsigned int i = 0; i < track.GetNumberOfHits(); i++) {
221 const auto energy = hits.GetEnergy(i);
225 const TVector3& position = hits.GetPosition(i);
226 const double time = hits.GetTime(i);
229 cerr <<
"TRestGeant4ToDetectorHitsProcess. Negative time found. This should never happen"
237 const string volumeName = hits.GetVolumeName(i).Data();
242 const REST_HitType type = fHitTypes.at(volumeName);
251 cout <<
"TRestGeant4ToDetectorHitsProcess. Hits added : " <<
fHitsEvent->GetNumberOfHits() << endl;
252 cout <<
"TRestGeant4ToDetectorHitsProcess. Hits total energy : " <<
fHitsEvent->GetTotalEnergy()
267 RESTWarning <<
"TRestGeant4ToDetectorHitsProcess. No TRestGeant4Metadata found in the input file"
271 set<string> volumesToAdd;
272 TiXmlElement* volumeDefinition =
GetElement(
"volume");
273 if (volumeDefinition ==
nullptr) {
275 if (volumeDefinition !=
nullptr) {
276 RESTWarning <<
"TRestGeant4ToDetectorHitsProcess. 'addVolume' tag is deprecated. Please use "
281 while (volumeDefinition !=
nullptr) {
282 const auto userVolume =
GetFieldValue(
"name", volumeDefinition);
283 const auto typeName =
GetFieldValue(
"type", volumeDefinition);
284 REST_HitType type = XYZ;
285 if (typeName ==
"veto") {
289 if (userVolume ==
"Not defined") {
290 RESTError <<
"TRestGeant4ToDetectorHitsProcess. No name defined for volume" <<
RESTendl;
295 auto physicalVolumes = geometryInfo.GetAllPhysicalVolumesMatchingExpression(userVolume);
296 if (physicalVolumes.empty()) {
297 const auto logicalVolumes = geometryInfo.GetAllLogicalVolumesMatchingExpression(userVolume);
298 for (
const auto& logicalVolume : logicalVolumes) {
299 for (
const auto& physicalVolume :
300 geometryInfo.GetAllPhysicalVolumesFromLogical(logicalVolume)) {
301 physicalVolumes.push_back(
302 geometryInfo.GetAlternativeNameFromGeant4PhysicalName(physicalVolume));
306 for (
const auto& physicalVolume : physicalVolumes) {
307 volumesToAdd.insert(physicalVolume.Data());
308 fHitTypes[physicalVolume.Data()] = type;
311 volumesToAdd.insert(userVolume);
312 fHitTypes[userVolume] = type;
318 for (
const auto& volume : volumesToAdd) {
332 RESTMetadata <<
"Volume added : " << volume <<
RESTendl;
void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t=0, REST_HitType type=XYZ)
Adds a new hit to this event.
TRestRun * GetRunInfo() const
Return the pointer of the hosting TRestRun object.
void BeginPrintProcess()
[name, cut range]
A base class for any REST event.
An event class to store geant4 generated event information.
void InitializeReferences(TRestRun *run) override
Initialize dynamical references when loading the event from a root file.
A process to transform a TRestGeant4Event into a TRestDetectorHitsEvent.
void Initialize() override
Function to initialize input/output event members and define the section name.
std::vector< TString > fVolumeSelection
The geometry volume names to be transferred to TRestDetectorHitsEvent.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
TRestDetectorHitsEvent * fHitsEvent
A pointer to the output TRestDetectorHitsEvent.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
TRestGeant4ToDetectorHitsProcess()
Default constructor.
~TRestGeant4ToDetectorHitsProcess() override
Default destructor.
void InitProcess() override
Process initialization. This process accesses the information inside TRestGeant4Metadata to identify ...
TRestGeant4Metadata * fGeant4Metadata
A pointer to the Geant4 simulation conditions stored in TRestGeant4Metadata.
void InitFromConfigFile() override
Function to read input parameters from the RML TRestGeant4ToDetectorHitsProcess metadata section.
TRestGeant4Event * fGeant4Event
A pointer to the input TRestGeant4Event.
void PrintMetadata() override
It prints on screen relevant data members from this class.
std::vector< Int_t > fVolumeId
The volume ids from the volumes selected for transfer to TRestDetectorHitsEvent.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
@ REST_Extreme
show everything
@ REST_Debug
+show the defined debug messages
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.