From bb8a120aa32af5b49846119ba31d50be2c1a6059 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Fri, 1 Apr 2022 13:08:14 +0200 Subject: [PATCH 01/17] TRestEvent - made methods consts, used const references, increased class version. No functional changes. (perhaps class version does not need to be increased?) --- source/framework/core/inc/TRestEvent.h | 36 ++++++++++++------------ source/framework/core/src/TRestEvent.cxx | 17 ++++++----- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/source/framework/core/inc/TRestEvent.h b/source/framework/core/inc/TRestEvent.h index 8ce892f1b..b763bf425 100644 --- a/source/framework/core/inc/TRestEvent.h +++ b/source/framework/core/inc/TRestEvent.h @@ -55,34 +55,34 @@ class TRestEvent : public TObject { public: // Setters - void SetRunOrigin(Int_t run_origin) { fRunOrigin = run_origin; } - void SetSubRunOrigin(Int_t sub_run_origin) { fSubRunOrigin = sub_run_origin; } + inline void SetRunOrigin(Int_t run_origin) { fRunOrigin = run_origin; } + inline void SetSubRunOrigin(Int_t sub_run_origin) { fSubRunOrigin = sub_run_origin; } - void SetID(Int_t id) { fEventID = id; } - void SetSubID(Int_t id) { fSubEventID = id; } - void SetSubEventTag(TString tag) { fSubEventTag = tag; } + inline void SetID(Int_t id) { fEventID = id; } + inline void SetSubID(Int_t id) { fSubEventID = id; } + inline void SetSubEventTag(const TString& tag) { fSubEventTag = tag; } void SetTime(Double_t time); void SetTime(Double_t seconds, Double_t nanoseconds); - void SetTimeStamp(TTimeStamp time) { fEventTime = time; } + inline void SetTimeStamp(const TTimeStamp& time) { fEventTime = time; } - void SetState(Bool_t state) { fOk = state; } - void SetOK(Bool_t state) { fOk = state; } + inline void SetState(Bool_t state) { fOk = state; } + inline void SetOK(Bool_t state) { fOk = state; } void SetEventInfo(TRestEvent* eve); // Getters - Int_t GetID() { return fEventID; } - Int_t GetSubID() { return fSubEventID; } - TString GetSubEventTag() { return fSubEventTag; } + inline Int_t GetID() const { return fEventID; } + inline Int_t GetSubID() const { return fSubEventID; } + inline TString GetSubEventTag() const { return fSubEventTag; } - Int_t GetRunOrigin() { return fRunOrigin; } - Int_t GetSubRunOrigin() { return fSubRunOrigin; } + inline Int_t GetRunOrigin() const { return fRunOrigin; } + inline Int_t GetSubRunOrigin() const { return fSubRunOrigin; } - Double_t GetTime() { return fEventTime.AsDouble(); } - TTimeStamp GetTimeStamp() { return fEventTime; } + inline Double_t GetTime() const { return fEventTime.AsDouble(); } + inline TTimeStamp GetTimeStamp() const { return fEventTime; } - Bool_t isOk() { return fOk; } + inline Bool_t isOk() const { return fOk; } virtual void Initialize() = 0; virtual void InitializeWithMetadata(TRestRun* r); @@ -93,7 +93,7 @@ class TRestEvent : public TObject { /// \brief Draw the event /// /// To be implemented in the derived class - virtual TPad* DrawEvent(TString option = "") { + virtual TPad* DrawEvent(const TString& option = "") { UNUSED(option); return new TPad(); } @@ -105,6 +105,6 @@ class TRestEvent : public TObject { // Destructor virtual ~TRestEvent(); - ClassDef(TRestEvent, 1); // REST event superclass + ClassDef(TRestEvent, 2); // REST event superclass }; #endif \ No newline at end of file diff --git a/source/framework/core/src/TRestEvent.cxx b/source/framework/core/src/TRestEvent.cxx index 6f7ead21e..2f5bb39d7 100644 --- a/source/framework/core/src/TRestEvent.cxx +++ b/source/framework/core/src/TRestEvent.cxx @@ -73,7 +73,6 @@ void TRestEvent::Initialize() { fSubEventID = 0; fSubEventTag = ""; fOk = true; - fPad = nullptr; } @@ -81,18 +80,18 @@ void TRestEvent::Initialize() { /// Set the time of the event /// void TRestEvent::SetTime(Double_t time) { - Int_t sec = (Int_t)time; - Int_t nsec = (Int_t)((time - sec) * 1E9); + auto seconds = (Int_t)time; + auto nanoseconds = (Int_t)((time - seconds) * 1E9); - fEventTime.SetSec(sec); - fEventTime.SetNanoSec(nsec); + fEventTime.SetSec(seconds); + fEventTime.SetNanoSec(nanoseconds); } ////////////////////////////////////////////////////////////////////////// /// \brief Clone the content of this TRestEvent object to another /// /// This method uses default root streamer to do the copying. The efficiency is -/// low. Override recommanded. +/// low. Override recommended. void TRestEvent::CloneTo(TRestEvent* target) { if (this->ClassName() != target->ClassName()) { cout << "In TRestEvent::CloneTo() : Event type doesn't match! (This :" << this->ClassName() @@ -125,12 +124,12 @@ void TRestEvent::CloneTo(TRestEvent* target) { /// Set the time of the event /// void TRestEvent::SetTime(Double_t seconds, Double_t nanoseconds) { - fEventTime.SetSec(seconds); - fEventTime.SetNanoSec(nanoseconds); + fEventTime.SetSec((Int_t)seconds); + fEventTime.SetNanoSec((Int_t)nanoseconds); } ////////////////////////////////////////////////////////////////////////// -/// Copy the six univeral information in TRestEvent from another TRestEvent +/// Copy the six universal information in TRestEvent from another TRestEvent /// void TRestEvent::SetEventInfo(TRestEvent* eve) { if (eve != nullptr) { From 634364a4682b42c1a76d0cd089f39ac203cbc9e1 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Fri, 1 Apr 2022 13:12:03 +0200 Subject: [PATCH 02/17] TRestHits - made some methods const --- source/framework/core/inc/TRestHits.h | 42 ++--- source/framework/core/src/TRestHits.cxx | 197 ++++++++++++------------ 2 files changed, 121 insertions(+), 118 deletions(-) diff --git a/source/framework/core/inc/TRestHits.h b/source/framework/core/inc/TRestHits.h index 453c0975c..ee0344dfa 100644 --- a/source/framework/core/inc/TRestHits.h +++ b/source/framework/core/inc/TRestHits.h @@ -21,11 +21,11 @@ #ifndef TRestSoft_TRestHits #define TRestSoft_TRestHits +#include #include +#include #include #include -#include -#include #include @@ -84,10 +84,10 @@ class TRestHits : public TObject { virtual void SwapHits(Int_t i, Int_t j); virtual void RemoveHit(int n); - virtual Bool_t areXY(); - virtual Bool_t areXZ(); - virtual Bool_t areYZ(); - virtual Bool_t areXYZ(); + virtual Bool_t areXY() const; + virtual Bool_t areXZ() const; + virtual Bool_t areYZ() const; + virtual Bool_t areXYZ() const; Bool_t isNaN(Int_t n); @@ -103,13 +103,13 @@ class TRestHits : public TObject { Bool_t isSortedByEnergy(); - Int_t GetNumberOfHits() { return fNHits; } + Int_t GetNumberOfHits() const { return fNHits; } - Double_t GetX(int n) { return ((Double_t)fX[n]); } // return value in mm - Double_t GetY(int n) { return ((Double_t)fY[n]); } // return value in mm - Double_t GetZ(int n) { return ((Double_t)fZ[n]); } // return value in mm - Double_t GetTime(int n) { return ((Double_t)fT[n]); } // return value in us - REST_HitType GetType(int n) { return fType[n]; } + Double_t GetX(int n) const { return ((Double_t)fX[n]); } // return value in mm + Double_t GetY(int n) const { return ((Double_t)fY[n]); } // return value in mm + Double_t GetZ(int n) const { return ((Double_t)fZ[n]); } // return value in mm + Double_t GetTime(int n) const { return ((Double_t)fT[n]); } // return value in us + REST_HitType GetType(int n) const { return fType[n]; } TVector3 GetPosition(int n); TVector3 GetVector(int i, int j); @@ -136,7 +136,7 @@ class TRestHits : public TObject { Double_t GetEnergyX(); Double_t GetEnergyY(); - Double_t GetEnergy(int n) { return ((Double_t)fEnergy[n]); } // return value in keV + Double_t GetEnergy(int n) const { return ((Double_t)fEnergy[n]); } // return value in keV Bool_t isHitNInsidePrism(Int_t n, TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta); @@ -174,11 +174,11 @@ class TRestHits : public TObject { Double_t GetMeanHitEnergy(); Double_t GetEnergyIntegral(); - Double_t GetTotalDepositedEnergy() { return fTotEnergy; } - Double_t GetTotalEnergy() { return fTotEnergy; } - Double_t GetEnergy() { return fTotEnergy; } - Double_t GetDistance2(int n, int m); - Double_t GetDistance(int N, int M) { return TMath::Sqrt(GetDistance2(N, M)); } + Double_t GetTotalDepositedEnergy() const { return fTotEnergy; } + Double_t GetTotalEnergy() const { return fTotEnergy; } + Double_t GetEnergy() const { return fTotEnergy; } + Double_t GetDistance2(int n, int m) const; + Double_t GetDistance(int N, int M) const { return TMath::Sqrt(GetDistance2(N, M)); } Double_t GetTotalDistance(); Double_t GetHitsPathLength(Int_t n = 0, Int_t m = 0); @@ -200,7 +200,7 @@ class TRestHits : public TObject { private: int maxindex = 0; int index = 0; - TRestHits* fHits = 0; + TRestHits* fHits = nullptr; bool isaccessor = false; float _x; float _y; @@ -249,7 +249,7 @@ class TRestHits : public TObject { return i1.index > i2.index; } friend bool operator>=(const TRestHits_Iterator& i1, const TRestHits_Iterator& i2) { - // default comparsion logic + // default comparison logic return i1.index >= i2.index; } friend bool operator<(const TRestHits_Iterator& i1, const TRestHits_Iterator& i2) { @@ -270,7 +270,7 @@ class TRestHits : public TObject { TRestHits_Iterator end() { return TRestHits_Iterator(this, fNHits); } typedef TRestHits_Iterator iterator; - // Construtor + // Constructor TRestHits(); // Destructor ~TRestHits(); diff --git a/source/framework/core/src/TRestHits.cxx b/source/framework/core/src/TRestHits.cxx index 255fbd1e6..011e2fb0d 100644 --- a/source/framework/core/src/TRestHits.cxx +++ b/source/framework/core/src/TRestHits.cxx @@ -19,6 +19,7 @@ ///_______________________________________________________________________________ #include "TRestHits.h" + #include "TROOT.h" using namespace std; using namespace TMath; @@ -32,7 +33,7 @@ TRestHits::TRestHits() { TRestHits::~TRestHits() {} -Bool_t TRestHits::areXY() { +Bool_t TRestHits::areXY() const { for (int i = 0; i < GetNumberOfHits(); i++) { if (fType[i] != XY) { // all hits should fit this condition to be considered XY @@ -44,7 +45,7 @@ Bool_t TRestHits::areXY() { return false; } -Bool_t TRestHits::areXZ() { +Bool_t TRestHits::areXZ() const { for (int i = 0; i < GetNumberOfHits(); i++) { if (fType[i] != XZ) { // all hits should fit this condition to be considered XY @@ -56,7 +57,7 @@ Bool_t TRestHits::areXZ() { return false; } -Bool_t TRestHits::areYZ() { +Bool_t TRestHits::areYZ() const { for (int i = 0; i < GetNumberOfHits(); i++) { if (fType[i] != YZ) { // all hits should fit this condition to be considered XY @@ -68,7 +69,7 @@ Bool_t TRestHits::areYZ() { return false; } -Bool_t TRestHits::areXYZ() { +Bool_t TRestHits::areXYZ() const { for (int i = 0; i < GetNumberOfHits(); i++) { if (fType[i] != XYZ) { // all hits should fit this condition to be considered XY @@ -552,110 +553,112 @@ void TRestHits::WriteHitsToTextFile(TString filename) { for (int i = 0; i < GetNumberOfHits(); i++) { if ((fType.size() == 0 ? !IsNaN(fX[i]) : fType[i] % X == 0)) fprintf(fff, "%d\t%e\t%s\t%e\t%e\n", i, fX[i], "NaN", fZ[i], fEnergy[i]); - if ((fType.size() == 0 ? !IsNaN(fY[i]) : fType[i] % Y == 0)) + if ((fType.size() == 0 ? !IsNaN(fY[i]) : fType[i] % Y == 0)) fprintf(fff, "%d\t%s\t%e\t%e\t%e\n", i, "NaN", fY[i], fZ[i], fEnergy[i]); } fclose(fff); } Double_t TRestHits::GetGaussSigmaX() { - Double_t gausSigmaX = 0; - Int_t nHits = GetNumberOfHits(); - Double_t x[nHits], y[nHits], ex[nHits], ey[nHits]; - if (nHits <= 3) { - gausSigmaX = 0; - } else { - for (int n = 0; n < GetNumberOfHits(); n++) { - x[n] = fX[n]; - y[n] = fEnergy[n]; - ex[n] = 0; - if (y[n] != 0) { - ey[n] = 10*sqrt(y[n]); - } else { - ey[n] = 0; - } - } - TGraphErrors *grX = new TGraphErrors(nHits,x,y,ex,ey); - Double_t maxY = MaxElement(nHits,grX->GetY()); - Double_t maxX = grX->GetX()[LocMax(nHits,grX->GetY())]; - - TF1 *fit = new TF1("","gaus"); - fit->SetParameter(0,maxY); - fit->SetParameter(1,maxX); - fit->SetParameter(2, 2.0); - grX->Fit(fit, "QNB"); // Q = quiet, no info in screen; N = no plot; B = no automatic start parmaeters; R = Use the Range specified in the function range - - gausSigmaX = fit->GetParameter(2); - - } - - return gausSigmaX; + Double_t gausSigmaX = 0; + Int_t nHits = GetNumberOfHits(); + Double_t x[nHits], y[nHits], ex[nHits], ey[nHits]; + if (nHits <= 3) { + gausSigmaX = 0; + } else { + for (int n = 0; n < GetNumberOfHits(); n++) { + x[n] = fX[n]; + y[n] = fEnergy[n]; + ex[n] = 0; + if (y[n] != 0) { + ey[n] = 10 * sqrt(y[n]); + } else { + ey[n] = 0; + } + } + TGraphErrors* grX = new TGraphErrors(nHits, x, y, ex, ey); + Double_t maxY = MaxElement(nHits, grX->GetY()); + Double_t maxX = grX->GetX()[LocMax(nHits, grX->GetY())]; + + TF1* fit = new TF1("", "gaus"); + fit->SetParameter(0, maxY); + fit->SetParameter(1, maxX); + fit->SetParameter(2, 2.0); + grX->Fit(fit, "QNB"); // Q = quiet, no info in screen; N = no plot; B = no automatic start + // parmaeters; R = Use the Range specified in the function range + + gausSigmaX = fit->GetParameter(2); + } + + return gausSigmaX; } Double_t TRestHits::GetGaussSigmaY() { - Double_t gausSigmaY = 0; - Int_t nHits = GetNumberOfHits(); - - Double_t x[nHits], y[nHits], ex[nHits], ey[nHits]; - if (nHits <= 3) { - gausSigmaY = 0; - } else { - for (int n = 0; n < GetNumberOfHits(); n++) { - x[n] = fY[n]; - y[n] = fEnergy[n]; - ex[n] = 0; - if (y[n] != 0) { - ey[n] = 10*sqrt(y[n]); - } else { - ey[n] = 0; - } - } - TGraphErrors *grY = new TGraphErrors(nHits,x,y,ex,ey); - Double_t maxY = MaxElement(nHits,grY->GetY()); - Double_t maxX = grY->GetX()[LocMax(nHits,grY->GetY())]; - - TF1 *fit = new TF1("","gaus"); - fit->SetParameter(0,maxY); - fit->SetParameter(1,maxX); - fit->SetParameter(2, 2.0); - grY->Fit(fit, "QNB"); // Q = quiet, no info in screen; N = no plot; B = no automatic start parmaeters; R = Use the Range specified in the function range - - gausSigmaY = fit->GetParameter(2); - } - return gausSigmaY; + Double_t gausSigmaY = 0; + Int_t nHits = GetNumberOfHits(); + + Double_t x[nHits], y[nHits], ex[nHits], ey[nHits]; + if (nHits <= 3) { + gausSigmaY = 0; + } else { + for (int n = 0; n < GetNumberOfHits(); n++) { + x[n] = fY[n]; + y[n] = fEnergy[n]; + ex[n] = 0; + if (y[n] != 0) { + ey[n] = 10 * sqrt(y[n]); + } else { + ey[n] = 0; + } + } + TGraphErrors* grY = new TGraphErrors(nHits, x, y, ex, ey); + Double_t maxY = MaxElement(nHits, grY->GetY()); + Double_t maxX = grY->GetX()[LocMax(nHits, grY->GetY())]; + + TF1* fit = new TF1("", "gaus"); + fit->SetParameter(0, maxY); + fit->SetParameter(1, maxX); + fit->SetParameter(2, 2.0); + grY->Fit(fit, "QNB"); // Q = quiet, no info in screen; N = no plot; B = no automatic start + // parmaeters; R = Use the Range specified in the function range + + gausSigmaY = fit->GetParameter(2); + } + return gausSigmaY; } Double_t TRestHits::GetGaussSigmaZ() { - Double_t gausSigmaZ = 0; - Int_t nHits = GetNumberOfHits(); - - Double_t x[nHits], y[nHits], ex[nHits], ey[nHits]; - if (nHits <= 3) { - gausSigmaZ = 0; - } else { - for (int n = 0; n < GetNumberOfHits(); n++) { - x[n] = fZ[n]; - y[n] = fEnergy[n]; - ex[n] = 0; - if (y[n] != 0) { - ey[n] = 10*sqrt(y[n]); - } else { - ey[n] = 0; - } - } - TGraphErrors *grZ = new TGraphErrors(nHits,x,y,ex,ey); - Double_t maxY = MaxElement(nHits,grZ->GetY()); - Double_t maxX = grZ->GetX()[LocMax(nHits,grZ->GetY())]; - - TF1 *fit = new TF1("","gaus",maxX-5,maxX+5); - fit->SetParameter(0,maxY); - fit->SetParameter(1,maxX); - fit->SetParameter(2, 2.0); - grZ->Fit(fit, "QNB"); // Q = quiet, no info in screen; N = no plot; B = no automatic start parmaeters; R = Use the Range specified in the function range - - gausSigmaZ = fit->GetParameter(2); - } - return gausSigmaZ; + Double_t gausSigmaZ = 0; + Int_t nHits = GetNumberOfHits(); + + Double_t x[nHits], y[nHits], ex[nHits], ey[nHits]; + if (nHits <= 3) { + gausSigmaZ = 0; + } else { + for (int n = 0; n < GetNumberOfHits(); n++) { + x[n] = fZ[n]; + y[n] = fEnergy[n]; + ex[n] = 0; + if (y[n] != 0) { + ey[n] = 10 * sqrt(y[n]); + } else { + ey[n] = 0; + } + } + TGraphErrors* grZ = new TGraphErrors(nHits, x, y, ex, ey); + Double_t maxY = MaxElement(nHits, grZ->GetY()); + Double_t maxX = grZ->GetX()[LocMax(nHits, grZ->GetY())]; + + TF1* fit = new TF1("", "gaus", maxX - 5, maxX + 5); + fit->SetParameter(0, maxY); + fit->SetParameter(1, maxX); + fit->SetParameter(2, 2.0); + grZ->Fit(fit, "QNB"); // Q = quiet, no info in screen; N = no plot; B = no automatic start + // parmaeters; R = Use the Range specified in the function range + + gausSigmaZ = fit->GetParameter(2); + } + return gausSigmaZ; } Double_t TRestHits::GetSkewXY() { @@ -821,7 +824,7 @@ Double_t TRestHits::GetTotalDistance() { return distance; } -Double_t TRestHits::GetDistance2(int n, int m) { +Double_t TRestHits::GetDistance2(int n, int m) const { Double_t dx = GetX(n) - GetX(m); Double_t dy = GetY(n) - GetY(m); Double_t dz = GetZ(n) - GetZ(m); From 52ec9349e2551236b073c35b00914eaca87632f2 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Fri, 1 Apr 2022 13:26:34 +0200 Subject: [PATCH 03/17] TRestHits - made all possible methods const --- source/framework/core/inc/TRestHits.h | 141 ++++++++++---------- source/framework/core/src/TRestHits.cxx | 163 ++++++++++++------------ 2 files changed, 153 insertions(+), 151 deletions(-) diff --git a/source/framework/core/inc/TRestHits.h b/source/framework/core/inc/TRestHits.h index ee0344dfa..a5aba7999 100644 --- a/source/framework/core/inc/TRestHits.h +++ b/source/framework/core/inc/TRestHits.h @@ -75,10 +75,10 @@ class TRestHits : public TObject { void RemoveHits(); - Int_t GetMostEnergeticHitInRange(Int_t n, Int_t m); + Int_t GetMostEnergeticHitInRange(Int_t n, Int_t m) const; - Double_t GetMaximumHitDistance(); - Double_t GetMaximumHitDistance2(); + Double_t GetMaximumHitDistance() const; + Double_t GetMaximumHitDistance2() const; virtual void MergeHits(int n, int m); virtual void SwapHits(Int_t i, Int_t j); @@ -89,112 +89,113 @@ class TRestHits : public TObject { virtual Bool_t areYZ() const; virtual Bool_t areXYZ() const; - Bool_t isNaN(Int_t n); + Bool_t isNaN(Int_t n) const; - void GetXArray(Float_t* x); - void GetYArray(Float_t* y); - void GetZArray(Float_t* z); + 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); + Double_t GetDistanceToNode(Int_t n) const; - Bool_t isSortedByEnergy(); + Bool_t isSortedByEnergy() const; - Int_t GetNumberOfHits() const { return fNHits; } + inline Int_t GetNumberOfHits() const { return fNHits; } - Double_t GetX(int n) const { return ((Double_t)fX[n]); } // return value in mm - Double_t GetY(int n) const { return ((Double_t)fY[n]); } // return value in mm - Double_t GetZ(int n) const { return ((Double_t)fZ[n]); } // return value in mm - Double_t GetTime(int n) const { return ((Double_t)fT[n]); } // return value in us - REST_HitType GetType(int n) const { return fType[n]; } + 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); - TVector3 GetVector(int i, int j); + TVector3 GetPosition(int n) const; + TVector3 GetVector(int i, int j) const; - Int_t GetNumberOfHitsX(); - Int_t GetNumberOfHitsY(); + Int_t GetNumberOfHitsX() const; + Int_t GetNumberOfHitsY() const; - Double_t GetMeanPositionX(); - Double_t GetMeanPositionY(); - Double_t GetMeanPositionZ(); - TVector3 GetMeanPosition(); + Double_t GetMeanPositionX() const; + Double_t GetMeanPositionY() const; + Double_t GetMeanPositionZ() const; + TVector3 GetMeanPosition() const; - Double_t GetSigmaXY2(); - Double_t GetSigmaX(); - Double_t GetSigmaY(); - Double_t GetSigmaZ2(); - Double_t GetSkewXY(); - Double_t GetSkewZ(); + Double_t GetSigmaXY2() const; + Double_t GetSigmaX() const; + Double_t GetSigmaY() const; + Double_t GetSigmaZ2() const; + Double_t GetSkewXY() const; + Double_t GetSkewZ() const; Double_t GetGaussSigmaX(); Double_t GetGaussSigmaY(); Double_t GetGaussSigmaZ(); - Double_t GetEnergyX(); - Double_t GetEnergyY(); + Double_t GetEnergyX() const; + Double_t GetEnergyY() const; - Double_t GetEnergy(int n) const { return ((Double_t)fEnergy[n]); } // return value in keV + inline Double_t GetEnergy(int n) const { return ((Double_t)fEnergy[n]); } // return value in keV Bool_t isHitNInsidePrism(Int_t n, TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta); + Double_t theta) const; Int_t GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta); - Double_t GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta); + Double_t theta) const; + Double_t GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta) const; Double_t GetMeanPositionXInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta); + Double_t theta) const; Double_t GetMeanPositionYInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta); + Double_t theta) const; Double_t GetMeanPositionZInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta); - TVector3 GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta); + Double_t theta) const; + TVector3 GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, + Double_t theta) const; - Bool_t isHitNInsideCylinder(Int_t n, TVector3 x0, TVector3 x1, Double_t radius); + Bool_t isHitNInsideCylinder(Int_t n, TVector3 x0, TVector3 x1, Double_t radius) const; - Int_t GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius); - Int_t GetNumberOfHitsInsideCylinder(Int_t i, Int_t j, Double_t radius); + Int_t GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; + Int_t GetNumberOfHitsInsideCylinder(Int_t i, Int_t j, Double_t radius) const; - Double_t GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius); - Double_t GetEnergyInCylinder(Int_t i, Int_t j, Double_t radius); - Double_t GetMeanPositionXInCylinder(TVector3 x0, TVector3 x1, Double_t radius); - Double_t GetMeanPositionYInCylinder(TVector3 x0, TVector3 x1, Double_t radius); - Double_t GetMeanPositionZInCylinder(TVector3 x0, TVector3 x1, Double_t radius); - TVector3 GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius); + Double_t GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; + Double_t GetEnergyInCylinder(Int_t i, Int_t j, Double_t radius) const; + Double_t GetMeanPositionXInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; + Double_t GetMeanPositionYInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; + Double_t GetMeanPositionZInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; + TVector3 GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; - Bool_t isHitNInsideSphere(Int_t n, TVector3 pos0, Double_t radius); - Bool_t isHitNInsideSphere(Int_t n, Double_t x0, Double_t y0, Double_t z0, Double_t radius); + Bool_t isHitNInsideSphere(Int_t n, TVector3 pos0, Double_t radius) const; + Bool_t isHitNInsideSphere(Int_t n, Double_t x0, Double_t y0, Double_t z0, Double_t radius) const; - Double_t GetEnergyInSphere(TVector3 pos0, Double_t radius); - Double_t GetEnergyInSphere(Double_t x, Double_t y, Double_t z, Double_t radius); + Double_t GetEnergyInSphere(TVector3 pos0, Double_t radius) const; + Double_t GetEnergyInSphere(Double_t x, Double_t y, Double_t z, Double_t radius) const; - Double_t GetMaximumHitEnergy(); - Double_t GetMinimumHitEnergy(); - Double_t GetMeanHitEnergy(); + Double_t GetMaximumHitEnergy() const; + Double_t GetMinimumHitEnergy() const; + Double_t GetMeanHitEnergy() const; - Double_t GetEnergyIntegral(); - Double_t GetTotalDepositedEnergy() const { return fTotEnergy; } - Double_t GetTotalEnergy() const { return fTotEnergy; } - Double_t GetEnergy() const { return fTotEnergy; } + Double_t GetEnergyIntegral() const; + 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; - Double_t GetDistance(int N, int M) const { return TMath::Sqrt(GetDistance2(N, M)); } - Double_t GetTotalDistance(); + inline Double_t GetDistance(int N, int M) const { return TMath::Sqrt(GetDistance2(N, M)); } + Double_t GetTotalDistance() const; - Double_t GetHitsPathLength(Int_t n = 0, Int_t m = 0); + Double_t GetHitsPathLength(Int_t n = 0, Int_t m = 0) const; - Double_t GetHitsTwist(Int_t n, Int_t m); - Double_t GetHitsTwistWeighted(Int_t n, Int_t m); + Double_t GetHitsTwist(Int_t n, Int_t m) const; + Double_t GetHitsTwistWeighted(Int_t n, Int_t m) const; - Int_t GetClosestHit(TVector3 position); + Int_t GetClosestHit(TVector3 position) const; - TVector2 GetProjection(Int_t n, Int_t m, TVector3 position); + TVector2 GetProjection(Int_t n, Int_t m, TVector3 position) const; - Double_t GetTransversalProjection(TVector3 p0, TVector3 direction, TVector3 position); + Double_t GetTransversalProjection(TVector3 p0, TVector3 direction, TVector3 position) const; void WriteHitsToTextFile(TString filename); - virtual void PrintHits(Int_t nHits = -1); + virtual void PrintHits(Int_t nHits = -1) const; class TRestHits_Iterator : public std::iterator { private: @@ -266,8 +267,8 @@ class TRestHits : public TObject { TRestHits_Iterator(TRestHits* h, int _index); }; - TRestHits_Iterator begin() { return TRestHits_Iterator(this, 0); } - TRestHits_Iterator end() { return TRestHits_Iterator(this, fNHits); } + inline TRestHits_Iterator begin() { return TRestHits_Iterator(this, 0); } + inline TRestHits_Iterator end() { return TRestHits_Iterator(this, fNHits); } typedef TRestHits_Iterator iterator; // Constructor diff --git a/source/framework/core/src/TRestHits.cxx b/source/framework/core/src/TRestHits.cxx index 011e2fb0d..b7b8ccebe 100644 --- a/source/framework/core/src/TRestHits.cxx +++ b/source/framework/core/src/TRestHits.cxx @@ -21,6 +21,7 @@ #include "TRestHits.h" #include "TROOT.h" + using namespace std; using namespace TMath; @@ -81,12 +82,12 @@ Bool_t TRestHits::areXYZ() const { return false; } -Bool_t TRestHits::isNaN(Int_t n) { +Bool_t TRestHits::isNaN(Int_t n) const { if (IsNaN(GetX(n)) && IsNaN(GetY(n)) && IsNaN(GetZ(n))) return true; return false; } -void TRestHits::GetXArray(Float_t* x) { +void TRestHits::GetXArray(Float_t* x) const { if (areYZ()) { for (int i = 0; i < GetNumberOfHits(); i++) x[i] = 0; } else { @@ -94,19 +95,7 @@ void TRestHits::GetXArray(Float_t* x) { } } -void TRestHits::InitializeXArray(Float_t x) { - for (int i = 0; i < GetNumberOfHits(); i++) fX[i] = x; -} - -void TRestHits::InitializeYArray(Float_t y) { - for (int i = 0; i < GetNumberOfHits(); i++) fY[i] = y; -} - -void TRestHits::InitializeZArray(Float_t z) { - for (int i = 0; i < GetNumberOfHits(); i++) fZ[i] = z; -} - -void TRestHits::GetYArray(Float_t* y) { +void TRestHits::GetYArray(Float_t* y) const { if (areXZ()) { for (int i = 0; i < GetNumberOfHits(); i++) y[i] = 0; } else { @@ -114,7 +103,7 @@ void TRestHits::GetYArray(Float_t* y) { } } -void TRestHits::GetZArray(Float_t* z) { +void TRestHits::GetZArray(Float_t* z) const { if (areXY()) { for (int i = 0; i < GetNumberOfHits(); i++) z[i] = 0; } else { @@ -122,14 +111,26 @@ void TRestHits::GetZArray(Float_t* z) { } } -Double_t TRestHits::GetEnergyIntegral() { +void TRestHits::InitializeXArray(Float_t x) { + for (int i = 0; i < GetNumberOfHits(); i++) fX[i] = x; +} + +void TRestHits::InitializeYArray(Float_t y) { + for (int i = 0; i < GetNumberOfHits(); i++) fY[i] = y; +} + +void TRestHits::InitializeZArray(Float_t z) { + for (int i = 0; i < GetNumberOfHits(); i++) fZ[i] = z; +} + +Double_t TRestHits::GetEnergyIntegral() const { Double_t sum = 0; for (int i = 0; i < GetNumberOfHits(); i++) sum += GetEnergy(i); return sum; } Bool_t TRestHits::isHitNInsidePrism(Int_t n, TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) { + Double_t theta) const { TVector3 axis = x1 - x0; Double_t prismLength = axis.Mag(); @@ -145,7 +146,7 @@ Bool_t TRestHits::isHitNInsidePrism(Int_t n, TVector3 x0, TVector3 x1, Double_t } Double_t TRestHits::GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) { + Double_t theta) const { Double_t energy = 0.; for (int n = 0; n < GetNumberOfHits(); n++) @@ -155,7 +156,7 @@ Double_t TRestHits::GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, D } Int_t TRestHits::GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) { + Double_t theta) const { Int_t hits = 0; for (int n = 0; n < GetNumberOfHits(); n++) @@ -164,7 +165,7 @@ Int_t TRestHits::GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t s return hits; } -Bool_t TRestHits::isHitNInsideCylinder(Int_t n, TVector3 x0, TVector3 x1, Double_t radius) { +Bool_t TRestHits::isHitNInsideCylinder(Int_t n, TVector3 x0, TVector3 x1, Double_t radius) const { /* cout << "TRestHits::isHitNInsideCylinder has not been validated." << endl; cout << "After validation this output should be removed" << endl;*/ @@ -198,11 +199,11 @@ Bool_t TRestHits::isHitNInsideCylinder(Int_t n, TVector3 x0, TVector3 x1, Double return false; } -Double_t TRestHits::GetEnergyInCylinder(Int_t i, Int_t j, Double_t radius) { +Double_t TRestHits::GetEnergyInCylinder(Int_t i, Int_t j, Double_t radius) const { return GetEnergyInCylinder(this->GetPosition(i), this->GetPosition(j), radius); } -Double_t TRestHits::GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius) { +Double_t TRestHits::GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { Double_t energy = 0.; for (int n = 0; n < GetNumberOfHits(); n++) { if (isHitNInsideCylinder(n, x0, x1, radius)) energy += this->GetEnergy(n); @@ -211,11 +212,11 @@ Double_t TRestHits::GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radiu return energy; } -Int_t TRestHits::GetNumberOfHitsInsideCylinder(Int_t i, Int_t j, Double_t radius) { +Int_t TRestHits::GetNumberOfHitsInsideCylinder(Int_t i, Int_t j, Double_t radius) const { return GetNumberOfHitsInsideCylinder(this->GetPosition(i), this->GetPosition(j), radius); } -Int_t TRestHits::GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) { +Int_t TRestHits::GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { Int_t hits = 0; for (int n = 0; n < GetNumberOfHits(); n++) if (isHitNInsideCylinder(n, x0, x1, radius)) hits++; @@ -223,11 +224,11 @@ Int_t TRestHits::GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_ return hits; } -Double_t TRestHits::GetEnergyInSphere(TVector3 pos0, Double_t radius) { +Double_t TRestHits::GetEnergyInSphere(TVector3 pos0, Double_t radius) const { return GetEnergyInSphere(pos0.X(), pos0.Y(), pos0.Z(), radius); } -Double_t TRestHits::GetEnergyInSphere(Double_t x0, Double_t y0, Double_t z0, Double_t radius) { +Double_t TRestHits::GetEnergyInSphere(Double_t x0, Double_t y0, Double_t z0, Double_t radius) const { Double_t sum = 0; for (int i = 0; i < GetNumberOfHits(); i++) { Double_t x = this->GetPosition(i).X(); @@ -241,11 +242,11 @@ Double_t TRestHits::GetEnergyInSphere(Double_t x0, Double_t y0, Double_t z0, Dou return sum; } -Bool_t TRestHits::isHitNInsideSphere(Int_t n, TVector3 pos0, Double_t radius) { +Bool_t TRestHits::isHitNInsideSphere(Int_t n, TVector3 pos0, Double_t radius) const { return isHitNInsideSphere(n, pos0.X(), pos0.Y(), pos0.Z(), radius); } -Bool_t TRestHits::isHitNInsideSphere(Int_t n, Double_t x0, Double_t y0, Double_t z0, Double_t radius) { +Bool_t TRestHits::isHitNInsideSphere(Int_t n, Double_t x0, Double_t y0, Double_t z0, Double_t radius) const { Double_t x = this->GetPosition(n).X(); Double_t y = this->GetPosition(n).Y(); Double_t z = this->GetPosition(n).Z(); @@ -337,21 +338,21 @@ void TRestHits::Rotate(Int_t n, Double_t alpha, TVector3 vAxis, TVector3 vMean) fZ[n] = vHit[2] + vMean[2]; } -Double_t TRestHits::GetMaximumHitEnergy() { +Double_t TRestHits::GetMaximumHitEnergy() const { Double_t energy = 0; for (int i = 0; i < GetNumberOfHits(); i++) if (GetEnergy(i) > energy) energy = GetEnergy(i); return energy; } -Double_t TRestHits::GetMinimumHitEnergy() { +Double_t TRestHits::GetMinimumHitEnergy() const { Double_t energy = GetMaximumHitEnergy(); for (int i = 0; i < GetNumberOfHits(); i++) if (GetEnergy(i) < energy) energy = GetEnergy(i); return energy; } -Double_t TRestHits::GetMeanHitEnergy() { return GetTotalEnergy() / GetNumberOfHits(); } +Double_t TRestHits::GetMeanHitEnergy() const { return GetTotalEnergy() / GetNumberOfHits(); } void TRestHits::MergeHits(int n, int m) { Double_t totalEnergy = fEnergy[n] + fEnergy[m]; @@ -379,7 +380,7 @@ void TRestHits::SwapHits(Int_t i, Int_t j) { iter_swap(fT.begin() + i, fT.begin() + j); } -Bool_t TRestHits::isSortedByEnergy() { +Bool_t TRestHits::isSortedByEnergy() const { for (int i = 0; i < GetNumberOfHits() - 1; i++) if (GetEnergy(i + 1) > GetEnergy(i)) return false; @@ -397,22 +398,22 @@ void TRestHits::RemoveHit(int n) { fNHits--; } -TVector3 TRestHits::GetPosition(int n) { - if ((fType.size() == 0 ? !IsNaN(fX[n]) : fType[n] == XY)) - return TVector3(((Double_t)fX[n]), ((Double_t)fY[n]), 0); - if ((fType.size() == 0 ? !IsNaN(fX[n]) : fType[n] == XZ)) - return TVector3(((Double_t)fX[n]), 0, ((Double_t)fZ[n])); - if ((fType.size() == 0 ? !IsNaN(fX[n]) : fType[n] == YZ)) - return TVector3(0, ((Double_t)fY[n]), ((Double_t)fZ[n])); - return TVector3(((Double_t)fX[n]), ((Double_t)fY[n]), ((Double_t)fZ[n])); +TVector3 TRestHits::GetPosition(int n) const { + if ((fType.size() == 0 ? !IsNaN(fX[n]) : fType[n] == XY)) { + return {(Double_t)fX[n], (Double_t)fY[n], 0}; + } + if ((fType.size() == 0 ? !IsNaN(fX[n]) : fType[n] == XZ)) { + return {(Double_t)fX[n], 0, (Double_t)fZ[n]}; + } + if ((fType.size() == 0 ? !IsNaN(fX[n]) : fType[n] == YZ)) { + return {0, (Double_t)fY[n], (Double_t)fZ[n]}; + } + return {(Double_t)fX[n], (Double_t)fY[n], (Double_t)fZ[n]}; } -TVector3 TRestHits::GetVector(int i, int j) { - TVector3 vector = GetPosition(i) - GetPosition(j); - return vector; -} +TVector3 TRestHits::GetVector(int i, int j) const { return GetPosition(i) - GetPosition(j); } -Int_t TRestHits::GetNumberOfHitsX() { +Int_t TRestHits::GetNumberOfHitsX() const { Int_t nHitsX = 0; for (int n = 0; n < GetNumberOfHits(); n++) @@ -421,7 +422,7 @@ Int_t TRestHits::GetNumberOfHitsX() { return nHitsX; } -Int_t TRestHits::GetNumberOfHitsY() { +Int_t TRestHits::GetNumberOfHitsY() const { Int_t nHitsY = 0; for (int n = 0; n < GetNumberOfHits(); n++) @@ -430,7 +431,7 @@ Int_t TRestHits::GetNumberOfHitsY() { return nHitsY; } -Double_t TRestHits::GetEnergyX() { +Double_t TRestHits::GetEnergyX() const { Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { if ((fType.size() == 0 ? !IsNaN(fX[n]) : fType[n] % X == 0)) { @@ -441,7 +442,7 @@ Double_t TRestHits::GetEnergyX() { return totalEnergy; } -Double_t TRestHits::GetEnergyY() { +Double_t TRestHits::GetEnergyY() const { Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { if ((fType.size() == 0 ? !IsNaN(fY[n]) : fType[n] % Y == 0)) { @@ -451,7 +452,7 @@ Double_t TRestHits::GetEnergyY() { return totalEnergy; } -Double_t TRestHits::GetMeanPositionX() { +Double_t TRestHits::GetMeanPositionX() const { Double_t meanX = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -467,7 +468,7 @@ Double_t TRestHits::GetMeanPositionX() { return meanX; } -Double_t TRestHits::GetMeanPositionY() { +Double_t TRestHits::GetMeanPositionY() const { Double_t meanY = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -483,7 +484,7 @@ Double_t TRestHits::GetMeanPositionY() { return meanY; } -Double_t TRestHits::GetMeanPositionZ() { +Double_t TRestHits::GetMeanPositionZ() const { Double_t meanZ = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -499,12 +500,12 @@ Double_t TRestHits::GetMeanPositionZ() { return meanZ; } -TVector3 TRestHits::GetMeanPosition() { +TVector3 TRestHits::GetMeanPosition() const { TVector3 mean(GetMeanPositionX(), GetMeanPositionY(), GetMeanPositionZ()); return mean; } -Double_t TRestHits::GetSigmaXY2() { +Double_t TRestHits::GetSigmaXY2() const { Double_t sigmaXY2 = 0; Double_t totalEnergy = this->GetTotalEnergy(); Double_t meanX = this->GetMeanPositionX(); @@ -518,7 +519,7 @@ Double_t TRestHits::GetSigmaXY2() { return sigmaXY2 /= totalEnergy; } -Double_t TRestHits::GetSigmaX() { +Double_t TRestHits::GetSigmaX() const { Double_t sigmaX2 = 0; Double_t sigmaX = 0; Double_t totalEnergy = this->GetTotalEnergy(); @@ -533,7 +534,7 @@ Double_t TRestHits::GetSigmaX() { return sigmaX = TMath::Sqrt(sigmaX2); } -Double_t TRestHits::GetSigmaY() { +Double_t TRestHits::GetSigmaY() const { Double_t sigmaY2 = 0; Double_t sigmaY = 0; Double_t totalEnergy = this->GetTotalEnergy(); @@ -661,7 +662,7 @@ Double_t TRestHits::GetGaussSigmaZ() { return gausSigmaZ; } -Double_t TRestHits::GetSkewXY() { +Double_t TRestHits::GetSkewXY() const { Double_t skewXY = 0; Double_t totalEnergy = this->GetTotalEnergy(); Double_t sigmaXY = TMath::Sqrt(this->GetSigmaXY2()); @@ -676,7 +677,7 @@ Double_t TRestHits::GetSkewXY() { return skewXY /= (totalEnergy * sigmaXY * sigmaXY * sigmaXY); } -Double_t TRestHits::GetSigmaZ2() { +Double_t TRestHits::GetSigmaZ2() const { Double_t sigmaZ2 = 0; Double_t totalEnergy = this->GetTotalEnergy(); Double_t meanZ = this->GetMeanPositionZ(); @@ -687,7 +688,7 @@ Double_t TRestHits::GetSigmaZ2() { return sigmaZ2 /= totalEnergy; } -Double_t TRestHits::GetSkewZ() { +Double_t TRestHits::GetSkewZ() const { Double_t skewZ = 0; Double_t totalEnergy = this->GetTotalEnergy(); Double_t sigmaZ = TMath::Sqrt(this->GetSigmaZ2()); @@ -700,7 +701,7 @@ Double_t TRestHits::GetSkewZ() { } Double_t TRestHits::GetMeanPositionXInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) { + Double_t theta) const { Double_t meanX = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -717,7 +718,7 @@ Double_t TRestHits::GetMeanPositionXInPrism(TVector3 x0, TVector3 x1, Double_t s } Double_t TRestHits::GetMeanPositionYInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) { + Double_t theta) const { Double_t meanY = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -733,7 +734,7 @@ Double_t TRestHits::GetMeanPositionYInPrism(TVector3 x0, TVector3 x1, Double_t s return meanY; } Double_t TRestHits::GetMeanPositionZInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) { + Double_t theta) const { Double_t meanZ = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -749,14 +750,14 @@ Double_t TRestHits::GetMeanPositionZInPrism(TVector3 x0, TVector3 x1, Double_t s } TVector3 TRestHits::GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) { + Double_t theta) const { TVector3 mean(GetMeanPositionXInPrism(x0, x1, sizeX, sizeY, theta), GetMeanPositionYInPrism(x0, x1, sizeX, sizeY, theta), GetMeanPositionZInPrism(x0, x1, sizeX, sizeY, theta)); return mean; } -Double_t TRestHits::GetMeanPositionXInCylinder(TVector3 x0, TVector3 x1, Double_t radius) { +Double_t TRestHits::GetMeanPositionXInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { Double_t meanX = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -772,7 +773,7 @@ Double_t TRestHits::GetMeanPositionXInCylinder(TVector3 x0, TVector3 x1, Double_ return meanX; } -Double_t TRestHits::GetMeanPositionYInCylinder(TVector3 x0, TVector3 x1, Double_t radius) { +Double_t TRestHits::GetMeanPositionYInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { Double_t meanY = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -788,7 +789,7 @@ Double_t TRestHits::GetMeanPositionYInCylinder(TVector3 x0, TVector3 x1, Double_ return meanY; } -Double_t TRestHits::GetMeanPositionZInCylinder(TVector3 x0, TVector3 x1, Double_t radius) { +Double_t TRestHits::GetMeanPositionZInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { Double_t meanZ = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -803,13 +804,13 @@ Double_t TRestHits::GetMeanPositionZInCylinder(TVector3 x0, TVector3 x1, Double_ return meanZ; } -TVector3 TRestHits::GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius) { +TVector3 TRestHits::GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { TVector3 mean(GetMeanPositionXInCylinder(x0, x1, radius), GetMeanPositionYInCylinder(x0, x1, radius), GetMeanPositionZInCylinder(x0, x1, radius)); return mean; } -Double_t TRestHits::GetHitsPathLength(Int_t n, Int_t m) { +Double_t TRestHits::GetHitsPathLength(Int_t n, Int_t m) const { if (n < 0) n = 0; if (m > GetNumberOfHits() - 1) m = GetNumberOfHits() - 1; @@ -818,7 +819,7 @@ Double_t TRestHits::GetHitsPathLength(Int_t n, Int_t m) { return distance; } -Double_t TRestHits::GetTotalDistance() { +Double_t TRestHits::GetTotalDistance() const { Double_t distance = 0; for (int i = 0; i < GetNumberOfHits() - 1; i++) distance += TMath::Sqrt(GetDistance2(i, i + 1)); return distance; @@ -836,7 +837,7 @@ Double_t TRestHits::GetDistance2(int n, int m) const { return dx * dx + dy * dy + dz * dz; } -Double_t TRestHits::GetDistanceToNode(Int_t n) { +Double_t TRestHits::GetDistanceToNode(Int_t n) const { Double_t distance = 0; if (n > GetNumberOfHits() - 1) n = GetNumberOfHits() - 1; @@ -845,12 +846,12 @@ Double_t TRestHits::GetDistanceToNode(Int_t n) { return distance; } -Int_t TRestHits::GetMostEnergeticHitInRange(Int_t n, Int_t m) { +Int_t TRestHits::GetMostEnergeticHitInRange(Int_t n, Int_t m) const { Int_t maxEn = 0; Int_t hit = -1; for (int i = n; i < m; i++) { - if (this->GetEnergy(i) > maxEn) { - maxEn = this->GetEnergy(i); + if (GetEnergy(i) > maxEn) { + maxEn = GetEnergy(i); hit = i; } } @@ -858,7 +859,7 @@ Int_t TRestHits::GetMostEnergeticHitInRange(Int_t n, Int_t m) { return hit; } -Int_t TRestHits::GetClosestHit(TVector3 position) { +Int_t TRestHits::GetClosestHit(TVector3 position) const { Int_t closestHit = 0; Double_t minDistance = 1.e30; @@ -875,7 +876,7 @@ Int_t TRestHits::GetClosestHit(TVector3 position) { return closestHit; } -TVector2 TRestHits::GetProjection(Int_t n, Int_t m, TVector3 position) { +TVector2 TRestHits::GetProjection(Int_t n, Int_t m, TVector3 position) const { TVector3 nodesSegment = this->GetVector(n, m); TVector3 origin = position - this->GetPosition(m); @@ -890,7 +891,7 @@ TVector2 TRestHits::GetProjection(Int_t n, Int_t m, TVector3 position) { return TVector2(longitudinal, transversal); } -Double_t TRestHits::GetTransversalProjection(TVector3 p0, TVector3 direction, TVector3 position) { +Double_t TRestHits::GetTransversalProjection(TVector3 p0, TVector3 direction, TVector3 position) const { TVector3 oX = position - p0; if (oX == TVector3(0, 0, 0)) return 0; @@ -900,7 +901,7 @@ Double_t TRestHits::GetTransversalProjection(TVector3 p0, TVector3 direction, TV return TMath::Sqrt(oX.Mag2() - longitudinal * longitudinal); } -Double_t TRestHits::GetHitsTwist(Int_t n, Int_t m) { +Double_t TRestHits::GetHitsTwist(Int_t n, Int_t m) const { if (n < 0) n = 0; if (m == 0) m = this->GetNumberOfHits(); @@ -921,7 +922,7 @@ Double_t TRestHits::GetHitsTwist(Int_t n, Int_t m) { return sum / cont; } -Double_t TRestHits::GetHitsTwistWeighted(Int_t n, Int_t m) { +Double_t TRestHits::GetHitsTwistWeighted(Int_t n, Int_t m) const { if (n < 0) n = 0; if (m == 0) m = this->GetNumberOfHits(); @@ -945,7 +946,7 @@ Double_t TRestHits::GetHitsTwistWeighted(Int_t n, Int_t m) { return sum / cont; } -Double_t TRestHits::GetMaximumHitDistance() { +Double_t TRestHits::GetMaximumHitDistance() const { Double_t maxDistance = 0; for (int n = 0; n < this->GetNumberOfHits(); n++) for (int m = n + 1; m < this->GetNumberOfHits(); m++) { @@ -956,7 +957,7 @@ Double_t TRestHits::GetMaximumHitDistance() { return maxDistance; } -Double_t TRestHits::GetMaximumHitDistance2() { +Double_t TRestHits::GetMaximumHitDistance2() const { Double_t maxDistance = 0; for (int n = 0; n < this->GetNumberOfHits(); n++) for (int m = n + 1; m < this->GetNumberOfHits(); m++) { @@ -967,7 +968,7 @@ Double_t TRestHits::GetMaximumHitDistance2() { return maxDistance; } -void TRestHits::PrintHits(Int_t nHits) { +void TRestHits::PrintHits(Int_t nHits) const { Int_t N = nHits; if (N == -1) N = GetNumberOfHits(); From e6da8d7072b83819ff977095ab57b6f4e1490231 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Fri, 1 Apr 2022 13:27:24 +0200 Subject: [PATCH 04/17] TRestHits - GetMostEnergeticHitInRange fixed bug --- source/framework/core/src/TRestHits.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/framework/core/src/TRestHits.cxx b/source/framework/core/src/TRestHits.cxx index b7b8ccebe..d91c203e2 100644 --- a/source/framework/core/src/TRestHits.cxx +++ b/source/framework/core/src/TRestHits.cxx @@ -847,15 +847,14 @@ Double_t TRestHits::GetDistanceToNode(Int_t n) const { } Int_t TRestHits::GetMostEnergeticHitInRange(Int_t n, Int_t m) const { - Int_t maxEn = 0; + double maxEnergy = 0; Int_t hit = -1; for (int i = n; i < m; i++) { - if (GetEnergy(i) > maxEn) { - maxEn = GetEnergy(i); + if (GetEnergy(i) > maxEnergy) { + maxEnergy = GetEnergy(i); hit = i; } } - // if (hit == -1) cout << "REST warning : No largest hit found! No hits?" << endl; return hit; } From aa5b537fd6a05ef68e3fe268c96b373f6930556f Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Fri, 1 Apr 2022 13:33:58 +0200 Subject: [PATCH 05/17] TRestHits - made all function argument `TVector3` passed by const reference --- source/framework/core/inc/TRestHits.h | 50 +++++++++--------- source/framework/core/src/TRestHits.cxx | 68 ++++++++++++++----------- 2 files changed, 62 insertions(+), 56 deletions(-) diff --git a/source/framework/core/inc/TRestHits.h b/source/framework/core/inc/TRestHits.h index a5aba7999..3e7784577 100644 --- a/source/framework/core/inc/TRestHits.h +++ b/source/framework/core/inc/TRestHits.h @@ -62,15 +62,13 @@ class TRestHits : public TObject { void Translate(Int_t n, Double_t x, Double_t y, Double_t z); /// Event is rotated in XYZ. void RotateIn3D(Int_t n, Double_t alpha, Double_t beta, Double_t gamma, - TVector3 vMean); // vMean is the mean position of the event - // from GetMeanPosition() + const TVector3& vMean); // vMean is the mean position of the event from GetMeanPosition() /// Rotation around an arbitrary axis vAxis - void Rotate(Int_t n, Double_t alpha, TVector3 vAxis, - TVector3 vMean); // vMean is the mean position of the event from - // GetMeanPosition() + void Rotate(Int_t n, Double_t alpha, const TVector3& vAxis, + const TVector3& vMean); // vMean is the mean position of the event from GetMeanPosition() void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t t = 0, REST_HitType type = XYZ); - void AddHit(TVector3 pos, Double_t en, Double_t t = 0, REST_HitType type = XYZ); + 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(); @@ -138,36 +136,37 @@ class TRestHits : public TObject { inline Double_t GetEnergy(int n) const { return ((Double_t)fEnergy[n]); } // return value in keV - Bool_t isHitNInsidePrism(Int_t n, TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, + 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(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, + Int_t GetNumberOfHitsInsidePrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, Double_t sizeY, Double_t theta) const; - Double_t GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, Double_t theta) const; - Double_t GetMeanPositionXInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, + Double_t GetEnergyInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, Double_t sizeY, + Double_t theta) const; + Double_t GetMeanPositionXInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, Double_t sizeY, Double_t theta) const; - Double_t GetMeanPositionYInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, + Double_t GetMeanPositionYInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, Double_t sizeY, Double_t theta) const; - Double_t GetMeanPositionZInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, + Double_t GetMeanPositionZInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, Double_t sizeY, Double_t theta) const; - TVector3 GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, + TVector3 GetMeanPositionInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, Double_t sizeY, Double_t theta) const; - Bool_t isHitNInsideCylinder(Int_t n, TVector3 x0, TVector3 x1, Double_t radius) const; + Bool_t isHitNInsideCylinder(Int_t n, const TVector3& x0, const TVector3& x1, Double_t radius) const; - Int_t GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; + Int_t GetNumberOfHitsInsideCylinder(const TVector3& x0, const TVector3& x1, Double_t radius) const; Int_t GetNumberOfHitsInsideCylinder(Int_t i, Int_t j, Double_t radius) const; - Double_t GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; + Double_t GetEnergyInCylinder(const TVector3& x0, const TVector3& x1, Double_t radius) const; Double_t GetEnergyInCylinder(Int_t i, Int_t j, Double_t radius) const; - Double_t GetMeanPositionXInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; - Double_t GetMeanPositionYInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; - Double_t GetMeanPositionZInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; - TVector3 GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const; + Double_t GetMeanPositionXInCylinder(const TVector3& x0, const TVector3& x1, Double_t radius) const; + Double_t GetMeanPositionYInCylinder(const TVector3& x0, const TVector3& x1, Double_t radius) const; + Double_t GetMeanPositionZInCylinder(const TVector3& x0, const TVector3& x1, Double_t radius) const; + TVector3 GetMeanPositionInCylinder(const TVector3& x0, const TVector3& x1, Double_t radius) const; - Bool_t isHitNInsideSphere(Int_t n, TVector3 pos0, Double_t radius) const; + Bool_t isHitNInsideSphere(Int_t n, const TVector3& pos0, Double_t radius) const; Bool_t isHitNInsideSphere(Int_t n, Double_t x0, Double_t y0, Double_t z0, Double_t radius) const; - Double_t GetEnergyInSphere(TVector3 pos0, Double_t radius) const; + Double_t GetEnergyInSphere(const TVector3& pos0, Double_t radius) const; Double_t GetEnergyInSphere(Double_t x, Double_t y, Double_t z, Double_t radius) const; Double_t GetMaximumHitEnergy() const; @@ -187,11 +186,12 @@ class TRestHits : public TObject { Double_t GetHitsTwist(Int_t n, Int_t m) const; Double_t GetHitsTwistWeighted(Int_t n, Int_t m) const; - Int_t GetClosestHit(TVector3 position) const; + Int_t GetClosestHit(const TVector3& position) const; - TVector2 GetProjection(Int_t n, Int_t m, TVector3 position) const; + TVector2 GetProjection(Int_t n, Int_t m, const TVector3& position) const; - Double_t GetTransversalProjection(TVector3 p0, TVector3 direction, TVector3 position) const; + Double_t GetTransversalProjection(const TVector3& p0, const TVector3& direction, + const TVector3& position) const; void WriteHitsToTextFile(TString filename); diff --git a/source/framework/core/src/TRestHits.cxx b/source/framework/core/src/TRestHits.cxx index d91c203e2..798239810 100644 --- a/source/framework/core/src/TRestHits.cxx +++ b/source/framework/core/src/TRestHits.cxx @@ -129,8 +129,8 @@ Double_t TRestHits::GetEnergyIntegral() const { return sum; } -Bool_t TRestHits::isHitNInsidePrism(Int_t n, TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) const { +Bool_t TRestHits::isHitNInsidePrism(Int_t n, const TVector3& x0, const TVector3& x1, Double_t sizeX, + Double_t sizeY, Double_t theta) const { TVector3 axis = x1 - x0; Double_t prismLength = axis.Mag(); @@ -145,7 +145,7 @@ Bool_t TRestHits::isHitNInsidePrism(Int_t n, TVector3 x0, TVector3 x1, Double_t return false; } -Double_t TRestHits::GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, +Double_t TRestHits::GetEnergyInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, Double_t sizeY, Double_t theta) const { Double_t energy = 0.; @@ -155,8 +155,8 @@ Double_t TRestHits::GetEnergyInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, D return energy; } -Int_t TRestHits::GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) const { +Int_t TRestHits::GetNumberOfHitsInsidePrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, + Double_t sizeY, Double_t theta) const { Int_t hits = 0; for (int n = 0; n < GetNumberOfHits(); n++) @@ -165,7 +165,8 @@ Int_t TRestHits::GetNumberOfHitsInsidePrism(TVector3 x0, TVector3 x1, Double_t s return hits; } -Bool_t TRestHits::isHitNInsideCylinder(Int_t n, TVector3 x0, TVector3 x1, Double_t radius) const { +Bool_t TRestHits::isHitNInsideCylinder(Int_t n, const TVector3& x0, const TVector3& x1, + Double_t radius) const { /* cout << "TRestHits::isHitNInsideCylinder has not been validated." << endl; cout << "After validation this output should be removed" << endl;*/ @@ -203,7 +204,7 @@ Double_t TRestHits::GetEnergyInCylinder(Int_t i, Int_t j, Double_t radius) const return GetEnergyInCylinder(this->GetPosition(i), this->GetPosition(j), radius); } -Double_t TRestHits::GetEnergyInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { +Double_t TRestHits::GetEnergyInCylinder(const TVector3& x0, const TVector3& x1, Double_t radius) const { Double_t energy = 0.; for (int n = 0; n < GetNumberOfHits(); n++) { if (isHitNInsideCylinder(n, x0, x1, radius)) energy += this->GetEnergy(n); @@ -216,7 +217,8 @@ Int_t TRestHits::GetNumberOfHitsInsideCylinder(Int_t i, Int_t j, Double_t radius return GetNumberOfHitsInsideCylinder(this->GetPosition(i), this->GetPosition(j), radius); } -Int_t TRestHits::GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { +Int_t TRestHits::GetNumberOfHitsInsideCylinder(const TVector3& x0, const TVector3& x1, + Double_t radius) const { Int_t hits = 0; for (int n = 0; n < GetNumberOfHits(); n++) if (isHitNInsideCylinder(n, x0, x1, radius)) hits++; @@ -224,7 +226,7 @@ Int_t TRestHits::GetNumberOfHitsInsideCylinder(TVector3 x0, TVector3 x1, Double_ return hits; } -Double_t TRestHits::GetEnergyInSphere(TVector3 pos0, Double_t radius) const { +Double_t TRestHits::GetEnergyInSphere(const TVector3& pos0, Double_t radius) const { return GetEnergyInSphere(pos0.X(), pos0.Y(), pos0.Z(), radius); } @@ -242,7 +244,7 @@ Double_t TRestHits::GetEnergyInSphere(Double_t x0, Double_t y0, Double_t z0, Dou return sum; } -Bool_t TRestHits::isHitNInsideSphere(Int_t n, TVector3 pos0, Double_t radius) const { +Bool_t TRestHits::isHitNInsideSphere(Int_t n, const TVector3& pos0, Double_t radius) const { return isHitNInsideSphere(n, pos0.X(), pos0.Y(), pos0.Z(), radius); } @@ -270,7 +272,7 @@ void TRestHits::AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t fTotEnergy += en; } -void TRestHits::AddHit(TVector3 pos, Double_t en, Double_t t, REST_HitType type) { +void TRestHits::AddHit(const TVector3& pos, Double_t en, Double_t t, REST_HitType type) { fNHits++; fX.push_back((Float_t)(pos.X())); @@ -311,7 +313,7 @@ void TRestHits::Translate(Int_t n, double x, double y, double z) { fZ[n] += z; } -void TRestHits::RotateIn3D(Int_t n, Double_t alpha, Double_t beta, Double_t gamma, TVector3 vMean) { +void TRestHits::RotateIn3D(Int_t n, Double_t alpha, Double_t beta, Double_t gamma, const TVector3& vMean) { TVector3 position = GetPosition(n); TVector3 vHit = position - vMean; @@ -324,7 +326,7 @@ void TRestHits::RotateIn3D(Int_t n, Double_t alpha, Double_t beta, Double_t gamm fZ[n] = vHit[2] + vMean[2]; } -void TRestHits::Rotate(Int_t n, Double_t alpha, TVector3 vAxis, TVector3 vMean) { +void TRestHits::Rotate(Int_t n, Double_t alpha, const TVector3& vAxis, const TVector3& vMean) { TVector3 vHit; vHit[0] = fX[n] - vMean[0]; @@ -700,8 +702,8 @@ Double_t TRestHits::GetSkewZ() const { return skewZ /= (totalEnergy * sigmaZ * sigmaZ * sigmaZ); } -Double_t TRestHits::GetMeanPositionXInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) const { +Double_t TRestHits::GetMeanPositionXInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, + Double_t sizeY, Double_t theta) const { Double_t meanX = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -717,8 +719,8 @@ Double_t TRestHits::GetMeanPositionXInPrism(TVector3 x0, TVector3 x1, Double_t s return meanX; } -Double_t TRestHits::GetMeanPositionYInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) const { +Double_t TRestHits::GetMeanPositionYInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, + Double_t sizeY, Double_t theta) const { Double_t meanY = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -733,8 +735,8 @@ Double_t TRestHits::GetMeanPositionYInPrism(TVector3 x0, TVector3 x1, Double_t s return meanY; } -Double_t TRestHits::GetMeanPositionZInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) const { +Double_t TRestHits::GetMeanPositionZInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, + Double_t sizeY, Double_t theta) const { Double_t meanZ = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -749,15 +751,16 @@ Double_t TRestHits::GetMeanPositionZInPrism(TVector3 x0, TVector3 x1, Double_t s return meanZ; } -TVector3 TRestHits::GetMeanPositionInPrism(TVector3 x0, TVector3 x1, Double_t sizeX, Double_t sizeY, - Double_t theta) const { +TVector3 TRestHits::GetMeanPositionInPrism(const TVector3& x0, const TVector3& x1, Double_t sizeX, + Double_t sizeY, Double_t theta) const { TVector3 mean(GetMeanPositionXInPrism(x0, x1, sizeX, sizeY, theta), GetMeanPositionYInPrism(x0, x1, sizeX, sizeY, theta), GetMeanPositionZInPrism(x0, x1, sizeX, sizeY, theta)); return mean; } -Double_t TRestHits::GetMeanPositionXInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { +Double_t TRestHits::GetMeanPositionXInCylinder(const TVector3& x0, const TVector3& x1, + Double_t radius) const { Double_t meanX = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -773,7 +776,8 @@ Double_t TRestHits::GetMeanPositionXInCylinder(TVector3 x0, TVector3 x1, Double_ return meanX; } -Double_t TRestHits::GetMeanPositionYInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { +Double_t TRestHits::GetMeanPositionYInCylinder(const TVector3& x0, const TVector3& x1, + Double_t radius) const { Double_t meanY = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -789,7 +793,8 @@ Double_t TRestHits::GetMeanPositionYInCylinder(TVector3 x0, TVector3 x1, Double_ return meanY; } -Double_t TRestHits::GetMeanPositionZInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { +Double_t TRestHits::GetMeanPositionZInCylinder(const TVector3& x0, const TVector3& x1, + Double_t radius) const { Double_t meanZ = 0; Double_t totalEnergy = 0; for (int n = 0; n < GetNumberOfHits(); n++) { @@ -804,7 +809,7 @@ Double_t TRestHits::GetMeanPositionZInCylinder(TVector3 x0, TVector3 x1, Double_ return meanZ; } -TVector3 TRestHits::GetMeanPositionInCylinder(TVector3 x0, TVector3 x1, Double_t radius) const { +TVector3 TRestHits::GetMeanPositionInCylinder(const TVector3& x0, const TVector3& x1, Double_t radius) const { TVector3 mean(GetMeanPositionXInCylinder(x0, x1, radius), GetMeanPositionYInCylinder(x0, x1, radius), GetMeanPositionZInCylinder(x0, x1, radius)); return mean; @@ -858,7 +863,7 @@ Int_t TRestHits::GetMostEnergeticHitInRange(Int_t n, Int_t m) const { return hit; } -Int_t TRestHits::GetClosestHit(TVector3 position) const { +Int_t TRestHits::GetClosestHit(const TVector3& position) const { Int_t closestHit = 0; Double_t minDistance = 1.e30; @@ -875,22 +880,23 @@ Int_t TRestHits::GetClosestHit(TVector3 position) const { return closestHit; } -TVector2 TRestHits::GetProjection(Int_t n, Int_t m, TVector3 position) const { +TVector2 TRestHits::GetProjection(Int_t n, Int_t m, const TVector3& position) const { TVector3 nodesSegment = this->GetVector(n, m); TVector3 origin = position - this->GetPosition(m); - if (origin == TVector3(0, 0, 0)) return TVector2(0, 0); + if (origin == TVector3(0, 0, 0)) return {0, 0}; Double_t longitudinal = nodesSegment.Unit().Dot(origin); - if (origin == nodesSegment) return TVector2(longitudinal, 0); + if (origin == nodesSegment) return {longitudinal, 0}; Double_t transversal = TMath::Sqrt(origin.Mag2() - longitudinal * longitudinal); - return TVector2(longitudinal, transversal); + return {longitudinal, transversal}; } -Double_t TRestHits::GetTransversalProjection(TVector3 p0, TVector3 direction, TVector3 position) const { +Double_t TRestHits::GetTransversalProjection(const TVector3& p0, const TVector3& direction, + const TVector3& position) const { TVector3 oX = position - p0; if (oX == TVector3(0, 0, 0)) return 0; From 6bad675811d820c8a0e7dd82f9b49f730dcf099f Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Fri, 1 Apr 2022 14:18:02 +0200 Subject: [PATCH 06/17] Geant4Lib - made most compatible methods const and fixed errors --- source/framework/core/inc/TRestEvent.h | 2 +- source/framework/core/src/TRestEvent.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/framework/core/inc/TRestEvent.h b/source/framework/core/inc/TRestEvent.h index b763bf425..41e17fd1c 100644 --- a/source/framework/core/inc/TRestEvent.h +++ b/source/framework/core/inc/TRestEvent.h @@ -87,7 +87,7 @@ class TRestEvent : public TObject { virtual void Initialize() = 0; virtual void InitializeWithMetadata(TRestRun* r); - virtual void PrintEvent(); + virtual void PrintEvent() const; ////////////////////////////////////////////////////////////////////////// /// \brief Draw the event diff --git a/source/framework/core/src/TRestEvent.cxx b/source/framework/core/src/TRestEvent.cxx index 2f5bb39d7..89f28c896 100644 --- a/source/framework/core/src/TRestEvent.cxx +++ b/source/framework/core/src/TRestEvent.cxx @@ -175,7 +175,7 @@ void TRestEvent::InitializeWithMetadata(TRestRun* r) { Initialize(); } /// You may want to call the base class inside the re-implemented one, /// by calling TRestEvent::PrintEvent(); /// -void TRestEvent::PrintEvent() { +void TRestEvent::PrintEvent() const { cout << "*******************************************************" << endl; cout << " EVENT ID : " << GetID() << endl; cout << " TIME : " << GetTimeStamp().AsString() << endl; From 7d23903dd122cc39f67454a77b065e664523a312 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Fri, 1 Apr 2022 17:11:59 +0200 Subject: [PATCH 07/17] TRestHits.cxx - added back bug to see if pipeline is fixed --- source/framework/core/src/TRestHits.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/framework/core/src/TRestHits.cxx b/source/framework/core/src/TRestHits.cxx index 798239810..e9641bac7 100644 --- a/source/framework/core/src/TRestHits.cxx +++ b/source/framework/core/src/TRestHits.cxx @@ -852,7 +852,7 @@ Double_t TRestHits::GetDistanceToNode(Int_t n) const { } Int_t TRestHits::GetMostEnergeticHitInRange(Int_t n, Int_t m) const { - double maxEnergy = 0; + Int_t maxEnergy = 0; Int_t hit = -1; for (int i = n; i < m; i++) { if (GetEnergy(i) > maxEnergy) { From 4073148680ca7e5d89304ca0f11add504de19b5d Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Fri, 1 Apr 2022 17:58:01 +0200 Subject: [PATCH 08/17] TRestEvent.h - reverted increase of class version --- source/framework/core/inc/TRestEvent.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/framework/core/inc/TRestEvent.h b/source/framework/core/inc/TRestEvent.h index 41e17fd1c..ff5b7fd9e 100644 --- a/source/framework/core/inc/TRestEvent.h +++ b/source/framework/core/inc/TRestEvent.h @@ -105,6 +105,6 @@ class TRestEvent : public TObject { // Destructor virtual ~TRestEvent(); - ClassDef(TRestEvent, 2); // REST event superclass + ClassDef(TRestEvent, 1); }; -#endif \ No newline at end of file +#endif From 2b138edee8332e24579f583cfff1d4886c5960b1 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Sun, 3 Apr 2022 03:10:08 +0200 Subject: [PATCH 09/17] pipeline - updated `MakeBasicTree.C` macro with more checks --- pipeline/MakeBasicTree.C | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/pipeline/MakeBasicTree.C b/pipeline/MakeBasicTree.C index d1ea9ceca..b5b1a0b5f 100644 --- a/pipeline/MakeBasicTree.C +++ b/pipeline/MakeBasicTree.C @@ -1,21 +1,22 @@ // This macro will extract the double observables and will fill a tree with std::vector -Int_t MakeBasicTree(string fname) { - TRestRun* run = new TRestRun(fname); +Int_t MakeBasicTree(const char* inputFilename, const char* outputFilename = "results.root", + Bool_t check = true) { + TRestRun run(inputFilename); - TRestAnalysisTree* aTree = run->GetAnalysisTree(); + TRestAnalysisTree* aTree = run.GetAnalysisTree(); std::vector obsValues; for (int n = 0; n < aTree->GetNumberOfObservables(); n++) { if (aTree->GetObservableType(n) == "double") obsValues.push_back(0); } - TFile* outFile = new TFile("results.root", "RECREATE"); + TFile* outFile = new TFile(outputFilename, "RECREATE"); TTree* myTree = new TTree("bTree", "basicTree"); myTree->Branch("doubleObservables", &obsValues); - for (int n = 0; n < run->GetEntries(); n++) { - run->GetEntry(n); + for (int n = 0; n < run.GetEntries(); n++) { + run.GetEntry(n); // cout << "Entry : " << n << endl; obsValues.clear(); @@ -31,7 +32,28 @@ Int_t MakeBasicTree(string fname) { myTree->Fill(); } + // check all trees have the same number of elements + if (run.GetEntries() != aTree->GetEntries() || run.GetEntries() != myTree->GetEntries()) { + cout << "ERROR: mismatch in number of tree entries" << endl; + return 1; + } myTree->Write(); outFile->Close(); + + // check output file tree has the correct number of entries + if (check) { + TFile outFileCheck(outputFilename, "READ"); + TTree* outTreeCheck = outFileCheck.Get("bTree"); + if (outTreeCheck == nullptr) { + cout << "ERROR: tree was not correctly written into file" << endl; + return 1; + } + + if (outTreeCheck->GetEntries() != run.GetEntries()) { + cout << "ERROR: output file check - mismatch in number of tree entries" << endl; + return 1; + } + } + return 0; } From 7e1732cc8ee681800cefb55c2a93041e2e87052e Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Sun, 3 Apr 2022 03:53:05 +0200 Subject: [PATCH 10/17] pipeline - updated `ValidateTrees.C` macro, more readable variable names --- pipeline/ValidateTrees.C | 62 +++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/pipeline/ValidateTrees.C b/pipeline/ValidateTrees.C index 32380d7eb..e2a822325 100644 --- a/pipeline/ValidateTrees.C +++ b/pipeline/ValidateTrees.C @@ -1,52 +1,60 @@ #include #include + #include #include -Int_t ValidateTrees(TString validationFile) { - TFile* f = new TFile("results.root"); - TTree* tr = (TTree*)f->Get("bTree"); - std::vector* vr = 0; - tr->SetBranchAddress("doubleObservables", &vr); - - TFile* fV = new TFile(validationFile); - TTree* tV = (TTree*)fV->Get("bTree"); - std::vector* vV = 0; - tV->SetBranchAddress("doubleObservables", &vV); - - if (tr->GetEntries() != tV->GetEntries()) { + +Int_t ValidateTrees(const char* validationFilename, const char* inputFilename = "results.root") { + TFile inputFile(inputFilename); + TTree* inputTree = inputFile.Get("bTree"); + std::vector* inputObservableVector = 0; + inputTree->SetBranchAddress("doubleObservables", &inputObservableVector); + + TFile validationFile(inputFilename); + TTree* validationTree = validationFile.Get("bTree"); + std::vector* validationObservableVector = 0; + validationTree->SetBranchAddress("doubleObservables", &validationObservableVector); + + if (inputTree->GetEntries() != validationTree->GetEntries()) { cout << "Number of entries is not the same!" << endl; - cout << "result: " << tr->GetEntries() << endl; - cout << "anticipated: " << tV->GetEntries() << endl; + cout << "result: " << inputTree->GetEntries() << endl; + cout << "anticipated: " << validationTree->GetEntries() << endl; return 1; } bool obsValErr = false; - for (int n = 0; n < tr->GetEntries(); n++) { - tr->GetEntry(n); - tV->GetEntry(n); + for (int n = 0; n < inputTree->GetEntries(); n++) { + inputTree->GetEntry(n); + validationTree->GetEntry(n); - if ((*vr).size() != (*vV).size()) { + if ((*inputObservableVector).size() != (*validationObservableVector).size()) { cout << "Vectors are different size at entry " << n << "!!" << endl; - cout << "results.root vector size : " << (*vr).size() << endl; - cout << "validation.root vector size : " << (*vV).size() << endl; + cout << "results.root vector size : " << (*inputObservableVector).size() << endl; + cout << "validation.root vector size : " << (*validationObservableVector).size() << endl; cout << "Validation vector contents: " << endl; - for (int m = 0; m < (*vV).size(); m++) cout << (*vV)[m] << "\t"; + for (int m = 0; m < (*validationObservableVector).size(); m++) + cout << (*validationObservableVector)[m] << "\t"; cout << endl; cout << "Results vector contents: " << endl; - for (int m = 0; m < (*vr).size(); m++) cout << (*vr)[m] << "\t"; + for (int m = 0; m < (*inputObservableVector).size(); m++) + cout << (*inputObservableVector)[m] << "\t"; cout << endl; return 2; } - for (int m = 0; m < (*vr).size(); m++) { - if ((Int_t)(1000. * (*vr)[m]) != (Int_t)(1000. * (*vV)[m])) { + for (int m = 0; m < (*inputObservableVector).size(); m++) { + if ((Int_t)(1000. * (*inputObservableVector)[m]) != + (Int_t)(1000. * (*validationObservableVector)[m])) { cout << "Double Observable with index " << m << " in entry " << n << " is not the same value!!" << endl; - printf(" value: %.15f, should be: %.15f\n", (*vr)[m], (*vV)[m]); + printf(" value: %.15f, should be: %.15f\n", (*inputObservableVector)[m], + (*validationObservableVector)[m]); - if (!TMath::IsNaN((*vr)[m] - (*vV)[m]) && abs(((*vr)[m] - (*vV)[m]) / (*vr)[m]) < 1e-15) { + if (!TMath::IsNaN((*inputObservableVector)[m] - (*validationObservableVector)[m]) && + abs(((*inputObservableVector)[m] - (*validationObservableVector)[m]) / + (*inputObservableVector)[m]) < 1e-15) { cout << " (ignored)" << endl; } else { obsValErr = true; @@ -56,6 +64,6 @@ Int_t ValidateTrees(TString validationFile) { } if (obsValErr) return 3; - cout << "Tree validation sucess!" << endl; + cout << "Tree validation success!" << endl; return 0; } From 092d4da6ee63f05e20af95a7a7e55c84ea133e59 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Sun, 3 Apr 2022 03:57:37 +0200 Subject: [PATCH 11/17] pipeline - renamed some variables in `MakeBasicTree.C` macro, more print info --- pipeline/MakeBasicTree.C | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/pipeline/MakeBasicTree.C b/pipeline/MakeBasicTree.C index b5b1a0b5f..ceee55dbc 100644 --- a/pipeline/MakeBasicTree.C +++ b/pipeline/MakeBasicTree.C @@ -3,41 +3,42 @@ Int_t MakeBasicTree(const char* inputFilename, const char* outputFilename = "res Bool_t check = true) { TRestRun run(inputFilename); - TRestAnalysisTree* aTree = run.GetAnalysisTree(); + TRestAnalysisTree* analysisTree = run.GetAnalysisTree(); std::vector obsValues; - for (int n = 0; n < aTree->GetNumberOfObservables(); n++) { - if (aTree->GetObservableType(n) == "double") obsValues.push_back(0); + for (int n = 0; n < analysisTree->GetNumberOfObservables(); n++) { + if (analysisTree->GetObservableType(n) == "double") obsValues.push_back(0); } TFile* outFile = new TFile(outputFilename, "RECREATE"); - TTree* myTree = new TTree("bTree", "basicTree"); + TTree* outTree = new TTree("bTree", "basicTree"); - myTree->Branch("doubleObservables", &obsValues); + outTree->Branch("doubleObservables", &obsValues); for (int n = 0; n < run.GetEntries(); n++) { run.GetEntry(n); // cout << "Entry : " << n << endl; obsValues.clear(); - for (int m = 0; m < aTree->GetNumberOfObservables(); m++) { - if (aTree->GetObservableType(m) == "double") { + for (int m = 0; m < analysisTree->GetNumberOfObservables(); m++) { + if (analysisTree->GetObservableType(m) == "double") { if (n == 0) { - cout << "index: " << obsValues.size() << ", obsName: " << aTree->GetObservableName(m) - << " value: " << aTree->GetObservableValue(m) << endl; + cout << "index: " << obsValues.size() + << ", obsName: " << analysisTree->GetObservableName(m) + << " value: " << analysisTree->GetObservableValue(m) << endl; } - obsValues.push_back(aTree->GetObservableValue(m)); + obsValues.push_back(analysisTree->GetObservableValue(m)); } } - myTree->Fill(); + outTree->Fill(); } // check all trees have the same number of elements - if (run.GetEntries() != aTree->GetEntries() || run.GetEntries() != myTree->GetEntries()) { + if (run.GetEntries() != analysisTree->GetEntries() || run.GetEntries() != outTree->GetEntries()) { cout << "ERROR: mismatch in number of tree entries" << endl; return 1; } - myTree->Write(); + outTree->Write(); outFile->Close(); // check output file tree has the correct number of entries @@ -55,5 +56,7 @@ Int_t MakeBasicTree(const char* inputFilename, const char* outputFilename = "res } } + cout << "Finished `MakeBasicTree.C` macro. Number of entries: " << run.GetEntries() << endl; + return 0; } From 1d064197ebc1c5a7d2fca2b74ae43c7148af7f92 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Mon, 4 Apr 2022 10:00:11 +0200 Subject: [PATCH 12/17] pipeline - fixed typo https://github.com/rest-for-physics/framework/pull/174#discussion_r841453550 --- pipeline/ValidateTrees.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline/ValidateTrees.C b/pipeline/ValidateTrees.C index e2a822325..d07bc5a4c 100644 --- a/pipeline/ValidateTrees.C +++ b/pipeline/ValidateTrees.C @@ -10,7 +10,7 @@ Int_t ValidateTrees(const char* validationFilename, const char* inputFilename = std::vector* inputObservableVector = 0; inputTree->SetBranchAddress("doubleObservables", &inputObservableVector); - TFile validationFile(inputFilename); + TFile validationFile(validationFilename); TTree* validationTree = validationFile.Get("bTree"); std::vector* validationObservableVector = 0; validationTree->SetBranchAddress("doubleObservables", &validationObservableVector); From 80d87e345ed56974ececd7329039d6b701ea6aae Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Mon, 4 Apr 2022 10:01:20 +0200 Subject: [PATCH 13/17] pipeline/MakeBasicTree.C - added error on empty tree --- pipeline/MakeBasicTree.C | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pipeline/MakeBasicTree.C b/pipeline/MakeBasicTree.C index ceee55dbc..b5729b1e5 100644 --- a/pipeline/MakeBasicTree.C +++ b/pipeline/MakeBasicTree.C @@ -56,6 +56,11 @@ Int_t MakeBasicTree(const char* inputFilename, const char* outputFilename = "res } } + if (run.GetEntries() == 0) { + cout << "ERROR: Macro finished without issues but number of final entries is 0" << endl; + return 1; + } + cout << "Finished `MakeBasicTree.C` macro. Number of entries: " << run.GetEntries() << endl; return 0; From cede9bcc50e025231f808088c4284eabb6275cc0 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Mon, 4 Apr 2022 11:00:35 +0200 Subject: [PATCH 14/17] .gitlab-ci.yml - updated pipeline --- .gitlab-ci.yml | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 045ea92ed..b1fa2b6de 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,4 @@ -image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-26-00_Geant4-v10.4.3_Garfield-af4a1451 -#image: nkx1231/root6-geant4-garfield:0.6 +image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics variables: # GIT_SUBMODULE_STRATEGY: recursive @@ -77,7 +76,7 @@ Validate Code: - python3 pipeline/validateProcesses.py source/libraries/ Build and Test: - type: test + stage: test script: - cd ${CI_PROJECT_DIR} - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} @@ -94,7 +93,7 @@ Build and Test: expire_in: 1 day Build and Install: - type: build + stage: build script: - cd ${CI_PROJECT_DIR} - python3 pull-submodules.py --force --dontask --latest:${CI_COMMIT_BRANCH} @@ -111,7 +110,7 @@ Build and Install: expire_in: 1 day Load REST Libraries: - type: install + stage: install script: - echo ${CI_PROJECT_DIR}/install/thisREST.sh - cat ${CI_PROJECT_DIR}/install/thisREST.sh @@ -119,13 +118,13 @@ Load REST Libraries: - restRoot -b -q List REST Macros: - type: install + stage: install script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - restManager ListMacros 01_NLDBD: - type: restG4 + stage: restG4 script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/install/examples/restG4/01.NLDBD/ @@ -138,7 +137,7 @@ List REST Macros: expire_in: 1 day 02_PandaXiiiMC: - type: restG4 + stage: restG4 script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC @@ -150,7 +149,7 @@ List REST Macros: expire_in: 1 day Load Gas: - type: metadata + stage: metadata script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ @@ -160,7 +159,7 @@ Load Gas: - $CI_SERVER_HOST == "lfna.unizar.es" Generate Gas: - type: metadata + stage: metadata script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/gas/ @@ -170,14 +169,14 @@ Generate Gas: - $CI_SERVER_HOST == "lfna.unizar.es" AnalysisTree: - type: core + stage: core script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/analysistree/ - restRoot -b -q simpleTree.cpp Generate Readout: - type: metadata + stage: metadata script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/metadata/readout/ @@ -188,7 +187,7 @@ Generate Readout: # - diff validation.txt print.txt Basic Readout: - type: metadata + stage: metadata script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/projects/basic-readouts/ @@ -199,7 +198,7 @@ Basic Readout: - restRoot -b -q BasicValidation.C'("basic.root", "pixelDecoding")' Test Metadata: - type: restManager_generate + stage: restManager_generate script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/install/examples @@ -210,7 +209,7 @@ Test Metadata: expire_in: 1 day TREX-DM Latest Data: - type: restManager_process + stage: restManager_process script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/trex @@ -229,7 +228,7 @@ TREX-DM Latest Data: expire_in: 1 day PandaXIII Topological: - type: restManager_process + stage: restManager_process script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC @@ -243,7 +242,7 @@ PandaXIII Topological: expire_in: 1 week PandaXIII Topological from Geant4: - type: restManager_process + stage: restManager_process script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/pandaxiii_MC @@ -257,7 +256,7 @@ PandaXIII Topological from Geant4: expire_in: 1 week PandaXIII Data: - type: restManager_process + stage: restManager_process script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/pandaxiii_data @@ -270,7 +269,7 @@ PandaXIII Data: expire_in: 1 week Event Selection: - type: restManager_process + stage: restManager_process script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/selection @@ -284,14 +283,14 @@ Event Selection: expire_in: 1 week AnalysisPlot: - type: postProcessing + stage: postProcessing script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/analysisPlot/ - restManager --c summary.rml --f ${CI_PROJECT_DIR}/pipeline/trex/Hits_01928.root AnalysisPlot2: - type: postProcessing + stage: postProcessing script: - source ${CI_PROJECT_DIR}/install/thisREST.sh - cd ${CI_PROJECT_DIR}/pipeline/analysisPlot/ @@ -299,7 +298,7 @@ AnalysisPlot2: - restRoot -b -q ValidateClassify.C Deploy: - type: deploy + stage: deploy only: - tags script: From cdcb06171390f5713b2f43d141dfdc7ddad9e255 Mon Sep 17 00:00:00 2001 From: juanan Date: Tue, 5 Apr 2022 11:09:58 +0200 Subject: [PATCH 15/17] Adding const methods to TRestVolumeHits --- source/framework/core/inc/TRestVolumeHits.h | 24 ++++++++++--------- source/framework/core/src/TRestVolumeHits.cxx | 16 ++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/source/framework/core/inc/TRestVolumeHits.h b/source/framework/core/inc/TRestVolumeHits.h index 821bbeb85..9c49bbe50 100644 --- a/source/framework/core/inc/TRestVolumeHits.h +++ b/source/framework/core/inc/TRestVolumeHits.h @@ -36,8 +36,8 @@ class TRestVolumeHits : public TRestHits { public: void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t time, REST_HitType type, Double_t sigmax, Double_t sigmay, Double_t sigmaz); - void AddHit(TVector3 pos, Double_t en, Double_t time, REST_HitType type, TVector3 sigma); - void AddHit(TRestVolumeHits& hits, Int_t n); + void AddHit(const TVector3& pos, Double_t en, Double_t time, REST_HitType type, const TVector3& sigma); + void AddHit(const TRestVolumeHits& hits, Int_t n); void RemoveHits(); void MergeHits(Int_t n, Int_t m); @@ -46,26 +46,28 @@ class TRestVolumeHits : public TRestHits { void SortByEnergy(); void SwapHits(Int_t i, Int_t j); - Bool_t areXY(); - Bool_t areXZ(); - Bool_t areYZ(); - Bool_t areXYZ(); + Bool_t areXY() const override; + Bool_t areXZ() const override; + Bool_t areYZ() const override; + Bool_t areXYZ() const override; // Setters // Getters - Double_t GetSigmaX(int n) { return fSigmaX[n]; } // return value in mm - Double_t GetSigmaY(int n) { return fSigmaY[n]; } // return value in mm - Double_t GetSigmaZ(int n) { return fSigmaZ[n]; } // return value in mm + inline Double_t GetSigmaX(int n) const { return fSigmaX[n]; } // return value in mm + inline Double_t GetSigmaY(int n) const { return fSigmaY[n]; } // return value in mm + inline Double_t GetSigmaZ(int n) const { return fSigmaZ[n]; } // return value in mm TVector3 GetSigma(int n); void PrintHits(); - Double_t GetClusterSize(int n) { + inline Double_t GetClusterSize(int n) const { return TMath::Sqrt(fSigmaX[n] * fSigmaX[n] + fSigmaY[n] * fSigmaY[n] + fSigmaZ[n] * fSigmaZ[n]); } - Double_t GetXYSize(int n) { return TMath::Sqrt(fSigmaX[n] * fSigmaX[n] + fSigmaY[n] * fSigmaY[n]); } + inline Double_t GetXYSize(int n) const { + return TMath::Sqrt(fSigmaX[n] * fSigmaX[n] + fSigmaY[n] * fSigmaY[n]); + } // Constructor & Destructor TRestVolumeHits(); diff --git a/source/framework/core/src/TRestVolumeHits.cxx b/source/framework/core/src/TRestVolumeHits.cxx index f4c7ff306..d56d6325f 100644 --- a/source/framework/core/src/TRestVolumeHits.cxx +++ b/source/framework/core/src/TRestVolumeHits.cxx @@ -43,7 +43,8 @@ void TRestVolumeHits::AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Do fSigmaZ.push_back((Float_t)sigmaz); } -void TRestVolumeHits::AddHit(TVector3 pos, Double_t en, Double_t time, REST_HitType type, TVector3 sigma) { +void TRestVolumeHits::AddHit(const TVector3& pos, Double_t en, Double_t time, REST_HitType type, + const TVector3& sigma) { if (fType.size() > 0 && type != fType[0]) { cout << "Error! Cannot add different typed hits into TRestVolumeHits!" << endl; return; @@ -55,7 +56,7 @@ void TRestVolumeHits::AddHit(TVector3 pos, Double_t en, Double_t time, REST_HitT fSigmaZ.push_back((Float_t)sigma.Z()); } -void TRestVolumeHits::AddHit(TRestVolumeHits& hits, Int_t n) { +void TRestVolumeHits::AddHit(const TRestVolumeHits& hits, Int_t n) { Double_t x = hits.GetX(n); Double_t y = hits.GetY(n); Double_t z = hits.GetZ(n); @@ -83,25 +84,25 @@ void TRestVolumeHits::RemoveHits() { fSigmaZ.clear(); } -Bool_t TRestVolumeHits::areXY() { +Bool_t TRestVolumeHits::areXY() const { if (fType.size() == 0) return TMath::IsNaN(fZ[0]) && !TMath::IsNaN(fX[0]) && !TMath::IsNaN(fY[0]); else return fType[0] == XY; } -Bool_t TRestVolumeHits::areXZ() { +Bool_t TRestVolumeHits::areXZ() const { if (fType.size() == 0) return !TMath::IsNaN(fZ[0]) && !TMath::IsNaN(fX[0]) && TMath::IsNaN(fY[0]); else return fType[0] == XZ; } -Bool_t TRestVolumeHits::areYZ() { +Bool_t TRestVolumeHits::areYZ() const { if (fType.size() == 0) return !TMath::IsNaN(fZ[0]) && TMath::IsNaN(fX[0]) && !TMath::IsNaN(fY[0]); else return fType[0] == YZ; } -Bool_t TRestVolumeHits::areXYZ() { +Bool_t TRestVolumeHits::areXYZ() const { if (fType.size() == 0) return !TMath::IsNaN(fZ[0]) && !TMath::IsNaN(fX[0]) && !TMath::IsNaN(fY[0]); else @@ -127,11 +128,8 @@ void TRestVolumeHits::RemoveHit(int n) { TRestHits::RemoveHit(n); fSigmaX.erase(fSigmaX.begin() + n); - ; fSigmaY.erase(fSigmaY.begin() + n); - ; fSigmaZ.erase(fSigmaZ.begin() + n); - ; } void TRestVolumeHits::SortByEnergy() { From 4f45a6231b1cc2962121ff46ed5dac3cd61f3ee6 Mon Sep 17 00:00:00 2001 From: Luis Obis Date: Tue, 5 Apr 2022 12:56:10 +0200 Subject: [PATCH 16/17] TRestVolumeHits - made a few more methods const --- source/framework/core/inc/TRestVolumeHits.h | 6 +++--- source/framework/core/src/TRestVolumeHits.cxx | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/framework/core/inc/TRestVolumeHits.h b/source/framework/core/inc/TRestVolumeHits.h index 9c49bbe50..f82e71d4e 100644 --- a/source/framework/core/inc/TRestVolumeHits.h +++ b/source/framework/core/inc/TRestVolumeHits.h @@ -35,7 +35,7 @@ class TRestVolumeHits : public TRestHits { public: void AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t time, REST_HitType type, - Double_t sigmax, Double_t sigmay, Double_t sigmaz); + Double_t sigmaX, Double_t sigmaY, Double_t sigmaZ); void AddHit(const TVector3& pos, Double_t en, Double_t time, REST_HitType type, const TVector3& sigma); void AddHit(const TRestVolumeHits& hits, Int_t n); @@ -58,9 +58,9 @@ class TRestVolumeHits : public TRestHits { inline Double_t GetSigmaY(int n) const { return fSigmaY[n]; } // return value in mm inline Double_t GetSigmaZ(int n) const { return fSigmaZ[n]; } // return value in mm - TVector3 GetSigma(int n); + TVector3 GetSigma(int n) const; - void PrintHits(); + void PrintHits() const; inline Double_t GetClusterSize(int n) const { return TMath::Sqrt(fSigmaX[n] * fSigmaX[n] + fSigmaY[n] * fSigmaY[n] + fSigmaZ[n] * fSigmaZ[n]); diff --git a/source/framework/core/src/TRestVolumeHits.cxx b/source/framework/core/src/TRestVolumeHits.cxx index d56d6325f..7b5df4ef8 100644 --- a/source/framework/core/src/TRestVolumeHits.cxx +++ b/source/framework/core/src/TRestVolumeHits.cxx @@ -17,30 +17,30 @@ ///_______________________________________________________________________________ #include "TRestVolumeHits.h" + using namespace std; -ClassImp(TRestVolumeHits) - //______________________________________________________________________________ - TRestVolumeHits::TRestVolumeHits() { +ClassImp(TRestVolumeHits); + +TRestVolumeHits::TRestVolumeHits() { // TRestVolumeHits default constructor } -//______________________________________________________________________________ TRestVolumeHits::~TRestVolumeHits() { // TRestVolumeHits destructor } void TRestVolumeHits::AddHit(Double_t x, Double_t y, Double_t z, Double_t en, Double_t time, - REST_HitType type, Double_t sigmax, Double_t sigmay, Double_t sigmaz) { + REST_HitType type, Double_t sigmaX, Double_t sigmaY, Double_t sigmaZ) { if (fType.size() > 0 && type != fType[0]) { cout << "Error! Cannot add different typed hits into TRestVolumeHits!" << endl; return; } TRestHits::AddHit(x, y, z, en, time, type); - fSigmaX.push_back((Float_t)sigmax); - fSigmaY.push_back((Float_t)sigmay); - fSigmaZ.push_back((Float_t)sigmaz); + fSigmaX.push_back((Float_t)sigmaX); + fSigmaY.push_back((Float_t)sigmaY); + fSigmaZ.push_back((Float_t)sigmaZ); } void TRestVolumeHits::AddHit(const TVector3& pos, Double_t en, Double_t time, REST_HitType type, @@ -150,11 +150,11 @@ void TRestVolumeHits::SwapHits(Int_t i, Int_t j) { TRestHits::SwapHits(i, j); } -TVector3 TRestVolumeHits::GetSigma(int n) { +TVector3 TRestVolumeHits::GetSigma(int n) const { return TVector3(((Double_t)fSigmaX[n]), ((Double_t)fSigmaY[n]), ((Double_t)fSigmaZ[n])); } -void TRestVolumeHits::PrintHits() { +void TRestVolumeHits::PrintHits() const { for (int n = 0; n < GetNumberOfHits(); n++) { cout << "Hit " << n << " X: " << GetX(n) << " Y: " << GetY(n) << " Z: " << GetZ(n) << " sX: " << GetSigmaX(n) << " sY: " << GetSigmaY(n) << " sZ: " << GetSigmaZ(n) From 99c0aead95d6874296ba02370308e9b844ad20fa Mon Sep 17 00:00:00 2001 From: jgalan Date: Tue, 5 Apr 2022 13:14:46 +0200 Subject: [PATCH 17/17] Updating PR badge --- .github/pr-badge.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/pr-badge.yml b/.github/pr-badge.yml index f6508d325..1eaab6569 100644 --- a/.github/pr-badge.yml +++ b/.github/pr-badge.yml @@ -2,15 +2,15 @@ message: "$payload.pull_request.user.login" color: "blue" - label: "PR Size" - message: "Large" + message: "Large: $additions" color: "red" when: "$additions > 200" - label: "PR Size" - message: "Medium" + message: "Medium: $additions" color: "orange" - when: "$additions > 100" + when: "$additions > 100 and $additions < 201" - label: "PR Size" - message: "Ok" + message: "Ok: $additions" color: "green" when: "$additions < 100" - imageUrl: "https://gitlab.cern.ch/rest-for-physics/framework/badges/$branchName/pipeline.svg"