62{
64 return StatusCode::SUCCESS;
65 }
66
68
69 double eSum = 0;
70 unsigned int index = 0;
71 std::vector<double> eSumCalos;
72 std::vector<unsigned int> nCellCalos;
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]);
86 P4PxPyPzE aP(aCell);
87 const double aPeta=aP.e() != 0 ? aP.eta() : 0;
88 const double aPphi=aP.phi() ;
89
90
91
92
93
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 }
101 msg(MSG::WARNING) <<
"Cell " <<
index <<
" phi inconsistency : " << aCell->phi()
102 <<
" vs recalculated " << aPphi <<
endmsg ;
103 }
104 }
106 if (msgLvl(MSG::VERBOSE)) {
107 for (const CaloCell* aCell : *theCont) {
108 const CaloDetDescrElement * theDDE=aCell->caloDDE();
109 msg(MSG::VERBOSE) <<
index <<
" " <<
" " << aCell
111 <<
" eta " << theDDE->
eta()
112 <<
" phi " << theDDE->
phi()
113 <<
" e " << aCell->e() <<
endmsg ;
115 }
116 }
117
118
121 {
122 msg(MSG::WARNING) <<
" There are cells for calo "
123 << iCalo <<
" but hasCalo is not set. " <<
endmsg ;
124 }
125 }
126
128
129
132 double theESumCalo=0;
133 unsigned int theNCellCalo=0;
134
137 for (;itrCell!=endCell;++itrCell){
138 theESumCalo+=(*itrCell)->e();
139 ++theNCellCalo;
140 }
141
142
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)
154 returnSc = StatusCode::FAILURE;
155 }
156
157
158
159 ATH_MSG_DEBUG(
"theESumCalo eSumCalos[iCalo] "<< theESumCalo <<
" " << eSumCalos[iCalo]);
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
173
174
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
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 }
195 }
196 }
197 ATH_MSG_DEBUG(
"Number of hash with no cells: " << nHoles <<
" out of " << hashMax);
198
199 std::vector<IdentifierHash>
hashes ;
201 double eSumFound=0;
202
204
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 }
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}
std::vector< const CaloCell * > CellVector
type to be used for the internal lookup table, and to return list of cells
CaloCell_Base_ID::SUBCALO SUBCALO
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
IdentifierHash calo_hash() const
cell calo hash
CaloCell_ID::SUBCALO getSubCalo() const
cell subcalo
float eta() const
cell eta
float phi() const
cell phi
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
DataModel_detail::const_iterator< DataVector > const_iterator
::StatusCode StatusCode
StatusCode definition for legacy code.