ATLAS Offline Software
Loading...
Searching...
No Matches
LArSuperCellBCIDAlg.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 *
4 * Name : LArSuperCellBCIDAlg.cxx
5 * PACKAGE : LArCalorimeter/LArROD/LArSuperCellBCIDAlg
6 *
7 * AUTHOR : Denis Oliveira Damazio
8 *
9 * PURPOSE : prepares SuperCellContainer to have the offset BCID-dependent correction. Special version for emulated cells
10 *
11 * **/
12
13#include "LArSuperCellBCIDAlg.h"
18
19LArSuperCellBCIDAlg::LArSuperCellBCIDAlg( const std::string& name, ISvcLocator* pSvcLocator)
20 : AthReentrantAlgorithm( name, pSvcLocator)
21{
22}
23
24StatusCode
26{
27
28 ATH_CHECK( m_sCellContainerInKey.initialize() );
29 ATH_CHECK( m_sCellContainerOutKey.initialize() );
30 ATH_CHECK( m_bcidAvgKey.initialize() );
31 ATH_CHECK(m_cablingKey.initialize() );
32 ATH_CHECK(detStore()->retrieve(m_laronline_id,"LArOnline_SuperCellID"));
33 return StatusCode::SUCCESS;
34}
35
36StatusCode
37LArSuperCellBCIDAlg::execute(const EventContext& context) const
38{
39
41
42 // Not really a condition, but almost
43 SG::ReadHandle<CaloBCIDAverage> caloLumiBCIDHandle(m_bcidAvgKey, context);
44 if ( not caloLumiBCIDHandle.isValid() ) {
45 ATH_MSG_DEBUG("Found invalid read handle for CaloBCIDAverage");
46 return StatusCode::FAILURE;
47 }
48 const CaloBCIDAverage* caloLumiBCID = caloLumiBCIDHandle.cptr();
49
50 auto cellsHandle = SG::makeHandle( m_sCellContainerInKey, context );
51 if ( not cellsHandle.isValid() ) {
52 ATH_MSG_ERROR("Did not get CaloCellContainer input");
53 return StatusCode::FAILURE;
54 }
55
56
57 const CaloCellContainer* scells_from_sg = cellsHandle.cptr();
58 ATH_MSG_DEBUG("Got a CaloCellContainer input with size : "<<scells_from_sg->size());
59
60 SG::WriteHandle<CaloCellContainer> scellContainerHandle( m_sCellContainerOutKey, context);
61 auto new_scell_cont = std::make_unique<CaloCellContainer> ();
62
63 new_scell_cont->reserve(scells_from_sg->size());
64
65 for(const auto *sc : *scells_from_sg){
66 if ( !sc ) continue;
67 std::unique_ptr<CaloCell> cell = sc->clone();
68 // calculate the BCID for all the cells associated to the SC
69 // since this is emulation
70 float correction(0.0);
71 HWIdentifier hwid = cabling->createSignalChannelID(sc->ID());
72 IdentifierHash hash_id = m_laronline_id->channel_Hash(hwid);
73 correction=caloLumiBCID->average((size_t)hash_id); // Accesses the internal cache of CaloBCIDAverage directly, no phi-symmetry use.
74 cell->setEnergy( sc->energy() - correction );
75 new_scell_cont->push_back( std::move(cell) );
76 }
77 ATH_CHECK( scellContainerHandle.record( std::move(new_scell_cont) ) );
78
79 return StatusCode::SUCCESS;
80}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
float average(const Identifier &id) const
Container class for CaloCell.
size_type size() const noexcept
Returns the number of elements in the collection.
This is a "hash" representation of an Identifier.
StatusCode execute(const EventContext &context) const
SG::WriteHandleKey< CaloCellContainer > m_sCellContainerOutKey
Property: SG key for the output supercell LAr channel container.
LArSuperCellBCIDAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Property SG Key for the OnOffMapping.
SG::ReadHandleKey< CaloBCIDAverage > m_bcidAvgKey
Property SG Key for the CaloLumiBCID.
SG::ReadHandleKey< CaloCellContainer > m_sCellContainerInKey
Property: SG key for the input calorimeter cell container.
const LArOnline_SuperCellID * m_laronline_id
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())