Project
Loading...
Searching...
No Matches
MC2RawEncoder.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef ALICEO2_ITSMFT_MC2RAWENCODER_H_
16#define ALICEO2_ITSMFT_MC2RAWENCODER_H_
17
18#include <gsl/gsl> // for guideline support library; array_view
19#include "ITSMFTReconstruction/RawPixelReader.h" // TODO : must be modified
26#include <unordered_map>
27
28namespace o2
29{
30
31namespace itsmft
32{
33
34template <class Mapping>
36{
38
39 public:
41 {
42 mRUEntry.fill(-1);
43 }
44
46 {
47 mWriter.close();
48 }
49
50 void digits2raw(gsl::span<const Digit> digits, const o2::InteractionRecord& bcData);
51 void finalize();
52 void init();
53
55
56 RUDecodeData* getRUDecode(int ruSW) { return mRUEntry[ruSW] < 0 ? nullptr : &mRUDecodeVec[mRUEntry[ruSW]]; }
57
58 void setVerbosity(int v)
59 {
60 mVerbosity = v;
61 mWriter.setVerbosity(v);
62 }
63 int getVerbosity() const { return mVerbosity; }
64
65 Mapping& getMapping() { return mMAP; }
66
67 void setMinMaxRUSW(uint8_t ruMin, uint8_t ruMax)
68 {
69 mRUSWMax = (ruMax < uint8_t(mMAP.getNRUs())) ? ruMax : mMAP.getNRUs() - 1;
70 mRUSWMin = ruMin < mRUSWMax ? ruMin : mRUSWMax;
71 }
72
73 int getRUSWMin() const { return mRUSWMin; }
74 int getRUSWMax() const { return mRUSWMax; }
75
77 bool isContinuousReadout() const { return mWriter.isContinuousReadout(); }
78
79 o2::raw::RawFileWriter& getWriter() { return mWriter; }
80
81 std::string getDefaultSinkName() const { return mDefaultSinkName; }
82 void setDefaultSinkName(const std::string& nm)
83 {
84 if (!nm.empty()) {
85 mDefaultSinkName = nm;
86 }
87 }
88
89 int carryOverMethod(const o2::header::RDHAny* rdh, const gsl::span<char> data, const char* ptr, int maxSize, int splitID,
90 std::vector<char>& trailer, std::vector<char>& header) const;
91
92 void newRDHMethod(const header::RDHAny* rdh, bool empty, std::vector<char>& toAdd) const;
93
94 // create new gbt link
96 {
97 int sz = mGBTLinks.size();
98 mGBTLinks.emplace_back();
99 return sz;
100 }
101
102 // get the link pointer
103 GBTLink* getGBTLink(int i) { return i < 0 ? nullptr : &mGBTLinks[i]; }
104 const GBTLink* getGBTLink(int i) const { return i < 0 ? nullptr : &mGBTLinks[i]; }
105
106 private:
107 void convertEmptyChips(int fromChip, int uptoChip, RUDecodeData& ru);
108 void convertChip(ChipPixelData& chipData, RUDecodeData& ru);
109 void fillGBTLinks(RUDecodeData& ru);
110
111 enum RoMode_t { NotSet,
112 Continuous,
113 Triggered };
114 o2::InteractionRecord mCurrIR; // currently processed int record
115 o2::raw::RawFileWriter mWriter{Mapping::getOrigin()}; // set origin of data
116 std::string mDefaultSinkName = "dataSink.raw";
117 Mapping mMAP;
118 Coder mCoder;
119 int mVerbosity = 0;
120 uint8_t mRUSWMin = 0;
121 uint8_t mRUSWMax = 0xff;
122 int mNRUs = 0;
123 int mNLinks = 0;
124 std::array<RUDecodeData, Mapping::getNRUs()> mRUDecodeVec;
125 std::array<int, Mapping::getNRUs()> mRUEntry;
126 std::vector<GBTLink> mGBTLinks;
127 std::unordered_map<uint16_t, const GBTLink*> mFEEId2Link;
128 std::unordered_map<uint16_t, GBTDataHeader> mFEEId2GBTHeader;
129 ClassDefNV(MC2RawEncoder, 1);
130};
131
132// template specifications
135
136} // namespace itsmft
137} // namespace o2
138
139#endif
class for the ALPIDE data decoding/encoding
int32_t i
Declaration of the Readout Unite decoder class.
Utility class to write detectors data to (multiple) raw data file(s) respecting CRU format.
Definition of the Alpide pixel reader for raw data processing.
TBranch * ptr
Checks validity of hardware address (HW) and transform it to digit AbsId index.
bool isContinuousReadout() const
GBTLink * getGBTLink(int i)
void setContinuousReadout(bool v)
int carryOverMethod(const o2::header::RDHAny *rdh, const gsl::span< char > data, const char *ptr, int maxSize, int splitID, std::vector< char > &trailer, std::vector< char > &header) const
RUDecodeData & getCreateRUDecode(int ruSW)
const GBTLink * getGBTLink(int i) const
o2::raw::RawFileWriter & getWriter()
std::string getDefaultSinkName() const
void setDefaultSinkName(const std::string &nm)
void setMinMaxRUSW(uint8_t ruMin, uint8_t ruMax)
void digits2raw(gsl::span< const Digit > digits, const o2::InteractionRecord &bcData)
RUDecodeData * getRUDecode(int ruSW)
void newRDHMethod(const header::RDHAny *rdh, bool empty, std::vector< char > &toAdd) const
bool isContinuousReadout() const
const GLdouble * v
Definition glcorearb.h:832
GLboolean * data
Definition glcorearb.h:298
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
void empty(int)
std::vector< Digit > digits