ATLAS Offline Software
Loading...
Searching...
No Matches
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
7NAME: CaloCellContaineCorrectorTool
8PACKAGE: offline/Calorimeter/CaloRec
9
10AUTHORS: David Rousseau
11CREATED: June 5,2004
12
13PURPOSE: Apply cell correction to CaloCellContainer
14
15********************************************************************/
16
19#include "CaloEvent/CaloCell.h"
21
22
24// INITIALIZE:
25// The initialize method will create all the required algorithm objects
27
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
67StatusCode
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
114StatusCode
116 const CaloCellContainer::iterator & itrCellEnd,
117 const EventContext& ctx) const
118{
119 // not clear what s the best way to do the loop
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
#define endmsg
#define ATH_MSG_INFO(x)
static Double_t sc
Gaudi::Property< std::vector< int > > m_caloNums
ToolHandleArray< CaloCellCorrection > m_cellCorrectionTools
StatusCode processOnCellIterators(const CaloCellContainer::iterator &itrCellBeg, const CaloCellContainer::iterator &itrCellEnd, const EventContext &ctx) const
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
Container class for CaloCell.
CaloCellContainer::iterator beginCalo(CaloCell_ID::SUBCALO caloNum)
get non const iterators on cell of just one calo
bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const
tell wether it has been filled with cells (maybe none) of a given calo
CaloCellContainer::iterator endCalo(CaloCell_ID::SUBCALO caloNum)
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Definition index.py:1
MsgStream & msg
Definition testRead.cxx:32