169 {
170 LArDigitContainer* digits=nullptr;
171 LArCalibDigitContainer* cdigits=nullptr;
172 LArAccumulatedDigitContainer* accdigits=nullptr;
173 LArAccumulatedCalibDigitContainer* caccdigits=nullptr;
174 LArFebHeaderContainer* febHeaders=nullptr;
175
177 SG::WriteHandle<LArDigitContainer> digitsHdl(
m_DigitKey,ctx);
178 ATH_CHECK(digitsHdl.record(std::make_unique<LArDigitContainer>()));
179 digits=digitsHdl.ptr();
181 }
182
184 SG::WriteHandle<LArCalibDigitContainer> cdigitsHdl(
m_calibDigitKey,ctx);
185 ATH_CHECK(cdigitsHdl.record(std::make_unique<LArCalibDigitContainer>()));
186 cdigits=cdigitsHdl.ptr();
188 }
189
191 SG::WriteHandle<LArAccumulatedDigitContainer> accdigitsHdl(
m_accDigitKey,ctx);
192 ATH_CHECK(accdigitsHdl.record(std::make_unique<LArAccumulatedDigitContainer>()));
193 accdigits=accdigitsHdl.ptr();
195 }
196
198 SG::WriteHandle<LArAccumulatedCalibDigitContainer> caccdigitsHdl(
m_accCalibDigitKey,ctx);
199 ATH_CHECK(caccdigitsHdl.record(std::make_unique<LArAccumulatedCalibDigitContainer>()));
200 caccdigits=caccdigitsHdl.ptr();
202 }
203
205 SG::WriteHandle<LArFebHeaderContainer> febHeadersHdl(
m_febHeaderKey,ctx);
206 ATH_CHECK(febHeadersHdl.record(std::make_unique<LArFebHeaderContainer>()));
207 febHeaders=febHeadersHdl.ptr();
209 }
210
211
213 std::map<eformat::SubDetectorGroup, std::vector<const uint32_t*> > rawEventTOC;
214 eformat::helper::build_toc(*fullEvent, rawEventTOC);
215 auto larRobs=rawEventTOC.find(eformat::LAR);
216 if (larRobs==rawEventTOC.end()) {
218 return StatusCode::SUCCESS;
219 }
220
221
222 std::unique_ptr<LArRodBlockStructure> rodBlock;
225
226 const LArCalibLineMapping *calibMap=nullptr;
228 SG::ReadCondHandle<LArCalibLineMapping> clHdl{
m_CLKey,ctx};
229 calibMap = *clHdl;
230 if(!calibMap) {
232 return StatusCode::FAILURE;
233 }
234 }
235
236 for (const uint32_t* robPtr : larRobs->second) {
238 ATH_MSG_VERBOSE(
"Decoding ROB fragment 0x" << std::hex << rob.rob_source_id () <<
" with " << std::dec << rob.rod_fragment_size_word() <<
"ROB words");
239
240 if (rob.rod_fragment_size_word() <3) {
241 ATH_MSG_ERROR(
"Encountered corrupt ROD fragment, less than 3 words!");
243 return StatusCode::FAILURE;
244 }else
245 continue;
246 }else if(rob.rob_source_id()& 0x1000 ){
247 ATH_MSG_VERBOSE(
" skip Latome fragment with source ID "<< std::hex << rob.rob_source_id());
248 rodBlock=nullptr;
249 continue;
250 }
251
252 eformat::helper::Version
ver(rob.rod_version());
253
254 if (rodBlock==
nullptr || rodMinorVersion !=
ver.minor_version() || rodBlockType!=(rob.rod_detev_type()&0xff)) {
255 rodMinorVersion=
ver.minor_version();
256 rodBlockType=rob.rod_detev_type()&0xff;
257 ATH_MSG_VERBOSE(
"Found version " << rodMinorVersion <<
" of Rod Block Type " << rodBlockType);
258 if (rodBlockType==10) {
259 rodBlock.reset(
new LArRodBlockAccumulatedV3 (this->
msgSvc().
get()));
260 }
261 else if (rodBlockType==7 || rodBlockType==2) {
262 if(rodMinorVersion>=6) {
263 rodBlock.reset(
new LArRodBlockCalibrationV3 (this->
msgSvc().
get()));
264 } else {
265 ATH_MSG_ERROR(
"Found unsupported ROD Block version " << rodMinorVersion
266 << " of ROD block type " << rodBlockType);
268 }
269 } else {
270 ATH_MSG_ERROR(
"Found unsupported Rod block type " << rodBlockType <<
" in ROB sourceId: 0x" << std::hex << rob.rob_source_id () << std::dec
271 << ", ROD source ID: 0x" << rob.rod_source_id() << std::dec);
273 return StatusCode::FAILURE;
274 else
275 continue;
276 }
277 }
278
279 const uint32_t* pData=rob.rod_data();
280 const uint32_t nData=rob.rod_ndata();
281 if (!rodBlock->setFragment(pData,nData)) {
282 ATH_MSG_ERROR(
"Failed to assign fragment pointer to LArRodBlockStructure");
283 return StatusCode::FAILURE;
284 }
285
287 const uint32_t onsum = rodBlock->onlineCheckSum();
288 const uint32_t offsum = rodBlock->offlineCheckSum();
289 if(onsum!=offsum) {
292 ATH_MSG_ERROR(
"offline checksum = 0x" << MSG::hex << offsum << MSG::dec);
294 return StatusCode::FAILURE;
295 else
296 continue;
297 }
298 }
299
300
301 do {
302 HWIdentifier fId(Identifier32(rodBlock->getFEBID()));
304 ATH_MSG_ERROR(
"Invalid FEB identifer 0x" << std::hex << fId.get_identifier32().get_compact());
306 return StatusCode::FAILURE;
307 else
308 continue;
309 }
310
312 const auto ftId=
m_onlineId->feedthrough_Id(fId);
314 ATH_MSG_DEBUG(
"Feedthrough with id 0x" << MSG::hex << ftId << MSG::dec <<
" not in preselection. Ignored.");
315 continue;
316 }
317 }
318
319
320 const int NthisFebChannel=
m_onlineId->channelInSlotMax(fId);
321
322
325 int fcNb;
326 std::vector<short> samples;
327 while (rodBlock->getNextRawData(fcNb,samples,gain)) {
328 if (fcNb>=NthisFebChannel)
329 continue;
330 if (samples.size()==0) continue;
331 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
333 samples.clear();
334 }
335 }
336
337
342 bool ispulsed;
343 int fcNb;
344 std::vector<short> samples;
345 while (rodBlock->getNextRawData(fcNb,samples,gain)) {
346 if (fcNb>=NthisFebChannel)
347 continue;
348 if (samples.size()==0) continue;
349 dac = rodBlock->getDAC();
350 delay = rodBlock->getDelay();
351 ispulsed = rodBlock->getPulsed(fcNb);
352 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
354 samples.clear();
355 }
356 }
357
358
361 int fcNb;
362 std::vector<uint64_t> samplesSum;
363 std::vector<uint64_t> samples2Sum;
365 while (rodBlock->getNextAccumulatedDigit(fcNb,samplesSum,samples2Sum,gain)) {
366 if (fcNb>=NthisFebChannel)
367 continue;
368 if (samplesSum.size()==0 || samples2Sum.size()==0) continue;
369 nTrigger = rodBlock->getNTrigger();
370 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
372 samplesSum.clear();
373 samples2Sum.clear();
374 }
375 }
376
377
385 bool ispulsed=false;
387 unsigned bitShift;
388 int fcNb;
389 std::vector<uint64_t> samplesSum;
390 std::vector<uint64_t> samples2Sum;
392 while (rodBlock->getNextAccumulatedCalibDigit(fcNb,samplesSum,samples2Sum,itmp,gain)) {
393 if (fcNb>=NthisFebChannel)
394 continue;
395 if (samplesSum.size()==0 || samples2Sum.size()==0) continue;
396 ispulsed_int=0;
397 bitShift=0;
398 dac = rodBlock->getDAC();
399 delay = rodBlock->getDelay();
400 nTrigger = rodBlock->getNTrigger();
401 nstep = rodBlock->getNStep();
402 istep = rodBlock->getStepIndex();
403 HWIdentifier cId =
m_onlineId->channel_Id(fId,fcNb);
404 const std::vector<HWIdentifier>& calibChannelIDs = calibMap->
calibSlotLine(cId);
405 for(std::vector<HWIdentifier>::const_iterator csl_it=calibChannelIDs.begin(); csl_it!=calibChannelIDs.end();++csl_it){
407 ispulsed=rodBlock->getPulsed(calibLine);
408 ispulsed_int=( ispulsed_int | ((
uint16_t)ispulsed<<bitShift) );
409 bitShift++;
410 }
411 caccdigits->
emplace_back(
new LArAccumulatedCalibDigit(cId, (
CaloGain::CaloGain)gain, std::move(samplesSum), std::move(samples2Sum), nTrigger, dac,
delay, ispulsed_int, nstep, istep));
412 }
414 }
415
416
418 std::unique_ptr<LArFebHeader> larFebHeader(new LArFebHeader(fId));
420 febHeaders->
push_back(std::move(larFebHeader));
421 }
422
423 }while (rodBlock->nextFEB());
424 }
425 return StatusCode::SUCCESS;
426}
#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
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
eformat::ROBFragment< PointerType > ROBFragment