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

Process for veto analysis #20

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics
steps:
- uses: actions/checkout@v3
- run: python3 pipeline/validateLibrary.py .
- run: python3 pipeline/validateLibrary.py .

build-connectorslib:
name: Build only connectorslib
Expand Down
96 changes: 96 additions & 0 deletions inc/TRestGeant4ToDetectorSignalVetoProcess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

#include <TRestDetectorSignalEvent.h>
#include <TRestEventProcess.h>
#include <TRestGeant4Event.h>
#include <TRestGeant4Metadata.h>

#ifndef RestCore_TRestGeant4ToRawSignalVetoProcess
#define RestCore_TRestGeant4ToRawSignalVetoProcess

class TRestGeant4ToDetectorSignalVetoProcess : public TRestEventProcess {
private:
TString fVetoVolumesExpression;
TString fVetoDetectorsExpression;
double fVetoDetectorOffsetSize = 0;
double fVetoLightAttenuation = 0;
double fVetoQuenchingFactor = 1.0;

public:
inline TString GetVetoVolumesExpression() const { return fVetoVolumesExpression; }
inline TString GetVetoDetectorExpression() const { return fVetoDetectorsExpression; }
inline double GetVetoDetectorOffsetSize() const { return fVetoDetectorOffsetSize; }
inline double GetVetoLightAttenuation() const { return fVetoLightAttenuation; }
inline double GetVetoQuenchingFactor() const { return fVetoQuenchingFactor; }
inline std::map<TString, Int_t> GetVetoVolumeToSignalIdMap() const { return fVetoVolumesToSignalIdMap; }

inline void SetVetoVolumesExpression(const TString& expression) { fVetoVolumesExpression = expression; }
inline void SetVetoDetectorsExpression(const TString& expression) {
fVetoDetectorsExpression = expression;
}
inline void SetVetoDetectorOffsetSize(double offset) { fVetoDetectorOffsetSize = offset; }
inline void SetVetoLightAttenuation(double attenuation) {
if (attenuation < 0) {
std::cerr << "Light attenuation factor must be positive" << std::endl;
exit(1);
}
fVetoLightAttenuation = attenuation;
}
inline void SetVetoQuenchingFactor(double quenchingFactor) {
if (quenchingFactor < 0 || quenchingFactor > 1) {
std::cerr << "Quenching factor must be between 0 and 1" << std::endl;
exit(1);
}
fVetoQuenchingFactor = quenchingFactor;
}

private:
TRestGeant4Event* fInputEvent = nullptr; //!
TRestDetectorSignalEvent* fOutputEvent = nullptr; //!
const TRestGeant4Metadata* fGeant4Metadata = nullptr; //!

std::vector<TString> fVetoVolumes;
std::vector<TString> fVetoDetectorVolumes;
std::map<TString, TVector3> fVetoDetectorBoundaryPosition;
std::map<TString, TVector3> fVetoDetectorBoundaryDirection;

std::map<TString, Int_t> fVetoVolumesToSignalIdMap;
std::set<TString> fParticlesNotQuenched = {"gamma", "e-", "e-", "mu-", "mu+"};

bool fDriftEnabled = false;
std::string fDriftVolume;
std::string fDriftReadoutVolume;
double fDriftReadoutOffset = 0;
TVector3 fDriftReadoutNormalDirection = TVector3(0, 0, 1);
double fDriftVelocity = 0;

void InitFromConfigFile() override;
void Initialize() override;
void LoadDefaultConfig();

public:
any GetInputEvent() const override { return fInputEvent; }
any GetOutputEvent() const override { return fOutputEvent; }

inline void SetGeant4Metadata(const TRestGeant4Metadata* metadata) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The process has access to TRestGeant4Metadata through TRestRun.

It is enough to do fGeant4Metada = GetMetadata<TRestGeant4Metadata>(); as it is done in other processes.

jgalan@sultan2:~/rest-framework/source/libraries/geant4$ grep -rnw . -e "GetMetadata"
./src/TRestGeant4NeutronTaggingProcess.cxx:145:    fG4Metadata = GetMetadata<TRestGeant4Metadata>();
./src/TRestGeant4BlobAnalysisProcess.cxx:66:    fG4Metadata = GetMetadata<TRestGeant4Metadata>();
./src/TRestGeant4AnalysisProcess.cxx:286:    fG4Metadata = GetMetadata<TRestGeant4Metadata>();
./src/TRestGeant4VetoAnalysisProcess.cxx:123:    fG4Metadata = GetMetadata<TRestGeant4Metadata>();
jgalan@sultan2:~/rest-framework/source/libraries/geant4$ 

Why do you want to set it externally?

fGeant4Metadata = metadata;
} // TODO: We should not need this! but `GetMetadata<TRestGeant4Metadata>()` is not working early in the
// processing (look at the tests for more details)

void InitProcess() override;
TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
void EndProcess() override;

void LoadConfig(const std::string& configFilename, const std::string& name = "");

void PrintMetadata() override;

const char* GetProcessName() const override { return "Geant4ToDetectorSignalVetoProcess"; }

TRestGeant4ToDetectorSignalVetoProcess();
TRestGeant4ToDetectorSignalVetoProcess(const char* configFilename);
~TRestGeant4ToDetectorSignalVetoProcess();

ClassDefOverride(TRestGeant4ToDetectorSignalVetoProcess, 1);
};

#endif // RestCore_TRestGeant4ToRawSignalVetoProcess
24 changes: 19 additions & 5 deletions src/TRestDetectorSignalToRawSignalProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
/// information loss when transferring the signal data to the raw-signal data.
/// To minimize the impact, the maximum data value of the output signals should
/// be high enough, and adjusted to the maximum value of a Short_t, being
/// this value 32768. The *gain* parameter may serve to re-adjust the
/// this value 32767. The *gain* parameter may serve to re-adjust the
/// amplitude of the output data array.
///
/// \warning If the value assigned to a data point in the output rawsignal
/// event exceeds 32768 it will cause an overflow, and the event data will
/// event exceeds 32767 it will cause an overflow, and the event data will
/// be corrupted. If the verboseLevel of the process is warning, an output
/// message will prevent the user. The event status will be invalid.
///
Expand All @@ -62,7 +62,7 @@
/// * **sampling**: It is the sampling time of the resulting raw signal
/// output data. Time units must be specified (ns, us, ms)".
///
/// * **Npoints**: The number of points of the resulting raw signals.
/// * **nPoints**: The number of points of the resulting raw signals.
///
/// * **triggerMode**: It defines how the start time is fixed. The
/// different options are:
Expand All @@ -74,10 +74,14 @@
/// deposit. The time at which the value of this integral is above
/// the value provided at the **integralThreshold** parameter will
/// be defined as the center of the acquisition window.
/// - *fixed*: User manually sets the time corresponding to the bin 0 via the **triggerFixedStartTime**
/// parameter. It is affected by the **triggerDelay** parameter.
///
/// * **integralThreshold**: It defines the value to be used in the
/// triggerThreshold method. This parameter is not used otherwise.
///
/// * **triggerFixedStartTime**: It defines the time (with units) of bin 0 when used with *fixed* trigger mode
///
///
/// \htmlonly <style>div.image img[src="trigger.png"]{width:500px;}</style> \endhtmlonly
///
Expand All @@ -95,9 +99,19 @@
/// * **gain**: Each data point from the resulting raw signal will be
/// multiplied by this factor before performing the conversion to
/// Short_t. Each value in the raw output signal should be between
/// -32768 and 32768, resulting event data will be corrupted otherwise.
/// -32768 and 32767, resulting event data will be corrupted otherwise.
/// The state of the event will be set to false fOk=false.
///
/// * **offset**: Value to add to all amplitudes (position of zero level)
///
/// * **calibrationEnergy**: Pair of energies used for linear calibration (alternative to setting gain/offset)
/// * **calibrationRange**: Pair of numbers between 0.0 and 1.0 to define linear calibration.
/// They correspond to the values of energy set by *calibrationEnergy*.
/// 0.0 corresponds to the minimum of the signal range (-32768 for Short_t) and 1.0 to the maximum (32767 for
/// Short_t)
///
/// * **shapingTime**: shaping time in time units. If set the signal will be shaped by sin shaper.
/// We allow shaping in this process to avoid artifacts produced if shaping the signal after digitalization
///
///--------------------------------------------------------------------------
///
Expand Down Expand Up @@ -360,4 +374,4 @@ void TRestDetectorSignalToRawSignalProcess::InitProcess() {
fTimeStart = fTriggerFixedStartTime - fTriggerDelay * fSampling;
fTimeEnd = fTimeStart + fNPoints * fSampling;
}
}
}
Loading