ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArROD
src
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
"
14
#include "
CaloEvent/CaloCellContainer.h
"
15
#include "
CaloDetDescr/ICaloSuperCellIDTool.h
"
16
#include "
xAODEventInfo/EventInfo.h
"
17
18
LArSuperCellBCIDEmAlg::LArSuperCellBCIDEmAlg
(
const
std::string& name, ISvcLocator* pSvcLocator)
19
:
AthReentrantAlgorithm
( name, pSvcLocator)
20
{
21
}
22
23
StatusCode
24
LArSuperCellBCIDEmAlg::initialize
()
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
34
StatusCode
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloCellContainer.h
ICaloSuperCellIDTool.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
LArSuperCellBCIDEmAlg.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
CaloBCIDAverage
Definition
CaloBCIDAverage.h:16
CaloBCIDAverage::average
float average(const Identifier &id) const
Definition
CaloBCIDAverage.h:27
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
LArSuperCellBCIDEmAlg::m_bcidAvgKey
SG::ReadHandleKey< CaloBCIDAverage > m_bcidAvgKey
Property SG Key for the CaloLumiBCID.
Definition
LArSuperCellBCIDEmAlg.h:57
LArSuperCellBCIDEmAlg::initialize
StatusCode initialize()
Definition
LArSuperCellBCIDEmAlg.cxx:24
LArSuperCellBCIDEmAlg::m_sCellContainerInKey
SG::ReadHandleKey< CaloCellContainer > m_sCellContainerInKey
Property: SG key for the input calorimeter cell container.
Definition
LArSuperCellBCIDEmAlg.h:47
LArSuperCellBCIDEmAlg::execute
StatusCode execute(const EventContext &context) const
Definition
LArSuperCellBCIDEmAlg.cxx:35
LArSuperCellBCIDEmAlg::LArSuperCellBCIDEmAlg
LArSuperCellBCIDEmAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArSuperCellBCIDEmAlg.cxx:18
LArSuperCellBCIDEmAlg::m_scidtool
ToolHandle< ICaloSuperCellIDTool > m_scidtool
Property: Offline / supercell mapping tool.
Definition
LArSuperCellBCIDEmAlg.h:42
LArSuperCellBCIDEmAlg::m_sCellContainerOutKey
SG::WriteHandleKey< CaloCellContainer > m_sCellContainerOutKey
Property: SG key for the output supercell LAr channel container.
Definition
LArSuperCellBCIDEmAlg.h:52
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0