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;
172 for(
const CaloCell* c : *cont_to_copy ) {
178 return StatusCode::SUCCESS;
186 ATH_MSG_DEBUG(
"Full Col " <<
" requested for event " << context );
191 std::scoped_lock
lock{cache->mutex};
196 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
197 cache->larContainer->eventNumber( context.evt() ) ;
202 if ( avg.cptr() && onoff.
cptr() ) {
203 cache->larContainer->updateBCID( *avg, **onoff );
213 deadHandle = deadHdl.
cptr();
218 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
221 convertROBs( robFrags, cache->larContainer.get(), cache->larRodBlockStructure_per_slot,
222 cache->rodMinorVersion, cache->robBlockType, deadHandle );
224 if ( vrodid32fullDet.size() != robFrags.size() ) {
225 ATH_MSG_DEBUG(
"Missing ROBs, requested " << vrodid32fullDet.size() <<
" obtained " << robFrags.size() );
226 clearMissing( vrodid32fullDet, robFrags, cache->larContainer.get() );
231 return StatusCode::SUCCESS;
238 ATH_MSG_DEBUG(
"Full Col " <<
" requested for event " << context );
243 std::scoped_lock
lock{cache->mutex};
247 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
248 if ( cache->tileContainer->eventNumber() != context.evt() ) {
249 cache->d0cells->clear();
251 cache->tileContainer->eventNumber( context.evt() );
256 return StatusCode::SUCCESS;
264 std::vector<uint32_t> vrodid32lar;
265 std::vector<uint32_t> vrodid32em;
266 std::vector<uint32_t> vrodid32hec;
267 std::vector<uint32_t> vrodid32hec0;
268 std::vector<uint32_t> vrodid32hec1;
269 std::vector<uint32_t> vrodid32hec2;
270 std::vector<uint32_t> vrodid32hec3;
271 std::vector<uint32_t> vrodid32fcalem;
272 std::vector<uint32_t> vrodid32fcalhad;
275 std::vector<uint32_t> vrodid32tile;
276 std::vector<IdentifierHash> rIdstile;
294 auto iii = std::unique_copy(vrodid32tile.begin(),vrodid32tile.end(),
m_vrodid32tile.begin());
295 auto iij = std::unique_copy(rIdstile.begin(),rIdstile.end(),
m_rIdstile.begin());
303 vrodid32lar.insert(vrodid32lar.end(),vrodid32em.begin(),vrodid32em.end());
304 vrodid32hec.insert(vrodid32hec.end(),vrodid32hec0.begin(),vrodid32hec0.end());
305 vrodid32lar.insert(vrodid32lar.end(),vrodid32hec.begin(),vrodid32hec.end());
306 vrodid32lar.insert(vrodid32lar.end(),vrodid32fcalhad.begin(),vrodid32fcalhad.end());
307 vrodid32lar.insert(vrodid32lar.end(),vrodid32fcalem.begin(),vrodid32fcalem.end());
318 const unsigned int nFebs=70;
319 const unsigned int high_granu = (
unsigned int)ceilf(
m_vrodid32fullDet.size()/((
float)nFebs) );
339 cache.larContainer = std::make_unique<LArCellCont>();
340 cache.larRodBlockStructure_per_slot =
nullptr;
342 cache.larContainer->initialize(**roimap, **onoff, **mcsym, **febrod, **larBadChan, *theCaloDDM).
343 orThrow(
"Cannot initialize LAr container", name());
345 std::vector<CaloCell*> local_cell_copy;
346 local_cell_copy.reserve(200000);
347 const LArCellCont* larcell = cache.larContainer.get();
350 cache.lastFSEvent = 0xFFFFFFFF;
352 cachefullcont->reserve(190000);
354 for(
unsigned int lcidx=0; lcidx < larcell->size(); lcidx++){
356 for(
unsigned int lccidx=0; lccidx<lcc->
size(); lccidx++){
358 if ( cell && cell->caloDDE() ) {
365 if ( !
bad ) local_cell_copy.push_back( cell );
372 auto tilecell = std::make_unique<TileCellCont>();
373 tilecell->setHashIdToROD( *tileHid2RESrcID );
374 tilecell->initialize().orThrow(
"Cannot initialize Tile container", name());
376 for (
unsigned int i=0; i<4; i++) {
380 m_tileDecoder->loadMBTS( tilecell->MBTS_map(), tilecell->MBTS_channel() );
382 auto d0cellsp = std::make_unique<TileROD_Decoder::D0CellsHLT>();
383 for (
unsigned int lcidx=0; lcidx < tilecell->size(); lcidx++){
385 for (
unsigned int lccidx=0; lccidx<lcc->
size(); lccidx++){
387 if ( cell ) local_cell_copy.push_back( cell );
391 const int ros = (frag_id >> 8);
393 const int drawer = (frag_id & 0xFF);
396 d0cellsp->m_cells[drawer] = *pCell;
399 cache.tileContainer = std::move(tilecell);
402 cache.d0cells = std::move(d0cellsp);
405 for(
unsigned int i=0; i<hashMax; i++){
406 cachefullcont->push_back_fast(
nullptr);
409 for(
unsigned int i=0; i<local_cell_copy.size(); i++){
410 unsigned int j = local_cell_copy.at(i)->caloDDE()->calo_hash();
412 cachefullcont->at(j) = local_cell_copy.at(i);
415 for(
unsigned int i=0;i<hashMax;i++)
416 if ( cachefullcont->at(i) ==
nullptr ){
420 if ( el->is_tile() ) {
436 cachefullcont->order();
438 if ( hashMax != cachefullcont->size() ) {
442 cachefullcont->setIsOrdered(
true);
443 cachefullcont->setIsOrderedAndComplete(
true);
444 cache.fullcont = std::move(cachefullcont);
446 local_cell_copy.clear();
453 uint16_t rodMinorVersion, uint32_t robBlockType,
const LArDeadOTXFromSC* deadHandle ) {
455 for (
auto rob: robFrags ) {
456 uint32_t sourceID = rob->source_id();
457 const auto it = larcell->
find( sourceID );
460 if ( it != larcell->end() && ( *it )->size() != 0 ) {
465 ATH_MSG_DEBUG(
"ROB of ID " << sourceID <<
" to be decoded" );
473 "event: Bad ROB block ( eformat checks ) : 0x"
474 << std::hex << sourceID << std::dec );
480 const uint32_t* roddata = 0;
481 rob->rod_data( roddata );
482 const size_t roddatasize = rob->rod_ndata();
483 if ( roddatasize < 3 ) {
485 "event: Empty ROD block ( less than 3 words ) : 0x"
486 << std::hex << sourceID << std::dec );
491 m_larDecoder->fillCollectionHLT( *rob, roddata, roddatasize, *coll, larRodBlockStructure_per_slot, rodMinorVersion, robBlockType );
496 for(
size_t i=0;i<128;i++) {
504 for(
size_t i=0;i<128;i++) {
522 const std::vector<IdentifierHash>& rIds,
529 std::vector<unsigned int> tile{0};
531 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
532 for (
size_t i = 0; i < rIds.size(); ++i){
533 tile[0] = tilecell->
find_rod(rIds[i]);
536 const auto it = tilecell->
find(rIds[i]);
537 if (it == tilecell->end())
continue;
540 if ( !robFrags.empty() && col !=
nullptr ) {
541 const size_t roddatasize = robFrags[0]->rod_ndata();
543 if (roddatasize < 3) {
545 "event: Empty ROD block (less than 3 words) : 0x"
546 << std::hex << tile[0] << std::dec );
547 if ( !tilecell->
cached(rIds[i])){
554 if ( !tilecell->
cached(rIds[i]) ) {
555 m_tileDecoder->fillCollectionHLT(robFrags[0],*col,*d0cells,mbts,hid2re);
567 const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>&
response,
568 std::set<uint32_t>& missing )
const {
570 std::set<uint32_t> receivedROBsSet;
572 receivedROBsSet.insert( rob->source_id() );
575 std::set<uint32_t> requestedROBsSet( request.begin(), request.end() );
576 std::set_difference( requestedROBsSet.begin(), requestedROBsSet.end(),
577 receivedROBsSet.begin(), receivedROBsSet.end(),
578 std::inserter( missing, missing.begin() ) );
583 const std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>&
response,
585 std::set<uint32_t> missing;
587 for ( uint32_t robID : missing ) {
588 const auto it = larcell->
find( robID );
589 if ( it != larcell->end() && not (*it)->empty() ) {
605 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
607 std::vector<uint32_t> requestROBs;
609 std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> robFrags;
610 switch ( detector ) {
619 if ( robFrags.empty() && !requestROBs.empty() ) {
620 return StatusCode::SUCCESS;
624 std::scoped_lock
lock{cache->mutex};
631 cache->larContainer->eventNumber( context.evt() );
635 if ( avg.cptr() && onoff.
cptr() ) cache->larContainer->updateBCID( *avg, **onoff );
644 deadHandle = deadHdl.
cptr();
648 convertROBs( robFrags, cache->larContainer.get(), cache->larRodBlockStructure_per_slot,
649 cache->rodMinorVersion, cache->robBlockType, deadHandle );
651 if ( requestROBs.size() != robFrags.size() ) {
652 ATH_MSG_DEBUG(
"Missing ROBs, requested " << requestROBs.size() <<
" obtained " << robFrags.size() );
653 clearMissing( requestROBs, robFrags, cache->larContainer.get() );
660 return StatusCode::SUCCESS;
670 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
672 std::vector<uint32_t> requestROBs;
673 std::vector<IdentifierHash> rIds;
677 std::scoped_lock
lock{cache->mutex};
678 if ( cache->tileContainer->eventNumber() != context.evt() ) {
679 cache->d0cells->clear();
681 cache->tileContainer->eventNumber( context.evt() );
683 convertROBs( context, rIds, cache->tileContainer.get(), cache->d0cells.get() );
685 return StatusCode::SUCCESS;
694 if ( cache->lastFSEvent == context.evt() )
return StatusCode::SUCCESS;
696 std::scoped_lock
lock{cache->mutex};
697 if ( cache->tileContainer->eventNumber() != context.evt() ) {
698 cache->d0cells->clear();
700 cache->tileContainer->eventNumber( context.evt() );
702 const std::vector<unsigned int>* ids = cache->tileContainer->MBTS_IDs();
703 std::vector<IdentifierHash> tileIds;
704 tileIds.reserve(ids->size());
705 for (
size_t i=0; i<ids->size(); i++) {
706 tileIds.push_back( (*ids)[i] );
708 convertROBs( context, tileIds, cache->tileContainer.get(), cache->d0cells.get() );
710 return StatusCode::SUCCESS;
716 std::vector<const TileCell*>& loadedCells ) {
723 std::scoped_lock
lock{cache->mutex};
725 loadedCells.reserve(mbts->size());
726 for (
size_t i=0; i<mbts->size(); ++i) {
727 loadedCells.push_back(mbts->at(i));
730 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
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
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
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