ATLAS Offline Software
Public Types | 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 Types

typedef ToolHandleArray< CaloCellCorrection >::iterator CellCorrectionToolIterator
 

Public Member Functions

 CaloCellContainerCorrectorTool (const std::string &type, const std::string &name, const IInterface *parent)
 
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

std::vector< int > m_caloNums
 
ToolHandleArray< CaloCellCorrectionm_cellCorrectionTools
 
bool m_caloSelection
 

Detailed Description

Definition at line 15 of file CaloCellContainerCorrectorTool.h.

Member Typedef Documentation

◆ CellCorrectionToolIterator

Definition at line 24 of file CaloCellContainerCorrectorTool.h.

Constructor & Destructor Documentation

◆ CaloCellContainerCorrectorTool()

CaloCellContainerCorrectorTool::CaloCellContainerCorrectorTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 27 of file CaloCellContainerCorrectorTool.cxx.

31  :base_class(type, name, parent),
33  m_caloSelection(false) {
34  declareProperty("CaloNums",m_caloNums);
35  declareProperty("CellCorrectionToolNames",m_cellCorrectionTools);
36  m_caloNums.clear();
37  //default: process all calo
38  m_caloNums.push_back( static_cast<int>(CaloCell_ID::NSUBCALO) );
39 }

Member Function Documentation

◆ initialize()

StatusCode CaloCellContainerCorrectorTool::initialize ( )
overridevirtual

Definition at line 49 of file CaloCellContainerCorrectorTool.cxx.

49  {
50 
51  //Retrieve tools
52  StatusCode sc = m_cellCorrectionTools.retrieve();
53  if (sc.isFailure()) {
54  msg(MSG::ERROR) << "Unable to retrieve tools " << m_cellCorrectionTools << endmsg;
55  }
56 
57  unsigned int nSubCalo=static_cast<unsigned int>(CaloCell_ID::NSUBCALO) ;
58 
59  //check calo number specified
60  m_caloSelection = true ;
61  if (m_caloNums.empty()) {
62  msg(MSG::WARNING) << " no calo specified for correction. Will do nothing. " << endmsg;
63  return StatusCode::SUCCESS;
64  } else if (m_caloNums.size()>nSubCalo ) {
65  msg(MSG::ERROR) << " More than "
66  << nSubCalo << " calo specified. Must be wrong. Stop." << endmsg;
67  return StatusCode::FAILURE;
68  } else if (m_caloNums.size()==1 && m_caloNums[0]==static_cast<int>(nSubCalo)) {
69  m_caloSelection = false ;
70  ATH_MSG_INFO("Correction will be applied on all calo.");
71  } else {
72  for (unsigned int index=0; index < m_caloNums.size() ; ++index) {
73  if (m_caloNums[index]<0 || m_caloNums[index]>=static_cast<int>(nSubCalo) ) {
74  msg(MSG::ERROR) << "Invalid calo specification:" << m_caloNums[index] << "Stop." << endmsg ;
75  return StatusCode::FAILURE;
76  } else {
77  ATH_MSG_INFO("Correction will be applied on calo:" << static_cast<int>(m_caloNums[index]));
78  }
79  }
80  }
81 
82 
83  ATH_MSG_INFO("Initialization completed successfully");
84  return StatusCode::SUCCESS;
85 
86 }

◆ process()

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

Definition at line 89 of file CaloCellContainerCorrectorTool.cxx.

91 {
92  if (!m_caloSelection) {
93  // no selection mode (faster)
94  CaloCellContainer::iterator itrCellBeg=theCont->begin();
95  CaloCellContainer::iterator itrCellEnd=theCont->end();
96 
97  StatusCode sc = processOnCellIterators(itrCellBeg, itrCellEnd, ctx );
98  if (sc.isFailure())
99  msg(MSG::WARNING) << "Failure from processOnCellIterators" << endmsg ;
100  }else {
101  // selection mode
102 
103  for (std::vector<int>::const_iterator itrCalo=m_caloNums.begin();itrCalo!=m_caloNums.end();++itrCalo){
104 
105  CaloCell_ID::SUBCALO caloNum=static_cast<CaloCell_ID::SUBCALO>(*itrCalo);
106 
107  CaloCellContainer::iterator itrCellBeg=theCont->beginCalo(caloNum);
108  CaloCellContainer::iterator itrCellEnd=theCont->endCalo(caloNum);
109 
110  if (!theCont->hasCalo(caloNum))
111  {
112  msg(MSG::WARNING) << " Attempt to apply correction but CaloCellContainer has not been filled for this calo : "
113  << *itrCalo << endmsg ;
114  } else
115  {
116  StatusCode sc=processOnCellIterators(itrCellBeg, itrCellEnd, ctx );
117  if (sc.isFailure())
118  msg(MSG::WARNING) << "Failure from processOnCellIterators for calo "
119  << static_cast<int> (caloNum)
120  << endmsg ;
121 
122  }
123 
124 
125  }
126 
127  }
128 
129 
130 
131  return StatusCode::SUCCESS ;
132 }

◆ processOnCellIterators()

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

Definition at line 136 of file CaloCellContainerCorrectorTool.cxx.

139 {
140  // not clear what s the best way to do the loop
142 
143  //if only one tool do not iterate (optimisation)
144  if (m_cellCorrectionTools.size()==1) {
145  const ToolHandle<CaloCellCorrection>& tool = *m_cellCorrectionTools.begin();
146  for (itrCell=itrCellBeg;itrCell!=itrCellEnd;++itrCell) {
147  tool->MakeCorrection (*itrCell, ctx);
148  }
149  }else {
150  for (itrCell=itrCellBeg;itrCell!=itrCellEnd;++itrCell) {
151  for (const ToolHandle<CaloCellCorrection>& tool : m_cellCorrectionTools) {
152  tool->MakeCorrection (*itrCell, ctx);
153  }
154  }
155  }
156 
157  return StatusCode::SUCCESS;
158 }

Member Data Documentation

◆ m_caloNums

std::vector<int> CaloCellContainerCorrectorTool::m_caloNums
private

Definition at line 35 of file CaloCellContainerCorrectorTool.h.

◆ m_caloSelection

bool CaloCellContainerCorrectorTool::m_caloSelection
private

Definition at line 40 of file CaloCellContainerCorrectorTool.h.

◆ m_cellCorrectionTools

ToolHandleArray<CaloCellCorrection> CaloCellContainerCorrectorTool::m_cellCorrectionTools
private

Definition at line 38 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:38
index
Definition: index.py:1
CaloCellContainerCorrectorTool::m_caloSelection
bool m_caloSelection
Definition: CaloCellContainerCorrectorTool.h:40
CaloCellContainerCorrectorTool::m_caloNums
std::vector< int > m_caloNums
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:136
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
DeMoScan.index
string index
Definition: DeMoScan.py:362
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
CaloCell_Base_ID::NSUBCALO
@ NSUBCALO
Definition: CaloCell_Base_ID.h:46
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7