98 #include "TRestDetectorHitsToSignalProcess.h"
124 if (LoadConfigFromFile(configFilename) == -1) {
128 if (fReadout ==
nullptr) {
145 SetName(
"hitsToSignalProcess-Default");
146 SetTitle(
"Default config");
148 cout <<
"Hits to signal metadata not found. Loading default values" << endl;
151 fElectricField = 1000;
160 SetSectionName(this->ClassName());
161 SetLibraryVersion(LIBRARY_VERSION);
166 fHitsEvent =
nullptr;
175 fGas = GetMetadata<TRestDetectorGas>();
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.");
187 if (!this->GetError()) {
188 this->SetError(
"Attempt to use TRestDetectorGas without Garfield");
191 if (fGasPressure <= 0) {
192 fGasPressure = fGas->GetPressure();
194 if (fElectricField <= 0) {
195 fElectricField = fGas->GetElectricField();
198 fGas->SetPressure(fGasPressure);
199 fGas->SetElectricField(fElectricField);
201 if (fDriftVelocity <= 0) {
202 fDriftVelocity = fGas->GetDriftVelocity();
206 if (fDriftVelocity <= 0) {
208 <<
"Drift velocity not defined. Please, define it in the process metadata or in TRestDetectorGas"
213 fReadout = GetMetadata<TRestDetectorReadout>();
214 if (fReadout ==
nullptr) {
215 if (!this->GetError()) {
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++) {
238 Double_t x = fHitsEvent->GetX(hit);
239 Double_t y = fHitsEvent->GetY(hit);
240 Double_t z = fHitsEvent->GetZ(hit);
241 Double_t t = fHitsEvent->GetTime(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");
256 Double_t energy = fHitsEvent->GetEnergy(hit);
259 RESTError <<
"TRestDetectorHitsToSignalProcess: Negative distance to readout plane. "
260 "This should not happen."
265 auto velocity = fDriftVelocity;
270 Double_t time = t + distance / velocity;
273 cout <<
"Module : " << moduleId <<
" Channel : " << channelId <<
" daq ID : " << daqId
278 cout <<
"Energy : " << energy <<
" time : " << time << endl;
282 " TRestDetectorHitsToSignalProcess: x %lf y %lf z %lf energy %lf t %lf "
283 "fDriftVelocity %lf fSampling %lf time %lf\n",
284 x, y, z, energy, t, fDriftVelocity, fSampling, time);
288 cout <<
"Drift velocity : " << fDriftVelocity <<
" mm/us" << endl;
290 time = ((Int_t)(time / fSampling)) * fSampling;
292 fSignalEvent->AddChargeToSignal(daqId, time, energy);
294 auto signal = fSignalEvent->GetSignalById(daqId);
295 signal->SetSignalName(channel->GetChannelName());
296 signal->SetSignalType(channel->GetChannelType());
300 RESTDebug <<
"TRestDetectorHitsToSignalProcess. Readout channel not find for position ("
301 << x <<
", " << y <<
", " << z <<
")!" << RESTendl;
307 fSignalEvent->SortSignals();
310 cout <<
"TRestDetectorHitsToSignalProcess : Number of signals added : "
311 << fSignalEvent->GetNumberOfSignals() << endl;
312 cout <<
"TRestDetectorHitsToSignalProcess : Total signals integral : " << fSignalEvent->GetIntegral()
316 if (fSignalEvent->GetNumberOfSignals() == 0) {
A process to transform a x,y,z coordinate hits into daq identified physical time signals.
void InitProcess() override
Process initialization. This process accesses the information inside TRestGeant4Metadata to identify ...
TRestDetectorHitsToSignalProcess()
Default constructor.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
~TRestDetectorHitsToSignalProcess()
Default destructor.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
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.
A base class for any REST event.
void SetEventInfo(TRestEvent *eve)
@ REST_Extreme
show everything
@ REST_Debug
+show the defined debug messages
constexpr double lightSpeed
Speed of light in m/s.