311 std::cout <<
"CaloNeighbours::initialize ERROR Could not find input file " <<
filename << std::endl;
315 std::cout <<
"CaloNeighbours::initialize ERROR Could not open file " <<
file << std::endl;
325 std::string cPrevOrNext,cName,cSourceRange,cTargetRange;
327 Range mySourceRange,myTargetRange;
329 bool isComment =
true;
332 const std::string cmdNext(
"nextSuperCalo");
333 const std::string cmdPrev(
"prevSuperCalo");
334 const std::string cmdPhi(
"calcPhi(");
335 const std::string cmdSide(
"calcSide(");
340 fin.getline(aLine,
sizeof(aLine)-1);
341 sLine = std::string(aLine);
342 }
while (sLine.empty() && !
fin.eof());
343 isComment = ( sLine.find(
'#') != std::string::npos );
346 while ( sLine.empty() && !
fin.eof()) {
347 fin.getline(aLine,
sizeof(aLine)-1);
348 sLine = std::string(aLine);
350 std::istringstream
header( sLine.c_str() );
353 int iPhiSource,iPhiTarget;
354 int iSideSource,iSideTarget;
355 if (
header >> cPrevOrNext >> cName >> cSourceRange >> cTargetRange) {
356 mySourceRange.
build(cSourceRange);
357 myTargetRange.
build(cTargetRange);
358 while (
header >> oArg ) {
359 if (oArg.find(cmdSide) != std::string::npos ) {
361 oArg.erase(0,cmdSide.size());
362 std::istringstream iside( oArg.c_str() );
363 iside >> iSideSource >>
dummy >> iSideTarget;
365 else if ( oArg.find(cmdPhi) != std::string::npos ) {
367 oArg.erase(0,cmdPhi.size());
368 std::istringstream iphi( oArg.c_str() );
369 iphi >> iPhiSource >>
dummy >> iPhiTarget;
373 bool endOfBlock =
false;
374 isNext = (cPrevOrNext.find(cmdNext) != std::string::npos);
375 isPrev = (cPrevOrNext.find(cmdPrev) != std::string::npos);
376 if ( isNext^isPrev ) {
389 auto myRegion = std::make_unique<CaloNeighbourRegion>(cName,
m_calo_id);
395 myRegion->setSide(iSideSource,iSideTarget);
397 myRegion->setPhi(iPhiSource,iPhiTarget);
398 myRegion->setSourceRange(mySourceRange);
399 myRegion->setTargetRange(myTargetRange);
401 std::map<IdentifierHash, std::vector<IdentifierHash>,
ltIdHash> neighbourMapPlus,neighbourMapMinus;
404 while ( !endOfBlock && sLine.empty() && !
fin.eof()) {
405 fin.getline(aLine,
sizeof(aLine)-1);
406 sLine = std::string(aLine);
407 if ( sLine.empty() ||
fin.eof() )
411 std::istringstream neighbour( sLine.c_str() );
413 std::vector<ExpandedIdentifier> myNeighbourCells;
414 if ( neighbour >> cExpId ) {
417 while ( neighbour >> cExpId ) {
420 myNeighbourCells.push_back(myNeighbourCell);
424 result = myRegion->setNeighbours(myCell,myNeighbourCells,neighbourMapPlus,neighbourMapMinus);
429 }
while (!
fin.eof() && !endOfBlock);
430 myRegion->initializeVectors(neighbourMapPlus,neighbourMapMinus);
437 std::cout <<
"CaloNeighbours::initialize ERROR Invalid neighbour dat file, exiting ... " << std::endl;
441 }
while (!
fin.eof()) ;