1 #ifndef __JTRIGGER__JTIMESLICEROUTER__
2 #define __JTRIGGER__JTIMESLICEROUTER__
28 namespace JPP {
using namespace JTRIGGER; }
99 const int numberOfBins) :
115 using namespace KM3NETDAQ;
116 using namespace JTOOLS;
119 this->
set(×lice);
122 for (
const_iterator i = this->
get()->begin(); i != this->
get()->end(); ++i) {
123 router.put(i->getModuleID(), distance(this->
get()->begin(), i));
127 const JDAQHit::JTDC_t TMIN = std::numeric_limits<JDAQHit::JTDC_t>::min();
128 const JDAQHit::JTDC_t TMAX = std::numeric_limits<JDAQHit::JTDC_t>::max();
133 if (Tmin < TMIN) { Tmin = TMIN; }
134 if (Tmax > TMAX) { Tmax = TMAX; }
137 int number_of_elements = 2;
139 for (
const_iterator i = this->
get()->begin(); i != this->
get()->end(); ++i) {
140 if (i->size() > number_of_elements) {
141 number_of_elements = i->size();
157 JBuffer_t buffer(bounds.
getSize() + 1);
159 for (
int i = 0; i != bounds.
getSize(); ++i) {
163 buffer[bounds.
getSize()] = TMAX;
166 table.resize(this->
get()->size());
168 const JDAQHit JDAQHitMin(0, TMIN, 0);
169 const JDAQHit JDAQHitMax(0, TMAX, 0);
177 for (
const_iterator frame = this->
get()->begin(); frame != this->
get()->end(); ++frame, ++grid) {
179 grid->configure(bounds);
181 if (!frame->empty()) {
183 if (frame-> begin()->getT() < grid->getXmin()) {
187 if (frame->rbegin()->getT() > grid->getXmax()) {
191 zbuf.resize(frame->size() + 2);
193 copy(frame->begin(), frame->end(), zbuf.begin() + 1);
195 *zbuf. begin() = JDAQHitMin;
196 *zbuf.rbegin() = JDAQHitMax;
199 JDAQFrame_t::const_iterator hit = zbuf.begin(); ++hit;
200 JBuffer_t ::const_iterator t1 = buffer.begin();
204 while (hit->getT() < *t1) { ++hit; }
206 i->getY().lpos = distance(static_cast<const JDAQFrame_t&>(zbuf).begin(),hit) - 1;
211 JDAQFrame_t::const_reverse_iterator hit = zbuf.rbegin(); ++hit;
212 JBuffer_t ::const_reverse_iterator t1 = buffer.rbegin();
216 while (hit->getT() >= *t1) { ++hit; }
218 i->getY().rpos = distance(static_cast<const JDAQFrame_t&>(zbuf).begin(),hit.base()) - 1;
279 const int first = grid.
getIndex(timeRange.getLowerLimit());
280 const int second = grid.
getIndex(timeRange.getUpperLimit());
282 return frame.
subset(grid.
getY(first).lpos, grid.
getY(second).rpos);
bool hasSuperFrame(const JDAQModuleIdentifier &module) const
Check presence of module.
const JDAQSuperFrame & getSuperFrame(const JDAQModuleIdentifier &module) const
Get super frame.
int getModuleID() const
Get module identifier.
std::vector< grid_type > table
JTimesliceRouter(const int numberOfBins)
Constructor.
The elements in a collection are sorted according to their abscissa values and a given distance opera...
void configure(const JDAQTimeslice ×lice)
Configure.
JTOOLS::JRouter< int > router_type
JDAQTimeslice::const_iterator const_iterator
unsigned int JTDC_t
leading edge [ns]
JTOOLS::JGridCollection< element_type > grid_type
int getFrameIndex(const double t_ns)
Get frame index for a given time in ns.
Auxiliary structure for indexing hits in a data frame.
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
JDAQFrameSubset getFrameSubset(const JDAQModuleIdentifier &module, const JTimeRange &timeRange) const
Get subset of frame given module identifier and range of hit times.
double getFrameTime()
Get frame time duration.
Template implementation of class that holds pointer to object(s).
JTimesliceRouter(const JDAQTimeslice ×lice, const int numberOfBins)
Constructor.
JTOOLS::JElement2D< double, JPair_t > element_type
double getTimeSinceRTS(const int frame_index)
Get time in ns since last RTS for a given frame index.
const int getAddress(const JDAQModuleIdentifier &module) const
Get address of module.
void copy(const Head &from, JHead &to)
Copy header from from to to.
KM3NeT DAQ constants, bit handling, etc.
Data frame of one optical module.
JDAQFrameSubset subset(const int i1, const int i2) const
Get subset of data.
virtual void set(const JDAQTimeslice *p)
Set pointer.