11 #include <type_traits>
14 : base_class(
name, pSvcLocator ),
15 m_bcidAvgKey(
"CaloBCIDAverage"),
17 m_lateInitDone(false), m_nSlots(0)
24 m_autoRetrieveTools =
false;
25 m_checkToolDeps =
false;
46 return StatusCode::SUCCESS;
56 for (
size_t slot = 0; slot <
m_nSlots; ++ slot ) {
72 return StatusCode::SUCCESS;
89 std::vector<IdentifierHash> requestHashIDs;
91 ATH_MSG_DEBUG(
"LArTT requested for event " << context <<
" and RoI " << roi );
94 if (
sc )
return StatusCode::FAILURE;
98 std::lock_guard<std::mutex> getCollClock{
m_hLTCaloSlot.get( context )->mutex };
108 ATH_MSG_DEBUG(
"requestHashIDs.size() in LoadColl = " << requestHashIDs.size() <<
" hash checksum "
112 for(
unsigned int i = 0 ;
i < requestHashIDs.size() ;
i++ )
117 loadedCells.
setMap( *roimap );
121 std::lock_guard<std::mutex> getCollClock{
m_hLTCaloSlot.get( context )->mutex };
122 loadedCells.
setRoIs( requestHashIDs );
124 if (
sc )
return StatusCode::FAILURE;
125 else return StatusCode::SUCCESS;
130 std::vector<const TileCell*>& loadedCells ) {
131 std::vector<IdentifierHash> requestHashIDs;
133 ATH_MSG_DEBUG(
"Tile requested for event " << context <<
" and RoI " << roi );
136 if (
sc )
return StatusCode::FAILURE;
140 std::lock_guard<std::mutex> getCollClock{
m_hLTCaloSlot.get( context )->mutex };
143 ATH_MSG_DEBUG(
"requestHashIDs.size() in LoadColl = " << requestHashIDs.size() <<
" hash checksum "
147 for(
unsigned int i = 0 ;
i < requestHashIDs.size() ;
i++ )
150 size_t listIDsize = requestHashIDs.size();
153 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
155 for (
size_t i = 0;
i < listIDsize; ++
i){
157 const std::vector<TileCellCollection*>::const_iterator
it =
158 (tilecell->
find(requestHashIDs[
i]));
160 if ( col ==
nullptr )
continue;
163 for (;itt!=End;++itt){
165 loadedCells.push_back(
cell );
169 return StatusCode::SUCCESS;
204 return StatusCode::SUCCESS;
210 ATH_MSG_DEBUG(
"Full Col " <<
" requested for event " << context );
219 std::lock_guard<std::mutex> collectionLock { cache->
mutex };
222 if ( cache->
lastFSEvent == context.evt() )
return 0x0;
241 deadHandle = deadHdl.
cptr();
247 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
257 if ( vrodid32fullDet.size() != robFrags.size() ) {
258 ATH_MSG_DEBUG(
"Missing ROBs, requested " << vrodid32fullDet.size() <<
" obtained " << robFrags.size() );
273 ATH_MSG_DEBUG(
"Full Col " <<
" requested for event " << context );
282 std::lock_guard<std::mutex> collectionLock { cache->
mutex };
285 if ( cache->
lastFSEvent == context.evt() )
return 0x0;
312 std::vector<uint32_t> vrodid32lar;
313 std::vector<uint32_t> vrodid32em;
314 std::vector<uint32_t> vrodid32hec;
315 std::vector<uint32_t> vrodid32hec0;
316 std::vector<uint32_t> vrodid32hec1;
317 std::vector<uint32_t> vrodid32hec2;
318 std::vector<uint32_t> vrodid32hec3;
319 std::vector<uint32_t> vrodid32fcalem;
320 std::vector<uint32_t> vrodid32fcalhad;
323 std::vector<uint32_t> vrodid32tile;
324 std::vector<IdentifierHash> rIdstile;
342 auto iii = std::unique_copy(vrodid32tile.begin(),vrodid32tile.end(),
m_vrodid32tile.begin());
343 auto iij = std::unique_copy(rIdstile.begin(),rIdstile.end(),
m_rIdstile.begin());
351 vrodid32lar.insert(vrodid32lar.end(),vrodid32em.begin(),vrodid32em.end());
352 vrodid32hec.insert(vrodid32hec.end(),vrodid32hec0.begin(),vrodid32hec0.end());
353 vrodid32lar.insert(vrodid32lar.end(),vrodid32hec.begin(),vrodid32hec.end());
354 vrodid32lar.insert(vrodid32lar.end(),vrodid32fcalhad.begin(),vrodid32fcalhad.end());
355 vrodid32lar.insert(vrodid32lar.end(),vrodid32fcalem.begin(),vrodid32fcalem.end());
366 unsigned int nFebs=70;
386 for (
size_t slot = 0; slot <
m_nSlots; ++ slot ) {
392 if ( cache->
larContainer->
initialize( **roimap, **onoff, **mcsym, **febrod, **larBadChan, *theCaloDDM).isFailure() )
394 std::vector<CaloCell*> local_cell_copy;
395 local_cell_copy.reserve(200000);
399 cachefullcont->
reserve(190000);
401 for(
unsigned int lcidx=0; lcidx < larcell->size(); lcidx++){
403 unsigned int lccsize = lcc->
size();
404 for(
unsigned int lccidx=0; lccidx<lccsize; lccidx++){
417 if (
good ) local_cell_copy.push_back(
cell );
426 if( tilecell->
initialize().isFailure() )
return 0x1;
427 for (
unsigned int i=0;
i<4;
i++) {
438 for(
unsigned int lcidx=0; lcidx < tilecell->size(); lcidx++){
440 unsigned int lccsize = lcc->
size();
441 for(
unsigned int lccidx=0; lccidx<lccsize; lccidx++){
443 if (
cell ) local_cell_copy.push_back(
cell );
446 int ros = (frag_id >> 8);
448 int drawer = (frag_id & 0xFF);
459 for(
unsigned int i=0;
i<hashMax;
i++){
463 unsigned int localcellMax = local_cell_copy.size();
464 for(
unsigned int i=0;
i<localcellMax;
i++){
465 unsigned int j = local_cell_copy.at(
i)->caloDDE()->calo_hash();
467 cachefullcont->
at(j) = local_cell_copy.at(
i);
470 for(
unsigned int i=0;
i<hashMax;
i++)
471 if ( cachefullcont->
at(
i) == nullptr ){
475 if (
el->is_tile() ) {
491 cachefullcont->
order();
493 if ( hashMax != cachefullcont->
size() )
499 local_cell_copy.clear();
510 for (
auto rob: robFrags ) {
511 uint32_t sourceID = rob->source_id();
512 const std::vector<LArCellCollection*>::const_iterator
it = larcell->
find( sourceID );
515 if (
it != larcell->end() && ( *it )->size() != 0 ) {
520 ATH_MSG_DEBUG(
"ROB of ID " << sourceID <<
" to be decoded" );
528 "event: Bad ROB block ( eformat checks ) : 0x"
529 << std::hex << sourceID << std::dec );
537 rob->rod_data( roddata );
538 size_t roddatasize = rob->rod_ndata();
539 if ( roddatasize < 3 ) {
541 "event: Empty ROD block ( less than 3 words ) : 0x"
542 << std::hex << sourceID << std::dec );
548 m_larDecoder->fillCollectionHLT( *rob, roddata, roddatasize, *coll, larRodBlockStructure_per_slot, rodMinorVersion, robBlockType );
553 for(
size_t i=0;
i<128;
i++) {
583 const std::vector<IdentifierHash>& rIds,
590 size_t listIDsize = rIds.size();
591 std::vector<unsigned int>
tile;
tile.push_back(0);
593 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags1;
594 for (
size_t i = 0;
i < listIDsize; ++
i){
600 const std::vector<TileCellCollection*>::const_iterator
it =
601 (tilecell->
find(rIds[
i]));
603 if ( robFrags1.size()!=0 && col != nullptr ) {
604 size_t roddatasize = robFrags1[0]->rod_ndata();
606 if (roddatasize < 3) {
608 "event: Empty ROD block (less than 3 words) : 0x"
609 << std::hex <<
tile[0] << std::dec );
610 msg(MSG::WARNING) <<
"Error reading bytestream "
611 <<
"event: Empty ROD block (less than 3 words) : 0x"
615 if ( !tilecell->
cached(rIds[
i])){
622 if ( !tilecell->
cached(rIds[
i]))
637 const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>&
response,
638 std::set<uint32_t>& missing )
const {
640 std::set<uint32_t> receivedROBsSet;
642 receivedROBsSet.insert( rob->source_id() );
643 std::set<uint32_t> requestedROBsSet( request.begin(), request.end() );
645 std::set_difference( requestedROBsSet.begin(), requestedROBsSet.end(),
646 receivedROBsSet.begin(), receivedROBsSet.end(),
647 std::inserter( missing, missing.begin() ) );
652 const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>&
response,
654 std::set<uint32_t> missing;
657 const std::vector<LArCellCollection*>::const_iterator
it = larcell->
find( robID );
658 if (
it != larcell->end() && ( *it )->size()!=0 ) {
675 if ( cache->
lastFSEvent == context.evt() )
return 0x0;
677 std::vector<uint32_t> requestROBs;
679 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
693 if ( robFrags.empty() && (!requestROBs.empty()) ) {
698 std::lock_guard<std::mutex> collectionLock { cache->
mutex };
720 deadHandle = deadHdl.
cptr();
726 if ( requestROBs.size() != robFrags.size() ) {
727 ATH_MSG_DEBUG(
"Missing ROBs, requested " << requestROBs.size() <<
" obtained " << robFrags.size() );
747 if ( cache->
lastFSEvent == context.evt() )
return 0x0;
749 std::vector<uint32_t> requestROBs;
750 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
751 std::vector<IdentifierHash> rIds;
760 std::lock_guard<std::mutex> collectionLock { cache->
mutex };
777 if ( cache->
lastFSEvent == context.evt() )
return 0x0;
779 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
784 std::lock_guard<std::mutex> collectionLock { cache->
mutex };
790 const std::vector<unsigned int>*
ids = tilecell->
MBTS_IDs();
791 std::vector<IdentifierHash> tileIds;
792 for(
size_t i=0;
i<
ids->size();
i++) tileIds.push_back( (*
ids)[
i] );
801 std::vector<const TileCell*>& loadedCells ) {
806 if (
sc )
return StatusCode::FAILURE;
809 std::lock_guard<std::mutex> collectionLock { cache->
mutex };
812 loadedCells.reserve(
mbts->size());
813 for (
size_t i=0;
i<
mbts->size(); ++
i)
814 loadedCells.push_back(
mbts->at(
i));
815 return StatusCode::SUCCESS;