Skip to content

Commit

Permalink
SIRENA update (v.5.0.0)
Browse files Browse the repository at this point in the history
- 'FilterMethod' input parameter can also be 'F0B0' => Pulse baseline always subtracted
  (tools/tesreconstruction/tesreconstruction.*, libsixt/integraSIRENA.*, libsixt/tasksSIRENA.cpp)
  • Loading branch information
bcobo committed Jul 3, 2023
1 parent d86cfda commit 3120c23
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 65 deletions.
10 changes: 5 additions & 5 deletions libsixt/integraSIRENA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
* - LbT: Baseline averaging length for the RS raw energy estimation (seconds)
* - noise_file: Noise file
* - filter_domain: Filtering Domain: Time(T) or Frequency(F)
* - filter_method: Filtering Method: F0 (deleting the zero frequency bin) or B0 (deleting the baseline)
* - filter_method: Filtering Method: F0 (deleting the zero frequency bin) or B0 (deleting the baseline) or F0B0 (deleting always the baseline)
* - energy_method: Energy calculation Method: OPTFILT, WEIGHT, WEIGHTN, I2R, I2RFITTED or PCA
* - filtEeV: Energy of the filters of the library to be used to calculate energy (only for OPTFILT, I2R and I2RFITTED)
* - Ifit: Constant to apply the I2RFITTED conversion
Expand Down Expand Up @@ -1177,7 +1177,7 @@
* - pulse_length: Pulse length
* - energy_method: Energy calculation Method: OPTFILT, WEIGHT, WEIGHTN, I2R, I2RFITTED or PCA
* - ofnoise: For optimal filtering, NSD or WEIGHTM
* - filter_method: Filtering Method: F0 (deleting the zero frequency bin) or B0 (deleting the baseline)
* - filter_method: Filtering Method: F0 (deleting the zero frequency bin) or B0 (deleting the baseline) or F0B0 (deleting always the baseline)
* - oflib: Work or not with a library with optimal filters (1/0)
* - ofinterp: Optimal Filter by using the Matched Filter or the DAB as matched filter (MF/DAB)
* It has been fixed in 'tesreconstruction' as 'DAB' (but it would be possible to work with 'MF')
Expand Down Expand Up @@ -1519,7 +1519,7 @@
if ((opmode == 0) ||
(((strcmp(energy_method,"OPTFILT") == 0) || (strcmp(energy_method,"I2R") == 0) || (strcmp(energy_method,"I2RFITTED") == 0) || (strcmp(energy_method,"I2RDER") == 0)) && (oflib == 0) && (strcmp(*ofinterp,"MF") == 0) && (opmode == 1)))
{
if ((opmode == 0) || (strcmp(filter_method,"F0") == 0))
if ((opmode == 0) || (strcmp(filter_method,"F0") == 0) || (strcmp(filter_method,"F0B0") == 0))
{
// It is not necessary to check the allocation because 'ntemplates' and 'mfilter_duration' have been checked previously
matrixAux_MF = gsl_matrix_alloc(ntemplates,mfilter_duration);
Expand Down Expand Up @@ -1763,7 +1763,7 @@
if ((opmode == 0) ||
(((strcmp(energy_method,"OPTFILT") == 0) || (strcmp(energy_method,"I2R") == 0) || (strcmp(energy_method,"I2RFITTED") == 0) || (strcmp(energy_method,"I2RDER") == 0)) && (oflib == 0) && (strcmp(*ofinterp,"MF") == 0)))
{
if ((opmode == 0) || (strcmp(filter_method,"F0") == 0))
if ((opmode == 0) || (strcmp(filter_method,"F0") == 0) || (strcmp(filter_method,"F0B0") == 0))
{
gsl_matrix_get_row(library_collection->matched_filters[it].mfilter,matrixAux_MF,it);
}
Expand Down Expand Up @@ -3195,7 +3195,7 @@
* - hduPRCLOFWM: Add or not the PRCLOFWM HDU in the library file (1/0)
* - energy_method: Energy calculation Method: OPTFILT, WEIGHT, WEIGHTN, I2R, I2RFITTED or PCA
* - ofnoise: Noise to use with Optimal Filtering: NSD or WEIGHTM
* - filter_method: Filtering Method: F0 (deleting the zero frequency bin) or B0 (deleting the baseline)
* - filter_method: Filtering Method: F0 (deleting the zero frequency bin) or B0 (deleting the baseline) or F0B0 (deleting always the baseline)
* - status: Input/output status
******************************************************************************/
NoiseSpec* getNoiseSpec(const char* const filename, int opmode, int hduPRCLOFWM, char *energy_method, char *ofnoise, char *filter_method, int* const status)
Expand Down
4 changes: 2 additions & 2 deletions libsixt/integraSIRENA.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ typedef struct ReconstructInitSIRENA
/** Filtering Domain: T (Time) or F (Frequency) **/
char FilterDomain[2];

/** Filtering Method: F0 (deleting the zero frequency bin) or F0 (deleting the baseline) **/
char FilterMethod[3];
/** Filtering Method: F0 (deleting the zero frequency bin) or B0 (deleting the baseline) or F0B0 (deleting always the baseline) **/
char FilterMethod[5];

/** Energy Method: OPTFILT, WEIGHT, WEIGHTN, I2R, I2RFITTED or PCA **/
char EnergyMethod[10];
Expand Down
16 changes: 14 additions & 2 deletions libsixt/pulseprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3297,8 +3297,15 @@ int noDetect(gsl_vector *der, ReconstructInitSIRENA *reconstruct_init, int *numb
gsl_vector *modelToSubtract = gsl_vector_alloc(pulse_length_ToSubtract);

gsl_vector *tstartPulsei = gsl_vector_alloc(3);

//gsl_vector_set(tstartPulsei,0,reconstruct_init->tstartPulse1);
double tstartPulse1_seconds = gsl_vector_get(reconstruct_init->tstartPulse1_i,num_previousDetectedPulses);
double tstartPulse1_seconds;
if ((isNumber(reconstruct_init->tstartPulse1) && (atoi(reconstruct_init->tstartPulse1) != 0)))
tstartPulse1_seconds = atoi(reconstruct_init->tstartPulse1);
else
tstartPulse1_seconds = gsl_vector_get(reconstruct_init->tstartPulse1_i,num_previousDetectedPulses);
cout<<"tstartPulse1_seconds: "<<tstartPulse1_seconds<<endl;
cout<<"Paso3"<<endl;
//std::cout << "tstartPulse1_seconds:" << std::setprecision(15) << tstartPulse1_seconds << '\n';
//std::cout << "tstartRecord:" <<std::setprecision(15) << tstartRecord<< '\n';
int tstartPulse1_samples;
Expand All @@ -3312,6 +3319,7 @@ int noDetect(gsl_vector *der, ReconstructInitSIRENA *reconstruct_init, int *numb
//tstartPulse1_samples = ceil((tstartPulse1_seconds-tstartRecord)*samprate)-1;
tstartPulse1_samples = ceil((tstartPulse1_seconds-tstartRecord)*samprate);
}
cout<<"Paso4"<<endl;
//std::cout << "(tstartPulse1_seconds-tstartRecord)*samprate: " << std::setprecision(15) << (tstartPulse1_seconds-tstartRecord)*samprate<< '\n';
//std::cout << "tstartPulse1_samples: " << std::setprecision(15) << tstartPulse1_samples<< '\n';
gsl_vector_set(tstartPulsei,0,tstartPulse1_samples);
Expand All @@ -3320,13 +3328,15 @@ int noDetect(gsl_vector *der, ReconstructInitSIRENA *reconstruct_init, int *numb

gsl_vector_set_zero(*flagTruncated);

cout<<"Paso5"<<endl;
if (reconstruct_init->tstartPulse2 == 0) *numberPulses = 1;
else if (reconstruct_init->tstartPulse3 == 0) *numberPulses = 2;
else *numberPulses = 3;

for (int i=0;i<*numberPulses;i++)
{
gsl_vector_set(*tstartgsl,i,gsl_vector_get(tstartPulsei,i));
cout<<"gsl_vector_get(*tstartgsl,i): "<<gsl_vector_get(*tstartgsl,i)<<endl;

if (i != *numberPulses-1)
{
Expand Down Expand Up @@ -3359,7 +3369,9 @@ int noDetect(gsl_vector *der, ReconstructInitSIRENA *reconstruct_init, int *numb
{

gsl_vector_set(*maxDERgsl,i,gsl_vector_max(&temp.vector));
cout<<"maxDERgsl: "<<gsl_vector_get(*maxDERgsl,i)<<endl;
gsl_vector_set(*samp1DERgsl,i,gsl_vector_get(der,gsl_vector_get(tstartPulsei,i)));
cout<<"samp1DERgsl: "<<gsl_vector_get(*samp1DERgsl,i)<<endl;

// Average of the first 4 samples of the derivative
sum_samp1DER = 0.0;
Expand All @@ -3369,7 +3381,7 @@ int noDetect(gsl_vector *der, ReconstructInitSIRENA *reconstruct_init, int *numb

}
gsl_vector_set(*samp1DERgsl,i,sum_samp1DER/4.0);
//cout<<"samp1DERgsl/4: "<<gsl_vector_get(*samp1DERgsl,i)<<endl;
cout<<"samp1DERgsl/4: "<<gsl_vector_get(*samp1DERgsl,i)<<endl;
}
else
{
Expand Down

0 comments on commit 3120c23

Please sign in to comment.