309 std::cout <<
"CaloNeighbours::initialize ERROR Could not find input file " <<
filename << std::endl;
313 std::cout <<
"CaloNeighbours::initialize ERROR Could not open file " <<
file << std::endl;
323 std::string cPrevOrNext,cName,cSourceRange,cTargetRange;
325 Range mySourceRange,myTargetRange;
327 bool isComment =
true;
330 const std::string cmdNext(
"nextSuperCalo");
331 const std::string cmdPrev(
"prevSuperCalo");
332 const std::string cmdPhi(
"calcPhi(");
333 const std::string cmdSide(
"calcSide(");
338 fin.getline(aLine,
sizeof(aLine)-1);
339 sLine = std::string(aLine);
340 }
while (sLine.empty() && !
fin.eof());
341 isComment = ( sLine.find(
'#') != std::string::npos );
344 while ( sLine.empty() && !
fin.eof()) {
345 fin.getline(aLine,
sizeof(aLine)-1);
346 sLine = std::string(aLine);
348 std::istringstream
header( sLine.c_str() );
351 int iPhiSource,iPhiTarget;
352 int iSideSource,iSideTarget;
353 if (
header >> cPrevOrNext >> cName >> cSourceRange >> cTargetRange) {
354 mySourceRange.
build(cSourceRange);
355 myTargetRange.
build(cTargetRange);
356 while (
header >> oArg ) {
357 if (oArg.find(cmdSide) != std::string::npos ) {
359 oArg.erase(0,cmdSide.size());
360 std::istringstream iside( oArg.c_str() );
361 iside >> iSideSource >>
dummy >> iSideTarget;
363 else if ( oArg.find(cmdPhi) != std::string::npos ) {
365 oArg.erase(0,cmdPhi.size());
366 std::istringstream iphi( oArg.c_str() );
367 iphi >> iPhiSource >>
dummy >> iPhiTarget;
371 bool endOfBlock =
false;
372 isNext = (cPrevOrNext.find(cmdNext) != std::string::npos);
373 isPrev = (cPrevOrNext.find(cmdPrev) != std::string::npos);
374 if ( isNext^isPrev ) {
387 auto myRegion = std::make_unique<CaloNeighbourRegion>(cName,
m_calo_id);
393 myRegion->setSide(iSideSource,iSideTarget);
395 myRegion->setPhi(iPhiSource,iPhiTarget);
396 myRegion->setSourceRange(mySourceRange);
397 myRegion->setTargetRange(myTargetRange);
399 std::map<IdentifierHash, std::vector<IdentifierHash>,
ltIdHash> neighbourMapPlus,neighbourMapMinus;
402 while ( !endOfBlock && sLine.empty() && !
fin.eof()) {
403 fin.getline(aLine,
sizeof(aLine)-1);
404 sLine = std::string(aLine);
405 if ( sLine.empty() ||
fin.eof() )
409 std::istringstream neighbour( sLine.c_str() );
411 std::vector<ExpandedIdentifier> myNeighbourCells;
412 if ( neighbour >> cExpId ) {
415 while ( neighbour >> cExpId ) {
418 myNeighbourCells.push_back(myNeighbourCell);
422 result = myRegion->setNeighbours(myCell,myNeighbourCells,neighbourMapPlus,neighbourMapMinus);
427 }
while (!
fin.eof() && !endOfBlock);
428 myRegion->initializeVectors(neighbourMapPlus,neighbourMapMinus);
435 std::cout <<
"CaloNeighbours::initialize ERROR Invalid neighbour dat file, exiting ... " << std::endl;
439 }
while (!
fin.eof()) ;