@@ -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
6774void 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-
248226std::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