ATLAS Offline Software
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 
19 LArSuperCellBCIDAlg::LArSuperCellBCIDAlg( const std::string& name, ISvcLocator* pSvcLocator)
20  : AthReentrantAlgorithm( name, pSvcLocator)
21 {
22 }
23 
26 {
27 
32  ATH_CHECK(detStore()->retrieve(m_laronline_id,"LArOnline_SuperCellID"));
33  return StatusCode::SUCCESS;
34 }
35 
37 LArSuperCellBCIDAlg::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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1632
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
LArSuperCellBCIDAlg::m_bcidAvgKey
SG::ReadHandleKey< CaloBCIDAverage > m_bcidAvgKey
Property SG Key for the CaloLumiBCID.
Definition: LArSuperCellBCIDAlg.h:54
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArSuperCellBCIDAlg::m_laronline_id
const LArOnline_SuperCellID * m_laronline_id
Definition: LArSuperCellBCIDAlg.h:61
HWIdentifier
Definition: HWIdentifier.h:13
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
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
LArSuperCellBCIDAlg::LArSuperCellBCIDAlg
LArSuperCellBCIDAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArSuperCellBCIDAlg.cxx:19
LArOnOffIdMapping.h
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
LArSuperCellBCIDAlg::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Property SG Key for the OnOffMapping.
Definition: LArSuperCellBCIDAlg.h:58
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloBCIDAverage
Definition: CaloBCIDAverage.h:16
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
LArSuperCellBCIDAlg.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LArSuperCellBCIDAlg::initialize
StatusCode initialize()
Definition: LArSuperCellBCIDAlg.cxx:25
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
EventInfo.h
LArSuperCellBCIDAlg::execute
StatusCode execute(const EventContext &context) const
Definition: LArSuperCellBCIDAlg.cxx:37
CaloBCIDAverage::average
float average(const Identifier &id) const
Definition: CaloBCIDAverage.h:27
SG::WriteHandle< CaloCellContainer >
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
LArSuperCellBCIDAlg::m_sCellContainerOutKey
SG::WriteHandleKey< CaloCellContainer > m_sCellContainerOutKey
Property: SG key for the output supercell LAr channel container.
Definition: LArSuperCellBCIDAlg.h:49
LArOnline_SuperCellID.h
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
LArSuperCellBCIDAlg::m_sCellContainerInKey
SG::ReadHandleKey< CaloCellContainer > m_sCellContainerInKey
Property: SG key for the input calorimeter cell container.
Definition: LArSuperCellBCIDAlg.h:44