86 MsgStream log(msgSvc(),name());
98 <<
"tool does not hang off the TBXMLWriter algorithm."
100 return StatusCode::FAILURE;
105 if ( checkOut.isFailure() )
108 <<
"cannot convert properties correctly!"
110 return StatusCode::FAILURE;
116 <<
"list of included calo samplings:"
123 <<
"\042 with SubCalo index "
133 const EventContext& ctx = Gaudi::Hive::currentContext();
134 EventIDBase::number_type run_number = ctx.eventID().run_number();
138 if ( checkOut.isFailure() )
141 <<
"cannot produce run XML files."
143 return StatusCode::FAILURE;
162 outStream <<
"<!-- TBXMLCaloCellWriterTool: begin write cell container "
165 std::vector<std::string> theCellAttrNames;
166 theCellAttrNames.push_back(
"name");
167 theCellAttrNames.push_back(
"ncols");
168 theCellAttrNames.push_back(
"nrows");
169 theCellAttrNames.push_back(
"idtype");
170 theCellAttrNames.push_back(
"etype");
171 std::vector<std::string> theCellAttrValues;
173 std::ostringstream theCols;
174 theCols <<
m_nCols << std::ends;
179 (
unsigned int)ceil( (
double)dataSize / (
double)
m_nCols );
180 std::ostringstream theRows;
181 theRows << nRows << std::ends;
182 theCellAttrValues.push_back(theCols.str());
183 theCellAttrValues.push_back(theRows.str());
184 theCellAttrValues.push_back(
"uint");
185 theCellAttrValues.push_back(
"double");
187 theCellAttrNames,theCellAttrValues);
198 baseIndex, lastIndex);
200 unsigned int theCtr = 0;
201 bool isTerminated =
false;
202 for ( ; firstCell != lastCell; ++firstCell )
205 double eta = (*firstCell)->eta();
206 double phi = (*firstCell)->phi();
212 theLayer = CaloSampling::Unknown;
223 (*firstCell)->caloDDE()->calo_hash();
225 int etaIndex =
m_idHelper->eta((*firstCell)->ID());
226 int phiIndex =
m_idHelper->phi((*firstCell)->ID());
227 int regIndex =
m_idHelper->region((*firstCell)->ID());
229 int lyrIndex =
m_idHelper->sampling((*firstCell)->ID());
232 if (
m_idHelper->is_em_barrel((*firstCell)->ID()) )
236 else if (
m_idHelper->is_em_endcap((*firstCell)->ID()) )
240 else if (
m_idHelper->is_tile_barrel((*firstCell)->ID()) )
244 else if (
m_idHelper->is_tile_extbarrel((*firstCell)->ID()) )
248 else if (
m_idHelper->is_hec((*firstCell)->ID()) )
252 else if (
m_idHelper->is_fcal((*firstCell)->ID()) )
257 double theEnergy = (*firstCell)->e();
258 if ( theCtr == 0 || ( theCtr %
m_nCols ) == 0 )
262 theIndex -= (int)baseIndex;
263 boost::io::ios_base_all_saver streamsave (outStream);
265 << std::setw(10) << std::setfill(
' ') << theIndex <<
" "
266 << std::setw(3) << std::setfill(
' ') << subIndex <<
" "
267 << std::setw(3) << std::setfill(
' ') << lyrIndex <<
" "
268 << std::setw(3) << std::setfill(
' ') << regIndex <<
" "
269 << std::setw(3) << std::setfill(
' ') << etaIndex <<
" "
270 << std::setw(3) << std::setfill(
' ') << phiIndex <<
" "
271 << std::setw(10) << std::setprecision(5) << theEnergy;
273 if ( (isTerminated = ( theCtr %
m_nCols )) == 0 )
275 outStream << std::endl;
279 if ( ! isTerminated ) outStream << std::endl;
282 outStream <<
"<!-- TBXMLCaloCellWriterTool: end write cell container "
286 return StatusCode::SUCCESS;
295 unsigned int runNumber)
303 std::ostringstream thisFileName;
304 thisFileName << fileDir <<
"/geom."
305 << std::setw(6) << std::setfill(
'0')
306 << runNumber <<
".xml" << std::ends;
308 std::ofstream thisFileStream((thisFileName.str()).c_str());
311 std::vector<std::string> theRunElements;
312 theRunElements.push_back(
"FCalGeomTable*");
313 this->
openDictionary(thisFileStream,
"FCalGeomTable",theRunElements);
314 std::vector<std::string> theRunAttr;
315 theRunAttr.push_back(
"name CDATA #REQUIRED");
316 this->
addAttributes(thisFileStream,
"FCalGeomTable",theRunAttr);
319 std::vector<std::string> anyData;
320 anyData.push_back(
"ANY");
322 std::vector<std::string> theGeomAttr;
323 theGeomAttr.push_back(
"name CDATA #REQUIRED");
324 this->
addAttributes(thisFileStream,
"FCalGeomTable",theGeomAttr);
339 firstIndex, lastIndex);
340 safeIndex = firstIndex;
343 std::vector<std::string> theRunValues(theRunAttr.size());
344 for (
unsigned int i=0; i<theRunAttr.size(); i++ )
346 if ( (theRunAttr[i]).
find(
"name") != std::string::npos )
348 theRunValues[i] =
"FCalMod0";
350 theRunAttr[i].substr(0,theRunAttr[i].find_first_of(
" "));
353 this->
openElement(thisFileStream,
"FCalGeomTable",theRunAttr,theRunValues);
354 theRunValues[0] =
"FCalCells";
355 this->
openElement(thisFileStream,
"FCalGeomTable",theRunAttr,theRunValues);
356 thisFileStream <<
"<!-- 32-bit Id"
364 <<
"-->" << std::endl;
367 std::map<int,double> smallestDx;
368 std::map<int,double> largestDx;
369 for (
unsigned int iCtr = (
unsigned int)safeIndex;
370 iCtr <= (
unsigned int)lastIndex; iCtr++ )
377 double dx = theElement->
dx();
379 if ( smallestDx.find(theCalo) == smallestDx.end() )
381 smallestDx[theCalo] = dx;
382 largestDx[theCalo] = dx;
386 if ( dx < smallestDx[theCalo] ) smallestDx[theCalo] = dx;
387 if ( dx > largestDx[theCalo] ) largestDx[theCalo] = dx;
392 for (
unsigned int iCtr=(
unsigned int)firstIndex;
393 iCtr<=(
unsigned int)lastIndex; iCtr++ )
405 double theX = theElement->
x();
406 double theY = theElement->
y();
407 double theZ = theElement->
z();
409 double dx = theElement->
dx();
410 int tileSize = dx > 1.1*smallestDx[theCalo] ? 1 : 0;
413 thisFileStream <<
" "
415 << std::setfill(
' ') << iCtr-(
unsigned int)firstIndex
417 << std::setw(2) << std::setfill(
' ') << theModule
419 << std::setw(2) << std::setfill(
' ') << theEta
421 << std::setw(2) << std::setfill(
' ') << thePhi
423 << std::setw(10) << std::setprecision(5) << theX <<
" "
424 << std::setw(10) << std::setprecision(5) << theY <<
" "
425 << std::setw(10) << std::setprecision(5) << theZ <<
" "
427 << std::setw(2) << std::setfill(
' ') << tileSize
431 thisFileStream.close();
433 return StatusCode::SUCCESS;
440 MsgStream log(msgSvc(),name());
449 std::vector<std::string>::iterator firstCalo =
m_includedCalos.begin();
451 while ( firstCalo != lastCalo )
453 if ( *firstCalo ==
"LAREM" )
458 else if ( *firstCalo ==
"LARHEC" )
463 else if ( *firstCalo ==
"LARFCAL" )
468 else if ( *firstCalo ==
"TILE" )
487 if ( sample ==
"PreSamplerB" )
489 if ( sample ==
"EMB0" )
491 if ( sample ==
"EMB1" )
493 if ( sample ==
"EMB2" )
495 if ( sample ==
"TileBar0" )
497 if ( sample ==
"TileBar1" )
499 if ( sample ==
"TileBar2" )
501 if ( sample ==
"TileExt0" )
503 if ( sample ==
"TileExt1" )
505 if ( sample ==
"TileExt2" )
509 if ( sample ==
"EME1" )
511 if ( sample ==
"EME2" )
513 if ( sample ==
"HEC0" )
515 if ( sample ==
"HEC1" )
517 if ( sample ==
"HEC2" )
519 if ( sample ==
"HEC3" )
521 if ( sample ==
"FCAL0" )
523 if ( sample ==
"FCAL1" )
525 if ( sample ==
"FCAL2" )
530 ? StatusCode::FAILURE
531 : StatusCode::SUCCESS;