Project
Loading...
Searching...
No Matches
HmpidCoder2.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
17
18#ifndef COMMON_HMPIDCODER2_H_
19#define COMMON_HMPIDCODER2_H_
20
21#include <cstdio>
22#include <cstdint>
23#include <iostream>
24#include <cstring>
25#include <cmath>
26#include <cstdlib>
27#include <vector>
28#include <memory>
29
34
35#include <fairlogger/Logger.h>
36#include "HMPIDBase/Geo.h"
38
39// ---- RDH 6 standard dimension -------
40#define RAWBLOCKDIMENSION_W 2048
41#define HEADERDIMENSION_W 16
42#define PAYLOADDIMENSION_W 2032
43#define PAYLOADMAXSPACE_W 2028
44
45// ---- CHARGE CONSTANTS -----
46#define CHARGE_CONST 150
47#define CHARGE_RAND_MAX 400
48
49using namespace o2::raw;
50
51namespace o2
52{
53
54namespace hmpid
55{
56
58{
59 public:
62
63 RawFileWriter mWriter{"HMP", false};
64
65 private:
66 // The standard definition of HMPID equipments at P2
67 // const int mEqIds[Geo::MAXEQUIPMENTS] = {0, 1, 2, 3, 4, 5, 8, 9, 6, 7, 10, 11, 12, 13};
68 // const int mCruIds[Geo::MAXEQUIPMENTS] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3};
69 // const int mLinkIds[Geo::MAXEQUIPMENTS] = {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 0, 1, 2};
70 // const int mFlpIds[Geo::MAXEQUIPMENTS] = {160, 160, 160, 160, 160, 160, 160, 160, 161, 161, 161, 161, 161, 161};
71
72 uint32_t* mPayloadBufferPtr;
73 uint32_t* mPadMap;
74 int mEventSizePerEquipment[Geo::MAXEQUIPMENTS];
75 int mEventPadsPerEquipment[Geo::MAXEQUIPMENTS];
76 int mPayloadBufferDimPerEquipment;
77 long mPadsCoded;
78 bool mSkipEmptyEvents;
79 std::unique_ptr<uint32_t[]> mUPayloadBufferPtr;
80 std::unique_ptr<uint32_t[]> mUPadMap;
81
83
84 int mBusyTime;
85 int mHmpidErrorFlag;
86 int mHmpidFrwVersion;
87
88 public:
89 HmpidCoder2(int numOfEquipments);
90 virtual ~HmpidCoder2() = default;
91
92 void setVerbosity(int Level)
93 {
94 mVerbose = Level;
95 };
97 {
98 return (mVerbose);
99 };
101 {
102 return (mNumberOfEquipments);
103 };
104 void setSkipEmptyEvents(bool Skip)
105 {
106 mSkipEmptyEvents = Skip;
107 }
109 {
110 return (mSkipEmptyEvents);
111 }
113
114 void setDetectorSpecificFields(float BusyTime = 0.001, int Error = 0, int Version = 9);
115 void openOutputStream(const std::string& outputFileName, const std::string& fileFor);
116 void closeOutputStream();
117
118 void codeEventChunkDigits(std::vector<o2::hmpid::Digit>& digits, InteractionRecord ir);
119 void dumpResults(const std::string& outputFileName);
120
121 private:
122 int getEquipmentPadIndex(int eq, int col, int dil, int cha);
123 void fillTheOutputBuffer(uint32_t* padMap);
124 void writePaginatedEvent(uint32_t orbit, uint16_t bc);
125 void setRDHFields(int eq = -1);
126};
127
128} // namespace hmpid
129} // namespace o2
130
131#endif /* COMMON_HMPIDCODER_H_ */
uint64_t orbit
Definition RawEventData.h:6
uint64_t bc
Definition RawEventData.h:5
Definition of the RAW Data Header.
uint32_t col
Definition RawData.h:4
Utility class to write detectors data to (multiple) raw data file(s) respecting CRU format.
static constexpr int MAXEQUIPMENTS
Definition Geo.h:79
void codeEventChunkDigits(std::vector< o2::hmpid::Digit > &digits, InteractionRecord ir)
o2::raw::RawFileWriter & getWriter()
void dumpResults(const std::string &outputFileName)
Dumps the results of the last coding.
RawFileWriter mWriter
Definition HmpidCoder2.h:63
void setSkipEmptyEvents(bool Skip)
void setDetectorSpecificFields(float BusyTime=0.001, int Error=0, int Version=9)
void openOutputStream(const std::string &outputFileName, const std::string &fileFor)
void closeOutputStream()
Close and flush the output streams.
virtual ~HmpidCoder2()=default
void setVerbosity(int Level)
Definition HmpidCoder2.h:92
uint32_t LinkSubSpec_t
Definition RDHUtils.h:34
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
o2::InteractionRecord ir(0, 0)
std::vector< Digit > digits