ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCellRec
src
LArCellMerger.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/********************************************************************
6
7
NAME: LArCellMerger
8
PACKAGE: offline/Calorimeter/LArCellRec
9
10
AUTHORS: G.Unal
11
CREATION: 9 July 2009
12
13
PURPOSE:
14
15
********************************************************************/
16
17
#include "
LArCellMerger.h
"
18
19
#include "
LArRawEvent/LArRawChannelContainer.h
"
20
#include "
CaloEvent/CaloCellContainer.h
"
21
#include "Identifier/Identifier.h"
22
#include "
Identifier/IdentifierHash.h
"
23
#include "
CaloIdentifier/CaloCell_ID.h
"
24
#include "
LArCabling/LArOnOffIdMapping.h
"
25
#include "
LArIdentifier/LArOnlineID.h
"
26
27
29
// INITIALIZE:
30
// The initialize method will create all the required algorithm objects
32
33
StatusCode
LArCellMerger::initialize
() {
34
35
ATH_CHECK
(detStore()->retrieve(
m_calo_id
,
"CaloCell_ID"
));
36
ATH_CHECK
( detStore()->retrieve(
m_onlineID
,
"LArOnlineID"
) );
37
ATH_CHECK
(
m_cablingKey
.initialize() );
38
39
ATH_CHECK
(
m_rawChannelContainerName
.initialize());
40
41
return
StatusCode::SUCCESS;
42
}
43
44
StatusCode
LArCellMerger::finalize
(){
45
return
StatusCode::SUCCESS;
46
}
47
48
StatusCode
LArCellMerger::process
(
CaloCellContainer
* theCont,
49
const
EventContext& ctx)
const
50
{
51
ATH_MSG_DEBUG
(
"in LArCellMerger::process"
);
52
53
SG::ReadHandle<LArRawChannelContainer>
rawColl(
m_rawChannelContainerName
, ctx);
54
if
(!rawColl.
isValid
()) {
55
ATH_MSG_ERROR
(
"Failed to retrieve LArRawChannelContainer with key "
<<
56
rawColl.
name
());
57
return
StatusCode::FAILURE;
58
}
59
60
SG::ReadCondHandle<LArOnOffIdMapping>
larCablingHdl(
m_cablingKey
, ctx);
61
const
LArOnOffIdMapping
* cabling=*larCablingHdl;
62
63
unsigned
nReplaced=0;
64
65
// loop over raw channel container
66
// as this new container is supposed to contain only few cells, we do a simple loop and the basics onlineId to offlineId conversion
67
// this could be a little slow if by mistake this container contains all cells (not what this tool is supposed to be used for)
68
for
(
const
LArRawChannel
& theRawChannel : *rawColl ) {
69
const
HWIdentifier
hwid=theRawChannel.channelID();
70
const
IdentifierHash
onlHash=
m_onlineID
->channel_Hash(hwid);
71
if
( cabling->isOnlineConnectedFromHash(onlHash)) {
72
const
IdentifierHash
theCellHashID= cabling->oflHashFromOnlHash(onlHash);
73
const
Identifier
id
=
m_calo_id
->cell_id(theCellHashID);
74
int
index
= theCont->
findIndex
(theCellHashID);
75
if
(
index
<0) {
76
ATH_MSG_WARNING
(
" cell "
<< hwid.
get_compact
() <<
" "
<<
id
.get_compact() <<
" is not in the container "
);
77
continue
;
78
}
79
CaloCell
* aCell = theCont->
at
(
index
);
80
81
if
(aCell) {
82
ATH_MSG_DEBUG
(
" replace energies in cell hwid= "
<< hwid.
get_identifier32
().
get_compact
()
83
<<
" offlineid = "
<<
id
.get_identifier32().get_compact()
84
<<
" old energy "
<< aCell->
e
() <<
" new energy "
<< theRawChannel.energy());
85
nReplaced++;
86
aCell->
setEnergy
((
float
)(theRawChannel.energy()));
87
aCell->
setTime
((
float
)(theRawChannel.time())*0.001);
// convert from ps int in raw channel to ns float in calocell
88
aCell->
setQuality
(theRawChannel.quality());
89
aCell->
setProvenance
(theRawChannel.provenance());
90
}
91
92
}
// isConnected
93
}
// loop over raw channel container
94
95
if
(nReplaced*5>theCont->
size
()) {
96
ATH_MSG_WARNING
(
"Replaced more than 20% of channels reco'ed online by channels reco'ed offline"
);
97
}
98
return
StatusCode::SUCCESS;
99
}
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_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloCellContainer.h
CaloCell_ID.h
IdentifierHash.h
LArCellMerger.h
LArOnOffIdMapping.h
LArOnlineID.h
LArRawChannelContainer.h
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
CaloCellContainer::findIndex
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
Definition
CaloCellContainer.cxx:363
CaloCell
Data object for each calorimeter readout cell.
Definition
CaloCell.h:57
CaloCell::e
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition
CaloCell.h:333
CaloCell::setTime
virtual void setTime(float time)
set time
Definition
CaloCell.h:484
CaloCell::setEnergy
virtual void setEnergy(float energy)
set energy
Definition
CaloCell.h:472
CaloCell::setQuality
void setQuality(uint16_t quality)
set quality
Definition
CaloCell.h:460
CaloCell::setProvenance
void setProvenance(uint16_t prov)
set Provenance
Definition
CaloCell.h:490
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
HWIdentifier
Definition
HWIdentifier.h:13
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition
Identifier32.h:47
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
Identifier::get_compact
value_type get_compact() const
Get the compact id.
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArCellMerger::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
handle to LAr cabling
Definition
LArCellMerger.h:59
LArCellMerger::initialize
virtual StatusCode initialize() override
initialize the tool
Definition
LArCellMerger.cxx:33
LArCellMerger::m_rawChannelContainerName
SG::ReadHandleKey< LArRawChannelContainer > m_rawChannelContainerName
key for raw channel container to merge to cells
Definition
LArCellMerger.h:64
LArCellMerger::m_onlineID
const LArOnlineID * m_onlineID
Definition
LArCellMerger.h:68
LArCellMerger::m_calo_id
const CaloCell_ID * m_calo_id
Definition
LArCellMerger.h:67
LArCellMerger::process
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
update theCellContainer
Definition
LArCellMerger.cxx:48
LArCellMerger::finalize
virtual StatusCode finalize() override
finalize the tool
Definition
LArCellMerger.cxx:44
LArOnOffIdMapping
Definition
LArOnOffIdMapping.h:20
LArRawChannel
Liquid Argon ROD output object base class.
Definition
LArRawChannel.h:40
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
Identifier
Definition
IdentifierFieldParser.cxx:14
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0