Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTimesliceL1.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JTIMESLICEL1__
2 #define __JTRIGGER__JTIMESLICEL1__
3 
4 #include <vector>
5 #include <algorithm>
6 
7 #include "JDAQ/JDAQTimeslice.hh"
8 #include "JTrigger/JTimeslice.hh"
11 #include "JDetector/JTimeRange.hh"
13 #include "JTrigger/JHitToolkit.hh"
14 
15 
16 /**
17  * \author mdejong
18  */
19 
20 namespace JTRIGGER {}
21 namespace JPP { using namespace JTRIGGER; }
22 
23 namespace JTRIGGER {
24 
26  using JDETECTOR::JModule;
30 
31 
32  /**
33  * Auxiliary class to build JDAQTimeslice for L1 timeslice.
34  */
35  template<class JDAQTimeslice_t>
36  class JTimesliceL1 :
37  public JDAQTimeslice_t
38  {
39  public:
40 
41 
42  /**
43  * Default constructor.
44  */
46  JDAQTimeslice_t()
47  {}
48 
49 
50  /**
51  * Constructor.
52  *
53  * \param timeslice triggered timeslice (e.g. L1)
54  * \param timesliceRouter timeslice router
55  * \param moduleRouter module router
56  * \param TMaxLocal_ns Maximal time for L1 [ns]
57  */
58  template<class JHit_t>
59  JTimesliceL1(const JTimeslice<JHit_t>& timeslice,
60  const JTimesliceRouter& timesliceRouter,
61  const JModuleRouter& moduleRouter,
62  const double TMaxLocal_ns) :
63  JDAQTimeslice_t()
64  {
65  using namespace std;
66 
67  this->setDAQChronometer(timeslice.getDAQChronometer());
68 
69  vector<JDAQHit> buffer;
70 
71  for (typename JTimeslice<JHit_t>::const_iterator frame = timeslice.begin(); frame != timeslice.end(); ++frame) {
72 
73  const JModule& module = moduleRouter.getModule(frame->getModuleID());
74  const JTimeRange timeOffset = getTimeRange(JTimeRange(0,0), module);
75 
76  buffer.clear();
77 
78  for (typename JFrame<JHit_t>::const_iterator p = frame->begin(); p != frame->end(); ) {
79 
80  double Tmin = frame->getT(*p);
81  double Tmax = Tmin + TMaxLocal_ns;
82 
83  while (++p != frame->end() && frame->getT(*p) <= Tmax) {
84  Tmax = frame->getT(*p) + TMaxLocal_ns;
85  }
86 
87  const JDAQFrameSubset& subset = timesliceRouter.getFrameSubset(frame->getModuleID(), JTimeRange(Tmin, Tmax).add(timeOffset));
88 
89  for (JDAQFrameSubset::const_iterator i = subset.begin(); i != subset.end(); ++i) {
90 
91  const JCalibration& calibration = module.getPMT(i->getPMT()).getCalibration();
92  const double t1 = getTime(*i, calibration);
93 
94  if (t1 >= Tmin && t1 <= Tmax) {
95  buffer.push_back(*i);
96  }
97  }
98  }
99 
100  this->push_back(JDAQSuperFrame(timesliceRouter.getSuperFrame(frame->getModuleID()).getDAQSuperFrameHeader()));
101 
102  this->rbegin()->add(buffer.size(), buffer.data());
103  }
104  }
105  };
106 }
107 
108 #endif
std::vector< value_type >::const_iterator const_iterator
Definition: JTimeslice.hh:34
const JDAQSuperFrame & getSuperFrame(const JDAQModuleIdentifier &module) const
Get super frame.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
Definition: JModule.hh:47
const_iterator begin() const
Definition: JDAQFrame.hh:48
Router for direct addressing of module data in detector data structure.
JTimesliceL1(const JTimeslice< JHit_t > &timeslice, const JTimesliceRouter &timesliceRouter, const JModuleRouter &moduleRouter, const double TMaxLocal_ns)
Constructor.
Definition: JTimesliceL1.hh:59
JTimesliceL1()
Default constructor.
Definition: JTimesliceL1.hh:45
Data structure for PMT calibration.
double getTime(const Hit &hit)
Get true time of hit.
Tools for handling different hit types.
JRange< double > JTimeRange
Type definition for time range.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e.
Subset of data frame.
Definition: JDAQFrame.hh:28
Hit data structure.
Definition: JDAQHit.hh:36
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.
range_type & add(argument_type x)
Add offset.
Definition: JRange.hh:385
Data frame for calibrated hits of one PMT.
Definition: JFrame.hh:31
JTimeRange getTimeRange(const JTimeRange &timeRange, const JModule &module)
Get de-calibrated time range.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Data time slice.
const JPMT & getPMT(const int index) const
Get PMT.
Definition: JModule.hh:141
Direct access to module in detector data structure.
Auxiliary class to build JDAQTimeslice for L1 timeslice.
Definition: JTimesliceL1.hh:36
const_iterator end() const
Definition: JDAQFrame.hh:49
Data frame of one optical module.
Time slice with calibrated data.
Definition: JTimeslice.hh:26