98#include "TRestDetectorHitsToSignalProcess.h"
145 SetName(
"hitsToSignalProcess-Default");
146 SetTitle(
"Default config");
148 cout <<
"Hits to signal metadata not found. Loading default values" << endl;
176 if (
fGas !=
nullptr) {
178 RESTError <<
"A TRestDetectorGas definition was found but REST was not linked to Garfield libraries."
181 <<
"Please, remove the TRestDetectorGas definition, and add gas parameters inside the process "
182 "TRestDetectorHitsToSignalProcess"
184 if (!
fGas->GetError()) {
185 fGas->SetError(
"REST was not compiled with Garfield.");
188 this->
SetError(
"Attempt to use TRestDetectorGas without Garfield");
208 <<
"Drift velocity not defined. Please, define it in the process metadata or in TRestDetectorGas"
216 this->
SetError(
"The readout was not properly initialized.");
233 cout <<
"Number of hits : " <<
fHitsEvent->GetNumberOfHits() << endl;
234 cout <<
"--------------------------" << endl;
237 for (
unsigned int hit = 0; hit <
fHitsEvent->GetNumberOfHits(); hit++) {
244 cout <<
"Hit : " << hit <<
" x : " << x <<
" y : " << y <<
" z : " << z <<
" t : " << t << endl;
247 for (
int p = 0; p <
fReadout->GetNumberOfReadoutPlanes(); p++) {
248 const auto [daqId, moduleId, channelId] =
fReadout->GetHitsDaqChannelAtReadoutPlane({x, y, z}, p);
252 auto channel =
fReadout->GetReadoutChannelWithDaqID(daqId);
254 const bool isVeto = (channel->GetChannelType() ==
"veto");
259 RESTError <<
"TRestDetectorHitsToSignalProcess: Negative distance to readout plane. "
260 "This should not happen."
272 <<
"TRestDetectorHitsToSignalProcess: Negative velocity. This should not happen."
277 Double_t time = t + distance / velocity;
280 cout <<
"Module : " << moduleId <<
" Channel : " << channelId <<
" daq ID : " << daqId
285 cout <<
"Energy : " << energy <<
" time : " << time << endl;
289 " TRestDetectorHitsToSignalProcess: x %lf y %lf z %lf energy %lf t %lf "
290 "fDriftVelocity %lf fSampling %lf time %lf\n",
295 cout <<
"Drift velocity : " <<
fDriftVelocity <<
" mm/us" << endl;
301 RESTError <<
"TRestDetectorHitsToSignalProcess: Negative time. This should not happen. "
309 signal->SetSignalName(channel->GetChannelName());
310 signal->SetSignalType(channel->GetChannelType());
314 RESTDebug <<
"TRestDetectorHitsToSignalProcess. Readout channel not find for position ("
315 << x <<
", " << y <<
", " << z <<
")!" <<
RESTendl;
324 cout <<
"TRestDetectorHitsToSignalProcess : Number of signals added : "
326 cout <<
"TRestDetectorHitsToSignalProcess : Total signals integral : " <<
fSignalEvent->GetIntegral()
A process to transform a x,y,z coordinate hits into daq identified physical time signals.
Double_t fSampling
The sampling rate in us.
void InitProcess() override
Process initialization. This process accesses the information inside TRestGeant4Metadata to identify ...
TRestDetectorHitsEvent * fHitsEvent
A pointer to the specific TRestDetectorHitsEvent output.
TRestDetectorGas * fGas
A pointer to the detector gas definition accessible to TRestRun.
TRestDetectorHitsToSignalProcess()
Default constructor.
Double_t fGasPressure
The gas pressure. If defined it will change the TRestDetectorGas pressure in atm.
TRestDetectorReadout * fReadout
A pointer to the detector readout definition available to TRestRun.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
~TRestDetectorHitsToSignalProcess()
Default destructor.
Double_t fDriftVelocity
The drift velocity in mm/us. If it is negative, it will be calculated from TRestDetectorGas.
TRestDetectorSignalEvent * fSignalEvent
A pointer to the specific TRestDetectorHitsEvent input.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
Double_t fElectricField
The electric field in V/mm. Used to calculate the drift velocity if TRestDetectorGas is defined.
void Initialize() override
Function to initialize input/output event members and define the section name.
Double_t GetDistanceTo(const TVector3 &pos) const
Returns the perpendicular distance to the readout plane from a given position pos.
A metadata class to generate/store a readout description.
T * GetMetadata()
Get a metadata object from the host TRestRun.
A base class for any REST event.
@ REST_Extreme
show everything
@ REST_Debug
+show the defined debug messages
constexpr double lightSpeed
Speed of light in m/s.