ATLAS Offline Software
Loading...
Searching...
No Matches
LArSuperCellBCIDEmAlg.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 : LArSuperCellBCIDEmAlg.cxx
5 * PACKAGE : LArCalorimeter/LArROD/LArSuperCellBCIDEmAlg
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
17
18LArSuperCellBCIDEmAlg::LArSuperCellBCIDEmAlg( const std::string& name, ISvcLocator* pSvcLocator)
19 : AthReentrantAlgorithm( name, pSvcLocator)
20{
21}
22
23StatusCode
25{
26
27 ATH_CHECK( m_sCellContainerInKey.initialize() );
28 ATH_CHECK( m_sCellContainerOutKey.initialize() );
29 ATH_CHECK( m_bcidAvgKey.initialize() );
30 ATH_CHECK( m_scidtool.retrieve() );
31 return StatusCode::SUCCESS;
32}
33
34StatusCode
35LArSuperCellBCIDEmAlg::execute(const EventContext& context) const
36{
37
38 // Not really a condition, but almost
39 SG::ReadHandle<CaloBCIDAverage> caloLumiBCIDHandle(m_bcidAvgKey, context);
40 if ( not caloLumiBCIDHandle.isValid() ) {
41 ATH_MSG_DEBUG("Found invalid read handle for CaloBCIDAverage");
42 return StatusCode::FAILURE;
43 }
44 const CaloBCIDAverage* caloLumiBCID = caloLumiBCIDHandle.cptr();
45
46 auto cellsHandle = SG::makeHandle( m_sCellContainerInKey, context );
47 if ( not cellsHandle.isValid() ) {
48 ATH_MSG_ERROR("Did not get CaloCellContainer input");
49 return StatusCode::FAILURE;
50 }
51
52 const CaloCellContainer* scells_from_sg = cellsHandle.cptr();
53 ATH_MSG_DEBUG("Got a CaloCellContainer input with size : "<<scells_from_sg->size());
54
55 SG::WriteHandle<CaloCellContainer> scellContainerHandle( m_sCellContainerOutKey, context);
56 auto new_scell_cont = std::make_unique<CaloCellContainer> ();
57
58 new_scell_cont->reserve(scells_from_sg->size());
59
60 for(const auto *sc : *scells_from_sg){
61 if ( !sc ) continue;
62 std::unique_ptr<CaloCell> cell = sc->clone();
63 // calculate the BCID for all the cells associated to the SC
64 // since this is emulation
65 float correction(0.0);
66 std::vector<Identifier> ids = m_scidtool->superCellToOfflineID( sc->ID() );
67 for ( auto id : ids ) correction+=caloLumiBCID->average(id); ;
68 cell->setEnergy( sc->energy() - correction );
69 new_scell_cont->push_back( std::move(cell) );
70 }
71 ATH_CHECK( scellContainerHandle.record( std::move(new_scell_cont) ) );
72
73 return StatusCode::SUCCESS;
74}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
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.
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.
StatusCode execute(const EventContext &context) const
LArSuperCellBCIDEmAlg(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< ICaloSuperCellIDTool > m_scidtool
Property: Offline / supercell mapping tool.
SG::WriteHandleKey< CaloCellContainer > m_sCellContainerOutKey
Property: SG key for the output supercell LAr channel container.
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())