84 MsgStream log(msgSvc(),name());
96 <<
"tool does not hang off the TBXMLWriter algorithm."
98 return StatusCode::FAILURE;
103 if ( checkOut.isFailure() )
106 <<
"cannot convert properties correctly!"
108 return StatusCode::FAILURE;
114 <<
"list of included calo samplings:"
121 <<
"\042 with SubCalo index "
131 const EventContext& ctx = Gaudi::Hive::currentContext();
132 EventIDBase::number_type run_number = ctx.eventID().run_number();
136 if ( checkOut.isFailure() )
139 <<
"cannot produce run XML files."
141 return StatusCode::FAILURE;
160 outStream <<
"<!-- TBXMLCaloCellWriterTool: begin write cell container "
163 std::vector<std::string> theCellAttrNames;
164 theCellAttrNames.push_back(
"name");
165 theCellAttrNames.push_back(
"ncols");
166 theCellAttrNames.push_back(
"nrows");
167 theCellAttrNames.push_back(
"idtype");
168 theCellAttrNames.push_back(
"etype");
169 std::vector<std::string> theCellAttrValues;
175 (
unsigned int)ceil( (
double)dataSize / (
double)
m_nCols );
176 theCellAttrValues.push_back(std::to_string(
m_nCols));
177 theCellAttrValues.push_back(std::to_string(nRows));
178 theCellAttrValues.push_back(
"uint");
179 theCellAttrValues.push_back(
"double");
181 theCellAttrNames,theCellAttrValues);
192 baseIndex, lastIndex);
194 unsigned int theCtr = 0;
195 bool isTerminated =
false;
196 for ( ; firstCell != lastCell; ++firstCell )
199 double eta = (*firstCell)->eta();
200 double phi = (*firstCell)->phi();
206 theLayer = CaloSampling::Unknown;
217 (*firstCell)->caloDDE()->calo_hash();
219 int etaIndex =
m_idHelper->eta((*firstCell)->ID());
220 int phiIndex =
m_idHelper->phi((*firstCell)->ID());
221 int regIndex =
m_idHelper->region((*firstCell)->ID());
223 int lyrIndex =
m_idHelper->sampling((*firstCell)->ID());
226 if (
m_idHelper->is_em_barrel((*firstCell)->ID()) )
230 else if (
m_idHelper->is_em_endcap((*firstCell)->ID()) )
234 else if (
m_idHelper->is_tile_barrel((*firstCell)->ID()) )
238 else if (
m_idHelper->is_tile_extbarrel((*firstCell)->ID()) )
242 else if (
m_idHelper->is_hec((*firstCell)->ID()) )
246 else if (
m_idHelper->is_fcal((*firstCell)->ID()) )
251 double theEnergy = (*firstCell)->e();
252 if ( theCtr == 0 || ( theCtr %
m_nCols ) == 0 )
256 theIndex -= (int)baseIndex;
257 boost::io::ios_base_all_saver streamsave (outStream);
259 << std::setw(10) << std::setfill(
' ') << theIndex <<
" "
260 << std::setw(3) << std::setfill(
' ') << subIndex <<
" "
261 << std::setw(3) << std::setfill(
' ') << lyrIndex <<
" "
262 << std::setw(3) << std::setfill(
' ') << regIndex <<
" "
263 << std::setw(3) << std::setfill(
' ') << etaIndex <<
" "
264 << std::setw(3) << std::setfill(
' ') << phiIndex <<
" "
265 << std::setw(10) << std::setprecision(5) << theEnergy;
267 if ( (isTerminated = ( theCtr %
m_nCols )) == 0 )
273 if ( ! isTerminated ) outStream <<
'\n';
276 outStream <<
"<!-- TBXMLCaloCellWriterTool: end write cell container "
280 return StatusCode::SUCCESS;
289 unsigned int runNumber)
296 std::ofstream thisFileStream(std::format(
"{}/geom.{:06}.xml", fileDir, runNumber));
299 std::vector<std::string> theRunElements;
300 theRunElements.push_back(
"FCalGeomTable*");
301 this->
openDictionary(thisFileStream,
"FCalGeomTable",theRunElements);
302 std::vector<std::string> theRunAttr;
303 theRunAttr.push_back(
"name CDATA #REQUIRED");
304 this->
addAttributes(thisFileStream,
"FCalGeomTable",theRunAttr);
307 std::vector<std::string> anyData;
308 anyData.push_back(
"ANY");
310 std::vector<std::string> theGeomAttr;
311 theGeomAttr.push_back(
"name CDATA #REQUIRED");
312 this->
addAttributes(thisFileStream,
"FCalGeomTable",theGeomAttr);
327 firstIndex, lastIndex);
328 safeIndex = firstIndex;
331 std::vector<std::string> theRunValues(theRunAttr.size());
332 for (
unsigned int i=0; i<theRunAttr.size(); i++ )
334 if ( (theRunAttr[i]).
find(
"name") != std::string::npos )
336 theRunValues[i] =
"FCalMod0";
338 theRunAttr[i].substr(0,theRunAttr[i].find_first_of(
' '));
341 this->
openElement(thisFileStream,
"FCalGeomTable",theRunAttr,theRunValues);
342 theRunValues[0] =
"FCalCells";
343 this->
openElement(thisFileStream,
"FCalGeomTable",theRunAttr,theRunValues);
344 thisFileStream <<
"<!-- 32-bit Id"
355 std::unordered_map<int, double> smallestDx;
356 smallestDx.reserve(8);
358 for (
unsigned int iCtr = safeIndex; iCtr <= lastIndex; ++iCtr)
361 const int theCalo =
m_idHelper->sub_calo(theId);
364 const double dx = theElement->
dx();
367 auto [it, inserted] = smallestDx.try_emplace(theCalo, dx);
368 if (!inserted && dx < it->second)
373 for (
unsigned int iCtr=(
unsigned int)firstIndex;
374 iCtr<=(
unsigned int)lastIndex; iCtr++ )
386 double theX = theElement->
x();
387 double theY = theElement->
y();
388 double theZ = theElement->
z();
390 double dx = theElement->
dx();
391 int tileSize = dx > 1.1*smallestDx[theCalo] ? 1 : 0;
394 thisFileStream <<
" "
396 << std::setfill(
' ') << iCtr-(
unsigned int)firstIndex
398 << std::setw(2) << std::setfill(
' ') << theModule
400 << std::setw(2) << std::setfill(
' ') << theEta
402 << std::setw(2) << std::setfill(
' ') << thePhi
404 << std::setw(10) << std::setprecision(5) << theX <<
" "
405 << std::setw(10) << std::setprecision(5) << theY <<
" "
406 << std::setw(10) << std::setprecision(5) << theZ <<
" "
408 << std::setw(2) << std::setfill(
' ') << tileSize
412 thisFileStream.close();
414 return StatusCode::SUCCESS;
421 MsgStream log(msgSvc(),name());
430 std::vector<std::string>::iterator firstCalo =
m_includedCalos.begin();
432 while ( firstCalo != lastCalo )
434 if ( *firstCalo ==
"LAREM" )
439 else if ( *firstCalo ==
"LARHEC" )
444 else if ( *firstCalo ==
"LARFCAL" )
449 else if ( *firstCalo ==
"TILE" )
468 if ( sample ==
"PreSamplerB" )
470 if ( sample ==
"EMB0" )
472 if ( sample ==
"EMB1" )
474 if ( sample ==
"EMB2" )
476 if ( sample ==
"TileBar0" )
478 if ( sample ==
"TileBar1" )
480 if ( sample ==
"TileBar2" )
482 if ( sample ==
"TileExt0" )
484 if ( sample ==
"TileExt1" )
486 if ( sample ==
"TileExt2" )
490 if ( sample ==
"EME1" )
492 if ( sample ==
"EME2" )
494 if ( sample ==
"HEC0" )
496 if ( sample ==
"HEC1" )
498 if ( sample ==
"HEC2" )
500 if ( sample ==
"HEC3" )
502 if ( sample ==
"FCAL0" )
504 if ( sample ==
"FCAL1" )
506 if ( sample ==
"FCAL2" )
511 ? StatusCode::FAILURE
512 : StatusCode::SUCCESS;