Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Private Attributes | List of all members
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 setHighRateVeto () const
 Set high-rate veto based on number of hits.
 
virtual bool getHighRateVeto (const JPMTIdentifier &id) const override
 Get high-rate veto of given PMT.
 
virtual bool getFIFOStatus (const JPMTIdentifier &id) const override
 Get FIFO (almost) full of given PMT.
 
virtual bool hasCLB (const JModuleIdentifier &id) const
 Check if CLB exist.
 
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

std::unique_ptr< JTDCTDC
 
std::unique_ptr< JStateMachinestate_machine
 

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

Definition at line 62 of file JCLBDefaultSimulatorInterface.hh.

◆ JTDC_t

Definition at line 63 of file JCLBDefaultSimulatorInterface.hh.

◆ JTOT_t

Definition at line 64 of file JCLBDefaultSimulatorInterface.hh.

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
65 }
virtual int getUDPNumberOfReceivedPackets(const JModuleIdentifier &id) const
Get number of received UDP packets.
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
86 }
virtual int getUDPMaximalSequenceNumber(const JModuleIdentifier &id) const
Get maximal sequence number of UDP packet.
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
107 }
virtual bool hasUDPTrailer(const JModuleIdentifier &id) const
Get UDP trailer status.
bool hasUDPTrailer() const
Get UDP trailer status.

◆ setHighRateVeto()

virtual bool JTRIGGER::JCLBRunByRunSimulator::setHighRateVeto ( ) const
inlinevirtual

Set high-rate veto based on number of hits.

Returns
false

Reimplemented from JDETECTOR::JCLBDefaultSimulatorInterface.

Definition at line 115 of file JCLBRunByRunSimulator.hh.

116 {
117 return false;
118 }

◆ 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 127 of file JCLBRunByRunSimulator.hh.

128 {
129 using namespace KM3NETDAQ;
130
131 if (summary_router.hasSummaryFrame(id.getModuleID())) {
132
133 const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getModuleID());
134
135 return frame.testHighRateVeto(id.getPMTAddress());
136 }
137
139 }
virtual bool getHighRateVeto(const JPMTIdentifier &id) const
Get high-rate veto of given PMT.
bool testHighRateVeto() const
Test high-rate veto status.

◆ getFIFOStatus()

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

Get FIFO (almost) full of given PMT.

Parameters
idPMT identifier
Returns
true if FIFO (almost) full; else false

Reimplemented from JDETECTOR::JCLBDefaultSimulatorInterface.

Definition at line 148 of file JCLBRunByRunSimulator.hh.

149 {
150 using namespace KM3NETDAQ;
151
152 if (summary_router.hasSummaryFrame(id.getModuleID())) {
153
154 const JDAQSummaryFrame& frame = summary_router.getSummaryFrame(id.getModuleID());
155
156 return frame.testFIFOStatus(id.getPMTAddress());
157 }
158
160 }
virtual bool getFIFOStatus(const JPMTIdentifier &id) const
Get FIFO (almost) full of given PMT.
bool testFIFOStatus() const
Test FIFO status.

◆ hasCLB()

virtual bool JTRIGGER::JCLBRunByRunSimulator::hasCLB ( const JModuleIdentifier & id) const
inlinevirtual

Check if CLB exist.

Parameters
idmodule identifier
Returns
true if summary data available; else false

Reimplemented from JDETECTOR::JCLBSimulator.

Definition at line 169 of file JCLBRunByRunSimulator.hh.

170 {
171 return summary_router.hasSummaryFrame(id.getID());
172 }

◆ 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 144 of file JCLBDefaultSimulatorInterface.hh.

145 {
146 using namespace KM3NETDAQ;
147
150 int status = DAQ_WHITE_RABBIT.write(1); // TDC status
151 int fifo = DAQ_UDP_TRAILER .write(hasUDPTrailer(id) ? 1 : 0); // FIFO status
152
153 for (size_t pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
154 JBit(pmt).set(status, getHighRateVeto(JPMTIdentifier(id,pmt))); // high-rate veto
155 JBit(pmt).set(fifo, getFIFOStatus (JPMTIdentifier(id,pmt))); // FIFO (almost) full
156 }
157
158 return JDAQFrameStatus(daq, status, fifo);
159 }
JWriter & write(JWriter &out) const override final
Write from input.
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
void set(int &mask) const
Set bit in given bit mask.
Definition JDAQ.hh:77

◆ 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 169 of file JCLBDefaultSimulatorInterface.hh.

170 {
171 using namespace std;
172 using namespace JPP;
173 using namespace KM3NETDAQ;
174
175
176 const double Tmin = 0.0; // Minimal TDC value [ns]
177 const double Tmax = getFrameTime(); // Maximal TDC value [ns]
178
180
181 vector<JDAQHit> buffer;
182
183 size_t ns = 0; // current number of hits in data frame
184
185 for (size_t pmt = 0; pmt != input.size(); ++pmt) {
186
187 const JPMTData<JPMTPulse>& in = input[pmt];
188
189 // TDC
190
191 for (JPMTData<JPMTPulse>::const_iterator hit = in.begin(); hit != in.end(); ++hit) {
192
193 if (hit->t_ns >= Tmin && hit->t_ns <= Tmax) {
194
195 double t1 = hit->t_ns;
196 double tot = hit->tot_ns;
197
198 // generate multiple hits if time-over-threshold exceeds dynamic range
199
200 while (tot > JDAQHit::getMaximalToT()) {
201
202 buffer.push_back(TDC->makeHit((JPMT_t) pmt, t1, (JTOT_t) JDAQHit::getMaximalToT()));
203
205 tot -= JDAQHit::getMaximalToT();
206 }
207
208 if (tot > getMinimalToT()) {
209 buffer.push_back(TDC->makeHit((JPMT_t) pmt, t1, (JTOT_t) (tot + 0.5)));
210 }
211 }
212 }
213
214 if (buffer.size() > ns + getMaximalNumberOfHits()) {
215
216 if (setHighRateVeto()) {
217 output.setHighRateVeto(pmt, true);
218 }
219
220 if (output.testHighRateVeto(pmt)) {
221 buffer.resize(ns + getMaximalNumberOfHits());
222 }
223 }
224
225 inplace_merge(buffer.begin(), buffer.begin() + ns, buffer.end());
226
227 ns = buffer.size();
228 }
229
230
231 // simulate UDP packet loss
232
233 const int n1 = getUDPNumberOfReceivedPackets(id);
234 const int n2 = getUDPMaximalSequenceNumber (id);
235
236 if (n1 < n2 + 1) {
237
238 const int ns = getBayesianMedian(n2, n1, 0);
239
240 JTDC_t t0 = (JTDC_t) Tmin;
241 JTDC_t ts = (JTDC_t) ((Tmax - Tmin) / ns);
242
243 for (int i = 0; i != ns; ++i, t0 += ts) {
244
245 if (gRandom->Rndm() * ns >= (double) n1) {
246
247 std::vector<JDAQHit>::iterator p = lower_bound(buffer.begin(), buffer.end(), t0, compare);
248 std::vector<JDAQHit>::iterator q = lower_bound(buffer.begin(), buffer.end(), t0 + ts, compare);
249
250 buffer.erase(p,q);
251 }
252 }
253 }
254
255
256 // process data through state machine
257
258 if (buffer.size() > 1) {
259
260 for (std::vector<JDAQHit>::iterator q = buffer.begin(), p = q++; q != buffer.end(); ++p, ++q) {
261
262 if (state_machine->maybeSwapped(*p,*q)) {
263 iter_swap(p,q);
264 }
265 }
266 }
267
268
269 // store data
270
271 output.add(buffer.size(), buffer.data());
272 }
static const struct JDETECTOR::JCLBDefaultSimulatorInterface::compare compare
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.
virtual bool setHighRateVeto() const
Set high-rate veto based on number of hits.
std::vector< JElement_t >::const_iterator const_iterator
Template definition of a multi-dimensional oscillation probability interpolation table.
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 351 of file JCLBDefaultSimulatorInterface.hh.

352 {
353 return 0.5;
354 }

Member Data Documentation

◆ summary_router

const JSummaryRouter& JTRIGGER::JCLBRunByRunSimulator::summary_router
protected

Definition at line 176 of file JCLBRunByRunSimulator.hh.

◆ compare

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

◆ TDC

std::unique_ptr<JTDC> JDETECTOR::JCLBDefaultSimulatorInterface::TDC
privateinherited

Definition at line 389 of file JCLBDefaultSimulatorInterface.hh.

◆ state_machine

std::unique_ptr<JStateMachine> JDETECTOR::JCLBDefaultSimulatorInterface::state_machine
privateinherited

Definition at line 390 of file JCLBDefaultSimulatorInterface.hh.


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