Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor updates #263

Merged
merged 10 commits into from
Jul 12, 2022
33 changes: 12 additions & 21 deletions source/framework/core/inc/TRestHits.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,32 @@
#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>

#include "TArrayD.h"
#include "TArrayI.h"
#include "TCanvas.h"
#include "TMath.h"
#include "TMatrixD.h"
#include "TObject.h"

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.
//! Allows saving 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 {
lobis marked this conversation as resolved.
Show resolved Hide resolved
class TRestHits {
public:
Int_t fNHits; ///< Number of punctual energy depositions, it is the length
///< for all the array
Int_t fNHits; ///< Number of punctual energy depositions, it is the length for all the arrays
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> 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<Float_t> fEnergy; // [fNHits] Energy deposited at each 3-coordinate position (units keV)
std::vector<REST_HitType> fType; //

public:
Expand All @@ -71,13 +63,12 @@ class TRestHits : public TObject {
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 Down
28 changes: 10 additions & 18 deletions source/framework/core/src/TRestRun.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
#include <windows.h>
#undef GetClassName
#else
#include "unistd.h"
#include <sys/stat.h>
#include <unistd.h>
#endif // !WIN32

#include <filesystem>

#include "TRestDataBase.h"
#include "TRestEventProcess.h"
#include "TRestManager.h"
Expand All @@ -61,17 +63,7 @@ TRestRun::TRestRun(const string& filename) {
}
}

TRestRun::~TRestRun() {
// if (fEventTree != nullptr) {
// delete fEventTree;
//}

// if (fAnalysisTree != nullptr) {
// delete fAnalysisTree;
//}

CloseFile();
}
TRestRun::~TRestRun() { CloseFile(); }

///////////////////////////////////////////////
/// \brief Set variables by default during initialization.
Expand Down Expand Up @@ -116,8 +108,6 @@ void TRestRun::Initialize() {
fEventBranchLoc = -1;
fFileProcess = nullptr;
fSaveHistoricData = true;

return;
}

///////////////////////////////////////////////
Expand Down Expand Up @@ -1021,17 +1011,19 @@ TFile* TRestRun::MergeToOutputFile(vector<string> filenames, string outputfilena
}

///////////////////////////////////////////////
/// \brief Create a new TFile as REST output file. Writing metadata objects into
/// it.
/// \brief Create a new TFile as REST output file. Writing metadata objects into it.
///
TFile* TRestRun::FormOutputFile() {
CloseFile();

fOutputFileName = FormFormat(fOutputFileName);
// remove unwanted "./" etc. from the path while resolving them
fOutputFileName = std::filesystem::weakly_canonical(fOutputFileName.Data());

fOutputFile = new TFile(fOutputFileName, "recreate");
fAnalysisTree = new TRestAnalysisTree("AnalysisTree", "AnalysisTree");
fEventTree = new TTree("EventTree", "EventTree");
// fAnalysisTree->CreateBranches();
lobis marked this conversation as resolved.
Show resolved Hide resolved
// fEventTree->CreateEventBranches();

fAnalysisTree->Write();
fEventTree->Write();
this->WriteWithDataBase();
Expand Down