31 #include "Identifier/Identifier.h"
36 #define MAX_BUFFER_LEN 1024
51 m_isValidMinus(false),
73 for(
unsigned int i=0;
i<theRange[
SIDE].get_indices();
i++) {
74 if ( theRange[
SIDE].get_value_at(
i) < 0 )
125 if ( !theRange.
match(
id) ) {
126 std::cout <<
"CaloNeighbours::set_neighbours ERROR: " << (std::string)
id <<
" is not within the Range " << (std::string)theRange << std::endl;
171 std::cout <<
"CaloNeighbours::get_id ERROR: " << (std::string)
id <<
" is not in the LAr or Tile calorimeters" << std::endl;
180 std::vector<ExpandedIdentifier>&
id2,
197 for (
int theSide = 0;theSide<nMaxSides;theSide++) {
198 for (
int theDPhi = 0;theDPhi<nMaxPhi;theDPhi++) {
200 int dphi2 = (
int)(theDPhi*rPhi+0.05);
214 std::vector<IdentifierHash> theTargetHashIDs;
223 theTargetHashIDs.push_back(myTargetHash);
226 neighbourMapPlus[myHash] = std::move(theTargetHashIDs);
229 neighbourMapMinus[myHash] = std::move(theTargetHashIDs);
244 for (
const auto&
p : neighbourMapMinus) {
252 for (
const auto&
p : neighbourMapPlus) {
266 neighbourList.insert(neighbourList.end(),
271 neighbourList.insert(neighbourList.end(),
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()) ;
462 const std::vector<std::unique_ptr<CaloNeighbourRegion> > ®ions,
463 std::vector<IdentifierHash>& neighbourList)
466 for (
const std::unique_ptr<CaloNeighbourRegion>&
p : regions) {
467 result =
p->getNeighbours(
id,neighbourList);