57 static constexpr
int tdcmax_ = 49;
70 : _verbosity(iConfig.getUntrackedParameter<int>(
"Verbosity", 0)),
71 tdc1_(iConfig.getParameter<
vector<int>>(
"tdc1")),
72 tdc2_(iConfig.getParameter<
vector<int>>(
"tdc2")),
73 packHBTDC_(iConfig.getParameter<bool>(
"packHBTDC")),
74 tok_QIE10DigiCollection_(
76 tok_QIE11DigiCollection_(
83 premix_(iConfig.getParameter<bool>(
"premix")) {
84 produces<FEDRawDataCollection>(
"");
85 for (
size_t i = 0;
i <
tdc1_.size();
i++) {
88 <<
" incorrect TDC ranges " <<
i <<
"-th element: " <<
tdc1_.at(
i) <<
", " <<
tdc2_.at(
i) <<
", " <<
tdcmax_;
117 map<int, unique_ptr<HCalFED>> fedMap;
124 if (qie10DigiCollection.isValid()) {
126 for (
unsigned int j = 0;
j < qie10dc.
size();
j++) {
130 int crateId =
eid.crateId();
131 int slotId =
eid.slot();
132 int uhtrIndex = ((slotId & 0xF) << 8) | (crateId & 0xFF);
140 if (!uhtrs.exist(uhtrIndex)) {
141 uhtrs.newUHTR(uhtrIndex, presamples);
143 uhtrs.addChannel(uhtrIndex, qiedf, readoutMap,
_verbosity);
151 if (qie11DigiCollection.isValid()) {
153 for (
unsigned int j = 0;
j < qie11dc.
size();
j++) {
157 int crateId =
eid.crateId();
158 int slotId =
eid.slot();
159 int uhtrIndex = ((slotId & 0xF) << 8) | (crateId & 0xFF);
166 if (!uhtrs.exist(uhtrIndex)) {
167 uhtrs.newUHTR(uhtrIndex, presamples);
169 uhtrs.addChannel(uhtrIndex, qiedf, readoutMap,
_verbosity);
176 if (hfDigiCollection.isValid()) {
179 DetId detid = qiedf->id();
182 int crateId =
eid.crateId();
183 int slotId =
eid.slot();
184 int uhtrIndex = (crateId & 0xFF) | ((slotId & 0xF) << 8);
185 int presamples = qiedf->presamples();
187 if (!uhtrs.exist(uhtrIndex)) {
188 uhtrs.newUHTR(uhtrIndex, presamples);
197 if (hbheDigiCollection.isValid()) {
200 DetId detid = qiedf->id();
203 int crateId =
eid.crateId();
204 int slotId =
eid.slot();
205 int uhtrIndex = (crateId & 0xFF) | ((slotId & 0xF) << 8);
206 int presamples = qiedf->presamples();
208 if (!uhtrs.exist(uhtrIndex)) {
209 uhtrs.newUHTR(uhtrIndex, presamples);
218 if (tpDigiCollection.isValid()) {
221 DetId detid = qiedf->id();
224 int crateId =
eid.crateId();
225 int slotId =
eid.slot();
226 int uhtrIndex = (crateId & 0xFF) | ((slotId & 0xF) << 8);
227 int ilink =
eid.fiberIndex();
228 int itower =
eid.fiberChanId();
229 int channelid = (itower & 0xF) | ((ilink & 0xF) << 4);
230 int presamples = qiedf->presamples();
232 if (!uhtrs.exist(uhtrIndex)) {
233 uhtrs.newUHTR(uhtrIndex, presamples);
235 uhtrs.addChannel(uhtrIndex, qiedf, channelid,
_verbosity);
245 for (UHTRpacker::UHTRMap::iterator uhtr = uhtrs.uhtrs.begin(); uhtr != uhtrs.uhtrs.end(); ++uhtr) {
248 uint64_t crateId = (uhtr->first) & 0xFF;
249 uint64_t slotId = (uhtr->first & 0xF00) >> 8;
251 uhtrs.finalizeHeadTail(&(uhtr->second),
_verbosity);
253 if (fedMap.find(fedId) == fedMap.end()) {
258 fedMap[
fedId]->addUHTR(uhtr->second, crateId, slotId);
266 for (map<
int, unique_ptr<HCalFED>>::iterator fed = fedMap.begin(); fed != fedMap.end(); ++fed) {
267 int fedId = fed->first;
269 auto& rawData = fed_buffers->FEDData(fedId);
270 fed->second->formatFEDdata(rawData);
274 FEDTrailer hcalFEDTrailer(rawData.data() + (rawData.size() - 8));
275 hcalFEDTrailer.
set(rawData.data() + (rawData.size() - 8),
292 desc.
add<vector<int>>(
"tdc1", {8, 14, 15, 17, 8, 14, 15, 17, 8, 14, 14, 17, 8, 14, 14, 17, 8, 13, 14, 16, 8, 13,
293 14, 16, 8, 12, 14, 15, 8, 12, 14, 15, 7, 12, 13, 15, 7, 12, 13, 15, 7, 12, 13, 15,
294 7, 12, 13, 15, 7, 11, 12, 14, 7, 11, 12, 14, 7, 11, 12, 14, 7, 11, 12, 7});
295 desc.
add<vector<int>>(
"tdc2", {10, 16, 17, 19, 10, 16, 17, 19, 10, 16, 16, 19, 10, 16, 16, 19, 10, 15, 16, 18, 10, 15,
296 16, 18, 10, 14, 16, 17, 10, 14, 16, 17, 9, 14, 15, 17, 9, 14, 15, 17, 9, 14, 15, 17,
297 9, 14, 15, 17, 9, 13, 14, 16, 9, 13, 14, 16, 9, 13, 14, 16, 9, 13, 14, 9});
298 desc.
add<
bool>(
"packHBTDC",
true);
305 desc.
add<
bool>(
"premix",
false);
306 descriptions.
add(
"hcalDigiToRawuHTR", desc);
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
EventNumber_t event() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EDGetTokenT< HBHEDigiCollection > tok_HBHEDigiCollection_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
QIE11DataFrame convertHB(QIE11DataFrame qiehe, std::vector< int > const &tdc1, std::vector< int > const &tdc2, const int tdcmax)
#define DEFINE_FWK_MODULE(type)
constexpr uint32_t rawId() const
get the raw id
std::vector< T >::const_iterator const_iterator
static constexpr int tdcmax_
int bunchCrossing() const
constexpr DetId detid() const
Get the detector id.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addDefault(ParameterSetDescription const &psetDescription)
static void set(unsigned char *trailer, uint32_t lenght, uint16_t crc, uint8_t evt_stat, uint8_t tts, bool moreTrailers=false)
Set all fields in the trailer.
constexpr int presamples() const
for backward compatibility
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
const edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > tok_electronicsMap_
~HcalDigiToRawuHTR() override
HcalDigiToRawuHTR(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const_iterator end() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned long long uint64_t
constexpr int presamples() const
for backward compatibility
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const vector< int > tdc1_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Warning, false > LogWarning
Readout chain identification for Hcal.
const edm::EDGetTokenT< HcalDataFrameContainer< QIE11DataFrame > > tok_QIE11DigiCollection_
const edm::EDGetTokenT< HcalTrigPrimDigiCollection > tok_TPDigiCollection_
const edm::EDGetTokenT< HFDigiCollection > tok_HFDigiCollection_
const_iterator begin() const
const vector< int > tdc2_
constexpr DetId detid() const
Get the detector id.
const edm::EDGetTokenT< HcalDataFrameContainer< QIE10DataFrame > > tok_QIE10DigiCollection_