Skip to content

Commit

Permalink
Revert "Merge pull request #263 from rest-for-physics/lobis-minor-upd…
Browse files Browse the repository at this point in the history
…ates"

This reverts commit d42b180, reversing
changes made to d1a9e8c.
  • Loading branch information
jgalan committed Aug 31, 2022
1 parent 80dcaa9 commit 49b6933
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 110 deletions.
131 changes: 66 additions & 65 deletions source/framework/core/inc/TRestHits.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,41 @@
#ifndef TRestSoft_TRestHits
#define TRestSoft_TRestHits

#include <TArrayD.h>
#include <TArrayI.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TGraphErrors.h>
#include <TH1.h>
#include <TMath.h>
#include <TMatrixD.h>
#include <TVector3.h>

#include <iostream>

enum REST_HitType { unknown = -1, X = 2, Y = 3, Z = 5, XY = 6, XZ = 10, YZ = 15, XYZ = 30 };

/// It saves a 3-coordinate position and an energy for each punctual deposition.
class TRestHits {
protected:
size_t fNHits = 0; ///< Number of punctual energy depositions, it is the length for all the arrays
Double_t fTotalEnergy = 0; ///< Event total energy

/// Position on X axis for each punctual deposition (units mm)
std::vector<Float_t> fX; // [fNHits]

/// Position on Y axis for each punctual deposition (units mm)
std::vector<Float_t> fY; // [fNHits]

/// Position on Z axis for each punctual deposition (units mm)
std::vector<Float_t> fZ; // [fNHits]
#include "TArrayD.h"
#include "TArrayI.h"
#include "TCanvas.h"
#include "TMath.h"
#include "TMatrixD.h"
#include "TObject.h"

/// Absolute time information for each punctual deposition (units us, 0 is time of decay)
std::vector<Float_t> fTime; // [fNHits]

/// Energy deposited at each 3-coordinate position (units keV)
std::vector<Float_t> fEnergy; // [fNHits]

/// The type of hit X,Y,XY,XYZ, ...
std::vector<REST_HitType> fType;
enum REST_HitType { unknown = -1, X = 2, Y = 3, Z = 5, XY = 6, XZ = 10, YZ = 15, XYZ = 30 };
//! It let save an event as a set of punctual deposition.
//! It saves a 3-coordinate position and an energy for each punctual deposition.
class TRestHits : public TObject {
public:
Int_t fNHits; ///< Number of punctual energy depositions, it is the length
///< for all the array
Double_t fTotEnergy; ///< Event total energy

std::vector<Float_t> fX; // [fNHits] Position on X axis for each punctual
// deposition (units mm)
std::vector<Float_t> fY; // [fNHits] Position on Y axis for each punctual
// deposition (units mm)
std::vector<Float_t> fZ; // [fNHits] Position on Z axis for each punctual
// deposition (units mm)
std::vector<Float_t> fT; // [fNHits] Absolute time information for each punctual deposition
// (units us, 0 is time of decay)
std::vector<Float_t> fEnergy; // [fNHits] Energy deposited at each
// 3-coordinate position (units keV)
std::vector<REST_HitType> fType; //

public:
void Translate(Int_t n, Double_t x, Double_t y, Double_t z);
Expand All @@ -70,12 +68,13 @@ class TRestHits {
void AddHit(const TVector3& pos, Double_t en, Double_t t = 0, REST_HitType type = XYZ);
void AddHit(TRestHits& hits, Int_t n);

void RemoveHits();

Int_t GetMostEnergeticHitInRange(Int_t n, Int_t m) const;

Double_t GetMaximumHitDistance() const;
Double_t GetMaximumHitDistance2() const;

virtual void RemoveHits();
virtual void MergeHits(int n, int m);
virtual void SwapHits(Int_t i, Int_t j);
virtual void RemoveHit(int n);
Expand All @@ -87,24 +86,24 @@ class TRestHits {

Bool_t isNaN(Int_t n) const;

void GetXArray(Float_t* x) const;
void GetYArray(Float_t* y) const;
void GetZArray(Float_t* z) const;

void InitializeXArray(Float_t x = 0);
void InitializeYArray(Float_t y = 0);
void InitializeZArray(Float_t z = 0);

Double_t GetDistanceToNode(Int_t n) const;

Bool_t isSortedByEnergy() const;

inline size_t GetNumberOfHits() const { return fNHits; }

inline const std::vector<Float_t>& GetX() const { return fX; }
inline const std::vector<Float_t>& GetY() const { return fY; }
inline const std::vector<Float_t>& GetZ() const { return fZ; }
inline const std::vector<Float_t>& GetTime() const { return fTime; }
inline const std::vector<Float_t>& GetEnergyVector() const { return fEnergy; }

inline Double_t GetX(int n) const { return ((Double_t)fX[n]); } // return value in mm
inline Double_t GetY(int n) const { return ((Double_t)fY[n]); } // return value in mm
inline Double_t GetZ(int n) const { return ((Double_t)fZ[n]); } // return value in mm
inline Double_t GetTime(int n) const { return ((Double_t)fTime[n]); } // return value in us
inline Double_t GetEnergy(int n) const { return ((Double_t)fEnergy[n]); } // return value in keV
inline Int_t GetNumberOfHits() const { return fNHits; }

inline Double_t GetX(int n) const { return ((Double_t)fX[n]); } // return value in mm
inline Double_t GetY(int n) const { return ((Double_t)fY[n]); } // return value in mm
inline Double_t GetZ(int n) const { return ((Double_t)fZ[n]); } // return value in mm
inline Double_t GetTime(int n) const { return ((Double_t)fT[n]); } // return value in us
inline REST_HitType GetType(int n) const { return fType[n]; }

TVector3 GetPosition(int n) const;
Expand Down Expand Up @@ -132,6 +131,8 @@ class TRestHits {
Double_t GetEnergyX() const;
Double_t GetEnergyY() const;

inline Double_t GetEnergy(int n) const { return ((Double_t)fEnergy[n]); } // return value in keV

Bool_t isHitNInsidePrism(Int_t n, const TVector3& x0, const TVector3& x1, Double_t sizeX, Double_t sizeY,
Double_t theta) const;
Int_t GetNumberOfHitsInsidePrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, Double_t sizeY,
Expand Down Expand Up @@ -169,11 +170,11 @@ class TRestHits {
Double_t GetMinimumHitEnergy() const;
Double_t GetMeanHitEnergy() const;

inline void CalculateTotalDepositedEnergy() { fTotalEnergy = GetEnergyIntegral(); }
void CalculateTotalDepositedEnergy() { fTotEnergy = GetEnergyIntegral(); }
Double_t GetEnergyIntegral() const;
inline Double_t GetTotalDepositedEnergy() const { return fTotalEnergy; }
inline Double_t GetTotalEnergy() const { return fTotalEnergy; }
inline Double_t GetEnergy() const { return fTotalEnergy; }
inline Double_t GetTotalDepositedEnergy() const { return fTotEnergy; }
inline Double_t GetTotalEnergy() const { return fTotEnergy; }
inline Double_t GetEnergy() const { return fTotEnergy; }
Double_t GetDistance2(int n, int m) const;
inline Double_t GetDistance(int N, int M) const { return TMath::Sqrt(GetDistance2(N, M)); }
Double_t GetTotalDistance() const;
Expand All @@ -199,10 +200,10 @@ class TRestHits {

class TRestHits_Iterator : public std::iterator<std::random_access_iterator_tag, TRestHits_Iterator> {
private:
int maxIndex = 0;
int maxindex = 0;
int index = 0;
TRestHits* fHits = nullptr;
bool isAccessor = false;
bool isaccessor = false;
float _x;
float _y;
float _z;
Expand All @@ -211,19 +212,19 @@ class TRestHits {
REST_HitType _type;

public:
float& x() { return isAccessor ? _x : fHits->fX[index]; }
float& y() { return isAccessor ? _y : fHits->fY[index]; }
float& z() { return isAccessor ? _z : fHits->fZ[index]; }
float& t() { return isAccessor ? _t : fHits->fTime[index]; }
float& e() { return isAccessor ? _e : fHits->fEnergy[index]; }
REST_HitType& type() { return isAccessor ? _type : fHits->fType[index]; }

float x() const { return isAccessor ? _x : fHits->fX[index]; }
float y() const { return isAccessor ? _y : fHits->fY[index]; }
float z() const { return isAccessor ? _z : fHits->fZ[index]; }
float t() const { return isAccessor ? _t : fHits->fTime[index]; }
float e() const { return isAccessor ? _e : fHits->fEnergy[index]; }
REST_HitType type() const { return isAccessor ? _type : fHits->fType[index]; }
float& x() { return isaccessor ? _x : fHits->fX[index]; }
float& y() { return isaccessor ? _y : fHits->fY[index]; }
float& z() { return isaccessor ? _z : fHits->fZ[index]; }
float& t() { return isaccessor ? _t : fHits->fT[index]; }
float& e() { return isaccessor ? _e : fHits->fEnergy[index]; }
REST_HitType& type() { return isaccessor ? _type : fHits->fType[index]; }

float x() const { return isaccessor ? _x : fHits->fX[index]; }
float y() const { return isaccessor ? _y : fHits->fY[index]; }
float z() const { return isaccessor ? _z : fHits->fZ[index]; }
float t() const { return isaccessor ? _t : fHits->fT[index]; }
float e() const { return isaccessor ? _e : fHits->fEnergy[index]; }
REST_HitType type() const { return isaccessor ? _type : fHits->fType[index]; }

// accessor: hit data is copied to self. The class acts like "TRestHit"
void toaccessor();
Expand All @@ -247,7 +248,7 @@ class TRestHits {
return i1.fHits != i2.fHits || i1.index != i2.index;
}
friend bool operator>(const TRestHits_Iterator& i1, const TRestHits_Iterator& i2) {
// default comparison logic
// default comparsion logic
return i1.index > i2.index;
}
friend bool operator>=(const TRestHits_Iterator& i1, const TRestHits_Iterator& i2) {
Expand All @@ -268,14 +269,14 @@ class TRestHits {

TRestHits_Iterator(TRestHits* h, int _index);
};
inline TRestHits_Iterator begin() { return {this, 0}; }
inline TRestHits_Iterator end() { return {this, static_cast<int>(fNHits)}; }
inline TRestHits_Iterator begin() { return TRestHits_Iterator(this, 0); }
inline TRestHits_Iterator end() { return TRestHits_Iterator(this, fNHits); }
typedef TRestHits_Iterator iterator;

TRestHits();
~TRestHits();

ClassDef(TRestHits, 6);
ClassDef(TRestHits, 5);
};

#endif
Loading

0 comments on commit 49b6933

Please sign in to comment.