Commit 6f2633f9 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'APX_eventloader_timesorting' into 'master'

EventLoaderATLASpix timesorting

See merge request !162
parents e7f1b3ea 9f455f5e
Pipeline #1095596 failed with stages
in 22 minutes and 57 seconds
......@@ -8,6 +8,7 @@
#include <dirent.h>
#include <fstream>
#include <iostream>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string.h>
......@@ -29,7 +30,6 @@ namespace corryvreckan {
// Functions
void initialise();
StatusCode run(std::shared_ptr<Clipboard> clipboard);
void finalise();
private:
/*
......@@ -38,14 +38,17 @@ namespace corryvreckan {
uint32_t gray_decode(uint32_t gray);
/*
* @brief Read data in the format written by the Karlsruhe readout system
* @brief Read data in the format written by the Caribou readout system and fill time-sorted buffer
* @return Bool which is false when reaching the end-of-file and true otherwise
*/
std::shared_ptr<PixelVector> read_legacy_data(std::shared_ptr<Event> event);
bool read_caribou_data();
/*
* @brief Read data in the format written by the Caribou readout system
*/
std::shared_ptr<PixelVector> read_caribou_data(std::shared_ptr<Event> event);
// custom comparator for time-sorted priority_queue
struct CompareTimeGreater {
bool operator()(const Pixel* a, const Pixel* b) { return a->timestamp() > b->timestamp(); }
};
// Buffer of timesorted pixel hits: (need to use greater here!)
std::priority_queue<Pixel*, std::vector<Pixel*>, CompareTimeGreater> sorted_pixels_;
std::shared_ptr<Detector> m_detector;
unsigned long long int m_oldtoa;
......@@ -54,10 +57,16 @@ namespace corryvreckan {
std::ifstream m_file;
// Resuming in next event:
std::streampos oldpos;
unsigned long long old_readout_ts;
unsigned long long old_fpga_ts;
unsigned long long busy_readout_ts;
unsigned long long readout_ts_ = 0;
unsigned long long fpga_ts_ = 0;
unsigned long long fpga_ts1_ = 0;
unsigned long long fpga_ts2_ = 0;
unsigned long long fpga_ts3_ = 0;
bool new_ts1_ = false;
bool new_ts2_ = false;
bool timestamps_cleared_ = false;
bool eof_reached = false;
// int ts1Range;
int ts2Range;
......@@ -96,18 +105,13 @@ namespace corryvreckan {
// Parameters:
std::string m_inputDirectory;
bool m_detectorBusy;
bool m_legacyFormat;
double m_clockCycle;
int m_highToTCut;
std::string m_calibrationFile;
std::vector<double> m_calibrationFactors;
// int m_clkdivendM;
int m_clkdivend2M;
std::map<std::string, int> m_identifiers;
unsigned int data_pixel_{}, data_header_{};
int m_buffer_depth;
};
} // namespace corryvreckan
#endif // EventLoaderATLASpix_H
......@@ -18,6 +18,7 @@ This module requires either another event loader of another detector type before
* `clkdivend2`: Value of clkdivend2 register in ATLASPix specifying the speed of TS2 counter. Default is `0`.
* `high_tot_cut`: "high ToT" histograms are filled if pixel ToT is larger than this cut. Default is `40`.
* `calibration_file` (optional): input file for pixel-wise calibration from ToT to charge in electrons. If not provided, the pixel charge is equivalent to pixel ToT.
* `buffer_depth`: Depth of buffer in which pixel hits are timesorted before being added to an event. If set to `1`, effectively no timesorting is done. Default is `1000`.
### Plots produced
* 2D hit map
......@@ -49,4 +50,7 @@ This module requires either another event loader of another detector type before
```toml
[ATLASpixEventLoader]
input_directory = /user/data/directory
clock_cycle = 8ns
clkdivend2 = 7
buffer_depth = 100
```
......@@ -90,4 +90,4 @@ namespace corryvreckan {
// Internal map to construct an object from it's type index
ObjectCreatorMap object_creator_map_;
};
} // namespace allpix
} // namespace corryvreckan
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment