You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

\This page provides an overview of the status and inner workings of the TES Readout development and eventual implementation.

Description of TES

 

TESMap.pdf

 

Error rendering macro 'viewpdf'

com.atlassian.confluence.macro.MacroExecutionException: com.atlassian.confluence.macro.MacroExecutionException: The viewfile macro is unable to locate the attachment "TESMap.pdf" on this page

 

PseudoCode

 

This is a proposed algorithm to handle the data produced by the TES detectors for LCLS-II.

 

The data is assumed to consist of several time streams per FPGA (250) sampled at 1 MHz. The beam repetition rate is 10 kHz, for a total of 100 samples minimum between valid (photon generated) events. The samples are assumed to be 16 bits.

Parfor : Parallel For

NumberOfChannels : number of channels to be handles by the FPGA

Samples per Window : Number of samples in a single pulse window

TotalNumberOfWindows : Maximum number of windows to be kept in memory for the configured filters. Currently only 3 for a total of four cases. The active window, the preceding one and the following one. Possibly more windows to be added before/after for more precision in the energy measurement.

Active Window : Window on which we are performing the filter calculation

Current Window : Window that is currently loading in buffers.

EventMatrix : Matrix containgin information about the presence of events in each window of each channel.

 

TES Algorithm
CreateCircularBuffers (NumberOfChannels,
SamplesPerWindow, TotalNumberOfWindows)
LoadFilters()
ConfigureDataChannel()

While IncomingData:
            LoadDatainBuffers()
            ApplyCrosstalkCorrection(All_Channels,CurrentWindow)

            EventMatrix = TagEvents(All_Channels)

	For each ActiveWindow : 
            WindowIncrement=+1
				Parfor each Channel:            
                	Switch (CheckEvents(EventMatrix)):
						Case No Event Before And After
						Energy = ApplyFilter(Filter00)
						Case Event Before And After
						Energy = ApplyFilter(Filter11)

						Case Event Before Only
						Energy = ApplyFilter(Filter10)

						Case Event After Only
						Energy = ApplyFilter(Filter00)


            SaveEnergyAndTimestamp(xtcFile)


		If WindowIncrement == SaveIncrement
			SaveWaveformtoXTC(xtcFile, TotalTimeWindow, AllChannels)


 


Def TagEvents:
	Parfor each channel : 
		If Slope > MinimumSlope:
			CurrentWindowEvent=True
		Else:
			CurrentWindowEvent=False
	
		EventMatrix(channel, currentWindowIndex) = CurrentWindowEvent
	Return EventMatrix

Def ApplyFilter(Filter):
	For each i, sample :
		Temp = linearFunction(sample) * sample 
		Temp = temp* Filter(i) *Filter2(i) %More filters added if necessary
		Energy = sum(temp)
		%Details on operations required for this step
		% Can we pipeline the linear function with the multiply and add?

 

 

Benchmarks

This table lists the latest benchmarks.

Currently, it evaluates the average time (over 1e6 iterations) to complete the number of products indicated as well as the sum of the resulting vector. The length of the vector varies according to the number of samples.

For a fixed number of samples, the code uses if statements to directly indicates how many filters to use. For the code using the binary decision tree, the number of filters is passed as a prepocessor argument. Once we know how many filters are necessary this will become a fixed value. 

These benchmarks were obtained os psanagpu116, using O3 and vectored optimization. As a reference, 10 kHz operation gives a time window of 100 µs.

Compile flags
g++ -std=c++11 -O3 -DNDEBUG -march=native -IEigen main.cpp

 

All values are in μs.

Number of products

Number of samples

12345
1000.0610.0740.0910.108 
2000.1130.1450.1760.210 
3000.1500.1900.2410.296 
4000.2000.2660.3290.397 
5000.2390.3210.4020.486 
6000.2790.3780.4760.576 
7000.3180.4350.5490.667 
Decision tree0.0920.1170.1380.1610.203

 

Latest code :

Latest version of code
#include <iostream>
#include <Eigen/Dense>
#include <chrono>
#include <unistd.h>
using namespace Eigen;
using namespace std;
#define FILTERS 5
#define VERBOSE 1
#define REPEAT 1000
#define SAMPLESPEREVENT 100
#define MAXWINDOW 6
#define MAXSAMPLESIZE MAXWINDOW*SAMPLESPEREVENT
#define MAXFILTERS 5
#define NUMEVENTS 1000
int evaluate_energy(const ArrayXi samples, const ArrayXXi filters, int windowsize){
    ArrayXi temp(MAXSAMPLESIZE, 1);
    int size = SAMPLESPEREVENT*windowsize;
    temp = (samples.head(size) + ArrayXi::Constant(size,52)) * 50; // linear transformation
    //cout << filters.block(0,0,size,1) << endl;
    #if FILTERS == 1
    temp = temp * filters.topRows(size);
    #elif FILTERS == 2
    temp = temp * filters.topLeftCorner(size,1) * filters.block(0,1,size,1);
    #elif FILTERS == 3
    temp = temp * filters.topLeftCorner(size,1) * filters.block(0,1,size,1) * filters.block(0,2,size,1);
    #elif FILTERS == 4
    temp = temp * filters.topLeftCorner(size,1) * filters.block(0,1,size,1) * filters.block(0,2,size,1) * filters.block(0,3,size,1);
    #elif FILTERS == 5
    temp = temp * filters.topLeftCorner(size,1) * filters.block(0,1,size,1) * filters.block(0,2,size,1) * filters.block(0,3,size,1) * filters.block(0,4,size,1);
    #endif
    int sum = temp.sum();
    //int sum = 22;
    return sum;
}
int main(int argc, char** argv)
{
    ArrayXi samples = ArrayXi::Random(MAXSAMPLESIZE);
    ArrayXXi filters = ArrayXXi::Random(MAXSAMPLESIZE, FILTERS);
    ArrayXXf tempEvents = ArrayXXf::Random(1, NUMEVENTS);
    Array<bool, 1, NUMEVENTS> isEvent;
    isEvent = tempEvents > 0.5;
    int sum;
    auto t1 = std::chrono::high_resolution_clock::now();
    for (int repeat = 0; repeat<REPEAT; repeat++){
        for (int i = 4; i<NUMEVENTS; i++){
            if (isEvent(i) == true){
                if (isEvent(i-1) == true){
                    //use filter of length 2
                    sum = evaluate_energy(samples, filters, 2);
                    #if VERBOSE > 1
                    cout << isEvent.segment<6>(i-5) << " -- " << "2 period filter used. The sum is " << sum << endl;
                    #endif
                }
                else{
                    if (isEvent(i-2) == true){
                    //use filter of length 3
                    sum = evaluate_energy(samples, filters, 3);
                    #if VERBOSE > 1
                    cout << isEvent.segment<6>(i-5) << " -- " << "3 period filter used. The sum is " << sum << endl;
                    #endif
                    }
                    else{
                        if (isEvent(i-3) == true){
                        //use filter of length 4
                        sum = evaluate_energy(samples, filters, 4);
                        #if VERBOSE > 1
                        cout << isEvent.segment<6>(i-5) << " -- " << "4 period filter used.  The sum is " << sum  << endl;
                        #endif
                        }
                        else{
                            if (isEvent(i-4) == true){
                                //use filter of length 5
                                sum = evaluate_energy(samples, filters, 5);
                                #if VERBOSE > 1
                                cout << isEvent.segment<6>(i-5) << " -- " << "5 period filter used. The sum is " << sum  << endl;
                                #endif
                            }
                            else{
                                //use single event filter
                                sum = evaluate_energy(samples, filters, 1);
                                #if VERBOSE > 1
                                cout << isEvent.segment<6>(i-5) << " -- " << "Single period filter used. The sum is " << sum  << endl;
                                #endif
                            }
                        }
                    }
                }
            }
        }
    }

    auto t2 = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double, std::milli> fp_ms = t2 - t1;
    #if VERBOSE > 0
    cout << "The sum is : " << sum << endl;
    cout << "The process took " << fp_ms.count() << "ms" << endl;
    #endif
  //Multiply vectors then sum the coefficients for inner product.
}

 

References

Ullom and Bennet. Review of superconducting transition sensors for X-ray and gamma-ray spectroscopy

Irwin and Hilton. Transition-edge sensors.

 

Tasks

TaskStatusComment
Create fake data vectorsNOT STARTED 
Implement event detection algorithmNOT STARTED 
Program arguments for benchmarkingIN PROGRESSArguments for the size of the vectors and the number of array products used
Decision tree for event casesIN PROGRESSSwitch case tree for given number of filters - reusable for different cases
Input data from simulationNOT STARTED 
   
   
  • No labels