ATLAS Offline Software
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 
13 #include "LArSuperCellBCIDEmAlg.h"
17 
18 LArSuperCellBCIDEmAlg::LArSuperCellBCIDEmAlg( const std::string& name, ISvcLocator* pSvcLocator)
19  : AthReentrantAlgorithm( name, pSvcLocator)
20 {
21 }
22 
25 {
26 
30  ATH_CHECK( m_scidtool.retrieve() );
31  return StatusCode::SUCCESS;
32 }
33 
35 LArSuperCellBCIDEmAlg::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 }
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LArSuperCellBCIDEmAlg::initialize
StatusCode initialize()
Definition: LArSuperCellBCIDEmAlg.cxx:24
ICaloSuperCellIDTool.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
LArSuperCellBCIDEmAlg::m_sCellContainerOutKey
SG::WriteHandleKey< CaloCellContainer > m_sCellContainerOutKey
Property: SG key for the output supercell LAr channel container.
Definition: LArSuperCellBCIDEmAlg.h:52
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloBCIDAverage
Definition: CaloBCIDAverage.h:16
LArSuperCellBCIDEmAlg::m_sCellContainerInKey
SG::ReadHandleKey< CaloCellContainer > m_sCellContainerInKey
Property: SG key for the input calorimeter cell container.
Definition: LArSuperCellBCIDEmAlg.h:47
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LArSuperCellBCIDEmAlg::m_scidtool
ToolHandle< ICaloSuperCellIDTool > m_scidtool
Property: Offline / supercell mapping tool.
Definition: LArSuperCellBCIDEmAlg.h:42
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
EventInfo.h
CaloBCIDAverage::average
float average(const Identifier &id) const
Definition: CaloBCIDAverage.h:27
SG::WriteHandle< CaloCellContainer >
LArSuperCellBCIDEmAlg::LArSuperCellBCIDEmAlg
LArSuperCellBCIDEmAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArSuperCellBCIDEmAlg.cxx:18
LArSuperCellBCIDEmAlg::execute
StatusCode execute(const EventContext &context) const
Definition: LArSuperCellBCIDEmAlg.cxx:35
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
LArSuperCellBCIDEmAlg::m_bcidAvgKey
SG::ReadHandleKey< CaloBCIDAverage > m_bcidAvgKey
Property SG Key for the CaloLumiBCID.
Definition: LArSuperCellBCIDEmAlg.h:57
LArSuperCellBCIDEmAlg.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.