ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloRec
src
CaloCellContainerCorrectorTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/********************************************************************
6
7
NAME: CaloCellContaineCorrectorTool
8
PACKAGE: offline/Calorimeter/CaloRec
9
10
AUTHORS: David Rousseau
11
CREATED: June 5,2004
12
13
PURPOSE: Apply cell correction to CaloCellContainer
14
15
********************************************************************/
16
17
#include "
CaloCellContainerCorrectorTool.h
"
18
#include "
CaloEvent/CaloCellContainer.h
"
19
#include "
CaloEvent/CaloCell.h
"
20
#include "
CaloIdentifier/CaloCell_ID.h
"
21
22
24
// INITIALIZE:
25
// The initialize method will create all the required algorithm objects
27
28
StatusCode
CaloCellContainerCorrectorTool::initialize
() {
29
30
//Retrieve tools
31
StatusCode
sc
=
m_cellCorrectionTools
.retrieve();
32
if
(
sc
.isFailure()) {
33
msg
(MSG::ERROR) <<
"Unable to retrieve tools "
<<
m_cellCorrectionTools
<<
endmsg
;
34
}
35
36
unsigned
int
nSubCalo=
static_cast<
unsigned
int
>
(
CaloCell_ID::NSUBCALO
) ;
37
38
//check calo number specified
39
m_caloSelection
= true ;
40
if
(
m_caloNums
.empty()) {
41
msg
(MSG::WARNING) <<
" no calo specified for correction. Will do nothing. "
<<
endmsg
;
42
return
StatusCode::SUCCESS;
43
}
else
if
(
m_caloNums
.size()>nSubCalo ) {
44
msg
(MSG::ERROR) <<
" More than "
45
<< nSubCalo <<
" calo specified. Must be wrong. Stop."
<<
endmsg
;
46
return
StatusCode::FAILURE;
47
}
else
if
(
m_caloNums
.size()==1 &&
m_caloNums
[0]==
static_cast<
int
>
(nSubCalo)) {
48
m_caloSelection
= false ;
49
ATH_MSG_INFO
(
"Correction will be applied on all calo."
);
50
}
else
{
51
for
(
unsigned
int
index
=0;
index
<
m_caloNums
.size() ; ++
index
) {
52
if
(
m_caloNums
[
index
]<0 ||
m_caloNums
[
index
]>=
static_cast<
int
>
(nSubCalo) ) {
53
msg
(MSG::ERROR) <<
"Invalid calo specification:"
<<
m_caloNums
[
index
] <<
"Stop."
<<
endmsg
;
54
return
StatusCode::FAILURE;
55
}
else
{
56
ATH_MSG_INFO
(
"Correction will be applied on calo:"
<<
static_cast<
int
>
(
m_caloNums
[
index
]));
57
}
58
}
59
}
60
61
62
ATH_MSG_INFO
(
"Initialization completed successfully"
);
63
return
StatusCode::SUCCESS;
64
65
}
66
67
StatusCode
68
CaloCellContainerCorrectorTool::process
(
CaloCellContainer
* theCont,
69
const
EventContext& ctx)
const
70
{
71
if
(!
m_caloSelection
) {
72
// no selection mode (faster)
73
CaloCellContainer::iterator
itrCellBeg=theCont->
begin
();
74
CaloCellContainer::iterator
itrCellEnd=theCont->
end
();
75
76
StatusCode
sc
=
processOnCellIterators
(itrCellBeg, itrCellEnd, ctx );
77
if
(
sc
.isFailure())
78
msg
(MSG::WARNING) <<
"Failure from processOnCellIterators"
<<
endmsg
;
79
}
else
{
80
// selection mode
81
82
for
(std::vector<int>::const_iterator itrCalo=
m_caloNums
.begin();itrCalo!=
m_caloNums
.end();++itrCalo){
83
84
CaloCell_ID::SUBCALO
caloNum=
static_cast<
CaloCell_ID::SUBCALO
>
(*itrCalo);
85
86
CaloCellContainer::iterator
itrCellBeg=theCont->
beginCalo
(caloNum);
87
CaloCellContainer::iterator
itrCellEnd=theCont->
endCalo
(caloNum);
88
89
if
(!theCont->
hasCalo
(caloNum))
90
{
91
msg
(MSG::WARNING) <<
" Attempt to apply correction but CaloCellContainer has not been filled for this calo : "
92
<< *itrCalo <<
endmsg
;
93
}
else
94
{
95
StatusCode
sc
=
processOnCellIterators
(itrCellBeg, itrCellEnd, ctx );
96
if
(
sc
.isFailure())
97
msg
(MSG::WARNING) <<
"Failure from processOnCellIterators for calo "
98
<<
static_cast<
int
>
(caloNum)
99
<<
endmsg
;
100
101
}
102
103
104
}
105
106
}
107
108
109
110
return
StatusCode::SUCCESS ;
111
}
112
113
114
StatusCode
115
CaloCellContainerCorrectorTool::processOnCellIterators
(
const
CaloCellContainer::iterator
& itrCellBeg,
116
const
CaloCellContainer::iterator
& itrCellEnd,
117
const
EventContext& ctx)
const
118
{
119
// not clear what s the best way to do the loop
120
CaloCellContainer::iterator
itrCell;
121
122
//if only one tool do not iterate (optimisation)
123
if
(
m_cellCorrectionTools
.size()==1) {
124
const
ToolHandle<CaloCellCorrection>& tool = *
m_cellCorrectionTools
.begin();
125
for
(itrCell=itrCellBeg;itrCell!=itrCellEnd;++itrCell) {
126
tool->MakeCorrection (*itrCell, ctx);
127
}
128
}
else
{
129
for
(itrCell=itrCellBeg;itrCell!=itrCellEnd;++itrCell) {
130
for
(
const
ToolHandle<CaloCellCorrection>& tool :
m_cellCorrectionTools
) {
131
tool->MakeCorrection (*itrCell, ctx);
132
}
133
}
134
}
135
136
return
StatusCode::SUCCESS;
137
}
138
139
140
141
142
143
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:30
CaloCellContainerCorrectorTool.h
CaloCellContainer.h
CaloCell.h
CaloCell_ID.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
CaloCellContainerCorrectorTool::initialize
virtual StatusCode initialize() override
Definition
CaloCellContainerCorrectorTool.cxx:28
CaloCellContainerCorrectorTool::m_caloNums
Gaudi::Property< std::vector< int > > m_caloNums
Definition
CaloCellContainerCorrectorTool.h:30
CaloCellContainerCorrectorTool::m_cellCorrectionTools
ToolHandleArray< CaloCellCorrection > m_cellCorrectionTools
Definition
CaloCellContainerCorrectorTool.h:33
CaloCellContainerCorrectorTool::m_caloSelection
bool m_caloSelection
Definition
CaloCellContainerCorrectorTool.h:35
CaloCellContainerCorrectorTool::processOnCellIterators
StatusCode processOnCellIterators(const CaloCellContainer::iterator &itrCellBeg, const CaloCellContainer::iterator &itrCellEnd, const EventContext &ctx) const
Definition
CaloCellContainerCorrectorTool.cxx:115
CaloCellContainerCorrectorTool::process
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
Definition
CaloCellContainerCorrectorTool.cxx:68
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
CaloCellContainer::beginCalo
CaloCellContainer::iterator beginCalo(CaloCell_ID::SUBCALO caloNum)
get non const iterators on cell of just one calo
Definition
CaloCellContainer.cxx:123
CaloCellContainer::hasCalo
bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const
tell wether it has been filled with cells (maybe none) of a given calo
Definition
CaloCellContainer.cxx:209
CaloCellContainer::endCalo
CaloCellContainer::iterator endCalo(CaloCell_ID::SUBCALO caloNum)
Definition
CaloCellContainer.cxx:128
CaloCell_Base_ID::NSUBCALO
@ NSUBCALO
Definition
CaloCell_Base_ID.h:45
CaloCell_ID::SUBCALO
CaloCell_Base_ID::SUBCALO SUBCALO
Definition
CaloCell_ID.h:50
DataVector< CaloCell >::iterator
DataModel_detail::iterator< DataVector > iterator
Definition
DataVector.h:842
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
index
Definition
index.py:1
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0