EUDAQ
 All Classes Namespaces Files Functions Variables Pages
MimosaConverterPlugin.hh
1 
2 #include "eudaq/DataConverterPlugin.hh"
3 #include "eudaq/StandardEvent.hh"
4 #include "eudaq/PluginManager.hh"
5 #include "eudaq/Utils.hh"
6 #include <vector>
7 
8 #include <stdio.h>
9 #include <string.h>
10 
11 // All LCIO-specific parts are put in conditional compilation blocks
12 // so that the other parts may still be used if LCIO is not available.
13 #if USE_LCIO
14 #include "IMPL/LCEventImpl.h"
15 #include "IMPL/TrackerRawDataImpl.h"
16 #include "IMPL/TrackerDataImpl.h"
17 #include "IMPL/LCCollectionVec.h"
18 #include "UTIL/CellIDEncoder.h"
19 #include "lcio.h"
20 #endif
21 
22 #if USE_EUTELESCOPE
23 #include "EUTELESCOPE.h"
24 #include "EUTelRunHeaderImpl.h"
25 //# include "EUTelTimepixDetector.h"
26 #include "EUTelSetupDescription.h"
27 #include "EUTelEventImpl.h"
28 #include "EUTelTrackerDataInterfacerImpl.h"
29 #include "EUTelGenericSparsePixel.h"
30 using eutelescope::EUTELESCOPE;
31 #endif
32 
33 // The event type for which this converter plugin will be registered
34 // Modify this to match your actual event type (from the Producer)
35 static const char *EVENT_TYPE = "MIMOSA32Raw";
36 static const int kRowPerChip = 64; // number of rows per chip
37 static const int kColPerChip = 16; // number of columns per chip
38 
39 namespace eudaq {
40 
41  // Declare a new class that inherits from DataConverterPlugin
43 
44  public:
45  bool GetStandardSubEvent(StandardEvent &sev, const Event &ev);
46 
47  private:
48  // The constructor can be private, only one static instance is created
49  // The DataConverterPlugin constructor must be passed the event type
50  // in order to register this converter for the corresponding conversions
51  // Member variables should also be initialized to default values here.
53  : DataConverterPlugin(EVENT_TYPE), m_exampleparam(0) {}
54 
55  template <typename T>
56  inline void pack(std::vector<unsigned char> &dst, T &data) {
57  unsigned char *src =
58  static_cast<unsigned char *>(static_cast<void *>(&data));
59  dst.insert(dst.end(), src, src + sizeof(T));
60  }
61 
62  template <typename T>
63  inline void unpack(std::vector<unsigned char> &src, int index, T &data) {
64  std::copy(&src[index], &src[index + sizeof(T)], &data);
65  }
66 
67  bool ReadFrame(short data[][kColPerChip]);
68 
69  void NewEvent();
70  bool ReadData();
71  bool ReadNextInt();
72 
73  std::vector<unsigned char> fData;
74  unsigned int fDataChar1;
75  unsigned int fDataChar2;
76  unsigned int fDataChar3;
77  unsigned int fDataChar4;
78  unsigned int fOffset;
79  short fDataFrame[kRowPerChip][kColPerChip];
80  short fDataFrame2[kRowPerChip][kColPerChip];
81 
82  // Information extracted in Initialize() can be stored here:
83  unsigned m_exampleparam;
84 
85  // The single instance of this converter plugin
86  static MimosaConverterPlugin m_instance;
87  }; // class ExampleConverterPlugin
88 
89  // Instantiate the converter plugin instance
90  MimosaConverterPlugin MimosaConverterPlugin::m_instance;
91 
92 } // namespace eudaq
Definition: StandardEvent.hh:128
DataConverterPlugin(std::string subtype)
Definition: DataConverterPlugin.cc:33
Definition: DataConverterPlugin.hh:132
Definition: MimosaConverterPlugin.hh:42
Definition: Event.hh:38