137 #include "TRestRawVetoAnalysisProcess.h"
165 LoadConfig(configFilename);
177 SetName(this->ClassName());
178 SetTitle(
"Default config");
194 if (LoadConfigFromFile(configFilename, name)) LoadDefaultConfig();
211 SetSectionName(this->ClassName());
212 SetLibraryVersion(LIBRARY_VERSION);
214 fSignalEvent =
nullptr;
223 map<int, Double_t> VetoMaxPeakAmplitude_map;
224 map<int, Double_t> VetoPeakTime_map;
226 Int_t VetoAboveThreshold = 0;
227 Int_t NVetoAboveThreshold = 0;
228 Int_t VetoInTimeWindow = 0;
229 Int_t NVetoInTimeWindow = 0;
231 fSignalEvent->SetRange(fRange);
233 VetoMaxPeakAmplitude_map.clear();
234 VetoPeakTime_map.clear();
240 if (fVetoSignalId[0] != -1) {
242 for (
unsigned int i = 0; i < fVetoSignalId.size(); i++) {
245 if (fSignalEvent->GetSignalIndex(fVetoSignalId[i]) != -1) {
247 TRestRawSignal* sgnl = fSignalEvent->GetSignalById(fVetoSignalId[i]);
251 fPointsOverThreshold);
260 VetoMaxPeakAmplitude_map[fVetoSignalId[i]] = 0;
264 fSignalEvent->RemoveSignalWithId(fVetoSignalId[i]);
268 VetoAboveThreshold = 1;
269 NVetoAboveThreshold += 1;
273 VetoInTimeWindow = 1;
274 NVetoInTimeWindow += 1;
279 SetObservableValue(
"PeakTime", VetoPeakTime_map);
280 SetObservableValue(
"MaxPeakAmplitude", VetoMaxPeakAmplitude_map);
281 if (fThreshold != -1) {
282 SetObservableValue(
"VetoAboveThreshold", VetoAboveThreshold);
283 SetObservableValue(
"NvetoAboveThreshold", NVetoAboveThreshold);
285 if (fTimeWindow[0] != -1) {
286 SetObservableValue(
"VetoInTimeWindow", VetoInTimeWindow);
287 SetObservableValue(
"NVetoInTimeWindow", NVetoInTimeWindow);
296 for (
unsigned int i = 0; i < fVetoGroupNames.size(); i++) {
297 fPeakTime.push_back(
"PeakTime_" + fVetoGroupNames[i]);
298 fPeakAmp.push_back(
"MaxPeakAmplitude_" + fVetoGroupNames[i]);
301 if (fVetoSignalId[0] == -1) {
303 for (
unsigned int i = 0; i < fVetoGroupNames.size(); i++) {
306 for (
unsigned int j = 0; j < groupIds.size(); j++) {
309 if (fSignalEvent->GetSignalIndex(groupIds[j]) != -1) {
315 fPointsOverThreshold);
323 VetoMaxPeakAmplitude_map[groupIds[j]] = 0;
327 fSignalEvent->RemoveSignalWithId(groupIds[j]);
331 VetoAboveThreshold = 1;
332 NVetoAboveThreshold += 1;
336 VetoInTimeWindow = 1;
337 NVetoInTimeWindow += 1;
341 SetObservableValue(fPeakTime[i], VetoPeakTime_map);
342 SetObservableValue(fPeakAmp[i], VetoMaxPeakAmplitude_map);
344 VetoMaxPeakAmplitude_map.clear();
345 VetoPeakTime_map.clear();
348 if (fThreshold != -1) {
349 SetObservableValue(
"VetoAboveThreshold", VetoAboveThreshold);
350 SetObservableValue(
"NvetoAboveThreshold", NVetoAboveThreshold);
352 if (fTimeWindow[0] != -1) {
353 SetObservableValue(
"VetoInTimeWindow", VetoInTimeWindow);
354 SetObservableValue(
"NVetoInTimeWindow", NVetoInTimeWindow);
359 fSignalEvent->PrintEvent();
370 auto it = find(fVetoGroupNames.begin(), fVetoGroupNames.end(), groupName);
371 if (it != fVetoGroupNames.end())
return it - fVetoGroupNames.begin();
377 Int_t index = GetGroupIndex(groupName);
378 if (index != -1)
return fVetoGroupIds[index];
379 return std::string(
"-1");
391 if (fTimeWindow.size() != 2) {
392 cout <<
"Error: timeWindow has to consist of two comma-separated values." << endl;
395 std::vector<double> potpars =
StringToElements(GetParameter(
"PointsOverThresholdPars",
"1.5,1.5,4"),
",");
396 fPointThreshold = potpars[0];
397 fSignalThreshold = potpars[1];
398 fPointsOverThreshold = (Int_t)potpars[2];
412 TiXmlElement* vetoDefinition = GetElement(
"vetoGroup");
414 while (vetoDefinition !=
nullptr) {
415 fVetoGroupNames.push_back(GetFieldValue(
"name", vetoDefinition));
416 fVetoGroupIds.push_back(GetFieldValue(
"signalIDs", vetoDefinition));
417 vetoDefinition = GetNextElement(vetoDefinition);
421 if (fVetoSignalId[0] != -1 && fVetoGroupNames.size() > 0) {
422 cout <<
"Error: veto groups and veto IDs defined separately!" << endl;
434 for (
unsigned int i = 0; i < fVetoGroupNames.size(); i++) {
435 RESTMetadata <<
"Veto group " << fVetoGroupNames[i] <<
" signal IDs: " << fVetoGroupIds[i]
439 if (fVetoSignalId[0] != -1) {
440 for (
unsigned int i = 0; i < fVetoSignalId.size(); i++) {
441 RESTMetadata <<
"Veto signal ID: " << fVetoSignalId[i] << RESTendl;
444 RESTMetadata <<
" " << RESTendl;
445 RESTMetadata <<
"All veto signal IDs: ";
446 for (
unsigned int i = 0; i < fVetoGroupIds.size() - 1; i++) {
447 RESTMetadata << fVetoGroupIds[i] <<
",";
449 RESTMetadata << fVetoGroupIds[fVetoGroupIds.size() - 1] << RESTendl;
451 if (fThreshold != -1) {
452 RESTMetadata <<
"Veto threshold: " << fThreshold << RESTendl;
454 if (fTimeWindow[0] != -1) {
455 RESTMetadata <<
"Peak time window: (" << fTimeWindow[0] <<
", " << fTimeWindow[1] <<
")" << RESTendl;
457 RESTMetadata <<
"Noise reduction: Points over Threshold parameters = (" << fPointThreshold <<
", "
458 << fSignalThreshold <<
", " << fPointsOverThreshold <<
")" << RESTendl;
A base class for any REST event.
An event container for time rawdata signals with fixed length.
It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.
Double_t GetMaxPeakValue()
It returns the amplitude of the signal maximum, baseline will be corrected if CalculateBaseLine was c...
void CalculateBaseLine(Int_t startBin, Int_t endBin, const std::string &option="")
This method calculates the average and fluctuation of the baseline in the specified range and writes ...
void InitializePointsOverThreshold(const TVector2 &thrPar, Int_t nPointsOver, Int_t nPointsFlat=512)
It initializes the fPointsOverThreshold array with the indexes of data points that are found over thr...
std::vector< Int_t > GetPointsOverThreshold() const
Returns a std::vector containing the indexes of data points over threshold.
Int_t GetMaxPeakBin()
It returns the bin at which the maximum peak amplitude happens.
~TRestRawVetoAnalysisProcess()
Default destructor.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) 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 Initialize() override
Function to initialize input/output event members and define the section name and library version.
void InitProcess() override
Function to use in initialization of process members before starting to process the event.
void InitFromConfigFile() override
Function reading input parameters from the RML TRestRawVetoAnalysisProcess section.
std::string GetGroupIds(std::string groupName)
Function that returns a string of the signal IDs for the specified veto group.
TRestRawVetoAnalysisProcess()
Default constructor.
Int_t GetGroupIndex(std::string groupName)
Function that returns the index of a specified veto group within the group name vector and ID vector.
void LoadDefaultConfig()
Function to load the default config in absence of RML input.
void PrintMetadata() override
It prints out the process parameters stored in the metadata structure.
@ REST_Extreme
show everything
@ REST_Debug
+show the defined debug messages
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.
Int_t StringToInteger(std::string in)
Gets an integer from a string.
TVector2 StringTo2DVector(std::string in)
Gets a 2D-vector from a string.
std::vector< double > StringToElements(std::string in, std::string separator)
Convert the input string into a vector of double elements.