Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CaloCellContainerCorrectorTool Class Reference

#include <CaloCellContainerCorrectorTool.h>

Inheritance diagram for CaloCellContainerCorrectorTool:
Collaboration diagram for CaloCellContainerCorrectorTool:

Public Member Functions

virtual StatusCode initialize () override
 
virtual StatusCode process (CaloCellContainer *theCellContainer, const EventContext &ctx) const override
 

Private Member Functions

StatusCode processOnCellIterators (const CaloCellContainer::iterator &itrCellBeg, const CaloCellContainer::iterator &itrCellEnd, const EventContext &ctx) const
 

Private Attributes

Gaudi::Property< std::vector< int > > m_caloNums {this,"CaloNums",{1,static_cast<int>(CaloCell_ID::NSUBCALO)} }
 
ToolHandleArray< CaloCellCorrectionm_cellCorrectionTools {this,"CellCorrectionToolNames",{}}
 
bool m_caloSelection =false
 

Detailed Description

Definition at line 15 of file CaloCellContainerCorrectorTool.h.

Member Function Documentation

◆ initialize()

StatusCode CaloCellContainerCorrectorTool::initialize ( )
overridevirtual

Definition at line 28 of file CaloCellContainerCorrectorTool.cxx.

28  {
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 }

◆ process()

StatusCode CaloCellContainerCorrectorTool::process ( CaloCellContainer theCellContainer,
const EventContext &  ctx 
) const
overridevirtual

Definition at line 68 of file CaloCellContainerCorrectorTool.cxx.

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 }

◆ processOnCellIterators()

StatusCode CaloCellContainerCorrectorTool::processOnCellIterators ( const CaloCellContainer::iterator itrCellBeg,
const CaloCellContainer::iterator itrCellEnd,
const EventContext &  ctx 
) const
private

Definition at line 115 of file CaloCellContainerCorrectorTool.cxx.

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 }

Member Data Documentation

◆ m_caloNums

Gaudi::Property<std::vector<int> > CaloCellContainerCorrectorTool::m_caloNums {this,"CaloNums",{1,static_cast<int>(CaloCell_ID::NSUBCALO)} }
private

Definition at line 30 of file CaloCellContainerCorrectorTool.h.

◆ m_caloSelection

bool CaloCellContainerCorrectorTool::m_caloSelection =false
private

Definition at line 35 of file CaloCellContainerCorrectorTool.h.

◆ m_cellCorrectionTools

ToolHandleArray<CaloCellCorrection> CaloCellContainerCorrectorTool::m_cellCorrectionTools {this,"CellCorrectionToolNames",{}}
private

Definition at line 33 of file CaloCellContainerCorrectorTool.h.


The documentation for this class was generated from the following files:
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
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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
DeMoScan.index
string index
Definition: DeMoScan.py:364
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