-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMTSort.h
More file actions
143 lines (113 loc) · 4.34 KB
/
MTSort.h
File metadata and controls
143 lines (113 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//
// Created by Vetle Wegner Ingeberg on 20/10/2022.
//
#ifndef XIA2TREE_MTSORT_H
#define XIA2TREE_MTSORT_H
#include <functional>
#include <histogram/ThreadSafeHistograms.h>
#include <UserSort/UserSortManager.h>
#include "ConfigManager.h"
#include "Task.h"
#include "Queue.h"
#include "event.h"
class ParticleRange;
namespace Task {
namespace ROOT {
class TTreeManager;
}
struct Detector_Histograms_t
{
ThreadSafeHistogram2D time;
ThreadSafeHistogram2D time_CFDfail;
ThreadSafeHistogram2D energy;
ThreadSafeHistogram2D energy_cal;
ThreadSafeHistogram1D mult;
Detector_Histograms_t(ThreadSafeHistograms &hist, const std::string &name, const size_t &num);
void Fill(const Entry_t &word);
void Fill(const subvector<Entry_t> &subvec,
const Entry_t *start = nullptr);
void Flush();
};
struct Particle_telescope_t
{
ThreadSafeHistogram2D ede_spectra[NUM_SI_DE_TEL];
ThreadSafeHistogram2D ede_spectra_raw[NUM_SI_DE_TEL];
Particle_telescope_t(ThreadSafeHistograms &hist, const size_t &num);
void Fill(const subvector<Entry_t> &deltaE, const subvector<Entry_t> &E);
void Fill(const std::vector<Entry_t> &deltaE, const std::vector<Entry_t> &E);
void Flush();
};
class HistManager {
private:
const OCL::UserConfiguration configuration;
Detector_Histograms_t labr;
Detector_Histograms_t si_de;
Detector_Histograms_t si_e;
Detector_Histograms_t ppacs;
//! Time energy spectra for particles.
Particle_telescope_t particle_coincidence[NUM_SI_E_DET]; // Sorted by back number
ThreadSafeHistogram2D ede_spectra[NUM_SI_DE_TEL];
ThreadSafeHistogram2D ede_time;
ThreadSafeHistogram2D thickness;
ThreadSafeHistogram2D particle_energy;
ThreadSafeHistogram2D labr_energy_gated, labr_energy_cal_gated;
ThreadSafeHistogram2D alfna_prompt, alfna_background;
ThreadSafeHistogram2D ts_ex_above_Sn;
ThreadSafeHistogram2D mult_ex;
ThreadSafeHistogram1D chargeIntegrator;
UserSortManager userSort;
Detector_Histograms_t *GetSpec(const DetectorType &type);
inline Particle_telescope_t *GetPart(const size_t &num){ return ( num < NUM_SI_DE_TEL ) ? particle_coincidence+num : nullptr; }
public:
HistManager(ThreadSafeHistograms &histograms, const OCL::UserConfiguration &configuration,
const char *custom_sort = nullptr);
~HistManager() = default;
//! Fill spectra with an event
void AddEntry(Triggered_event &buffer);
//! Fill a single word
//void AddEntry(const Entry_t &word);
//! Fill spectra directly from iterators
template<class It>
inline void AddEntries(It start, It stop){
using std::placeholders::_1;
std::for_each(start, stop, [this](const auto &p){ this->AddEntry(p); });
}
void Flush();
};
class MTSort : public Base
{
private:
MTEventQueue_t &input_queue;
HistManager hm;
const OCL::UserConfiguration& userConfig;
std::unique_ptr<ROOT::TTreeManager> tree;
public:
MTSort(MTEventQueue_t &input, ThreadSafeHistograms &histograms, const OCL::UserConfiguration &config,
const char *tree_name = nullptr, const char *user_sort = nullptr);
~MTSort() override = default;
void Run() override;
void Flush();
};
class Sorters
{
private:
MTEventQueue_t &input_queue;
ThreadSafeHistograms histograms;
std::vector<MTSort *> sorters;
const OCL::UserConfiguration &user_config;
std::string user_sort_path;
std::string tree_file_name;
std::vector<std::string> tree_files; //! To be returned to the user when everything is said and done.
public:
Sorters(MTEventQueue_t &input, OCL::UserConfiguration &config, const char *tree_name = nullptr, const char *user_sort = nullptr);
~Sorters();
void flush();
Histograms &GetHistograms(){
flush();
return histograms.GetHistograms();
}
[[nodiscard]] std::vector<std::string> GetTreeFiles() const { return tree_files; }
MTSort *GetNewSorter();
};
}
#endif //XIA2TREE_MTSORT_H