195#include "TRestGeant4AnalysisProcess.h"
271 std::vector<string> fObservables;
272 fObservables = TRestEventProcess::ReadObservables();
274 if (fPerProcessSensitiveEnergy) {
275 fObservables.emplace_back(
"PerProcessPhotoelectric");
276 fObservables.emplace_back(
"PerProcessCompton");
277 fObservables.emplace_back(
"PerProcessElectronicIoni");
278 fObservables.emplace_back(
"PerProcessAlphaIoni");
279 fObservables.emplace_back(
"PerProcessIonIoni");
280 fObservables.emplace_back(
"PerProcessHadronicIoni");
281 fObservables.emplace_back(
"PerProcessProtonIoni");
282 fObservables.emplace_back(
"PerProcessMsc");
283 fObservables.emplace_back(
"PerProcessHadronElastic");
284 fObservables.emplace_back(
"PerProcessNeutronElastic");
286 for (
unsigned int i = 0; i < fObservables.size(); i++) {
287 if (fObservables[i].find(
"VolumeEDep") != string::npos) {
288 TString volName = fObservables[i].substr(0, fObservables[i].length() - 10).c_str();
294 fVolumeName.push_back(volName.Data());
299 cout <<
"??????????????????????????????????????????????????" << endl;
300 cout <<
"REST warning : TRestGeant4AnalysisProcess." << endl;
301 cout <<
"------------------------------------------" << endl;
303 cout <<
" Volume " << volName <<
" is not an active volume" << endl;
305 cout <<
"List of active volumes : " << endl;
306 cout <<
"------------------------ " << endl;
310 cout <<
"??????????????????????????????????????????????????" << endl;
315 if (fObservables[i].find(
"MeanPos") != string::npos) {
316 TString volName2 = fObservables[i].substr(0, fObservables[i].length() - 8).c_str();
317 std::string dirId = fObservables[i].substr(fObservables[i].length() - 1, 1);
328 cout <<
"??????????????????????????????????????????????????" << endl;
329 cout <<
"REST warning : TRestGeant4AnalysisProcess." << endl;
330 cout <<
"------------------------------------------" << endl;
332 cout <<
" Volume " << volName2 <<
" is not an active volume" << endl;
334 cout <<
"List of active volumes : " << endl;
335 cout <<
"------------------------ " << endl;
339 cout <<
"??????????????????????????????????????????????????" << endl;
343 if ((dirId !=
"X") && (dirId !=
"Y") && (dirId !=
"Z")) {
345 cout <<
"??????????????????????????????????????????????????" << endl;
346 cout <<
"REST warning : TRestGeant4AnalysisProcess." << endl;
347 cout <<
"------------------------------------------" << endl;
349 cout <<
" Direction " << dirId <<
" is not valid" << endl;
350 cout <<
" Only X, Y or Z accepted" << endl;
354 if (fObservables[i].find(
"Process") != string::npos) {
356 if (fObservables[i].find(
"RadiactiveDecay") != string::npos) ls = 15;
357 if (fObservables[i].find(
"Photoelectric") != string::npos) ls = 13;
358 if (fObservables[i].find(
"PhotonNuclear") != string::npos) ls = 13;
359 if (fObservables[i].find(
"Bremstralung") != string::npos) ls = 12;
360 if (fObservables[i].find(
"NInelastic") != string::npos) ls = 10;
361 if (fObservables[i].find(
"HadElastic") != string::npos) ls = 10;
362 if (fObservables[i].find(
"NCapture") != string::npos) ls = 8;
363 if (fObservables[i].find(
"Compton") != string::npos) ls = 7;
364 if (fObservables[i].find(
"Neutron") != string::npos) ls = 7;
365 if (fObservables[i].find(
"Alpha") != string::npos) ls = 5;
366 if (fObservables[i].find(
"Argon") != string::npos) ls = 5;
367 if (fObservables[i].find(
"Xenon") != string::npos) ls = 5;
368 if (fObservables[i].find(
"Neon") != string::npos) ls = 4;
370 TString processName = fObservables[i].substr(fObservables[i].length() - (ls + 7), ls).c_str();
371 TString volName3 = fObservables[i].substr(0, fObservables[i].length() - (ls + 7)).c_str();
380 if (fObservables[i].find(
"TracksCounter") != string::npos) {
381 TString particleName = fObservables[i].substr(0, fObservables[i].length() - 13).c_str();
386 if (fObservables[i].find(
"TracksEDep") != string::npos) {
387 TString particleName = fObservables[i].substr(0, fObservables[i].length() - 10).c_str();
403 Double_t sensitiveVolumeEnergy =
fOutputG4Event->GetEnergyInVolume(sensitiveVolumeName.Data());
405 double hitTime = std::numeric_limits<double>::infinity();
407 const auto hits = track.GetHits();
408 for (
size_t hitIndex = 0; hitIndex < hits.GetNumberOfHits(); hitIndex++) {
409 const auto volumeName = hits.GetVolumeName(hitIndex);
410 if (volumeName != sensitiveVolumeName) {
413 const double energy = hits.GetEnergy(hitIndex);
418 const double time = hits.GetTime(hitIndex);
419 if (time < hitTime) {
427 cout <<
"----------------------------" << endl;
429 cout <<
"Sensitive volume Energy : " << sensitiveVolumeEnergy << endl;
430 cout <<
"Total energy : " <<
fOutputG4Event->GetTotalDepositedEnergy() << endl;
444 Double_t xDirection =
fOutputG4Event->GetPrimaryEventDirection(0).X();
447 Double_t yDirection =
fOutputG4Event->GetPrimaryEventDirection(0).Y();
450 Double_t zDirection =
fOutputG4Event->GetPrimaryEventDirection(0).Z();
453 TVector3 v(xDirection, yDirection, zDirection);
457 Double_t energyPrimary =
fOutputG4Event->GetPrimaryEventEnergy(0);
469 vector<string> processNames = {
"phot",
"compt"};
470 for (
auto& processName : processNames) {
471 Int_t containsProcess = 0;
476 if (!processName.empty()) {
477 processName[0] = toupper(processName[0]);
504 if (
fDirID[n] == (TString)
"X")
507 else if (
fDirID[n] == (TString)
"Y")
510 else if (
fDirID[n] == (TString)
"Z")
517 cout <<
"G4 Tracks : " <<
fOutputG4Event->GetNumberOfTracks() << endl;
518 cout <<
"----------------------------" << endl;
void SetObservableValue(const std::string &name, const T &value)
Set observable value for AnalysisTree.
A base class for any REST event.
A pure analysis process to extract information from a TRestGeant4Event.
void Initialize() override
Function to initialize input/output event members and define the section name.
std::vector< std::string > fEnergyInObservables
It stores the name of observables xxxVolumeEDep related to the energy deposition in volume xxx.
std::vector< std::string > fDirID
void InitProcess() override
Process initialization. Observable names are interpreted and auxiliar observable members,...
TRestGeant4Event * fInputG4Event
A pointer to the specific TRestGeant4Event input.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
TRestGeant4Metadata * fG4Metadata
A pointer to the simulation metadata information accessible to TRestRun.
~TRestGeant4AnalysisProcess()
Default destructor.
std::vector< std::string > fTracksEDepObservables
A std::vector storing the observable name xxxTracksEDep for a given xxx particle.
std::vector< std::string > fParticleTrackCounter
A std::vector storing the xxx particle name extracted from xxxTracksCounter.
std::vector< std::string > fProcessObservables
A std::vector storing the name of observables related to processes in a particular active volume.
std::vector< Int_t > fVolumeID2
A std::vector storing the active volume ids corresponding mean position observable xxxMeanPosX,...
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
std::vector< Int_t > fVolumeID
A std::vector storing the active volume ids of observables xxxVolumeEDep.
TRestGeant4Event * fOutputG4Event
A pointer to the specific TRestGeant4Event output.
std::vector< std::string > fTrackCounterObservables
A std::vector storing the observable name xxxTracksCounter for a given xxx particle.
std::vector< Int_t > fVolumeID3
A std::vector storing the active volume ids corresponding process observable .
TRestGeant4AnalysisProcess()
Default constructor.
std::vector< std::string > fMeanPosObservables
A std::vector storing the name of active volumes.
std::vector< std::string > fProcessName
A std::vector storing the name of processes.
void EndProcess() override
Function to include required actions after all events have been processed.
std::vector< std::string > fParticleTrackEdep
A std::vector storing the xxx particle name extracted from xxxTracksEDep.
An event class to store geant4 generated event information.
Double_t GetBoundingBoxSize()
This method returns the event size as the size of the bounding box enclosing all hits.
@ REST_Debug
+show the defined debug messages