Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
software/JDAQ/JDAQTimeslice.cc
Go to the documentation of this file.
1 #include <map>
2 #include <vector>
3 #include <algorithm>
4 
5 #include "JDAQ/JDAQEvent.hh"
7 #include "JDAQ/JDAQTimeslice.hh"
8 
9 
10 /**
11  * \author mdejong
12  */
13 
14 namespace KM3NETDAQ {
15 
16  /**
17  * Constructor.
18  *
19  * \param event DAQ event
20  * \param snapshot use shapshot hits (else use triggered hits)
21  */
23  const bool snapshot) :
25  JDAQTimesliceHeader(event.getDAQChronometer()),
26  std::vector<JDAQSuperFrame>()
27  {
28  using namespace std;
29 
30  map<int, vector<JDAQHit> > buffer;
31 
32  if (snapshot) {
33 
34  for (vector<JDAQSnapshotHit>::const_iterator hit = event.begin<JDAQSnapshotHit> (); hit != event.end<JDAQSnapshotHit> (); ++hit) {
35  buffer[hit->getModuleID()].push_back(*hit);
36  }
37 
38  } else {
39 
40  for (vector<JDAQTriggeredHit>::const_iterator hit = event.begin<JDAQTriggeredHit>(); hit != event.end<JDAQTriggeredHit>(); ++hit) {
41  buffer[hit->getModuleID()].push_back(*hit);
42  }
43  }
44 
45 
46  for (map<int, vector<JDAQHit> >::iterator entry = buffer.begin(); entry != buffer.end(); ++entry) {
47 
48  sort(entry->second.begin(), entry->second.end());
49 
50  this->push_back(JDAQSuperFrame(JDAQSuperFrameHeader(getDAQChronometer(), entry->first)));
51 
52  this->rbegin()->add(entry->second.size(), entry->second.data());
53  }
54  }
55 
56 
57  /**
58  * Constructor.
59  *
60  * \param event DAQ event
61  * \param summary summary
62  * \param snapshot use shapshot hits (else use triggered hits)
63  */
65  const JDAQSummaryslice& summary,
66  const bool snapshot) :
69  std::vector<JDAQSuperFrame>()
70  {
71  using namespace std;
72  using namespace JPP;
73 
74  map<int, vector<JDAQHit> > buffer;
75 
76  if (snapshot) {
77 
78  for (vector<JDAQSnapshotHit>::const_iterator hit = event.begin<JDAQSnapshotHit> (); hit != event.end<JDAQSnapshotHit> (); ++hit) {
79  buffer[hit->getModuleID()].push_back(*hit);
80  }
81 
82  } else {
83 
84  for (vector<JDAQTriggeredHit>::const_iterator hit = event.begin<JDAQTriggeredHit>(); hit != event.end<JDAQTriggeredHit>(); ++hit) {
85  buffer[hit->getModuleID()].push_back(*hit);
86  }
87  }
88 
90 
91  for (JDAQSummaryslice::const_iterator i = summary.begin(); i != summary.end(); ++i) {
92  sumo[i->getModuleID()] = i->getDAQFrameStatus();
93  }
94 
95  for (map<int, vector<JDAQHit> >::iterator entry = buffer.begin(); entry != buffer.end(); ++entry) {
96 
97  sort(entry->second.begin(), entry->second.end());
98 
100 
101  map<int, JDAQFrameStatus>::const_iterator ps = sumo.find(entry->first);
102 
103  if (ps != sumo.end()) {
104  status = ps->second;
105  }
106 
107  this->push_back(JDAQSuperFrame(JDAQSuperFrameHeader(getDAQChronometer(), entry->first, status)));
108 
109  this->rbegin()->add(entry->second.size(), entry->second.data());
110  }
111  }
112 }
DAQ key hit.
Definition: JDAQKeyHit.hh:24
Auxiliary class for a DAQ type holder.
static const JDAQFrameStatus & getInstance()
Get reference to unique instance of this class object.
JDAQTimeslice()
Default constructor.
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
const_iterator< T > end() const
Get end of data.
const_iterator< T > begin() const
Get begin of data.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Data time slice.
Data frame of one optical module.