-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSource.h
81 lines (65 loc) · 2.17 KB
/
Source.h
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
#ifndef Source_h
#define Source_h
#include <atomic>
#include <chrono>
#include <filesystem>
#include <memory>
#include <mutex>
#include <string>
#include "Framework/Event.h"
#include "DataFormats/PointsCloud.h"
#include "DataFormats/ClusterCollection.h"
#include "DataFormats/LayerTilesConstants.h"
namespace edm {
class Source {
public:
explicit Source(int maxEvents,
int runForMinutes,
ProductRegistry& reg,
std::filesystem::path const& inputFile,
bool validation);
virtual ~Source() = default;
void startProcessing();
int maxEvents() const { return maxEvents_; }
int processedEvents() const { return numEvents_; }
// thread safe
virtual std::unique_ptr<Event> produce(int streamId, ProductRegistry const& reg) = 0;
protected:
int maxEvents_;
// these are all for the mode where the processing length is limited by time
int const runForMinutes_;
std::chrono::steady_clock::time_point startTime_;
std::mutex timeMutex_;
std::atomic<int> numEventsTimeLastCheck_ = 0;
std::atomic<bool> shouldStop_ = false;
std::atomic<int> numEvents_ = 0;
bool validation_;
};
class Source2D : public Source {
public:
explicit Source2D(int maxEvents,
int runForMinutes,
ProductRegistry& reg,
std::filesystem::path const& inputFile,
bool validation);
//thread safe
std::unique_ptr<Event> produce(int streamId, ProductRegistry const& reg) override;
private:
EDPutTokenT<PointsCloud> const cloudToken_;
std::vector<PointsCloud> cloud_;
};
class Source3D : public Source {
public:
explicit Source3D(int maxEvents,
int runForMinutes,
ProductRegistry& reg,
std::filesystem::path const& inputFile,
bool validation);
//thread safe
std::unique_ptr<Event> produce(int streamId, ProductRegistry const& reg) override;
private:
EDPutTokenT<ClusterCollection> const clusterToken_;
std::vector<ClusterCollection> clusters_;
};
} // namespace edm
#endif