Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JACOUSTICS::JPlatypus Class Reference

Thread pool for global fits using super events. More...

#include <JPlatypus_t.hh>

Public Types

typedef JTOOLS::JHashMap< int, JEmitterJEmitters
 
typedef JLANG::JObjectIterator< JSuperEvtinput_type
 

Public Member Functions

 JPlatypus (const JGeometry &geometry, const JEmitters &emitters, const JSoundVelocity &velocity, const JFitParameters &parameters, input_type &input, const size_t ns)
 Constructor.
 
 ~JPlatypus ()
 Destructor.
 

Static Public Attributes

static JMATH::JQuantile_t Q
 chi2/NDF
 

Private Attributes

std::vector< std::thread > workers
 
input_typeinput
 
std::mutex in
 
std::mutex out
 
std::condition_variable cv
 
bool stop
 

Detailed Description

Thread pool for global fits using super events.

Definition at line 34 of file JPlatypus_t.hh.

Member Typedef Documentation

◆ JEmitters

◆ input_type

Constructor & Destructor Documentation

◆ JPlatypus()

JACOUSTICS::JPlatypus::JPlatypus ( const JGeometry & geometry,
const JEmitters & emitters,
const JSoundVelocity & velocity,
const JFitParameters & parameters,
input_type & input,
const size_t ns )
inline

Constructor.

Parameters
geometrydetector geometry
emittersemitters geometry
velocitysound velocity
parametersparameters
inputinput
nsnumber of threads

Definition at line 50 of file JPlatypus_t.hh.

55 :
56 input(input),
57 stop(false)
58 {
59 using namespace std;
60 using namespace JPP;
61
62 Q.reset();
63
64 for (size_t i = 0; i < ns; ++i) {
65
66 thread worker([this, geometry, emitters, velocity, parameters]() {
67
69
70 for (JKatoomba<JGandalf> katoomba(geometry, velocity, parameters.option); ; ) {
71
72 katoomba.estimator.reset(getMEstimator(parameters.mestimator));
73
74 {
75 unique_lock<mutex> lock(in);
76
77 cv.wait(lock, [this]() { return stop || this->input.hasNext(); });
78
79 if (stop && !this->input.hasNext()) {
80 return;
81 }
82
83 const JSuperEvt* evt = this->input.next();
84
85 data.clear();
86
87 for (JSuperEvt::rx_type::const_iterator hit = evt->rx.begin(); hit != evt->rx.end(); ++hit) {
88
89 data.push_back(JHit(emitters[hit->id],
90 hit->counter,
91 JLocation(hit->string, hit->floor),
92 hit->toa,
93 parameters.sigma_s,
94 hit->weight));
95 }
96
97 katoomba.value = getModel(*evt);
98 }
99
100 const double chi2 = katoomba (data.begin(), data.end()) / katoomba.estimator->getRho(1.0);
101 const double ndf = getWeight(data.begin(), data.end()) - katoomba.value.getN();
102
103 {
104 unique_lock<mutex> lock(out);
105
106 Q.put(chi2 / ndf);
107 }
108 }
109 });
110
111 workers.emplace_back(std::move(worker));
112 }
113 }
std::condition_variable cv
static JMATH::JQuantile_t Q
chi2/NDF
std::vector< std::thread > workers
Logical location of module.
Definition JLocation.hh:40
double getWeight(T __begin, T __end)
Get total weight of data points.
JModel getModel(const JEvt &evt)
Get model.
JMEstimator * getMEstimator(const int type)
Get M-Estimator.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double sigma_s
time-of-arrival resolution [s]
Acoustics hit.
Template definition of fit function of acoustic model.
Acoustic super event fit.
Definition JSuperEvt.hh:38
virtual const pointer_type & next() override
Get next element.
virtual bool hasNext() override
Check availability of next element.
void put(const double x)
Put value.
void reset()
Reset.

◆ ~JPlatypus()

JACOUSTICS::JPlatypus::~JPlatypus ( )
inline

Destructor.

Definition at line 119 of file JPlatypus_t.hh.

120 {
121 using namespace std;
122
123 {
124 unique_lock<mutex> lock(in);
125
126 stop = true;
127 }
128
129 cv.notify_all();
130
131 for (auto& worker : workers) {
132 worker.join();
133 }
134 }

Member Data Documentation

◆ Q

JMATH::JQuantile_t JACOUSTICS::JPlatypus::Q
static

chi2/NDF

Definition at line 136 of file JPlatypus_t.hh.

◆ workers

std::vector<std::thread> JACOUSTICS::JPlatypus::workers
private

Definition at line 139 of file JPlatypus_t.hh.

◆ input

input_type& JACOUSTICS::JPlatypus::input
private

Definition at line 140 of file JPlatypus_t.hh.

◆ in

std::mutex JACOUSTICS::JPlatypus::in
private

Definition at line 141 of file JPlatypus_t.hh.

◆ out

std::mutex JACOUSTICS::JPlatypus::out
private

Definition at line 142 of file JPlatypus_t.hh.

◆ cv

std::condition_variable JACOUSTICS::JPlatypus::cv
private

Definition at line 143 of file JPlatypus_t.hh.

◆ stop

bool JACOUSTICS::JPlatypus::stop
private

Definition at line 144 of file JPlatypus_t.hh.


The documentation for this class was generated from the following files: