EUDAQ
 All Classes Namespaces Files Functions Variables Pages
DataConverterPlugin.hh
1 #ifndef EUDAQ_INCLUDED_DataConverterPlugin
2 #define EUDAQ_INCLUDED_DataConverterPlugin
3 
4 #include "eudaq/StandardEvent.hh"
5 #include "eudaq/RawDataEvent.hh"
6 
7 #if USE_LCIO
8 #include "IMPL/LCEventImpl.h"
9 #include "IMPL/TrackerRawDataImpl.h"
10 #include "IMPL/TrackerDataImpl.h"
11 #include "IMPL/LCCollectionVec.h"
12 #include "IMPL/LCGenericObjectImpl.h"
13 #include "UTIL/CellIDEncoder.h"
14 #include "lcio.h"
15 using namespace IMPL;
16 using namespace UTIL;
17 using lcio::TrackerDataImpl;
18 #endif
19 #include "TLUEvent.hh"
20 
21 #define NOTIMESTAMPSET (uint64_t) - 1
22 #define NOTIMEDURATIONSET 0
23 
25 // Compare Time stamps
26 #define Event_IS_EARLY -1
27 #define Event_IS_LATE 1
28 #define Event_IS_Sync 0
29 
30 namespace EVENT {
31  class LCEvent;
32  class LCRunHeader;
33 }
34 namespace lcio {
35  using namespace EVENT;
36 }
37 
38 #include <string>
39 #include <algorithm>
40 
41 namespace eudaq {
42 
43 #ifdef USE_LCIO
44  bool Collection_createIfNotExist(lcio::LCCollectionVec **zsDataCollection,
45  const lcio::LCEvent &lcioEvent,
46  const char *name);
47  void ConvertPlaneToLCIOGenericPixel(StandardPlane &plane,
48  lcio::TrackerDataImpl &zsFrame);
49 #endif // USE_LCIO
50 
51  inline int compareTLU2DUT(unsigned TLU_Trigger_Number,
52  unsigned DUT_Trigger_number) {
53  if (DUT_Trigger_number == TLU_Trigger_Number) {
54  return Event_IS_Sync;
55  } else if (DUT_Trigger_number > TLU_Trigger_Number) {
56  return Event_IS_EARLY;
57  }
58  return Event_IS_LATE;
59  }
60  template <typename T>
61  inline int compareTLU2DUT(T TLU_Trigger_Number, T DUT_Trigger_number) {
62  if (DUT_Trigger_number == TLU_Trigger_Number) {
63  return Event_IS_Sync;
64  } else if (DUT_Trigger_number > TLU_Trigger_Number) {
65  return Event_IS_EARLY;
66  }
67  return Event_IS_LATE;
68  }
69 
70  template <typename T>
71  inline int hasTimeOVerlaping(T eventBegin, T EventEnd, T TLUStart, T TLUEnd) {
72 
73  if (eventBegin <= TLUEnd) {
74  if (EventEnd >= TLUStart) {
75 
76  /*
77 
78  | event start |event End
79 ----------------------------------------->
80  t
81 
82 | tlu start | tlu End
83 ------------------------------------------>
84  t
85 
86 */
87  return Event_IS_Sync;
88  }
89 
90  /*
91 
92 | event start |event End
93 ----------------------------------------->
94  t
95 
96  | tlu start | tlu End
97 ------------------------------------------>
98  t
99 
100 */
101  return Event_IS_EARLY;
102  }
103 
104  /*
105 
106  | event start |event End
107  ----------------------------------------->
108  t
109 
110  | tlu start | tlu End
111  ------------------------------------------>
112  t
113 
114  */
115 
116  return Event_IS_LATE;
117  }
118 
119  class Configuration;
120 
133  public:
134  typedef std::pair<unsigned, std::string> t_eventid;
135 
136  virtual void Initialize(eudaq::Event const &,
137  eudaq::Configuration const &) {}
138 
139  virtual unsigned GetTriggerID(eudaq::Event const &) const;
140  virtual int IsSyncWithTLU(eudaq::Event const &ev,
141  eudaq::TLUEvent const &tlu) const {
142  // dummy comparator. it is just checking if the event numbers are the
143  // same.
144 
145  // auto triggerID=ev.GetEventNumber();
146  unsigned triggerID = ev.GetTag<unsigned>("tlu_trigger_id", 0);
147  auto tlu_triggerID = tlu.GetEventNumber();
148  return compareTLU2DUT(tlu_triggerID, triggerID);
149  }
150 
151  virtual void setCurrentTLUEvent(eudaq::Event &ev,
152  eudaq::TLUEvent const &tlu) {
153  ev.SetTag("tlu_trigger_id", tlu.GetEventNumber());
154  }
155  virtual void GetLCIORunHeader(lcio::LCRunHeader &, eudaq::Event const &,
156  eudaq::Configuration const &) const {}
157 
160  virtual bool GetLCIOSubEvent(lcio::LCEvent & /*result*/,
161  eudaq::Event const & /*source*/) const {
162  return false;
163  }
164 
167  virtual bool GetStandardSubEvent(StandardEvent & /*result*/,
168  eudaq::Event const & /*source*/) const {
169  return false;
170  };
171 
175  virtual t_eventid const &GetEventType() const { return m_eventtype; }
176 
179  virtual ~DataConverterPlugin() {}
180 
181  protected:
187  t_eventid m_eventtype;
188 
192  DataConverterPlugin(std::string subtype);
193  DataConverterPlugin(unsigned type, std::string subtype = "");
194 
195  private:
205  DataConverterPlugin &operator=(const DataConverterPlugin &);
206  };
207 
208 } // namespace eudaq
209 
210 #endif // EUDAQ_INCLUDED_DataConverterPlugin
Definition: TLUEvent.hh:10
Definition: Configuration.hh:12
virtual ~DataConverterPlugin()
Definition: DataConverterPlugin.hh:179
virtual t_eventid const & GetEventType() const
Definition: DataConverterPlugin.hh:175
t_eventid m_eventtype
Definition: DataConverterPlugin.hh:187
virtual bool GetStandardSubEvent(StandardEvent &, eudaq::Event const &) const
Definition: DataConverterPlugin.hh:167
Definition: StandardEvent.hh:128
Definition: DataConverterPlugin.hh:132
Definition: Event.hh:38
virtual bool GetLCIOSubEvent(lcio::LCEvent &, eudaq::Event const &) const
Definition: DataConverterPlugin.hh:160