Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
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 
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 
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 
CaloCellContainerCorrectorTool::initialize
virtual StatusCode initialize() override
Definition: CaloCellContainerCorrectorTool.cxx:28
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellContainerCorrectorTool::m_cellCorrectionTools
ToolHandleArray< CaloCellCorrection > m_cellCorrectionTools
Definition: CaloCellContainerCorrectorTool.h:33
index
Definition: index.py:1
CaloCellContainerCorrectorTool::m_caloSelection
bool m_caloSelection
Definition: CaloCellContainerCorrectorTool.h:35
CaloCell.h
CaloCellContainer::endCalo
CaloCellContainer::iterator endCalo(CaloCell_ID::SUBCALO caloNum)
Definition: CaloCellContainer.cxx:128
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloCell_ID.h
CaloCellContainerCorrectorTool::processOnCellIterators
StatusCode processOnCellIterators(const CaloCellContainer::iterator &itrCellBeg, const CaloCellContainer::iterator &itrCellEnd, const EventContext &ctx) const
Definition: CaloCellContainerCorrectorTool.cxx:115
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
CaloCellContainer.h
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
CaloCellContainerCorrectorTool.h
CaloCellContainer::beginCalo
CaloCellContainer::iterator beginCalo(CaloCell_ID::SUBCALO caloNum)
get non const iterators on cell of just one calo
Definition: CaloCellContainer.cxx:123
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DeMoScan.index
string index
Definition: DeMoScan.py:364
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
CaloCellContainerCorrectorTool::m_caloNums
Gaudi::Property< std::vector< int > > m_caloNums
Definition: CaloCellContainerCorrectorTool.h:30
CaloCell_Base_ID::NSUBCALO
@ NSUBCALO
Definition: CaloCell_Base_ID.h:46
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.