171 {
172 LArDigitContainer* digits=nullptr;
173 LArCalibDigitContainer* cdigits=nullptr;
174 LArAccumulatedDigitContainer* accdigits=nullptr;
175 LArAccumulatedCalibDigitContainer* caccdigits=nullptr;
176 LArFebHeaderContainer* febHeaders=nullptr;
177
179 SG::WriteHandle<LArDigitContainer> digitsHdl(
m_DigitKey,ctx);
180 ATH_CHECK(digitsHdl.record(std::make_unique<LArDigitContainer>()));
181 digits=digitsHdl.ptr();
183 }
184
186 SG::WriteHandle<LArCalibDigitContainer> cdigitsHdl(
m_calibDigitKey,ctx);
187 ATH_CHECK(cdigitsHdl.record(std::make_unique<LArCalibDigitContainer>()));
188 cdigits=cdigitsHdl.ptr();
190 }
191
193 SG::WriteHandle<LArAccumulatedDigitContainer> accdigitsHdl(
m_accDigitKey,ctx);
194 ATH_CHECK(accdigitsHdl.record(std::make_unique<LArAccumulatedDigitContainer>()));
195 accdigits=accdigitsHdl.ptr();
197 }
198
200 SG::WriteHandle<LArAccumulatedCalibDigitContainer> caccdigitsHdl(
m_accCalibDigitKey,ctx);
201 ATH_CHECK(caccdigitsHdl.record(std::make_unique<LArAccumulatedCalibDigitContainer>()));
202 caccdigits=caccdigitsHdl.ptr();
204 }
205
207 SG::WriteHandle<LArFebHeaderContainer> febHeadersHdl(
m_febHeaderKey,ctx);
208 ATH_CHECK(febHeadersHdl.record(std::make_unique<LArFebHeaderContainer>()));
209 febHeaders=febHeadersHdl.ptr();
211 }
212
213
215 std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> > rawEventTOC;
216 eformat::helper::build_toc(*fullEvent, rawEventTOC);
217 auto larRobs=rawEventTOC.find(eformat::LAR);
218 if (larRobs==rawEventTOC.end()) {
220 return StatusCode::SUCCESS;
221 }
222
223
224 std::unique_ptr<LArRodBlockStructure> rodBlock;
227
228 const LArCalibLineMapping *calibMap=nullptr;
230 SG::ReadCondHandle<LArCalibLineMapping> clHdl{
m_CLKey,ctx};
231 calibMap = *clHdl;
232 if(!calibMap) {
234 return StatusCode::FAILURE;
235 }
236 }
237
238 for (const uint32_t* robPtr : larRobs->second) {
240 ATH_MSG_VERBOSE(
"Decoding ROB fragment 0x" << std::hex << rob.rob_source_id () <<
" with " << std::dec << rob.rod_fragment_size_word() <<
"ROB words");
241
242 if (rob.rod_fragment_size_word() <3) {
243 ATH_MSG_ERROR(
"Encountered corrupt ROD fragment, less than 3 words!");
245 return StatusCode::FAILURE;
246 }else
247 continue;
248 }else if(rob.rob_source_id()& 0x1000 ){
249 ATH_MSG_VERBOSE(
" skip Latome fragment with source ID "<< std::hex << rob.rob_source_id());
250 rodBlock=nullptr;
251 continue;
252 }
253
254 eformat::helper::Version
ver(rob.rod_version());
255
256 if (rodBlock==
nullptr || rodMinorVersion !=
ver.minor_version() || rodBlockType!=(rob.rod_detev_type()&0xff)) {
257 rodMinorVersion=
ver.minor_version();
258 rodBlockType=rob.rod_detev_type()&0xff;
259 ATH_MSG_VERBOSE(
"Found version " << rodMinorVersion <<
" of Rod Block Type " << rodBlockType);
260 if (rodBlockType==10) {
261 rodBlock.reset(new LArRodBlockAccumulatedV3);
262 }
263 else if (rodBlockType==7 || rodBlockType==2) {
264 if(rodMinorVersion>=6) {
265 rodBlock.reset(new LArRodBlockCalibrationV3);
266 } else {
267 ATH_MSG_ERROR(
"Found unsupported ROD Block version " << rodMinorVersion
268 << " of ROD block type " << rodBlockType);
270 }
271 } else {
272 ATH_MSG_ERROR(
"Found unsupported Rod block type " << rodBlockType <<
" in ROB sourceId: 0x" << std::hex << rob.rob_source_id () << std::dec
273 << ", ROD source ID: 0x" << rob.rod_source_id() << std::dec);
275 return StatusCode::FAILURE;
276 else
277 continue;
278 }
279 }
280
281 const uint32_t* pData=rob.rod_data();
282 const uint32_t nData=rob.rod_ndata();
283 if (!rodBlock->setFragment(pData,nData)) {
284 ATH_MSG_ERROR(
"Failed to assign fragment pointer to LArRodBlockStructure");
285 return StatusCode::FAILURE;
286 }
287
289 const uint32_t onsum = rodBlock->onlineCheckSum();
290 const uint32_t offsum = rodBlock->offlineCheckSum();
291 if(onsum!=offsum) {
294 ATH_MSG_ERROR(
"offline checksum = 0x" << MSG::hex << offsum << MSG::dec);
296 return StatusCode::FAILURE;
297 else
298 continue;
299 }
300 }
301
302
303 do {
304 HWIdentifier fId(Identifier32(rodBlock->getFEBID()));
306 ATH_MSG_ERROR(
"Invalid FEB identifer 0x" << std::hex << fId.get_identifier32().get_compact());
308 return StatusCode::FAILURE;
309 else
310 continue;
311 }
312
314 const auto ftId=
m_onlineId->feedthrough_Id(fId);
316 ATH_MSG_DEBUG(
"Feedthrough with id 0x" << MSG::hex << ftId << MSG::dec <<
" not in preselection. Ignored.");
317 continue;
318 }
319 }
320
321
322 const int NthisFebChannel=
m_onlineId->channelInSlotMax(fId);
323
324
327 int fcNb;
328 std::vector<short> samples;
329 while (rodBlock->getNextRawData(fcNb,samples,gain)) {
330 if (fcNb>=NthisFebChannel)
331 continue;
332 if (samples.size()==0) continue;
333 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
335 samples.clear();
336 }
337 }
338
339
344 bool ispulsed;
345 int fcNb;
346 std::vector<short> samples;
347 while (rodBlock->getNextRawData(fcNb,samples,gain)) {
348 if (fcNb>=NthisFebChannel)
349 continue;
350 if (samples.size()==0) continue;
351 dac = rodBlock->getDAC();
352 delay = rodBlock->getDelay();
353 ispulsed = rodBlock->getPulsed(fcNb);
354 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
356 samples.clear();
357 }
358 }
359
360
363 int fcNb;
364 std::vector<uint64_t> samplesSum;
365 std::vector<uint64_t> samples2Sum;
367 while (rodBlock->getNextAccumulatedDigit(fcNb,samplesSum,samples2Sum,gain)) {
368 if (fcNb>=NthisFebChannel)
369 continue;
370 if (samplesSum.size()==0 || samples2Sum.size()==0) continue;
371 nTrigger = rodBlock->getNTrigger();
372 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
374 samplesSum.clear();
375 samples2Sum.clear();
376 }
377 }
378
379
387 bool ispulsed=false;
389 unsigned bitShift;
390 int fcNb;
391 std::vector<uint64_t> samplesSum;
392 std::vector<uint64_t> samples2Sum;
394 while (rodBlock->getNextAccumulatedCalibDigit(fcNb,samplesSum,samples2Sum,itmp,gain)) {
395 if (fcNb>=NthisFebChannel)
396 continue;
397 if (samplesSum.size()==0 || samples2Sum.size()==0) continue;
398 ispulsed_int=0;
399 bitShift=0;
400 dac = rodBlock->getDAC();
401 delay = rodBlock->getDelay();
402 nTrigger = rodBlock->getNTrigger();
403 nstep = rodBlock->getNStep();
404 istep = rodBlock->getStepIndex();
405 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
406 const std::vector<HWIdentifier>& calibChannelIDs = calibMap->
calibSlotLine(cId);
407 for(std::vector<HWIdentifier>::const_iterator csl_it=calibChannelIDs.begin(); csl_it!=calibChannelIDs.end();++csl_it){
409 ispulsed=rodBlock->getPulsed(calibLine);
410 ispulsed_int=( ispulsed_int | ((
uint16_t)ispulsed<<bitShift) );
411 bitShift++;
412 }
413 caccdigits->
emplace_back(
new LArAccumulatedCalibDigit(cId, (
CaloGain::CaloGain)gain, std::move(samplesSum), std::move(samples2Sum), nTrigger, dac,
delay, ispulsed_int, nstep, istep));
414 }
416 }
417
418
420 std::unique_ptr<LArFebHeader> larFebHeader(new LArFebHeader(fId));
422 febHeaders->
push_back(std::move(larFebHeader));
423 }
424
425 }while (rodBlock->nextFEB());
426 }
427 return StatusCode::SUCCESS;
428}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
double delay(std::size_t d)
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type emplace_back(value_type pElem)
Add an element to the end of the collection.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void setDelayScale(const double scale)
set the delay Scale
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
SG::WriteHandleKey< LArAccumulatedCalibDigitContainer > m_accCalibDigitKey
BooleanProperty m_failOnCorruption
BooleanProperty m_verifyChecksum
SG::WriteHandleKey< LArDigitContainer > m_DigitKey
ServiceHandle< IROBDataProviderSvc > m_robDataProviderSvc
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
SG::WriteHandleKey< LArAccumulatedDigitContainer > m_accDigitKey
DoubleProperty m_delayScale
SG::WriteHandleKey< LArFebHeaderContainer > m_febHeaderKey
const LArOnlineID * m_onlineId
std::set< HWIdentifier > m_vFinalPreselection
SG::WriteHandleKey< LArCalibDigitContainer > m_calibDigitKey
eformat::ROBFragment< PointerType > ROBFragment