ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CaloNeighbours Class Reference

#include <CaloNeighbours.h>

Collaboration diagram for CaloNeighbours:

Public Member Functions

 CaloNeighbours ()
 
virtual ~CaloNeighbours ()
 
int initialize (const CaloCell_Base_ID *caloID, const std::string &filename)
 
int get_nextInCalo (const IdentifierHash &id, std::vector< IdentifierHash > &neighbourList) const
 
int get_prevInCalo (const IdentifierHash &id, std::vector< IdentifierHash > &neighbourList) const
 

Static Public Member Functions

static int get_neighbours (const IdentifierHash &id, const std::vector< std::unique_ptr< CaloNeighbourRegion > > &regions, std::vector< IdentifierHash > &neighbourList)
 

Private Attributes

const CaloCell_Base_IDm_calo_id
 
std::vector< std::unique_ptr< CaloNeighbourRegion > > m_next_regions
 
std::vector< std::unique_ptr< CaloNeighbourRegion > > m_prev_regions
 

Detailed Description

Definition at line 92 of file CaloNeighbours.h.

Constructor & Destructor Documentation

◆ CaloNeighbours()

CaloNeighbours::CaloNeighbours ( )

Definition at line 282 of file CaloNeighbours.cxx.

282  :
283  m_calo_id(nullptr)
284 { }

◆ ~CaloNeighbours()

CaloNeighbours::~CaloNeighbours ( )
virtualdefault

Member Function Documentation

◆ get_neighbours()

int CaloNeighbours::get_neighbours ( const IdentifierHash id,
const std::vector< std::unique_ptr< CaloNeighbourRegion > > &  regions,
std::vector< IdentifierHash > &  neighbourList 
)
static

Definition at line 461 of file CaloNeighbours.cxx.

464 {
465  int result = 0;
466  for (const std::unique_ptr<CaloNeighbourRegion>& p : regions) {
467  result = p->getNeighbours(id,neighbourList);
468  if ( result != 0 )
469  return result;
470  }
471  return result;
472 }

◆ get_nextInCalo()

int CaloNeighbours::get_nextInCalo ( const IdentifierHash id,
std::vector< IdentifierHash > &  neighbourList 
) const

Definition at line 447 of file CaloNeighbours.cxx.

448 {
449  return get_neighbours(id,m_next_regions,neighbourList);
450 }

◆ get_prevInCalo()

int CaloNeighbours::get_prevInCalo ( const IdentifierHash id,
std::vector< IdentifierHash > &  neighbourList 
) const

Definition at line 454 of file CaloNeighbours.cxx.

455 {
456  return get_neighbours(id,m_prev_regions,neighbourList);
457 }

◆ initialize()

int CaloNeighbours::initialize ( const CaloCell_Base_ID caloID,
const std::string &  filename 
)

Definition at line 293 of file CaloNeighbours.cxx.

295 {
296  int result =0;
297  // std::cout << " CaloNeighbours::initialize " << std::endl;
298  m_calo_id = caloID;
299  m_next_regions.resize(0);
300  m_prev_regions.resize(0);
301  // Find the full path to filename:
302  std::string file = PathResolver::find_file (filename, "DATAPATH");
303  // std::cout << "Reading file " << file << std::endl;
304  std::ifstream fin;
305  if (!file.empty()) {
306  fin.open(file.c_str());
307  }
308  else {
309  std::cout << "CaloNeighbours::initialize ERROR Could not find input file " << filename << std::endl;
310  return 1;
311  }
312  if (fin.bad()) {
313  std::cout << "CaloNeighbours::initialize ERROR Could not open file " << file << std::endl;
314  return 1;
315  }
316 
317  //
318  // Parse the input file
319  //
320 
321  char aLine[MAX_BUFFER_LEN],dummy;
322  std::string sLine;
323  std::string cPrevOrNext,cName,cSourceRange,cTargetRange;
324  std::string cExpId;
325  Range mySourceRange,myTargetRange;
326  std::string oArg;
327  bool isComment = true;
328  bool isNext = false;
329  bool isPrev = false;
330  const std::string cmdNext("nextSuperCalo");
331  const std::string cmdPrev("prevSuperCalo");
332  const std::string cmdPhi("calcPhi(");
333  const std::string cmdSide("calcSide(");
334 
335  while( isComment ) {
336  sLine.resize( 0 );
337  do {
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 );
342  }
343  do {
344  while ( sLine.empty() && !fin.eof()) {
345  fin.getline(aLine,sizeof(aLine)-1);
346  sLine = std::string(aLine);
347  }
348  std::istringstream header( sLine.c_str() );
349  bool hasPhi=false;
350  bool hasSide=false;
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 ) {
358  hasSide = true;
359  oArg.erase(0,cmdSide.size());
360  std::istringstream iside( oArg.c_str() );
361  iside >> iSideSource >> dummy >> iSideTarget;
362  }
363  else if ( oArg.find(cmdPhi) != std::string::npos ) {
364  hasPhi = true;
365  oArg.erase(0,cmdPhi.size());
366  std::istringstream iphi( oArg.c_str() );
367  iphi >> iPhiSource >> dummy >> iPhiTarget;
368  }
369  }
370  sLine.resize(0);
371  bool endOfBlock = false;
372  isNext = (cPrevOrNext.find(cmdNext) != std::string::npos);
373  isPrev = (cPrevOrNext.find(cmdPrev) != std::string::npos);
374  if ( isNext^isPrev ) {
375 // std::cout << (isNext?cmdNext:cmdPrev) << " "
376 // << cName << " "
377 // << (std::string)mySourceRange << " "
378 // << (std::string)myTargetRange;
379 // if ( hasSide ) {
380 // std::cout << " hasSide(" << iSideSource << "," << iSideTarget << ")";
381 // }
382 // if ( hasPhi ) {
383 // std::cout << " hasPhi(" << iPhiSource << "," << iPhiTarget << ")";
384 // }
385 // std::cout << std::endl;
386  // create new CaloNeighbourRegion
387  auto myRegion = std::make_unique<CaloNeighbourRegion>(cName,m_calo_id);
388  if ( isNext )
389  myRegion->setType(nextInCalo);
390  else
391  myRegion->setType(prevInCalo);
392  if ( hasSide )
393  myRegion->setSide(iSideSource,iSideTarget);
394  if ( hasPhi )
395  myRegion->setPhi(iPhiSource,iPhiTarget);
396  myRegion->setSourceRange(mySourceRange);
397  myRegion->setTargetRange(myTargetRange);
398  // create temporary neighbour maps
399  std::map<IdentifierHash, std::vector<IdentifierHash>, ltIdHash> neighbourMapPlus,neighbourMapMinus;
400 
401  do {
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() )
406  endOfBlock = true;
407  }
408  if (!endOfBlock) {
409  std::istringstream neighbour( sLine.c_str() );
410  ExpandedIdentifier myCell,myNeighbourCell;
411  std::vector<ExpandedIdentifier> myNeighbourCells;
412  if ( neighbour >> cExpId ) {
413  myCell = ExpandedIdentifier(cExpId);
414  // std::cout << (std::string)myCell << ":";
415  while ( neighbour >> cExpId ) {
416  myNeighbourCell = ExpandedIdentifier(cExpId);
417  // std::cout << " " << (std::string)myNeighbourCell;
418  myNeighbourCells.push_back(myNeighbourCell);
419  }
420  // std::cout << std::endl;
421  sLine.resize(0);
422  result = myRegion->setNeighbours(myCell,myNeighbourCells,neighbourMapPlus,neighbourMapMinus);
423  if ( result != 0 )
424  return result;
425  }
426  }
427  } while (!fin.eof() && !endOfBlock);
428  myRegion->initializeVectors(neighbourMapPlus,neighbourMapMinus);
429  if (isNext)
430  m_next_regions.push_back(std::move(myRegion));
431  else
432  m_prev_regions.push_back(std::move(myRegion));
433  }
434  else {
435  std::cout << "CaloNeighbours::initialize ERROR Invalid neighbour dat file, exiting ... " << std::endl;
436  return 1;
437  }
438  }
439  }while (!fin.eof()) ;
440  fin.close();
441 
442  return 0;
443 }

Member Data Documentation

◆ m_calo_id

const CaloCell_Base_ID* CaloNeighbours::m_calo_id
private

Definition at line 113 of file CaloNeighbours.h.

◆ m_next_regions

std::vector<std::unique_ptr<CaloNeighbourRegion> > CaloNeighbours::m_next_regions
private

Definition at line 115 of file CaloNeighbours.h.

◆ m_prev_regions

std::vector<std::unique_ptr<CaloNeighbourRegion> > CaloNeighbours::m_prev_regions
private

Definition at line 116 of file CaloNeighbours.h.


The documentation for this class was generated from the following files:
MAX_BUFFER_LEN
#define MAX_BUFFER_LEN
Definition: CaloNeighbours.cxx:36
get_generator_info.result
result
Definition: get_generator_info.py:21
header
Definition: hcg.cxx:526
CaloNeighbours::m_calo_id
const CaloCell_Base_ID * m_calo_id
Definition: CaloNeighbours.h:113
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
nextInCalo
@ nextInCalo
Definition: CaloNeighbours.h:30
CalibDbCompareRT.dummy
dummy
Definition: CalibDbCompareRT.py:59
file
TFile * file
Definition: tile_monitor.h:29
CaloNeighbours::m_prev_regions
std::vector< std::unique_ptr< CaloNeighbourRegion > > m_prev_regions
Definition: CaloNeighbours.h:116
ltIdHash
Definition: CaloNeighbours.h:32
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
CaloNeighbours::get_neighbours
static int get_neighbours(const IdentifierHash &id, const std::vector< std::unique_ptr< CaloNeighbourRegion > > &regions, std::vector< IdentifierHash > &neighbourList)
Definition: CaloNeighbours.cxx:461
prevInCalo
@ prevInCalo
Definition: CaloNeighbours.h:30
CaloNeighbours::m_next_regions
std::vector< std::unique_ptr< CaloNeighbourRegion > > m_next_regions
Definition: CaloNeighbours.h:115
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Definition: PathResolver.cxx:183
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23
compute_lumi.fin
fin
Definition: compute_lumi.py:19
makeTOC.header
header
Definition: makeTOC.py:28
Range::build
void build(const std::string &text)
Build Range from a textual description.
Definition: DetectorDescription/Identifier/src/Range.cxx:58