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 284 of file CaloNeighbours.cxx.

284  :
285  m_calo_id(nullptr)
286 { }

◆ ~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 463 of file CaloNeighbours.cxx.

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

◆ get_nextInCalo()

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

Definition at line 449 of file CaloNeighbours.cxx.

450 {
451  return get_neighbours(id,m_next_regions,neighbourList);
452 }

◆ get_prevInCalo()

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

Definition at line 456 of file CaloNeighbours.cxx.

457 {
458  return get_neighbours(id,m_prev_regions,neighbourList);
459 }

◆ initialize()

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

Definition at line 295 of file CaloNeighbours.cxx.

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

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:38
get_generator_info.result
result
Definition: get_generator_info.py:21
header
Definition: hcg.cxx:526
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
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:210
nextInCalo
@ nextInCalo
Definition: CaloNeighbours.h:30
file
TFile * file
Definition: tile_monitor.h:29
python.xAODType.dummy
dummy
Definition: xAODType.py:4
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:463
prevInCalo
@ prevInCalo
Definition: CaloNeighbours.h:30
CaloNeighbours::m_next_regions
std::vector< std::unique_ptr< CaloNeighbourRegion > > m_next_regions
Definition: CaloNeighbours.h:115
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
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