Skip to content

Commit 2d52078

Browse files
authored
[EMCAL-682,EMCAL-660,EMCAL-650] Discarding empty links in raw payload (#5517)
* [EMCAL-682,EMCAL-660,EMCAL-650] Discarding empty links in raw payload * Moving link assignment and online IDs to Geometery * Remove the include Geometry
1 parent 70c2823 commit 2d52078

4 files changed

Lines changed: 91 additions & 55 deletions

File tree

Detectors/EMCAL/base/include/EMCALBase/Geometry.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,21 @@ class Geometry
501501
/// \throw InvalidCellIDException if cell ID does not exist
502502
math_utils::Point3D<double> RelPosCellInSModule(Int_t absId) const;
503503

504+
/// \brief Get link ID, row and column from cell ID, have a look here: https://alice.its.cern.ch/jira/browse/EMCAL-660
505+
/// \param towerID Cell ID
506+
/// \return link ID
507+
/// \return row
508+
/// \return col
509+
std::tuple<int, int, int> getOnlineID(int towerID);
510+
511+
/// \brief Temporary link assignment (till final link assignment is known -
512+
/// \brief eventually taken from CCDB)
513+
/// \brief Current mapping can be found under https://alice.its.cern.ch/jira/browse/EMCAL-660
514+
/// \param ddlID DDL ID
515+
/// \return CRORC ID
516+
/// \return CRORC Link
517+
std::tuple<int, int> getLinkAssignment(int ddlID) const { return std::make_tuple(mCRORCID[ddlID / 2], mCRORCLink[ddlID]); };
518+
504519
std::vector<EMCALSMType> GetEMCSystem() const { return mEMCSMSystem; } // EMC System, SM type list
505520
// Local Coordinates of SM
506521
std::vector<Double_t> GetCentersOfCellsEtaDir() const
@@ -670,6 +685,9 @@ class Geometry
670685

671686
Float_t mSteelFrontThick; ///< Thickness of the front stell face of the support box - 9-sep-04; obsolete?
672687

688+
std::array<int, 20> mCRORCID = {110, 112, 110, 112, 110, 112, 111, 113, 111, 113, 111, 113, 114, 116, 114, 116, 115, 117, 115, 117}; // CRORC ID w.r.t SM
689+
std::array<int, 40> mCRORCLink = {0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 0, 1, 0, 1, 2, 3, 2, 3, 4, -1, 4, 5, 0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, -1}; // CRORC limk w.r.t FEE ID
690+
673691
mutable const TGeoHMatrix* SMODULEMATRIX[EMCAL_MODULES]; ///< Orientations of EMCAL super modules
674692
std::vector<std::tuple<int, int, int, int>> mCellIndexLookup; ///< Lookup table for cell indices
675693

Detectors/EMCAL/base/src/Geometry.cxx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,3 +1762,28 @@ std::tuple<double, double> Geometry::GetPhiBoundariesOfSMGap(Int_t nPhiSec) cons
17621762
}
17631763
return std::make_tuple(mPhiBoundariesOfSM[2 * nPhiSec + 1], mPhiBoundariesOfSM[2 * nPhiSec + 2]);
17641764
}
1765+
1766+
std::tuple<int, int, int> Geometry::getOnlineID(int towerID)
1767+
{
1768+
auto cellindex = GetCellIndex(towerID);
1769+
auto supermoduleID = std::get<0>(cellindex);
1770+
auto etaphi = GetCellPhiEtaIndexInSModule(supermoduleID, std::get<1>(cellindex), std::get<2>(cellindex), std::get<3>(cellindex));
1771+
auto etaphishift = ShiftOfflineToOnlineCellIndexes(supermoduleID, std::get<0>(etaphi), std::get<1>(etaphi));
1772+
int row = std::get<0>(etaphishift), col = std::get<1>(etaphishift);
1773+
1774+
int ddlInSupermoudel = -1;
1775+
if (0 <= row && row < 8) {
1776+
ddlInSupermoudel = 0; // first cable row
1777+
} else if (8 <= row && row < 16 && 0 <= col && col < 24) {
1778+
ddlInSupermoudel = 0; // first half;
1779+
} else if (8 <= row && row < 16 && 24 <= col && col < 48) {
1780+
ddlInSupermoudel = 1; // second half;
1781+
} else if (16 <= row && row < 24) {
1782+
ddlInSupermoudel = 1; // third cable row
1783+
}
1784+
if (supermoduleID % 2 == 1) {
1785+
ddlInSupermoudel = 1 - ddlInSupermoudel; // swap for odd=C side, to allow us to cable both sides the same
1786+
}
1787+
1788+
return std::make_tuple(supermoduleID * 2 + ddlInSupermoudel, row, col);
1789+
}

Detectors/EMCAL/simulation/include/EMCALSimulation/RawWriter.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ namespace emcal
3535
{
3636

3737
class Geometry;
38-
3938
struct AltroBunch {
4039
int mStarttime;
4140
std::vector<int> mADCs;
@@ -104,11 +103,9 @@ class RawWriter
104103

105104
protected:
106105
std::vector<AltroBunch> findBunches(const std::vector<o2::emcal::Digit*>& channelDigits);
107-
std::tuple<int, int, int> getOnlineID(int towerID);
108-
std::tuple<int, int> getLinkAssignment(int ddlID);
109106

110107
ChannelHeader createChannelHeader(int hardwareAddress, int payloadSize, bool isBadChannel);
111-
std::vector<char> createRCUTrailer(int payloadsize, int feca, int fecb, double timesample, uint64_t triggertime);
108+
std::vector<char> createRCUTrailer(int payloadsize, double timesample, uint64_t triggertime, int feeID);
112109
std::vector<int> encodeBunchData(const std::vector<int>& data);
113110

114111
private:

Detectors/EMCAL/simulation/src/RawWriter.cxx

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,31 @@ void RawWriter::init()
2424
{
2525
mRawWriter = std::make_unique<o2::raw::RawFileWriter>(o2::header::gDataOriginEMC, false);
2626
mRawWriter->setCarryOverCallBack(this);
27+
28+
// initialize mappers
29+
if (!mMappingHandler) {
30+
mMappingHandler = std::make_unique<o2::emcal::MappingHandler>();
31+
}
32+
2733
for (auto iddl = 0; iddl < 40; iddl++) {
2834
// For EMCAL set
2935
// - FEE ID = DDL ID
3036
// - C-RORC and link increasing with DDL ID
3137
// @TODO replace with link assignment on production FLPs,
3238
// eventually storing in CCDB
33-
auto [crorc, link] = getLinkAssignment(iddl);
39+
40+
// initialize containers for SRU
41+
SRUDigitContainer srucont;
42+
srucont.mSRUid = iddl;
43+
mSRUdata.push_back(srucont);
44+
45+
// Skip empty links with these ddl IDs,
46+
// ddl ID 21 and 39 are empty links, while 23 and 36 are connected to LEDmon only
47+
if (iddl == 21 || iddl == 22 || iddl == 36 || iddl == 39) {
48+
continue;
49+
}
50+
51+
auto [crorc, link] = mGeometry->getLinkAssignment(iddl);
3452
std::string rawfilename = mOutputLocation;
3553
switch (mFileFor) {
3654
case FileFor_t::kFullDet:
@@ -51,17 +69,6 @@ void RawWriter::init()
5169
}
5270
mRawWriter->registerLink(iddl, crorc, link, 0, rawfilename.data());
5371
}
54-
// initialize mappers
55-
if (!mMappingHandler) {
56-
mMappingHandler = std::make_unique<o2::emcal::MappingHandler>();
57-
}
58-
59-
// initialize containers for SRU
60-
for (auto isru = 0; isru < 40; isru++) {
61-
SRUDigitContainer srucont;
62-
srucont.mSRUid = isru;
63-
mSRUdata.push_back(srucont);
64-
}
6572
}
6673

6774
void RawWriter::digitsToRaw(gsl::span<o2::emcal::Digit> digitsbranch, gsl::span<o2::emcal::TriggerRecord> triggerbranch)
@@ -86,7 +93,7 @@ bool RawWriter::processTrigger(const o2::emcal::TriggerRecord& trg)
8693
if (tower > 20000) {
8794
std::cout << "Wrong cell ID " << tower << std::endl;
8895
}
89-
auto onlineindices = getOnlineID(tower);
96+
auto onlineindices = mGeometry->getOnlineID(tower);
9097
int sruID = std::get<0>(onlineindices);
9198
auto towerdata = mSRUdata[sruID].mChannels.find(tower);
9299
if (towerdata == mSRUdata[sruID].mChannels.end()) {
@@ -115,6 +122,10 @@ bool RawWriter::processTrigger(const o2::emcal::TriggerRecord& trg)
115122

116123
std::vector<char> payload; // this must be initialized per SRU, becuase pages are per SRU, therefore the payload was not reset.
117124

125+
if (srucont.mSRUid == 21 || srucont.mSRUid == 22 || srucont.mSRUid == 36 || srucont.mSRUid == 39) {
126+
continue;
127+
}
128+
118129
for (const auto& [tower, channel] : srucont.mChannels) {
119130
// Find out hardware address of the channel
120131
auto hwaddress = mMappingHandler->getMappingForDDL(srucont.mSRUid).getHardwareAddress(channel.mRow, channel.mCol, ChannelType_t::HIGH_GAIN); // @TODO distinguish between high- and low-gain cells
@@ -159,14 +170,14 @@ bool RawWriter::processTrigger(const o2::emcal::TriggerRecord& trg)
159170
}
160171

161172
// Create RCU trailer
162-
auto trailerwords = createRCUTrailer(payload.size() / 4, 16, 16, 100., trg.getBCData().toLong());
173+
auto trailerwords = createRCUTrailer(payload.size() / 4, 100., trg.getBCData().toLong(), srucont.mSRUid);
163174
for (auto word : trailerwords) {
164175
payload.emplace_back(word);
165176
}
166177

167178
// register output data
168179
auto ddlid = srucont.mSRUid;
169-
auto [crorc, link] = getLinkAssignment(ddlid);
180+
auto [crorc, link] = mGeometry->getLinkAssignment(ddlid);
170181
LOG(DEBUG1) << "Adding payload with size " << payload.size() << " (" << payload.size() / 4 << " ALTRO words)";
171182
mRawWriter->addData(ddlid, crorc, link, 0, trg.getBCData(), payload, false, trg.getTriggerBits());
172183
}
@@ -212,39 +223,6 @@ std::vector<AltroBunch> RawWriter::findBunches(const std::vector<o2::emcal::Digi
212223
return result;
213224
}
214225

215-
std::tuple<int, int, int> RawWriter::getOnlineID(int towerID)
216-
{
217-
auto cellindex = mGeometry->GetCellIndex(towerID);
218-
auto supermoduleID = std::get<0>(cellindex);
219-
auto etaphi = mGeometry->GetCellPhiEtaIndexInSModule(supermoduleID, std::get<1>(cellindex), std::get<2>(cellindex), std::get<3>(cellindex));
220-
auto etaphishift = mGeometry->ShiftOfflineToOnlineCellIndexes(supermoduleID, std::get<0>(etaphi), std::get<1>(etaphi));
221-
int row = std::get<0>(etaphishift), col = std::get<1>(etaphishift);
222-
223-
int ddlInSupermoudel = -1;
224-
if (0 <= row && row < 8) {
225-
ddlInSupermoudel = 0; // first cable row
226-
} else if (8 <= row && row < 16 && 0 <= col && col < 24) {
227-
ddlInSupermoudel = 0; // first half;
228-
} else if (8 <= row && row < 16 && 24 <= col && col < 48) {
229-
ddlInSupermoudel = 1; // second half;
230-
} else if (16 <= row && row < 24) {
231-
ddlInSupermoudel = 1; // third cable row
232-
}
233-
if (supermoduleID % 2 == 1) {
234-
ddlInSupermoudel = 1 - ddlInSupermoudel; // swap for odd=C side, to allow us to cable both sides the same
235-
}
236-
237-
return std::make_tuple(supermoduleID * 2 + ddlInSupermoudel, row, col);
238-
}
239-
240-
std::tuple<int, int> RawWriter::getLinkAssignment(int ddlID)
241-
{
242-
// Temporary link assignment (till final link assignment is known -
243-
// eventually taken from CCDB)
244-
// - Link (0-5) and C-RORC ID linear with ddlID
245-
return std::make_tuple(ddlID / 6, ddlID % 6);
246-
}
247-
248226
std::vector<int> RawWriter::encodeBunchData(const std::vector<int>& data)
249227
{
250228
std::vector<int> encoded;
@@ -286,13 +264,31 @@ ChannelHeader RawWriter::createChannelHeader(int hardwareAddress, int payloadSiz
286264
return header;
287265
}
288266

289-
std::vector<char> RawWriter::createRCUTrailer(int payloadsize, int feca, int fecb, double timesample, uint64_t triggertime)
267+
std::vector<char> RawWriter::createRCUTrailer(int payloadsize, double timesample, uint64_t triggertime, int feeID)
290268
{
291269
RCUTrailer trailer;
292-
trailer.setActiveFECsA(feca);
293-
trailer.setActiveFECsB(fecb);
294270
trailer.setPayloadSize(payloadsize);
295271
trailer.setTimeSamplePhaseNS(triggertime, timesample);
272+
273+
// You can find details about these settings here https://alice.its.cern.ch/jira/browse/EMCAL-650
274+
trailer.setRCUID(feeID);
275+
trailer.setFirmwareVersion(2);
276+
trailer.setActiveFECsA(0x0);
277+
trailer.setActiveFECsB(0x1);
278+
trailer.setBaselineCorrection(0);
279+
trailer.setPolarity(false);
280+
trailer.setNumberOfPresamples(0);
281+
trailer.setNumberOfPostsamples(0);
282+
trailer.setSecondBaselineCorrection(false);
283+
trailer.setGlitchFilter(0);
284+
trailer.setNumberOfNonZeroSuppressedPostsamples(1);
285+
trailer.setNumberOfNonZeroSuppressedPresamples(1);
286+
trailer.setNumberOfPretriggerSamples(0);
287+
trailer.setNumberOfSamplesPerChannel(15);
288+
trailer.setZeroSuppression(true);
289+
trailer.setSparseReadout(true);
290+
trailer.setNumberOfAltroBuffers(RCUTrailer::BufferMode_t::NBUFFERS4);
291+
296292
auto trailerwords = trailer.encode();
297293
std::vector<char> encoded(trailerwords.size() * sizeof(uint32_t));
298294
memcpy(encoded.data(), trailerwords.data(), trailerwords.size() * sizeof(uint32_t));

0 commit comments

Comments
 (0)