19 using namespace Diana;
25 bool CompareTimes(
const std::pair<int, unsigned long long> &EventAndTime1,
26 const std::pair<int, unsigned long long> &EventAndTime2)
28 return EventAndTime1.second < EventAndTime2.second;
35 fIteration = GetIteration();
36 fSortByRun = GetBool(
"SortByRun",
true,
false);
39 act.fActionId = ACT_NEXTEV;
41 eva.
Add<
QInt>(
"TimeSort",
"SortedIndex");
46 act.fActionId = ACT_GOTOEV;
47 act.fEventNumber = (fEventVector.begin()->second[fIndex]).first;
62 act.fActionId = ACT_NEXTEV;
73 std::pair<int, unsigned long long> EventAndTime;
78 EventAndTime.second = t.GetFromStartRunNs();
79 if(fEventVector.find(run) == fEventVector.end()){
81 fEventVector[run] = std::vector< std::pair<int, unsigned long long>>();
82 fChannelVector[run] = std::vector<int>();
85 fEventVector[run].push_back(EventAndTime);
86 fChannelVector[run].push_back(chan);
87 if(fStartTime[run] == 0) fStartTime[run] = t.GetStartRunUnix();
90 void * vtmp = (
void*) &header;
95 eva.
Get<
QInt>(
"TimeSort",
"SortedIndex") = fIndex;
96 if(fIndex<fNumberOfEvents){
97 act.fActionId = ACT_GOTOEV;
100 std::map<int,std::vector< std::pair<int, unsigned long long>>>::iterator it;
101 for(it=fEventVector.begin();it!=fEventVector.end();it++){
102 if(index>=it->second.size()){
103 index -= it->second.size();
107 act.fEventNumber = (fEventVector[run][index]).first;
111 act.fActionId = ACT_QUIT;
123 std::map<int,std::vector< std::pair<int, unsigned long long>>>::iterator it;
125 for(it=fEventVector.begin();it!=fEventVector.end();it++){
126 sort(it->second.begin(), it->second.end(),
CompareTimes);
127 fNumberOfEvents+=it->second.size();
129 if(GetBool(
"SortInPlace",
true)) act = ACT_RERUN;
bool CompareTimes(const std::pair< int, unsigned long long > &EventAndTime1, const std::pair< int, unsigned long long > &EventAndTime2)
#define REGISTER_MODULE(clazz)
Module for sorting events by time.
virtual Action Do(Diana::QEventAssembler &ev)
virtual Action Done()
Done method is called after event loop.
base types wrapped into a QObject. Currently implemented types are QInt QDouble and QFloat....
class to store ActionId and fEventNumber (in case fActionId=ACT_GOTOEV)
Visitor class of QEvent that provides full handling of QEvent.
QEvent & GetEvent()
Get the QEvent.
void Get(const char *owner, WriteHandle< Q > &handle)
Get QObject from the event in write mode. This method has to be called in the event loop,...
void Add(const char *owner, WriteHandle< Q > &handle)
Add QObject to the event. This method has to be called before the event loop, e.g....
void Require(const std::string &owner, const std::string &name) const
notify the QEvent that we need a QObject, if not found an exception is thrown
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
unsigned int GetReadNumber() const
return the event number as read by the current reader.
Raw event: bolometer channel, trigger positions and types.
const int & GetChannelId() const
Get ChannelId.
void SetStartRunUnix(unsigned int time)
set time of start of run in seconds from 1/1/1970
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...