Skip to content

Commit 9e072ff

Browse files
authored
Merge pull request #67 from rest-for-physics/jgalan_analysis_upgrade
New observable boundingSize inside TRestGeant4AnalysisProcess
2 parents 6c6af93 + 896e4d3 commit 9e072ff

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(LibraryVersion "1.8")
1+
set(LibraryVersion "1.9")
22
add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")
33

44
if (${REST_DECAY0} MATCHES "ON")

inc/TRestGeant4Event.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class TRestGeant4Event : public TRestEvent {
132132
void SetBoundaries(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin,
133133
Double_t zMax);
134134

135+
Double_t GetBoundingBoxSize();
136+
135137
inline size_t GetNumberOfPrimaries() const { return fPrimaryParticleNames.size(); }
136138

137139
inline TString GetPrimaryEventParticleName(size_t n = 0) const { return fPrimaryParticleNames[n]; }
@@ -238,6 +240,7 @@ class TRestGeant4Event : public TRestEvent {
238240

239241
// Constructor
240242
TRestGeant4Event();
243+
241244
// Destructor
242245
virtual ~TRestGeant4Event();
243246

src/TRestGeant4AnalysisProcess.cxx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,12 @@
145145
///
146146
/// * **thetaPrimary**: polar angle of the primary generated particle.
147147
/// * **phiPrimary**: azimuth angle of the primary generated particle.
148-
///
149148
/// * **energyPrimary**: energy of the primary event generated.
150149
///
150+
/// * **boundingSize**: It stores a value with the event size calculated
151+
/// as the diagonal distance of a bounding box defined to contain all the
152+
/// hits that produced an energy deposit.
153+
///
151154
/// The following code ilustrates the addition of a primary event
152155
/// observable.
153156
///
@@ -417,8 +420,6 @@ TRestEvent* TRestGeant4AnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {
417420
fInputG4Event = (TRestGeant4Event*)inputEvent;
418421
*fOutputG4Event = *((TRestGeant4Event*)inputEvent);
419422

420-
TString obsName;
421-
422423
Double_t energy = fOutputG4Event->GetSensitiveVolumeEnergy();
423424

424425
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Debug) {
@@ -456,19 +457,25 @@ TRestEvent* TRestGeant4AnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {
456457
SetObservableValue((string) "energyPrimary", energyPrimary);
457458

458459
Double_t energyTotal = fOutputG4Event->GetTotalDepositedEnergy();
459-
obsName = this->GetName() + (TString) ".totalEdep";
460460
SetObservableValue((string) "totalEdep", energyTotal);
461461

462+
Double_t size = fOutputG4Event->GetBoundingBoxSize();
463+
SetObservableValue((string) "boundingSize", size);
464+
462465
// process names as named by Geant4
463466
// processes present here will be added to the list of observables which can be used to see if the event
464467
// contains the process of interest.
465468
vector<string> processNames = {"phot", "compt"};
466-
for (const auto& processName : processNames) {
469+
for (auto& processName : processNames) {
467470
Int_t containsProcess = 0;
468471
if (fOutputG4Event->ContainsProcess(fG4Metadata->GetGeant4PhysicsInfo().GetProcessID(processName))) {
469472
containsProcess = 1;
470473
}
471-
SetObservableValue("ContainsProcess" + processName, containsProcess);
474+
475+
if (processName.size() > 0) {
476+
processName[0] = toupper(processName[0]);
477+
SetObservableValue("containsProcess" + processName, containsProcess);
478+
}
472479
}
473480

474481
/*
@@ -547,7 +554,7 @@ TRestEvent* TRestGeant4AnalysisProcess::ProcessEvent(TRestEvent* inputEvent) {
547554
cout << "----------------------------" << endl;
548555
}
549556

550-
// These cuts should be in another process or eliminated?!!
557+
/// We should use here ApplyCut
551558
if (energy < fLowEnergyCut) return nullptr;
552559
if (fHighEnergyCut > 0 && energy > fHighEnergyCut) return nullptr;
553560

src/TRestGeant4Event.cxx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,20 @@ void TRestGeant4Event::SetBoundaries(Double_t xMin, Double_t xMax, Double_t yMin
281281
fMaxZ = zMax;
282282
}
283283

284+
///////////////////////////////////////////////
285+
/// \brief This method returns the event size as the size of the bounding box
286+
/// enclosing all hits.
287+
///
288+
Double_t TRestGeant4Event::GetBoundingBoxSize() {
289+
SetBoundaries();
290+
291+
Double_t dX = fMaxX - fMinX;
292+
Double_t dY = fMaxY - fMinY;
293+
Double_t dZ = fMaxZ - fMinZ;
294+
295+
return TMath::Sqrt(dX * dX + dY * dY + dZ * dZ);
296+
}
297+
284298
void TRestGeant4Event::SetBoundaries() {
285299
Double_t maxX = -1e10, minX = 1e10, maxZ = -1e10, minZ = 1e10, maxY = -1e10, minY = 1e10;
286300
Double_t minEnergy = 1e10, maxEnergy = -1e10;
@@ -297,6 +311,8 @@ void TRestGeant4Event::SetBoundaries() {
297311

298312
Double_t en = hits.GetEnergy(nhit);
299313

314+
if (en <= 0) continue;
315+
300316
if (x > maxX) maxX = x;
301317
if (x < minX) minX = x;
302318
if (y > maxY) maxY = y;

0 commit comments

Comments
 (0)