Jpp 20.0.0-rc.8
the software that should make you happy
Loading...
Searching...
No Matches
JTRIGGER::JCLBRunByRunSimulator Class Reference

CLB simulation based on run-by-run information. More...

#include <JCLBRunByRunSimulator.hh>

Inheritance diagram for JTRIGGER::JCLBRunByRunSimulator:
JDETECTOR::JCLBDefaultSimulator JDETECTOR::JCLBDefaultSimulatorInterface JDETECTOR::JCLBSimulator

Public Types

typedef JDAQHit::JPMT_t JPMT_t
 
typedef JDAQHit::JTDC_t JTDC_t
 
typedef JDAQHit::JTOT_t JTOT_t
 

Public Member Functions

 JCLBRunByRunSimulator (const JSummaryRouter &router)
 Constructor.
 
virtual int getUDPNumberOfReceivedPackets (const JModuleIdentifier &id) const override
 Get number of received UDP packets.
 
virtual int getUDPMaximalSequenceNumber (const JModuleIdentifier &id) const override
 Get maximal sequence number of UDP packet.
 
virtual bool hasUDPTrailer (const JModuleIdentifier &id) const override
 Get UDP trailer status.
 
virtual bool getHighRateVeto (const JPMTIdentifier &id) const override
 Get high-rate veto of given PMT.
 
JDAQFrameStatus getDAQFrameStatus (const JModuleIdentifier &id) const
 Get DAQ frame status of given module.
 
virtual void processData (const JModuleIdentifier &id, const JCLBInput &input, JDAQSuperFrame &output) const override
 Process data.
 

Static Public Member Functions

static double getMinimalToT ()
 Get minimal pulse length of time-over-threshold measurement.
 

Static Public Attributes

static const struct JDETECTOR::JCLBDefaultSimulatorInterface::compare compare
 

Protected Attributes

const JSummaryRoutersummary_router
 

Private Attributes

JLANG::JSinglePointer< JTDCTDC
 
JLANG::JSinglePointer< JStateMachinestate_machine
 
std::vector< JDAQHitbuffer
 

Detailed Description

CLB simulation based on run-by-run information.

This class overwrites the method JCLBDefaultSimulator::getHighRateVeto. The actual high-rate veto is obtained from summary data.

Definition at line 32 of file JCLBRunByRunSimulator.hh.

Member Typedef Documentation

◆ JPMT_t

◆ JTDC_t

◆ JTOT_t

Constructor & Destructor Documentation

◆ JCLBRunByRunSimulator()

JTRIGGER::JCLBRunByRunSimulator::JCLBRunByRunSimulator ( const JSummaryRouter & router)
inline

Constructor.

Parameters
routersummary router

Definition at line 41 of file JCLBRunByRunSimulator.hh.

41 :
43 summary_router(router)
44 {}
JCLBDefaultSimulator(const JDAQHit::JTDC_t Tmax=0)
Constructor.

Member Function Documentation

◆ getUDPNumberOfReceivedPackets()

virtual int JTRIGGER::JCLBRunByRunSimulator::getUDPNumberOfReceivedPackets ( const JModuleIdentifier & id) const
inlineoverridevirtual

Get number of received UDP packets.

Parameters
idmodule identifier
Returns
number of received UDP packets

Reimplemented from JDETECTOR::JCLBDefaultSimulatorInterface.

Definition at line 53 of file JCLBRunByRunSimulator.hh.

54 {
55 using namespace KM3NETDAQ;
56
57 if (summary_router.hasSummaryFrame(id.getID())) {
58
59 const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getID());
60
61 return frame.getUDPNumberOfReceivedPackets();
62 }
63
64 return 1;
65 }
bool hasSummaryFrame(const JDAQModuleIdentifier &module) const
Has summary frame.
const JDAQSummaryFrame & getSummaryFrame(const JDAQModuleIdentifier &module) const
Get summary frame.
int getUDPNumberOfReceivedPackets() const
Get number of received UDP packets.
Data storage class for rate measurements of all PMTs in one module.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39

◆ getUDPMaximalSequenceNumber()

virtual int JTRIGGER::JCLBRunByRunSimulator::getUDPMaximalSequenceNumber ( const JModuleIdentifier & id) const
inlineoverridevirtual

Get maximal sequence number of UDP packet.

Parameters
idmodule identifier
Returns
maximal sequence number

Reimplemented from JDETECTOR::JCLBDefaultSimulatorInterface.

Definition at line 74 of file JCLBRunByRunSimulator.hh.

75 {
76 using namespace KM3NETDAQ;
77
78 if (summary_router.hasSummaryFrame(id.getID())) {
79
80 const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getID());
81
82 return frame.getUDPMaximalSequenceNumber();
83 }
84
85 return 0;
86 }
int getUDPMaximalSequenceNumber() const
Get maximal sequence number of UDP packet.

◆ hasUDPTrailer()

virtual bool JTRIGGER::JCLBRunByRunSimulator::hasUDPTrailer ( const JModuleIdentifier & id) const
inlineoverridevirtual

Get UDP trailer status.

Parameters
idmodule identifier
Returns
true

Reimplemented from JDETECTOR::JCLBDefaultSimulatorInterface.

Definition at line 95 of file JCLBRunByRunSimulator.hh.

96 {
97 using namespace KM3NETDAQ;
98
99 if (summary_router.hasSummaryFrame(id.getID())) {
100
101 const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getID());
102
103 return frame.hasUDPTrailer();
104 }
105
106 return false;
107 }
bool hasUDPTrailer() const
Get UDP trailer status.

◆ getHighRateVeto()

virtual bool JTRIGGER::JCLBRunByRunSimulator::getHighRateVeto ( const JPMTIdentifier & id) const
inlineoverridevirtual

Get high-rate veto of given PMT.

Parameters
idPMT identifier
Returns
true if high-rate veto; else false

Reimplemented from JDETECTOR::JCLBDefaultSimulatorInterface.

Definition at line 116 of file JCLBRunByRunSimulator.hh.

117 {
118 using namespace KM3NETDAQ;
119
120 if (summary_router.hasSummaryFrame(id.getModuleID())) {
121
122 const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getModuleID());
123
124 return !getPMTStatus(frame, JStatus(), id.getPMTAddress());
125 }
126
127 return false;
128 }
bool getPMTStatus(const JStatus &status)
Test status of PMT.
Auxiliary class for handling status.
Definition JStatus.hh:31

◆ getDAQFrameStatus()

JDAQFrameStatus JDETECTOR::JCLBDefaultSimulatorInterface::getDAQFrameStatus ( const JModuleIdentifier & id) const
inlineinherited

Get DAQ frame status of given module.

Parameters
idmodule identifier
Returns
DAQ frame status

Definition at line 143 of file JCLBDefaultSimulatorInterface.hh.

144 {
145 using namespace KM3NETDAQ;
146
149 int status = DAQ_WHITE_RABBIT.write(1); // TDC status
150 int fifo = DAQ_UDP_TRAILER .write(hasUDPTrailer(id) ? 1 : 0); // FIFO status
151
152 for (size_t pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
153 JBit(pmt).set(status, getHighRateVeto(JPMTIdentifier(id,pmt)) ? 1 : 0) ; // high-rate veto
154 }
155
156 return JDAQFrameStatus(daq, status, fifo);
157 }
virtual bool hasUDPTrailer(const JModuleIdentifier &id) const
Get UDP trailer status.
virtual int getUDPMaximalSequenceNumber(const JModuleIdentifier &id) const
Get maximal sequence number of UDP packet.
virtual int getUDPNumberOfReceivedPackets(const JModuleIdentifier &id) const
Get number of received UDP packets.
virtual bool getHighRateVeto(const JPMTIdentifier &id) const
Get high-rate veto of given PMT.
bool write(const Vec &v, std::ostream &os)
Write a Vec(tor) to a stream.
Definition io_ascii.hh:155
static const JBits DAQ_UDP_RECEIVED_PACKETS(0, 15)
Mask of UDP received packets.
static const JBits DAQ_UDP_SEQUENCE_NUMBER(16, 31)
Mask of UDP sequence number.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition JDAQ.hh:26
static const JBit DAQ_WHITE_RABBIT(31)
White Rabbit status.
static const JBit DAQ_UDP_TRAILER(31)
UDP trailer.
Auxiliary data structure for single bit.
Definition JDAQ.hh:36
int write(const int value) const
Write given value as bit mask.
Definition JDAQ.hh:115
void set(int &mask) const
Set bit in given bit mask.
Definition JDAQ.hh:77
int write(const int value) const
Write given value as bit mask.
Definition JDAQ.hh:238

◆ processData()

virtual void JDETECTOR::JCLBDefaultSimulatorInterface::processData ( const JModuleIdentifier & id,
const JCLBInput & input,
JDAQSuperFrame & output ) const
inlineoverridevirtualinherited

Process data.

Parameters
idmodule identifier
inputPMT data
outputCLB data

Implements JDETECTOR::JCLBSimulator.

Definition at line 167 of file JCLBDefaultSimulatorInterface.hh.

168 {
169 using namespace std;
170 using namespace JPP;
171 using namespace KM3NETDAQ;
172
173
174 const double Tmin = 0.0; // Minimal TDC value [ns]
175 const double Tmax = getFrameTime(); // Maximal TDC value [ns]
176
178
179 buffer.clear();
180
181 size_t ns = 0; // current number of hits in data frame
182
183 for (size_t pmt = 0; pmt != input.size(); ++pmt) {
184
185 const JPMTData<JPMTPulse>& in = input[pmt];
186
187 // TDC
188
189 for (JPMTData<JPMTPulse>::const_iterator hit = in.begin(); hit != in.end(); ++hit) {
190
191 if (hit->t_ns >= Tmin && hit->t_ns <= Tmax) {
192
193 double t1 = hit->t_ns;
194 double tot = hit->tot_ns;
195
196 // generate multiple hits if time-over-threshold exceeds dynamic range
197
198 while (tot > JDAQHit::getMaximalToT()) {
199
200 buffer.push_back(TDC->makeHit((JPMT_t) pmt, t1, (JTOT_t) JDAQHit::getMaximalToT()));
201
203 tot -= JDAQHit::getMaximalToT();
204 }
205
206 if (tot > getMinimalToT()) {
207 buffer.push_back(TDC->makeHit((JPMT_t) pmt, t1, (JTOT_t) (tot + 0.5)));
208 }
209 }
210 }
211
212 if (buffer.size() > ns + getMaximalNumberOfHits()) {
213
214 output.setHighRateVeto(pmt, true);
215
216 buffer.resize(ns + getMaximalNumberOfHits());
217 }
218
219 inplace_merge(buffer.begin(), buffer.begin() + ns, buffer.end());
220
221 ns = buffer.size();
222 }
223
224
225 // simulate UDP packet loss
226
227 const int n1 = getUDPNumberOfReceivedPackets(id);
228 const int n2 = getUDPMaximalSequenceNumber (id);
229
230 if (n1 < n2 + 1) {
231
232 const int ns = getBayesianMedian(n2, n1, 0);
233
234 JTDC_t t0 = (JTDC_t) Tmin;
235 JTDC_t ts = (JTDC_t) ((Tmax - Tmin) / ns);
236
237 for (int i = 0; i != ns; ++i, t0 += ts) {
238
239 if (gRandom->Rndm() * ns >= (double) n1) {
240
241 std::vector<JDAQHit>::iterator p = lower_bound(buffer.begin(), buffer.end(), t0, compare);
242 std::vector<JDAQHit>::iterator q = lower_bound(buffer.begin(), buffer.end(), t0 + ts, compare);
243
244 buffer.erase(p,q);
245 }
246 }
247 }
248
249
250 // process data through state machine
251
252 if (buffer.size() > 1) {
253
254 for (std::vector<JDAQHit>::iterator q = buffer.begin(), p = q++; q != buffer.end(); ++p, ++q) {
255
256 if (state_machine->maybeSwapped(*p,*q)) {
257 iter_swap(p,q);
258 }
259 }
260 }
261
262
263 // store data
264
265 output.add(buffer.size(), buffer.data());
266 }
static const struct JDETECTOR::JCLBDefaultSimulatorInterface::compare compare
JLANG::JSinglePointer< JStateMachine > state_machine
static double getMinimalToT()
Get minimal pulse length of time-over-threshold measurement.
JDAQFrameStatus getDAQFrameStatus(const JModuleIdentifier &id) const
Get DAQ frame status of given module.
Template data structure for PMT I/O.
std::vector< JElement_t >::const_iterator const_iterator
void setHighRateVeto(const int tdc, const bool value)
Set high-rate veto.
void setDAQFrameStatus(const JDAQFrameStatus &status)
Set DAQ frame status.
static JTOT_t getMaximalToT()
Get maximal time-over-threshold.
Definition JDAQHit.hh:108
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
size_t getBayesianMedian(const size_t m, const size_t k)
Get estimate of maximum number.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void inplace_merge(T __begin, const size_t N, const size_t *delimiter)
Merge multiple sorted ranges.
Definition JMergeSort.cc:29
size_t getMaximalNumberOfHits()
Get maximal number of hits from one PMT within data frame.
double getFrameTime()
Get frame time duration.
Definition JDAQClock.hh:162
Auxiliary class for TDC constraints.
Definition JTDC_t.hh:39

◆ getMinimalToT()

static double JDETECTOR::JCLBDefaultSimulatorInterface::getMinimalToT ( )
inlinestaticinherited

Get minimal pulse length of time-over-threshold measurement.

Returns
TDC value [ns]

Definition at line 322 of file JCLBDefaultSimulatorInterface.hh.

323 {
324 return 0.5;
325 }

Member Data Documentation

◆ summary_router

const JSummaryRouter& JTRIGGER::JCLBRunByRunSimulator::summary_router
protected

Definition at line 132 of file JCLBRunByRunSimulator.hh.

◆ compare

const struct JDETECTOR::JCLBDefaultSimulatorInterface::compare JDETECTOR::JCLBDefaultSimulatorInterface::compare
staticinherited

◆ TDC

JLANG::JSinglePointer<JTDC> JDETECTOR::JCLBDefaultSimulatorInterface::TDC
privateinherited

Definition at line 360 of file JCLBDefaultSimulatorInterface.hh.

◆ state_machine

JLANG::JSinglePointer<JStateMachine> JDETECTOR::JCLBDefaultSimulatorInterface::state_machine
privateinherited

Definition at line 361 of file JCLBDefaultSimulatorInterface.hh.

◆ buffer

std::vector<JDAQHit> JDETECTOR::JCLBDefaultSimulatorInterface::buffer
mutableprivateinherited

Definition at line 362 of file JCLBDefaultSimulatorInterface.hh.


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