Commit a68d5883 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Completely new version of EUDAQ2 EventLoader. More clean but less checks and features (still)

parent eac6db8e
Pipeline #780135 passed with stages
in 13 minutes and 44 seconds
......@@ -31,6 +31,15 @@ namespace corryvreckan {
*/
class EventLoaderEUDAQ2 : public Module {
enum class EventPosition {
UNKNOWN, // StandardEvent position unknown
BEFORE, // StandardEvent is before current event
DURING, // StandardEvent is during current event
AFTER, // StandardEvent is after current event
};
class EndOfFile : public Exception {};
public:
/**
* @brief Constructor for this unique module
......@@ -48,66 +57,37 @@ namespace corryvreckan {
* @brief [Run the function of this module]
*/
StatusCode run(std::shared_ptr<Clipboard> clipboard);
/**
* @brief [Finalize this module]
*/
void finalise();
private:
/**
* @brief Get event start/end time: if event exists on clipboard --> take this, otherwise take input values and put
* new event onto clipboard
* @param start Start time of the currently read detector data
* @param end End time of the currently read detector data
* @param clipboard The clipboard of the event
* @return pair with event start and end time, either from definded event on clipboard or from local data
* @brief Read and return the next event (smallest possible granularity) and return the decoded StandardEvent
*/
std::pair<double, double> get_event_times(double start, double end, std::shared_ptr<Clipboard>& clipboard);
std::shared_ptr<eudaq::StandardEvent> get_next_event();
/**
* @brief Process events: extract hits and put onto clipboard, also define event start/end
* @param evt Event object (event or subevent) to be processed
* @param clipboard The clipboard of the event
* @return EventPosition: before/in/after event window, trigger_id_not_found or invalid
* @brief Check whether the current EUDAQ StandardEvent is within the defined Corryvreckan event
* @param clipboard Shared pointer to the event clipboard
* @param evt The EUDAQ StandardEvent to check
* @return Position of the StandardEvent with respect to the current Corryvreckan event
*/
enum EventPosition { before_window, in_window, after_window, trigger_id_not_found, invalid };
enum EventPosition process_tlu_event(eudaq::EventSPC evt, std::shared_ptr<Clipboard>& clipboard);
EventPosition is_within_event(std::shared_ptr<Clipboard> clipboard, std::shared_ptr<eudaq::StandardEvent> evt);
/**
* @brief Process events: extract hits and put onto clipboard, also define event start/end
* @param evt Event object (event or subevent) to be processed
* @param clipboard The clipboard of the event
* @brief Store pixel data from relevant detectors on the clipboard
* @param clipboard Shared pointer to the event clipboard
* @param evt StandardEvent to read the pixel data from
*/
enum EventPosition process_event(eudaq::EventSPC evt, std::shared_ptr<Clipboard>& clipboard);
void store_data(std::shared_ptr<Clipboard> clipboard, std::shared_ptr<eudaq::StandardEvent> evt);
std::shared_ptr<Detector> m_detector;
std::string m_filename{};
int m_corry_events;
double m_timeBeforeTLUtimestamp;
double m_timeAfterTLUtimestamp;
double m_searchTimeBeforeTLUtimestamp;
double m_searchTimeAfterTLUtimestamp;
// If skip_before_t0 is set true but the data does not contain t0
// (because during data taking drop_before_t0 was set),we go
// through the entire file, don't find it and return with an ERROR
// such that the user doesn't think they're skipping before T0 when
// this is not what's done behind the scenes.
bool m_skipBeforeT0;
eudaq::EventSPC current_evt;
eudaq::FileReaderUP reader;
// Pixel histograms
TH2F* hitmap;
TH1F* hHitTimes;
TH1F* hPixelsPerFrame;
TH1D* hEventStart;
TH1D* hTluTrigTimeToFrameStart;
std::map<std::string, size_t> event_counts{};
std::map<std::string, size_t> event_counts_inframe{};
// EUDAQ file reader instance to retrieve data from
eudaq::FileReaderUP reader_;
// Buffer of undecoded EUDAQ events
std::vector<eudaq::EventSPC> events_;
// Currently processed decoded EUDAQ StandardEvent:
std::shared_ptr<eudaq::StandardEvent> event_;
};
} // namespace corryvreckan
# EventLoaderEUDAQ2
**Maintainer**: Jens Kroeger (jens.kroeger@cern.ch)
**Module Type**: *DETECTOR*
**Status**: under development
**Maintainer**: Jens Kroeger (<jens.kroeger@cern.ch>), Simon Spannagel (<simon.spannagel@cern.ch>)
**Module Type**: *DETECTOR*
**Status**: under development
### Description
This module allows data recorded by EUDAQ2 and stored in a EUDAQ2 binary file as raw detector data to be read into Corryvreckan.
For each detector type, the corresponding converter module in EUDAQ2 is used to transform the data into the `StandardPlane` event type before storing the individual `Pixel` objects on the Corryvreckan clipboard.
TLU event are not converted into `StandardEvents` but their timestamps can be used directly without conversion.
The detectors need to be named according to the following scheme: `<detector_type>_<plane>` where `detector_type` is either of the types above and `<plane>` is an integer number iterating over the planes of the same type.
If the data of different detectors is stored in separate files, the parameters `name` or `type` can be used as shown in the usage example below.
It should be noted that the order of the detectors is crucial.
The first detector that appears in the configuration defines the event window to which the hits of all other detectors are compared.
In the example below this is the CLICpix2.
For each event, the algorithm checks for an event on the clipboard.
If none is available, the current event defines the event on the clipboard.
Otherwise, it is checked whether or not the current event lies within the clipboard even.
If yes, the corresponding pixels are added to the clipboard for this event.
If earlier, the next event is read until a matching event is found.
If later, the pointer to this event is kept and it continues with the next detector.
Correlate EUDAQ2 devices, based on time.
### Requirements
This module requires an installation of [EUDAQ2](https://eudaq.github.io/). The installation path needs to be set to
......@@ -29,21 +13,19 @@ export EUDAQ2PATH=/path/to/eudaq2
```
when running CMake to find the library to link against and headers to include.
### Contract between EUDAQ Decoder and EventLoader
The decoder promises to
* return `true` only when there is a fully decoded event available and `false` in all other cases.
* not return any event before a possible T0 signal in the data.
* return the smallest possible granularity of data in time either as even or as sub-events within one event.
* always return valid event time stamps. If the device does not have timestamps, it should return zero for the beginning of the event and have a valid trigger number set.
### Parameters
* `file_name`: File name of the EUDAQ2 raw data file. This parameter is mandatory.
* `time_before_tlu_timestamp`: Defines how much earlier than the TLU timestamp the event window should begin. Default value is `115 us`.
* `time_after_tlu_timestamp`: Defines how much later than the TLU timestamp the event window should end. Default value is `230 us`.
* `search_time_before_tlu_timestamp`: Defines the start of the window around the TLU timestamp that needs to lie within the current event window for the respective frame of the TLU triggered detector to be matched. Default value is `100 ns`.
* `search_time_after_tlu_timestamp`: Defines the end of the window around the TLU timestamp that needs to lie within the current event window for the respective frame of the TLU triggered detector to be matched. Default value is `100 ns`.
The default values for the latter four parameters are not yet tuned and might need to be optimised.
### Plots produced
For each detector the following histograms are produced:
* 2D hitmap
* Hit timestamps
* Pixels per frame
* Event start times
* TLU trigger time difference to frame begin (filled only if TLU events exist)
*none*
### Usage
```toml
......
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