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