Skip to content

Commit

Permalink
Merge branch 'lobis-readout-remove-hits' of https://github.com/rest-f…
Browse files Browse the repository at this point in the history
…or-physics/detectorlib into lobis-readout-remove-hits

* 'lobis-readout-remove-hits' of https://github.com/rest-for-physics/detectorlib: (33 commits)
  class version
  readout analysis working on veto
  update class version
  compute additional observables in readout
  add check
  add option to remove hits outside readout
  comment unused function
  add gas work function
  code review
  [pre-commit.ci] auto fixes from pre-commit.com hooks
  Get Fano factor from Garfield
  initialization of efield
  attempt to unify gas pressure initialization
  correctly initialize pressure from gas
  [pre-commit.ci] auto fixes from pre-commit.com hooks
  TRestDetectorHitsEvent::Sort disabled for MacOs
  downloads
  remove debug
  troubleshoot
  troubleshoot
  ...
  • Loading branch information
lobis committed May 7, 2024
2 parents f8ecb72 + 93f42a3 commit 1ad2366
Show file tree
Hide file tree
Showing 21 changed files with 275 additions and 171 deletions.
10 changes: 5 additions & 5 deletions inc/TRestDetectorGarfieldDriftProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ class TRestDetectorGarfieldDriftProcess : public TRestEventProcess {
#endif
protected:
#if defined USE_Garfield
Double_t fGasPressure; // atm
// Double_t fElectricField; // V/cm
Double_t fDriftPotential; // V
Double_t fPEReduction; // reduction factor of primary electrons to track
double fStopDistance; ///< Distance from readout to stop electron drift, in mm
Double_t fGasPressure = -1; // atm
// Double_t fElectricField; // V/cm
Double_t fDriftPotential; // V
Double_t fPEReduction; // reduction factor of primary electrons to track
double fStopDistance; ///< Distance from readout to stop electron drift, in mm

TString fGDML_Filename;

Expand Down
14 changes: 10 additions & 4 deletions inc/TRestDetectorGas.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class TRestDetectorGas : public TRestDetectorDriftVolume {
void InitFromConfigFile() override;
std::string ConstructFilename();

void AddGasComponent(std::string gasName, Double_t fraction);
void AddGasComponent(const std::string& gasName, Double_t fraction);

void GenerateGasFile();

Expand All @@ -127,7 +127,7 @@ class TRestDetectorGas : public TRestDetectorDriftVolume {

public:
TRestDetectorGas();
TRestDetectorGas(const char* configFilename, std::string name = "", bool gasGeneration = false,
TRestDetectorGas(const char* configFilename, const std::string& name = "", bool gasGeneration = false,
bool test = false);
~TRestDetectorGas();

Expand All @@ -149,7 +149,7 @@ class TRestDetectorGas : public TRestDetectorDriftVolume {

void CalcGarField(double Emin, double Emax, int n);

Int_t Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) override;
Int_t Write(const char* name = nullptr, Int_t option = 0, Int_t bufsize = 0) override;

void InitFromRootFile() override;

Expand Down Expand Up @@ -223,7 +223,7 @@ class TRestDetectorGas : public TRestDetectorDriftVolume {
return GetAttachmentCoefficient(fElectricField * units("V/cm"));
}

void GetGasWorkFunction();
void GetGasWorkFunctionOld();

/// Returns the gas fraction in volume for component *n*.
inline Double_t GetGasComponentFraction(Int_t n) {
Expand All @@ -236,6 +236,12 @@ class TRestDetectorGas : public TRestDetectorDriftVolume {
return fGasComponentFraction[n];
}

/// Returns the gas fano factor
Double_t GetGasFanoFactor() const;

/// Returns the gas work function in eV
Double_t GetGasWorkFunction() const;

/// Return pointer to Garfield::MediumGas for gas properties
inline MediumMagboltz* GetGasMedium() const { return fGasMedium; };

Expand Down
4 changes: 2 additions & 2 deletions inc/TRestDetectorHitsToSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class TRestDetectorHitsToSignalProcess : public TRestEventProcess {
Double_t fSampling = 1; //<

/// The gas pressure. If defined it will change the TRestDetectorGas pressure in atm.
Double_t fGasPressure = 1; // atm
Double_t fGasPressure = -1; // atm

/// The electric field in V/mm. Used to calculate the drift velocity if TRestDetectorGas is defined.
Double_t fElectricField = 100; //<
Double_t fElectricField = -1; //<

/// The drift velocity in mm/us. If it is negative, it will be calculated from TRestDetectorGas.
Double_t fDriftVelocity = -1; // mm/us
Expand Down
24 changes: 12 additions & 12 deletions inc/TRestDetectorSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@

class TRestDetectorSignal {
private:
Int_t GetMinIndex();
Int_t GetMinIndex() const;
Int_t GetTimeIndex(Double_t t);

protected:
Int_t fSignalID = -1;

std::vector<Float_t> fSignalTime; // Vector with the time of the signal
std::vector<Float_t> fSignalCharge; // Vector with the charge of the signal
std::vector<Double_t> fSignalTime; // Vector with the time of the signal
std::vector<Double_t> fSignalCharge; // Vector with the charge of the signal

// TODO: remove this and use readout
std::string fName; // Name of the signal
Expand All @@ -49,10 +49,10 @@ class TRestDetectorSignal {

std::vector<Int_t> fPointsOverThreshold; //!

void IncreaseAmplitude(TVector2 p);
void SetPoint(TVector2 p);
void IncreaseAmplitude(const TVector2& p);
void SetPoint(const TVector2& p);

// TODO other objects should probably skip using GetMaxIndex direclty
// TODO other objects should probably skip using GetMaxIndex directly
Int_t GetMaxIndex(Int_t from = 0, Int_t to = 0);

TVector2 GetMaxGauss();
Expand Down Expand Up @@ -97,11 +97,11 @@ class TRestDetectorSignal {

void Normalize(Double_t scale = 1.);

std::vector<Int_t> GetPointsOverThreshold() { return fPointsOverThreshold; }
std::vector<Int_t> GetPointsOverThreshold() const { return fPointsOverThreshold; }

Double_t GetAverage(Int_t start = 0, Int_t end = 0);
Int_t GetMaxPeakWidth();
Double_t GetMaxPeakWithTime(Double_t startTime, Double_t endTime);
Double_t GetMaxPeakWithTime(Double_t startTime, Double_t endTime) const;

Double_t GetMaxPeakValue();
Double_t GetMinPeakValue();
Expand All @@ -114,14 +114,14 @@ class TRestDetectorSignal {
Double_t GetMinTime() const;
Double_t GetMaxTime() const;

Double_t GetData(Int_t index) const { return (double)fSignalCharge[index]; }
Double_t GetTime(Int_t index) const { return (double)fSignalTime[index]; }
Double_t GetData(Int_t index) const { return fSignalCharge[index]; }
Double_t GetTime(Int_t index) const { return fSignalTime[index]; }

// Setters
void SetSignalID(Int_t sID) { fSignalID = sID; }
void SetID(Int_t sID) { fSignalID = sID; }

void NewPoint(Float_t time, Float_t data);
void NewPoint(Double_t time, Double_t data);
void IncreaseAmplitude(Double_t t, Double_t d);

void SetPoint(Double_t t, Double_t d);
Expand Down Expand Up @@ -167,6 +167,6 @@ class TRestDetectorSignal {
// Destructor
~TRestDetectorSignal();

ClassDef(TRestDetectorSignal, 3);
ClassDef(TRestDetectorSignal, 4);
};
#endif
8 changes: 4 additions & 4 deletions inc/TRestDetectorSignalToHitsProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TRestDetectorSignalToHitsProcess : public TRestEventProcess {
/// A pointer to the specific TRestDetectorHitsEvent input
TRestDetectorSignalEvent* fSignalEvent; //!

/// A pointer to the detector readout definition accesible to TRestRun
/// A pointer to the detector readout definition accessible to TRestRun
TRestDetectorReadout* fReadout; //!

/// A pointer to the detector gas definition accessible to TRestRun
Expand All @@ -51,10 +51,10 @@ class TRestDetectorSignalToHitsProcess : public TRestEventProcess {

protected:
/// The electric field in standard REST units (V/mm). Only relevant if TRestDetectorGas is used.
Double_t fElectricField = 100;
Double_t fElectricField = -1;

/// The gas pressure in atm. Only relevant if TRestDetectorGas is used.
Double_t fGasPressure = 1;
Double_t fGasPressure = -1;

/// The drift velocity in standard REST units (mm/us).
Double_t fDriftVelocity = -1;
Expand Down Expand Up @@ -98,7 +98,7 @@ class TRestDetectorSignalToHitsProcess : public TRestEventProcess {

TRestDetectorSignalToHitsProcess();
TRestDetectorSignalToHitsProcess(const char* configFilename);
~TRestDetectorSignalToHitsProcess();
~TRestDetectorSignalToHitsProcess() override;

ClassDefOverride(TRestDetectorSignalToHitsProcess, 4);
};
Expand Down
3 changes: 2 additions & 1 deletion macros/REST_Detector_CheckReadout.C
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ Int_t REST_Detector_CheckReadout(TString rootFile, TString name, Double_t region
vector<TGraph*> modGraph(nModConst);
vector<TLatex*> channelIDLabel(nPixConst);

double xmin = 1E9, xmax = -1E9, ymin = 1E9, ymax = -1E9;
double xmin = std::numeric_limits<Double_t>::max(), xmax = std::numeric_limits<Double_t>::min(),
ymin = std::numeric_limits<Double_t>::max(), ymax = std::numeric_limits<Double_t>::min();

Int_t graph = 0;
Int_t modGraphID = 0;
Expand Down
9 changes: 5 additions & 4 deletions macros/REST_Detector_ViewReadout.C
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ int REST_Detector_ViewReadout(TString rootFile, TString name = "", Int_t plane =
vector<TGraph*> modGraph(nModConst);
vector<TLatex*> channelIDLabel(nPixConst);

double xmin = 1E9, xmax = -1E9, ymin = 1E9, ymax = -1E9;
double xmin = std::numeric_limits<Double_t>::max(), xmax = std::numeric_limits<Double_t>::min(),
ymin = std::numeric_limits<Double_t>::max(), ymax = std::numeric_limits<Double_t>::min();

Int_t graph = 0;
Int_t modGraphID = 0;
Expand Down Expand Up @@ -120,9 +121,9 @@ int REST_Detector_ViewReadout(TString rootFile, TString name = "", Int_t plane =
// pixelGraph[graph]->SetMinimum( -200 );
// pixelGraph[graph]->GetXaxis()->SetLimits(-200,200);

Double_t xMin = 1e10;
Double_t yMin = 1e10;
Double_t xMax = -1e10;
Double_t xMin = numeric_limits<Double_t>::max();
Double_t yMin = numeric_limits<Double_t>::max();
Double_t xMax = numeric_limits<Double_t>::min();
for (int l = 0; l < 5; l++) {
if (x[l] < xMin) xMin = x[l];
if (y[l] < yMin) yMin = y[l];
Expand Down
2 changes: 1 addition & 1 deletion src/TRestDetectorDaqChannelSwitchingProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void TRestDetectorDaqChannelSwitchingProcess::InitProcess() {
auto mod = fReadout->GetReadoutModuleWithID(iter->first);
if (mod == nullptr) continue;
// finding out the old "firstdaqchannel" value
int mindaq = 1e9;
int mindaq = std::numeric_limits<Int_t>::max();
for (size_t i = 0; i < mod->GetNumberOfChannels(); i++) {
if (mod->GetChannel(i)->GetDaqID() < mindaq) {
mindaq = mod->GetChannel(i)->GetDaqID();
Expand Down
4 changes: 2 additions & 2 deletions src/TRestDetectorElectronDiffusionProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void TRestDetectorElectronDiffusionProcess::LoadDefaultConfig() {

fElectricField = 2000;
fAttachment = 0;
fGasPressure = 1;
fGasPressure = -1;
}

void TRestDetectorElectronDiffusionProcess::Initialize() {
Expand All @@ -44,7 +44,7 @@ void TRestDetectorElectronDiffusionProcess::Initialize() {

fElectricField = 0;
fAttachment = 0;
fGasPressure = 1;
fGasPressure = -1;

fTransversalDiffusionCoefficient = 0;
fLongitudinalDiffusionCoefficient = 0;
Expand Down
7 changes: 5 additions & 2 deletions src/TRestDetectorGarfieldDriftProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ void TRestDetectorGarfieldDriftProcess::InitProcess() {
fGfSensor->AddElectrode(fGeometry->GetGfComponent(0), "m");
fGfSensor->SetTimeWindow(0., 0.1, 500);

double xmin = -1e9, xmax = 1e9, ymin = -1e9, ymax = 1e9;
double xmin = std::numeric_limits<Double_t>::min(), xmax = std::numeric_limits<Double_t>::max(),
ymin = std::numeric_limits<Double_t>::min(), ymax = std::numeric_limits<Double_t>::max();
TGeoShape* readoutshape = fGeometry->GetReadoutElecNode(0)->GetVolume()->GetShape();
TGeoMatrix* readoutmatrix = fGeometry->GetReadoutElecNode(0)->GetMatrix();
double xmid = 10. * readoutmatrix->GetTranslation()[0],
Expand Down Expand Up @@ -415,7 +416,9 @@ TRestEvent* TRestDetectorGarfieldDriftProcess::ProcessEvent(TRestEvent* inputEve
}
}

if (fOutputHitsEvent->GetNumberOfHits() == 0) return nullptr;
if (fOutputHitsEvent->GetNumberOfHits() == 0) {
return nullptr;
}

// fSignalEvent->PrintEvent();

Expand Down
Loading

0 comments on commit 1ad2366

Please sign in to comment.