QualityControl  1.5.1
O2 Data Quality Control Framework
Decoding.h
Go to the documentation of this file.
1 
6 #ifndef QC_MODULE_MUONCHAMBERS_DATA_DECODER_H
7 #define QC_MODULE_MUONCHAMBERS_DATA_DECODER_H
8 
10 #include "MCH/sampa_header.h"
11 #include "MCH/Mapping.h"
12 #include "MCHBase/Digit.h"
13 
14 using namespace o2::quality_control::core;
15 
16 namespace o2
17 {
18 namespace quality_control_modules
19 {
20 namespace muonchambers
21 {
22 
23 enum DualSampaStatus {
24  notSynchronized = 1,
25  //synchronized = 2,
26  headerToRead = 3,
27  sizeToRead = 4,
28  timeToRead = 5,
29  dataToRead = 6
30  //chargeToRead = 7,
31  //OK = 8 // Data block filled (over a time window)
32 };
33 
34 struct SampaHit {
35  uint8_t cru_id, fee_id, data_path, link_id, ds_addr, chan_addr;
36  int64_t bxc;
37  uint32_t size, time;
38  std::vector<uint16_t> samples;
39  uint64_t csum;
40  int32_t delta;
41  MapPad pad;
42 };
43 
44 struct DualSampa {
45  int id;
46  DualSampaStatus status; // Status during the data filling
47  uint64_t data; // curent data
48  int bit; // current position
49  uint64_t powerMultiplier; // power to convert to move bits
50  int nsyn2Bits; // Nb of words waiting synchronization
51  Sampa::SampaHeaderStruct header; // current channel header
52  unsigned long bxc[2];
53  int32_t csize, ctime, cid, sample;
54  int chan_addr[2];
55  uint64_t packetsize;
56  int nbHit; // incremented each time a header packet is received for this card
57  int nbHitChan[64]; // incremented each time a header packet for a given packet is received for this card
58  int ndata[2][32];
59  int nclus[2][32];
60  double pedestal[2][32], noise[2][32];
61  int32_t min[2][32], max[2][32], delta[2][32];
62  SampaHit hit;
63 };
64 
66  long int bxc;
67 };
68 
71 class Decoder
72 {
73  public:
75  Decoder();
77  ~Decoder();
78 
79  // Definition of the methods for the template method pattern
80  void initialize();
81  void processData(const char* buf, size_t size);
82  void decodeRaw(uint32_t* payload_buf, size_t nGBTwords, int cru_id, int link_id);
83  void decodeUL(uint32_t* payload_buf, size_t nWords, int cru_id, int dpw_id);
84  void clearHits();
85  void clearDigits();
86  std::vector<SampaHit>& getHits() { return mHits; }
87  std::vector<o2::mch::Digit>& getDigits() { return mDigits; }
88  void reset();
89 
90  int32_t getMapCRU(int cruid, int linkid)
91  {
92  return mMapCRU.getLink(cruid, linkid);
93  }
94 
95  bool getMapCRUInv(int32_t link_id, int32_t& cruid, int32_t& crulink)
96  {
97  return mMapCRU.getLinkInv(link_id, cruid, crulink);
98  }
99 
100  int32_t getMapFEC(uint32_t link_id, uint32_t ds_addr, uint32_t& de, uint32_t& dsid)
101  {
102  if (!mMapFEC.getDSMapping(link_id, ds_addr, de, dsid))
103  return -1;
104  return de;
105  }
106 
107  int32_t getMapFECinv(uint32_t de, uint32_t dsid, uint32_t& link_id, uint32_t& ds_addr)
108  {
109  if (!mMapFEC.getDSMappingInv(de, dsid, link_id, ds_addr))
110  return -1;
111  return link_id;
112  }
113 
114  MapFEC& getMapFEC() { return mMapFEC; }
115 
116  private:
117  int hb_orbit;
118  DualSampa ds[MCH_MAX_CRU_ID][24][40];
119  DualSampaGroup dsg[MCH_MAX_CRU_ID][24][8];
120  int ds_enable[MCH_MAX_CRU_IN_FLP][24][40];
121  std::vector<SampaHit> mHits;
122  std::vector<o2::mch::Digit> mDigits;
123  int nFrames;
124  MapCRU mMapCRU;
125  MapFEC mMapFEC;
126 };
127 
128 } // namespace muonchambers
129 } // namespace quality_control_modules
130 } // namespace o2
131 
132 #endif // QC_MODULE_MUONCHAMBERS_DATA_DECODER_H
Definition: sampa_header.h:12
These methods can be used to build a complex processing topology. It spawns 3 separate dummy processi...
Definition: Activity.h:19
decoding of MCH data
Definition: Decoding.h:71