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
CaloCellContainerCheckerTool Class Reference

#include <CaloCellContainerCheckerTool.h>

Inheritance diagram for CaloCellContainerCheckerTool:
Collaboration diagram for CaloCellContainerCheckerTool:

Public Member Functions

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

Private Member Functions

StatusCode doProcess (const CaloCellContainer *theCellContainer, const EventContext &ctx) const
 

Private Attributes

Gaudi::Property< unsigned > m_eventsToCheck {this,"EventsToCheck",5}
 
const CaloCell_IDm_theCaloCCIDM = nullptr
 

Detailed Description

Definition at line 16 of file CaloCellContainerCheckerTool.h.

Member Function Documentation

◆ doProcess()

StatusCode CaloCellContainerCheckerTool::doProcess ( const CaloCellContainer theCellContainer,
const EventContext &  ctx 
) const
private

Definition at line 60 of file CaloCellContainerCheckerTool.cxx.

62 {
63  if (ctx.evt() >= m_eventsToCheck) {
64  return StatusCode::SUCCESS;
65  }
66 
67  StatusCode returnSc = StatusCode::SUCCESS ;
68 
69  double eSum = 0;
70  unsigned int index = 0;
71  std::vector<double> eSumCalos;
72  std::vector<unsigned int> nCellCalos;
73  for (int iCalo=CaloCell_ID::LAREM; iCalo<CaloCell_ID::NSUBCALO ; ++iCalo) {
74  eSumCalos.push_back(0.);
75  nCellCalos.push_back(0);
76  }
77 
78 
79  for (const CaloCell* aCell : *theCont) {
80  const CaloDetDescrElement * theDDE=aCell->caloDDE();
81  int iCalo = static_cast<int>(theDDE->getSubCalo());
82  eSum+=aCell->e();
83  eSumCalos[iCalo]+=aCell->e();
84  ++(nCellCalos[iCalo]);
85  ++index ;
86  P4PxPyPzE aP(aCell);
87  const double aPeta=aP.e() != 0 ? aP.eta() : 0;
88  const double aPphi=aP.phi() ;
89 
90  // not needed anymore : now implemented in FOurMom
91  // if (aCell->e()<0) {
92  // aPeta=-aPeta;
93  // aPphi=aCaloPhiRange.fix(aPphi+aCaloPhiRange.twopi()/2.);
94  //}
95 
96  if (aCell->e()!=0 && std::abs(aCell->eta()-aPeta)>0.0001) {
97  msg(MSG::WARNING) << "Cell " << index << " eta inconsistency : " << aCell->eta()
98  << " vs recalculated " << aPeta << endmsg ;
99  }
100  if (aCell->e()!=0 && std::abs(CaloPhiRange::diff(aCell->phi(),aPphi))>0.0001) {
101  msg(MSG::WARNING) << "Cell " << index << " phi inconsistency : " << aCell->phi()
102  << " vs recalculated " << aPphi << endmsg ;
103  }
104  }
105  index =0;
106  if (msgLvl(MSG::VERBOSE)) {
107  for (const CaloCell* aCell : *theCont) {
108  const CaloDetDescrElement * theDDE=aCell->caloDDE();
109  msg(MSG::VERBOSE) << index << " " << " " << aCell
110  << " hash id " << theDDE->calo_hash()
111  << " eta " << theDDE->eta()
112  << " phi " << theDDE->phi()
113  << " e " << aCell->e() << endmsg ;
114  ++index;
115  }
116  }
117 
118  //check hasCalo() flags
119  for (int iCalo=CaloCell_ID::LAREM; iCalo<CaloCell_ID::NSUBCALO ; ++iCalo) {
120  if (nCellCalos[iCalo]>0 && !theCont->hasCalo(static_cast<CaloCell_ID::SUBCALO>(iCalo) ) )
121  {
122  msg(MSG::WARNING) << " There are cells for calo "
123  << iCalo << " but hasCalo is not set. " << endmsg ;
124  }
125  }
126 
127  ATH_MSG_DEBUG(" eSum " << eSum);
128 
129  //check now the sub calo iterators
130  for (int iCalo=CaloCell_ID::LAREM; iCalo<CaloCell_ID::NSUBCALO ; ++iCalo) {
131  CaloCell_ID::SUBCALO enumCalo=static_cast<CaloCell_ID::SUBCALO>(iCalo);
132  double theESumCalo=0;
133  unsigned int theNCellCalo=0;
134 
135  CaloCellContainer::const_iterator itrCell=theCont->beginConstCalo(enumCalo);
136  CaloCellContainer::const_iterator endCell=theCont->endConstCalo(enumCalo);
137  for (;itrCell!=endCell;++itrCell){
138  theESumCalo+=(*itrCell)->e();
139  ++theNCellCalo;
140  }
141 
142 
143  ATH_MSG_DEBUG(" theNCellCalo="<<theNCellCalo
144  <<" nCellCalos[iCalo]=" <<nCellCalos[iCalo]
145  <<" theCont->nCellsCalo(enumCalo)=" << theCont->nCellsCalo(enumCalo) );
146 
147  if (theNCellCalo!=nCellCalos[iCalo] ||
148  static_cast<int>(theNCellCalo)!=theCont->nCellsCalo(enumCalo) ) {
149  msg(MSG::ERROR) << " Iterators: ncell do not match"
150  << " theNCellCalo="<<theNCellCalo
151  <<" nCellCalos[iCalo]=" <<nCellCalos[iCalo]
152  <<" theCont->nCellsCalo(enumCalo)=" << theCont->nCellsCalo(enumCalo)
153  << endmsg;
154  returnSc = StatusCode::FAILURE;
155  }
156 
157 
158 
159  ATH_MSG_DEBUG("theESumCalo eSumCalos[iCalo] "<< theESumCalo << " " << eSumCalos[iCalo]);
160  const double epsilon=1e-5;
161  if (fabs(theESumCalo-eSumCalos[iCalo])>epsilon) {
162  msg(MSG::ERROR) << " Non const iterators: E sum do not match"
163  << " subcalo " << iCalo
164  << " should be " << eSumCalos[iCalo]
165  << " is " << theESumCalo <<" (" << theESumCalo-eSumCalos[iCalo] << ")" << endmsg ;
166  returnSc = StatusCode::FAILURE;
167  }
168 
169 
170  }
171 
172  // check find methods
173 
174  // count number of holes
175  const unsigned int hashMax=m_theCaloCCIDM->calo_cell_hash_max();
176  unsigned int nHoles =0;
177 
178  ATH_MSG_DEBUG("Now check all hashes give meaningful answer");
179  for (unsigned int theHash=0;theHash<hashMax;++theHash){
180  const CaloCell * theCell = theCont->findCell(theHash) ;
181  if (theCell==nullptr) {
182  ++nHoles;
183  if (msgLvl(MSG::VERBOSE)) {
184  //const CaloDetDescrElement* theCaloDDM->dde=get_element(theHash);
185  const Identifier id=m_theCaloCCIDM->cell_id(theHash);
186  const int subcalo=m_theCaloCCIDM->sub_calo(theHash);
187  const int sampling=m_theCaloCCIDM->calo_sample(theHash);
188  const int pos_neg=m_theCaloCCIDM->pos_neg(id);
189  const int region=m_theCaloCCIDM->region(id);
190  const int sample=m_theCaloCCIDM->sample(id);
191  msg(MSG::VERBOSE) << "Cell not found: id=0x" << std::hex << id << std::dec
192  << ", SubCalo=" <<subcalo <<", sampling="<< sampling << ", pos_neg="
193  << pos_neg << ", region=" << region << ", sample=" << sample << endmsg;
194  }//end if verbose
195  }//end if cell==0
196  }//end loop over hashes
197  ATH_MSG_DEBUG("Number of hash with no cells: " << nHoles << " out of " << hashMax);
198 
199  std::vector<IdentifierHash> hashes ;
200  hashes.clear();
201  double eSumFound=0;
202 
203  index =0;
204 
205  for ( CaloCellContainer::const_iterator itrCell=theCont->begin();itrCell!=theCont->end();++itrCell){
206  IdentifierHash theHash = (*itrCell)->caloDDE()->calo_hash();
207  if ((*itrCell)->et()>2000 * MeV ) {
208  hashes.push_back(theHash);
209  eSumFound+=(*itrCell)->energy();
210  }
211  const CaloCell * reCell=theCont->findCell(theHash);
212  if (reCell!=*itrCell){
213 
214  const CaloDetDescrElement * reCaloDDE=nullptr ;
215  unsigned int reHash=0 ;
216 
217 
218  if (reCell!=nullptr) reCaloDDE=reCell->caloDDE();
219  if (reCaloDDE!=nullptr) reHash = reCaloDDE->calo_hash();
220 
221 
222  msg(MSG::ERROR) << index << "Cell " << theHash << " " << *itrCell
223  << " not found back " << reCell
224  << " reCaloDDE " << reCaloDDE
225  << " rehash " << reHash << endmsg ;
226  returnSc = StatusCode::FAILURE;
227  }
228  ++index;
229  }
230 
231  ATH_MSG_DEBUG("number of cells to be refound " << hashes.size() << " total energy " << eSumFound);
232 
234  foundCells.clear();
235 
236  theCont->findCellVector(hashes,foundCells);
237 
238  if (hashes.size()!=foundCells.size()){
239  msg(MSG::ERROR) << "number of cells to be found " << hashes.size() << "number found: " << foundCells.size() << endmsg ;
240  returnSc = StatusCode::FAILURE;
241  }
242 
243 
244  double reSumFound=0;
245 
246  for (CaloCellContainer::CellVector::const_iterator itrCell=foundCells.begin();itrCell!=foundCells.end(); ++itrCell)
247  if (*itrCell!=0) reSumFound+=(*itrCell)->e();
248 
249 
250  if (std::abs(reSumFound-eSumFound)>10 * MeV ){
251  msg(MSG::ERROR) << "Found cells wrong E sum " << reSumFound << " instead of " << eSumFound << endmsg ;
252  returnSc = StatusCode::FAILURE;
253  }
254 
255  return returnSc ;
256 }

◆ initialize()

StatusCode CaloCellContainerCheckerTool::initialize ( )
overridevirtual

Definition at line 36 of file CaloCellContainerCheckerTool.cxx.

36  {
37 
38  ATH_CHECK(detStore()->retrieve(m_theCaloCCIDM,"CaloCell_ID"));
39  return StatusCode::SUCCESS;
40 }

◆ process() [1/2]

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

Definition at line 44 of file CaloCellContainerCheckerTool.cxx.

46 {
47  return doProcess (theCont, ctx);
48 }

◆ process() [2/2]

StatusCode CaloCellContainerCheckerTool::process ( CaloConstCellContainer theCellContainer,
const EventContext &  ctx 
) const
overridevirtual

Definition at line 52 of file CaloCellContainerCheckerTool.cxx.

54 {
55  return doProcess (theCont->asDataVector(), ctx);
56 }

Member Data Documentation

◆ m_eventsToCheck

Gaudi::Property<unsigned> CaloCellContainerCheckerTool::m_eventsToCheck {this,"EventsToCheck",5}
private

Definition at line 34 of file CaloCellContainerCheckerTool.h.

◆ m_theCaloCCIDM

const CaloCell_ID* CaloCellContainerCheckerTool::m_theCaloCCIDM = nullptr
private

Definition at line 35 of file CaloCellContainerCheckerTool.h.


The documentation for this class was generated from the following files:
CaloCellContainerCheckerTool::doProcess
StatusCode doProcess(const CaloCellContainer *theCellContainer, const EventContext &ctx) const
Definition: CaloCellContainerCheckerTool.cxx:60
python.root_lsr_rank.hashes
hashes
Definition: root_lsr_rank.py:34
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
CaloCellContainerCheckerTool::m_theCaloCCIDM
const CaloCell_ID * m_theCaloCCIDM
Definition: CaloCellContainerCheckerTool.h:35
CaloCell_Base_ID::region
int region(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
index
Definition: index.py:1
CaloCell_Base_ID::pos_neg
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
python.SystemOfUnits.MeV
int MeV
Definition: SystemOfUnits.py:154
CaloCell_Base_ID::calo_sample
int calo_sample(const Identifier id) const
returns an int taken from Sampling enum and describing the subCalo to which the Id belongs.
Definition: CaloCell_Base_ID.cxx:141
CaloDetDescrElement::getSubCalo
CaloCell_ID::SUBCALO getSubCalo() const
cell subcalo
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:433
CaloDetDescrElement::calo_hash
IdentifierHash calo_hash() const
cell calo hash
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:412
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:116
CaloCell_Base_ID::sample
int sample(const Identifier id) const
Tile field values (NOT_VALID == invalid request)
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:305
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
CaloCell_Base_ID::sub_calo
int sub_calo(const Identifier id) const
returns an int taken from SUBCALO enum and describing the subCalo to which the Id belongs.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
CaloCell_Base_ID::cell_id
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
DeMoScan.index
string index
Definition: DeMoScan.py:364
P4PxPyPzE
Definition: P4PxPyPzE.h:29
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloCellContainerCheckerTool::m_eventsToCheck
Gaudi::Property< unsigned > m_eventsToCheck
Definition: CaloCellContainerCheckerTool.h:34
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloCell_Base_ID::NSUBCALO
@ NSUBCALO
Definition: CaloCell_Base_ID.h:46
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
CaloCellContainer::CellVector
std::vector< const CaloCell * > CellVector
type to be used for the internal lookup table, and to return list of cells
Definition: CaloCellContainer.h:83
CaloPhiRange::diff
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
Definition: CaloPhiRange.cxx:22
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
Identifier
Definition: IdentifierFieldParser.cxx:14