17 m_autoRetrieveTools =
false;
18 m_checkToolDeps =
false;
39 return StatusCode::SUCCESS;
47 if (cache.larContainer)
ATH_CHECK( cache.larContainer->finalize() );
48 if (cache.tileContainer)
ATH_CHECK( cache.tileContainer->finalize() );
49 if (cache.d0cells) cache.d0cells->clear();
55 return StatusCode::SUCCESS;
60 cell->setEnergyFast(0.0);
67 cell->setTime_nonvirt(-100.0F);
68 cell->setQuality_nonvirt(
static_cast<unsigned char>(255), 0, 0);
69 cell->setQuality_nonvirt(
static_cast<unsigned char>(255), 0, 1);
79 std::vector<IdentifierHash> requestHashIDs;
81 ATH_MSG_DEBUG(
"LArTT requested for event " << context <<
" and RoI " << roi );
96 ATH_MSG_DEBUG(
"requestHashIDs.size() in LoadColl = " << requestHashIDs.size() <<
" hash checksum "
97 << std::accumulate( requestHashIDs.begin(), requestHashIDs.end(),
IdentifierHash( 0 ),
99 if ( msgLvl( MSG::VERBOSE ) ) {
100 for(
unsigned int i = 0 ; i < requestHashIDs.size() ; i++ )
105 loadedCells.
setMap( *roimap );
110 loadedCells.
setRoIs( requestHashIDs );
112 return StatusCode::SUCCESS;
117 std::vector<const TileCell*>& loadedCells ) {
118 std::vector<IdentifierHash> requestHashIDs;
120 ATH_MSG_DEBUG(
"Tile requested for event " << context <<
" and RoI " << roi );
129 ATH_MSG_DEBUG(
"requestHashIDs.size() in LoadColl = " << requestHashIDs.size() <<
" hash checksum "
130 << std::accumulate( requestHashIDs.begin(), requestHashIDs.end(),
IdentifierHash( 0 ),
132 if ( msgLvl( MSG::VERBOSE ) ) {
133 for(
unsigned int i = 0 ; i < requestHashIDs.size() ; i++ )
134 ATH_MSG_VERBOSE(
"requestHashIDs[" << i <<
"]=" << requestHashIDs[i] );
138 const TileCellCont* tilecell = cache->tileContainer.get();
141 for (
size_t i = 0; i < requestHashIDs.size(); ++i){
143 const auto it = tilecell->
find(requestHashIDs[i]);
144 if (it == tilecell->end())
continue;
147 if ( col ==
nullptr )
continue;
150 loadedCells.push_back( cell );
154 return StatusCode::SUCCESS;
176 for(
const CaloCell* c : *cont_to_copy ) {
182 return StatusCode::SUCCESS;
190 ATH_MSG_DEBUG(
"Full Col " <<
" requested for event " << context );
195 std::scoped_lock
lock{cache->mutex};
200 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
201 cache->larContainer->eventNumber( context.evt() ) ;
206 if ( avg.cptr() && onoff.
cptr() ) {
207 cache->larContainer->updateBCID( *avg, **onoff );
217 deadHandle = deadHdl.
cptr();
222 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
226 convertROBs( robFrags, cache->larContainer.get(), cache->larRodBlockStructure_per_slot,
227 cache->rodMinorVersion, cache->robBlockType, deadHandle );
229 if ( vrodid32fullDet.size() != robFrags.size() ) {
230 ATH_MSG_DEBUG(
"Missing ROBs, requested " << vrodid32fullDet.size() <<
" obtained " << robFrags.size() );
231 clearMissing( vrodid32fullDet, robFrags, cache->larContainer.get() );
236 return StatusCode::SUCCESS;
243 ATH_MSG_DEBUG(
"Full Col " <<
" requested for event " << context );
248 std::scoped_lock
lock{cache->mutex};
252 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
253 if ( cache->tileContainer->eventNumber() != context.evt() ) {
254 cache->d0cells->clear();
256 cache->tileContainer->eventNumber( context.evt() );
261 return StatusCode::SUCCESS;
269 std::vector<uint32_t> vrodid32lar;
270 std::vector<uint32_t> vrodid32em;
271 std::vector<uint32_t> vrodid32hec;
272 std::vector<uint32_t> vrodid32hec0;
273 std::vector<uint32_t> vrodid32hec1;
274 std::vector<uint32_t> vrodid32hec2;
275 std::vector<uint32_t> vrodid32hec3;
276 std::vector<uint32_t> vrodid32fcalem;
277 std::vector<uint32_t> vrodid32fcalhad;
280 std::vector<uint32_t> vrodid32tile;
281 std::vector<IdentifierHash> rIdstile;
299 auto iii = std::unique_copy(vrodid32tile.begin(),vrodid32tile.end(),
m_vrodid32tile.begin());
300 auto iij = std::unique_copy(rIdstile.begin(),rIdstile.end(),
m_rIdstile.begin());
308 vrodid32lar.insert(vrodid32lar.end(),vrodid32em.begin(),vrodid32em.end());
309 vrodid32hec.insert(vrodid32hec.end(),vrodid32hec0.begin(),vrodid32hec0.end());
310 vrodid32lar.insert(vrodid32lar.end(),vrodid32hec.begin(),vrodid32hec.end());
311 vrodid32lar.insert(vrodid32lar.end(),vrodid32fcalhad.begin(),vrodid32fcalhad.end());
312 vrodid32lar.insert(vrodid32lar.end(),vrodid32fcalem.begin(),vrodid32fcalem.end());
323 const unsigned int nFebs=70;
324 const unsigned int high_granu = (
unsigned int)ceilf(
m_vrodid32fullDet.size()/((
float)nFebs) );
344 cache.larContainer = std::make_unique<LArCellCont>();
345 cache.larRodBlockStructure_per_slot =
nullptr;
347 cache.larContainer->initialize(**roimap, **onoff, **mcsym, **febrod, **larBadChan, *theCaloDDM).
348 orThrow(
"Cannot initialize LAr container", name());
350 std::vector<CaloCell*> local_cell_copy;
351 local_cell_copy.reserve(200000);
352 const LArCellCont* larcell = cache.larContainer.get();
355 cache.lastFSEvent = 0xFFFFFFFF;
357 cachefullcont->reserve(190000);
359 for(
unsigned int lcidx=0; lcidx < larcell->size(); lcidx++){
361 for(
unsigned int lccidx=0; lccidx<lcc->
size(); lccidx++){
363 if ( cell && cell->caloDDE() ) {
370 if ( !
bad ) local_cell_copy.push_back( cell );
377 auto tilecell = std::make_unique<TileCellCont>();
378 tilecell->setHashIdToROD( *tileHid2RESrcID );
379 tilecell->initialize().orThrow(
"Cannot initialize Tile container", name());
381 for (
unsigned int i=0; i<4; i++) {
385 m_tileDecoder->loadMBTS( tilecell->MBTS_map(), tilecell->MBTS_channel() );
387 const std::vector<unsigned int>* mbts_rods = tilecell->MBTS_RODs();
388 for(
size_t i = 0 ; i < mbts_rods->size(); i++) {
394 auto d0cellsp = std::make_unique<TileROD_Decoder::D0CellsHLT>();
395 for (
unsigned int lcidx=0; lcidx < tilecell->size(); lcidx++){
397 for (
unsigned int lccidx=0; lccidx<lcc->
size(); lccidx++){
399 if ( cell ) local_cell_copy.push_back( cell );
403 const int ros = (frag_id >> 8);
405 const int drawer = (frag_id & 0xFF);
408 d0cellsp->m_cells[drawer] = *pCell;
411 cache.tileContainer = std::move(tilecell);
414 cache.d0cells = std::move(d0cellsp);
417 for(
unsigned int i=0; i<hashMax; i++){
418 cachefullcont->push_back_fast(
nullptr);
421 for(
unsigned int i=0; i<local_cell_copy.size(); i++){
422 unsigned int j = local_cell_copy.at(i)->caloDDE()->calo_hash();
424 cachefullcont->at(j) = local_cell_copy.at(i);
427 for(
unsigned int i=0;i<hashMax;i++)
428 if ( cachefullcont->at(i) ==
nullptr ){
432 if ( el->is_tile() ) {
448 cachefullcont->order();
450 if ( hashMax != cachefullcont->size() ) {
454 cachefullcont->setIsOrdered(
true);
455 cachefullcont->setIsOrderedAndComplete(
true);
456 cache.fullcont = std::move(cachefullcont);
458 local_cell_copy.clear();
465 uint16_t rodMinorVersion, uint32_t robBlockType,
const LArDeadOTXFromSC* deadHandle ) {
467 for (
auto rob: robFrags ) {
468 uint32_t sourceID = rob->source_id();
469 const auto it = larcell->
find( sourceID );
472 if ( it != larcell->end() && ( *it )->size() != 0 ) {
477 ATH_MSG_DEBUG(
"ROB of ID " << sourceID <<
" to be decoded" );
485 "event: Bad ROB block ( eformat checks ) : 0x"
486 << std::hex << sourceID << std::dec );
492 const uint32_t* roddata = 0;
493 rob->rod_data( roddata );
494 const size_t roddatasize = rob->rod_ndata();
495 if ( roddatasize < 3 ) {
497 "event: Empty ROD block ( less than 3 words ) : 0x"
498 << std::hex << sourceID << std::dec );
503 m_larDecoder->fillCollectionHLT( *rob, roddata, roddatasize, *coll, larRodBlockStructure_per_slot, rodMinorVersion, robBlockType );
508 for(
size_t i=0;i<128;i++) {
516 for(
size_t i=0;i<128;i++) {
534 const std::vector<IdentifierHash>& rIds,
541 std::vector<unsigned int> tile{0};
543 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
544 for (
size_t i = 0; i < rIds.size(); ++i){
545 tile[0] = tilecell->
find_rod(rIds[i]);
548 const auto it = tilecell->
find(rIds[i]);
549 if (it == tilecell->end())
continue;
552 if ( !robFrags.empty() && col !=
nullptr ) {
553 const size_t roddatasize = robFrags[0]->rod_ndata();
555 if (roddatasize < 3) {
557 "event: Empty ROD block (less than 3 words) : 0x"
558 << std::hex << tile[0] << std::dec );
559 if ( !tilecell->
cached(rIds[i])){
566 if ( !tilecell->
cached(rIds[i]) ) {
567 m_tileDecoder->fillCollectionHLT(robFrags[0],*col,*d0cells,mbts,hid2re);
579 const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>&
response,
580 std::set<uint32_t>& missing )
const {
582 std::set<uint32_t> receivedROBsSet;
584 receivedROBsSet.insert( rob->source_id() );
587 std::set<uint32_t> requestedROBsSet( request.begin(), request.end() );
588 std::set_difference( requestedROBsSet.begin(), requestedROBsSet.end(),
589 receivedROBsSet.begin(), receivedROBsSet.end(),
590 std::inserter( missing, missing.begin() ) );
595 const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>&
response,
597 std::set<uint32_t> missing;
599 for ( uint32_t robID : missing ) {
600 const auto it = larcell->
find( robID );
601 if ( it != larcell->end() && not (*it)->empty() ) {
617 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
619 std::vector<uint32_t> requestROBs;
621 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
622 switch ( detector ) {
632 if ( robFrags.empty() && !requestROBs.empty() ) {
633 return StatusCode::SUCCESS;
637 std::scoped_lock
lock{cache->mutex};
644 cache->larContainer->eventNumber( context.evt() );
648 if ( avg.cptr() && onoff.
cptr() ) cache->larContainer->updateBCID( *avg, **onoff );
657 deadHandle = deadHdl.
cptr();
661 convertROBs( robFrags, cache->larContainer.get(), cache->larRodBlockStructure_per_slot,
662 cache->rodMinorVersion, cache->robBlockType, deadHandle );
664 if ( requestROBs.size() != robFrags.size() ) {
665 ATH_MSG_DEBUG(
"Missing ROBs, requested " << requestROBs.size() <<
" obtained " << robFrags.size() );
666 clearMissing( requestROBs, robFrags, cache->larContainer.get() );
673 return StatusCode::SUCCESS;
683 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
685 std::vector<uint32_t> requestROBs;
686 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
687 std::vector<IdentifierHash> rIds;
692 std::scoped_lock
lock{cache->mutex};
693 if ( cache->tileContainer->eventNumber() != context.evt() ) {
694 cache->d0cells->clear();
696 cache->tileContainer->eventNumber( context.evt() );
698 convertROBs( context, rIds, cache->tileContainer.get(), cache->d0cells.get() );
700 return StatusCode::SUCCESS;
709 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
711 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
714 std::scoped_lock
lock{cache->mutex};
715 if ( cache->tileContainer->eventNumber() != context.evt() ) {
716 cache->d0cells->clear();
718 cache->tileContainer->eventNumber( context.evt() );
720 const std::vector<unsigned int>* ids = cache->tileContainer->MBTS_IDs();
721 std::vector<IdentifierHash> tileIds;
722 tileIds.reserve(ids->size());
723 for (
size_t i=0; i<ids->size(); i++) {
724 tileIds.push_back( (*ids)[i] );
726 convertROBs( context, tileIds, cache->tileContainer.get(), cache->d0cells.get() );
728 return StatusCode::SUCCESS;
734 std::vector<const TileCell*>& loadedCells ) {
741 std::scoped_lock
lock{cache->mutex};
743 loadedCells.reserve(mbts->size());
744 for (
size_t i=0; i<mbts->size(); ++i) {
745 loadedCells.push_back(mbts->at(i));
748 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Definition of CaloDetDescrManager.
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
LArBadXCont< LArBadChannel > LArBadChannelCont
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Header file to be included by clients of the Monitored infrastructure.
DETID
An enum to define subdetector names.
Container class for CaloCell.
size_type calo_cell_hash_max() const
cell 'global' hash table max size
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
Helper class for offline cell identifiers.
Data object for each calorimeter readout cell.
CaloCellContainer that can accept const cell pointers.
void setIsOrderedAndComplete(bool ordered)
indicate that the container is complete and in order
void setIsOrdered(bool ordered)
indicates that the container is ordered
void push_back_fast(const CaloCell *cell)
reimplementation of push_back to gain speed in readin
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
void clear()
Erase all the elements in the collection.
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
const T * at(size_type n) const
Access an element, as an rvalue.
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
Describes the API of the Region of Ineterest geometry.
virtual double eta() const =0
virtual double phi() const =0
Methods to retrieve data members.
This is a "hash" representation of an Identifier.
bool problematicForUnknownReason() const
bool good() const
Returns true if no problems at all (all bits at zero).
LArBC_t offlineStatus(const Identifier id) const
Query the status of a particular channel by offline ID This is the main client access method.
Container Class for LArCell in a ROB used by EF.
Class which contains statically allocated LArCellCollections.
void applyBCIDCorrection(unsigned int rodid)
method to apply correction based on the luminosity to the energy
HWIdentifier findsec(unsigned int id) const
Each Collection contains data from 2 FEBs.
const std::vector< LArCellCollection * >::const_iterator find(const HWIdentifier &id) const
Finds a collection by its LArReadoutModuleID.
Data object for LAr calorimeter readout cell.
const std::vector< float > & correctionFromThisOTXdead(HWIdentifier febid) const
bool isThisOTXdead(HWIdentifier febid) const
uint32_t getFEBID() const
void setRoIs(const VEC_TT_ID &ids)
void setMap(const LArRoIMap *map)
void setContainer(const CONTAINER *c)
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
const_pointer_type cptr()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
This class builds the Tile cells.
unsigned int find_rod(const unsigned int &id) const
const std::vector< TileCellCollection * >::const_iterator find(const unsigned int &id) const
Finds a collection.
const TileCellCollection * MBTS_collection(void) const
bool cached(const unsigned int &rodid)
const TileHid2RESrcID * getHashIdToROD() const
This class provides conversion between fragment ID and RESrcID.
PublicToolHandle< TileROD_Decoder > m_tileDecoder
std::vector< unsigned int > m_mbts_add_rods
ToolHandle< IRegSelTool > m_regionSelector_TTHEC
SG::ReadCondHandleKey< TileHid2RESrcID > m_tileHid2RESrcIDKey
StatusCode prepareLArFullCollections(const EventContext &context)
SG::ReadHandleKey< CaloBCIDAverage > m_bcidAvgKey
void lateInit(const EventContext &context)
std::mutex m_lardecoderProtect
void reset_TileCol(TileCellCollection *col)
void convertROBs(const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &robFrags, LArCellCont *larcell, LArRodBlockStructure *&larRodBlockStructure, uint16_t rodMinorVersion, uint32_t robBlockType, const LArDeadOTXFromSC *dead)
StatusCode prepareMBTSCollections(const EventContext &context)
void clearMissing(const std::vector< uint32_t > &request, const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &response, LArCellCont *larcell)
clear fragments of the collection for which ROBs were not available
SG::ReadCondHandleKey< LArFebRodMapping > m_febRodMappingKey
Gaudi::Property< bool > m_applyOffsetCorrection
SG::ReadCondHandleKey< LArOnOffIdMapping > m_onOffIdMappingKey
std::vector< uint32_t > m_vrodid32tile
std::mutex m_tiledecoderProtect
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
PublicToolHandle< LArRodDecoder > m_larDecoder
ToolHandle< GenericMonitoringTool > m_monTool
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
virtual StatusCode initialize() override
virtual StatusCode loadCollections(const EventContext &context, const IRoiDescriptor &roi, const DETID detID, const int sampling, LArTT_Selector< LArCellCont > &loadedCells) override
std::mutex m_getCollMutex
ToolHandle< IRegSelTool > m_regionSelector_FCALEM
SG::ReadHandleKey< LArDeadOTXFromSC > m_deadOTXFromSCKey
virtual StatusCode loadMBTS(const EventContext &context, std::vector< const TileCell * > &loadedCells) override
SG::ReadCondHandleKey< LArRoIMap > m_larRoIMapKey
std::vector< std::vector< uint32_t > > m_vrodid32fullDetHG
ToolHandle< IRegSelTool > m_regionSelector_TTEM
StatusCode prepareTileFullCollections(const EventContext &context)
SG::SlotSpecificObj< HLTCaloEventCache > m_hLTCaloSlot
StatusCode prepareLArCollections(const EventContext &context, const IRoiDescriptor &roi, const int sampling, DETID detector)
LAr TT collections preparation code.
std::vector< unsigned int > m_insertedCells
void missingROBs(const std::vector< uint32_t > &request, const std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > &response, std::set< uint32_t > &missing) const
fill the set of missing robs given the request and response from RoBDatProvider
std::vector< uint32_t > m_vrodid32fullDet
ToolHandle< IRegSelTool > m_regionSelector_FCALHAD
ToolHandle< IRegSelTool > m_regionSelector_TILE
std::once_flag m_lateInitFlag
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
SG::ReadCondHandleKey< LArMCSym > m_mcsymKey
StatusCode prepareTileCollections(const EventContext &context, const IRoiDescriptor &roi)
void reset_LArCol(LArCellCollection *coll)
virtual StatusCode finalize() override
std::vector< IdentifierHash > m_rIdstile
virtual StatusCode loadFullCollections(const EventContext &context, CaloConstCellContainer &cont) override
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
DataModel_detail::iterator< DVL > unique(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of unique for DataVector/List.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
convience structure to keep together a collection and auxiliar full collection selectors