94 #include "TRestDetectorSignalRecoveryProcess.h"
120 if (LoadConfigFromFile(configFilename) == -1) LoadDefaultConfig();
134 SetName(
"removeChannels-Default");
135 SetTitle(
"Default config");
143 SetSectionName(this->ClassName());
144 SetLibraryVersion(LIBRARY_VERSION);
146 fInputSignalEvent =
nullptr;
163 if (LoadConfigFromFile(configFilename, name) == -1) LoadDefaultConfig();
172 fReadout = GetMetadata<TRestDetectorReadout>();
174 if (fReadout ==
nullptr) {
175 RESTError <<
"TRestDetectorSignalRecoveryProcess. Readout has not been initialized!" << RESTendl;
186 for (
int n = 0; n < fInputSignalEvent->GetNumberOfSignals(); n++)
187 fOutputSignalEvent->AddSignal(*fInputSignalEvent->GetSignal(n));
191 for (
unsigned int x = 0; x < fChannelIds.size(); x++) {
192 Int_t type = GetAdjacentSignalIds(fChannelIds[x], idL, idR);
193 RESTDebug <<
"Channel id : " << fChannelIds[x] <<
" Left : " << idL <<
" Right : " << idR << RESTendl;
195 if (idL == -1 || idR == -1)
continue;
205 if (leftSgnl ==
nullptr || rightSgnl ==
nullptr)
continue;
208 recoveredSignal.SetID(fChannelIds[x]);
212 for (
int n = 0; n < leftSgnl->GetNumberOfPoints(); n++) {
213 recoveredSignal.
IncreaseAmplitude(leftSgnl->GetTime(n), leftSgnl->GetData(n) / 2.);
215 leftSgnl->
IncreaseAmplitude(leftSgnl->GetTime(n), -1. * leftSgnl->GetData(n) / 2.);
218 for (
int n = 0; n < rightSgnl->GetNumberOfPoints(); n++) {
219 recoveredSignal.
IncreaseAmplitude(rightSgnl->GetTime(n), rightSgnl->GetData(n) / 2.);
221 rightSgnl->
IncreaseAmplitude(rightSgnl->GetTime(n), -1. * rightSgnl->GetData(n) / 2.);
223 }
else if (type == 2 || type == 3) {
226 for (
int n = 0; n < leftSgnl->GetNumberOfPoints(); n++)
227 recoveredSignal.
IncreaseAmplitude(leftSgnl->GetTime(n), leftSgnl->GetData(n) / 6.);
229 for (
int n = 0; n < rightSgnl->GetNumberOfPoints(); n++)
230 recoveredSignal.
IncreaseAmplitude(rightSgnl->GetTime(n), 2 * rightSgnl->GetData(n) / 6.);
235 for (
int n = 0; n < leftSgnl->GetNumberOfPoints(); n++)
236 recoveredSignal.
IncreaseAmplitude(leftSgnl->GetTime(n), 2 * leftSgnl->GetData(n) / 6.);
238 for (
int n = 0; n < rightSgnl->GetNumberOfPoints(); n++)
239 recoveredSignal.
IncreaseAmplitude(rightSgnl->GetTime(n), rightSgnl->GetData(n) / 6.);
244 for (
int n = 0; n < leftSgnl->GetNumberOfPoints(); n++)
245 leftSgnl->
IncreaseAmplitude(leftSgnl->GetTime(n), -1. * leftSgnl->GetData(n) / 4.);
246 for (
int n = 0; n < rightSgnl->GetNumberOfPoints(); n++)
247 rightSgnl->
IncreaseAmplitude(rightSgnl->GetTime(n), -1. * rightSgnl->GetData(n) / 4.);
249 RESTWarning <<
"Adjacent channels for signal " << fChannelIds[x] <<
" not found " << RESTendl;
253 if (fOutputSignalEvent->GetSignalIndex(fChannelIds[x]) > 0)
254 fOutputSignalEvent->RemoveSignalWithId(fChannelIds[x]);
256 fOutputSignalEvent->AddSignal(recoveredSignal);
264 RESTDebug <<
"Channel recovered!! " << RESTendl;
265 if (leftSgnl !=
nullptr && rightSgnl !=
nullptr)
266 for (
int n = 0; n < leftSgnl->GetNumberOfPoints(); n++)
267 RESTDebug <<
"Sample " << n <<
" : " << leftSgnl->GetData(n) <<
" + " << rightSgnl->GetData(n)
268 <<
" = " << recoveredSignal.GetData(n) << RESTendl;
271 RESTDebug <<
"Channels after : " << fOutputSignalEvent->GetNumberOfSignals() << RESTendl;
273 return fOutputSignalEvent;
291 for (
int p = 0; p < fReadout->GetNumberOfReadoutPlanes(); p++) {
306 if (std::find(fChannelIds.begin(), fChannelIds.end(), idLeft) != fChannelIds.end()) {
312 if (std::find(fChannelIds.begin(), fChannelIds.end(), idRight) != fChannelIds.end()) {
Int_t GetDaqID() const
Returns the corresponding daq channel id.
Bool_t IsDaqIDInside(Int_t daqID)
Determines if a given daqID number is in the range of the module.
TRestDetectorReadoutChannel * GetChannel(size_t n)
Returns a pointer to a readout channel by index.
Int_t DaqToReadoutChannel(Int_t daqChannel)
Returns the physical readout channel index for a given daq id channel number.
size_t GetNumberOfModules() const
Returns the total number of modules in the readout plane.
TRestDetectorReadoutModule * GetModule(size_t mod)
Returns a pointer to a readout module using its std::vector index.
A process allowing to recover selected channels from a TRestRawSignalEvent.
~TRestDetectorSignalRecoveryProcess()
Default destructor.
void InitProcess() override
Function to initialize the process. TRestDetectorSignalRecoveryProcess requires to get a pointer to T...
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
TRestDetectorSignalRecoveryProcess()
Default constructor.
int GetAdjacentSignalIds(Int_t signalId, Int_t &idLeft, Int_t &idRight)
It returns the channel daq id of the adjacent readout channels. It will properly identify that we got...
void Initialize() override
Function to initialize input/output event members and define the section name.
TRestEvent * ProcessEvent(TRestEvent *eventInput) override
The main processing event function.
void LoadConfig(const std::string &configFilename, const std::string &name="")
Function to load the configuration from an external configuration file.
void IncreaseAmplitude(TVector2 p)
If the point already exists inside the detector signal event, the amplitude value will be added to th...
A base class for any REST event.