Skip to content

Commit 2de6c67

Browse files
MijaTokaIzaakWN
authored andcommitted
Add Econ-T indexer
Add Econ-T indexer Adding Trigger Cell and Module Indexers Add new ESProducer for Trigger ModuleMapping Created copy files to edit for testing porpouses Renaming of the TriggerESProfucer file Change geometry module to make it work in the current branch Firsts edit to Trigger Tester Change class and Module name Add new classes and modules to BuildFiles Corrected a miss naming Adding the files to EDM type lookup Small correctiond to Trigger Tester First debug of EDM EDM error fixed Testing Trigger producer Corrected a bug in the calculation of NTrLinks per for a given module type Changing some comments Change of function name to reflect it being Trigger variant Added a getter that takes a dense TCidx Corrected Typo Added new trig_fed column to module locator and updated Trigger ESProducer to account for that Added HGCalDigiTrigger from hgcal-comm (Buggy) Added new SoA for Trigger Cells Change order of loading of ESProducers Small change in ModuleIndexerTrigger.h Comments and spacing Fix Triger Link Indexing for TM + minor bug fixes (Fixed) Added new SoA for Trigger Modules; Module done, Dense Index to do Module Trigger SoA producer tested Delete unused cff file Add Dense Index Trigger Info Change to the hgcalmapping_cff to allow running of just DAQ module locators. Small change to default module locator trigger for tensting porpuses Add regex for SiPM Tiles in Trigger Index ESProducer Changing comments Code formatting Delete test data Delete references to fantom directories Undo tester changes fix includes & include guards
1 parent aa39901 commit 2de6c67

24 files changed

+1687
-4
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
#ifndef CondFormats_HGCalObjects_interface_HGCalMappingCellTriggerParameterIndex_h
2+
#define CondFormats_HGCalObjects_interface_HGCalMappingCellTriggerParameterIndex_h
3+
4+
#include <iostream>
5+
#include <cstdint>
6+
#include <vector>
7+
#include <numeric>
8+
// #include "DataFormats/HGCalDigi/interface/HGCalElectronicsId.h"
9+
#include "CondFormats/Serialization/interface/Serializable.h"
10+
#include "CondFormats/HGCalObjects/interface/HGCalDenseIndexerBase.h"
11+
12+
/**
13+
@short utility class to assign dense readout trigger cell indexing
14+
*/
15+
class HGCalMappingCellIndexerTrigger {
16+
public:
17+
// typedef HGCalDenseIndexerBase WaferDenseIndexerBase;
18+
19+
HGCalMappingCellIndexerTrigger() = default;
20+
21+
/**
22+
adds to map of type codes (= module types) to handle and updatest the max. number of eRx
23+
*/
24+
void processNewCell(std::string typecode, uint16_t ROC, uint16_t trLink, uint16_t trCell) {
25+
// Skip if trLink, trCell not connected
26+
if (trLink == uint16_t(-1) || trCell == uint16_t(-1))
27+
return;
28+
//assign index to this typecode and resize the max vectors
29+
if (typeCodeIndexer_.count(typecode) == 0) {
30+
typeCodeIndexer_[typecode] = typeCodeIndexer_.size();
31+
maxROC_.resize(typeCodeIndexer_.size(), 0);
32+
maxTrLink_.resize(typeCodeIndexer_.size(), 0);
33+
maxTCPerLink_.resize(typeCodeIndexer_.size(), 0);
34+
}
35+
36+
size_t idx = typeCodeIndexer_[typecode];
37+
38+
/*High density modules have links {0, 2} and low {0, 1, 2, 3} so to make it work I need to divide by 2*/
39+
if (typecode[1] == 'H')
40+
trLink /= 2;
41+
/*SiPM tiles have trCells indexed from 1 instead from 0*/
42+
if (typecode[0] == 'T')
43+
trCell--;
44+
maxROC_[idx] = std::max(maxROC_[idx], static_cast<uint16_t>(ROC + 1));
45+
maxTrLink_[idx] = std::max(maxTrLink_[idx], static_cast<uint16_t>(trLink + 1));
46+
maxTCPerLink_[idx] = std::max(maxTCPerLink_[idx], static_cast<uint16_t>(trCell + 1));
47+
}
48+
49+
/**
50+
@short process the current list of type codes handled and updates the dense indexers
51+
*/
52+
void update() {
53+
uint32_t n = typeCodeIndexer_.size();
54+
offsets_ = std::vector<uint32_t>(n, 0);
55+
di_ = std::vector<HGCalDenseIndexerBase>(n, HGCalDenseIndexerBase(3)); /* The indices are {ROC, trLink, TC}*/
56+
for (uint32_t idx = 0; idx < n; idx++) {
57+
uint16_t maxROCs = maxROC_[idx];
58+
uint16_t maxLinks = maxTrLink_[idx];
59+
uint16_t maxTCPerLink = maxTCPerLink_[idx];
60+
di_[idx].updateRanges({{maxROCs, maxLinks, maxTCPerLink}});
61+
if (idx < n - 1)
62+
offsets_[idx + 1] = di_[idx].getMaxIndex();
63+
}
64+
65+
//accumulate the offsets in the array
66+
std::partial_sum(offsets_.begin(), offsets_.end(), offsets_.begin());
67+
}
68+
69+
/**
70+
@short gets index given typecode string
71+
*/
72+
size_t getEnumFromTypecode(std::string typecode) const {
73+
auto it = typeCodeIndexer_.find(typecode);
74+
if (it == typeCodeIndexer_.end())
75+
throw cms::Exception("ValueError") << " unable to find typecode=" << typecode << " in cell indexer";
76+
return it->second;
77+
}
78+
79+
/**
80+
@short checks if there is a typecode corresponding to an index
81+
*/
82+
std::string getTypecodeFromEnum(size_t idx) const {
83+
for (const auto& it : typeCodeIndexer_)
84+
if (it.second == idx)
85+
return it.first;
86+
throw cms::Exception("ValueError") << " unable to find typecode corresponding to idx=" << idx;
87+
}
88+
89+
/**
90+
@short returns the dense indexer for a typecode
91+
*/
92+
HGCalDenseIndexerBase getDenseIndexFor(std::string typecode) const {
93+
return getDenseIndexerFor(getEnumFromTypecode(typecode));
94+
}
95+
96+
/**
97+
@short returns the dense indexer for a given internal index
98+
*/
99+
HGCalDenseIndexerBase getDenseIndexerFor(size_t idx) const {
100+
if (idx >= di_.size())
101+
throw cms::Exception("ValueError") << " index requested for cell dense indexer (i=" << idx
102+
<< ") is larger than allocated";
103+
return di_[idx];
104+
}
105+
106+
/**
107+
@short builders for the dense index
108+
*/
109+
uint16_t denseIndex(std::string typecode, uint32_t ROC, uint32_t trLink, uint32_t trCell) const {
110+
return denseIndex(getEnumFromTypecode(typecode), ROC, trLink, trCell);
111+
}
112+
uint32_t denseIndex(size_t idx, uint32_t ROC, uint32_t trLink, uint32_t trCell) const {
113+
return di_[idx].denseIndex({{ROC, trLink, trCell}}) + offsets_[idx];
114+
}
115+
116+
/**
117+
@short decodes the dense index code
118+
*/
119+
/* ###############################
120+
Only for Data, Trigger does not have elecId yet
121+
uint32_t elecIdFromIndex(uint32_t rtn, std::string typecode) const {
122+
return elecIdFromIndex(rtn, getEnumFromTypecode(typecode));
123+
}
124+
uint32_t elecIdFromIndex(uint32_t rtn, size_t idx) const {
125+
if (idx >= di_.size())
126+
throw cms::Exception("ValueError") << " index requested for cell dense indexer (i=" << idx
127+
<< ") is larger than allocated";
128+
rtn -= offsets_[idx];
129+
auto rtn_codes = di_[idx].unpackDenseIndex(rtn); // {}
130+
return HGCalElectronicsId(false, 0, 0, 0, rtn_codes[0], rtn_codes[1]).raw();
131+
}
132+
################################*/
133+
134+
/**
135+
@short returns the max. dense index expected
136+
*/
137+
uint32_t maxDenseIndex() const {
138+
size_t i = maxTrLink_.size();
139+
if (i == 0)
140+
return 0;
141+
return offsets_.back() + maxTrLink_.back() * maxTCPerLink_.back();
142+
}
143+
144+
/**
145+
@short gets the number of words (cells) for a given typecode
146+
TODO:(?) For the partials it will give a number rounded to the closest multiple of 16/8 if M[L/H],
147+
ask if this needs correcting or if it is acceptable
148+
e.g.: ML-T has 22 TCs but this will return 32 or MH-T has 19 but it will return 24
149+
*/
150+
size_t getNWordsExpectedFor(std::string typecode) const {
151+
auto it = getEnumFromTypecode(typecode);
152+
return getNWordsExpectedFor(it);
153+
}
154+
size_t getNWordsExpectedFor(size_t typecodeidx) const { return getDenseIndexerFor(typecodeidx).getMaxIndex(); }
155+
156+
/**
157+
@short gets the number of Trigger Links for a given typecode
158+
*/
159+
size_t getNTrLinkExpectedFor(std::string typecode) const {
160+
auto it = getEnumFromTypecode(typecode);
161+
return getNTrLinkExpectedFor(it);
162+
}
163+
size_t getNTrLinkExpectedFor(size_t typecodeidx) const { return maxTrLink_[typecodeidx] * maxROC_[typecodeidx]; }
164+
165+
constexpr static char maxHalfPerROC_ = 2;
166+
// constexpr static uint16_t maxChPerErx_ = 37; //36 channels + 1 calib
167+
// constexpr static uint16_t maxTCPerTrLink_ = 4; // 4 TC per TrLink: Not True for TM
168+
169+
std::map<std::string, size_t> typeCodeIndexer_;
170+
std::vector<uint16_t> maxROC_;
171+
std::vector<uint16_t> maxTrLink_;
172+
std::vector<uint16_t> maxTCPerLink_;
173+
std::vector<uint32_t> offsets_;
174+
std::vector<HGCalDenseIndexerBase> di_;
175+
176+
~HGCalMappingCellIndexerTrigger() {}
177+
178+
COND_SERIALIZABLE;
179+
};
180+
181+
#endif

0 commit comments

Comments
 (0)