ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
InDet::GNNTrackReaderTool Class Reference

InDet::GNNTrackReaderTool is a tool that reads track candidates of each event from a CSV file named as "track_runNumber_eventNumber.csv" or with a customized pre-fix. The directory, inputTracksDir, contains CSV files for all events. 1) If the inputTracksDir is not specified, the tool will read the CSV files from the current directory. 2) If the corresponding CSV file does not exist for a given event (runNumber, eventNumber), the tool will print an error message and return an empty list. More...

#include <GNNTrackReaderTool.h>

Inheritance diagram for InDet::GNNTrackReaderTool:
Collaboration diagram for InDet::GNNTrackReaderTool:

Public Member Functions

 GNNTrackReaderTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual void getTracks (uint32_t runNumber, uint32_t eventNumber, std::vector< std::vector< uint32_t > > &tracks) const override final
 Get track candidates from a CSV file named by runNumber and eventNumber. More...
 
virtual MsgStream & dump (MsgStream &out) const override
 
virtual std::ostream & dump (std::ostream &out) const override
 

Protected Member Functions

 GNNTrackReaderTool ()=delete
 
 GNNTrackReaderTool (const GNNTrackReaderTool &)=delete
 
GNNTrackReaderTooloperator= (const GNNTrackReaderTool &)=delete
 
MsgStream & dumpevent (MsgStream &out) const
 

Protected Attributes

StringProperty m_inputTracksDir {this, "inputTracksDir", "."}
 
StringProperty m_csvPrefix {this, "csvPrefix", "track"}
 

Detailed Description

InDet::GNNTrackReaderTool is a tool that reads track candidates of each event from a CSV file named as "track_runNumber_eventNumber.csv" or with a customized pre-fix. The directory, inputTracksDir, contains CSV files for all events. 1) If the inputTracksDir is not specified, the tool will read the CSV files from the current directory. 2) If the corresponding CSV file does not exist for a given event (runNumber, eventNumber), the tool will print an error message and return an empty list.

Author
xiang.nosp@m.yang.nosp@m..ju@c.nosp@m.ern..nosp@m.ch

Definition at line 32 of file GNNTrackReaderTool.h.

Constructor & Destructor Documentation

◆ GNNTrackReaderTool() [1/3]

InDet::GNNTrackReaderTool::GNNTrackReaderTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 12 of file GNNTrackReaderTool.cxx.

13  :
14  base_class(type, name, parent)
15 {
16  declareInterface<IGNNTrackReaderTool>(this);
17 }

◆ GNNTrackReaderTool() [2/3]

InDet::GNNTrackReaderTool::GNNTrackReaderTool ( )
protecteddelete

◆ GNNTrackReaderTool() [3/3]

InDet::GNNTrackReaderTool::GNNTrackReaderTool ( const GNNTrackReaderTool )
protecteddelete

Member Function Documentation

◆ dump() [1/2]

MsgStream & InDet::GNNTrackReaderTool::dump ( MsgStream &  out) const
overridevirtual

Definition at line 19 of file GNNTrackReaderTool.cxx.

20 {
21  out<<std::endl;
22  return dumpevent(out);
23 }

◆ dump() [2/2]

std::ostream & InDet::GNNTrackReaderTool::dump ( std::ostream &  out) const
overridevirtual

Definition at line 25 of file GNNTrackReaderTool.cxx.

26 {
27  return out;
28 }

◆ dumpevent()

MsgStream & InDet::GNNTrackReaderTool::dumpevent ( MsgStream &  out) const
protected

Definition at line 30 of file GNNTrackReaderTool.cxx.

31 {
32  out<<"|---------------------------------------------------------------------|"
33  <<std::endl;
34  out<<"| Number output tracks | "<<std::setw(12)
35  <<" |"<<std::endl;
36  out<<"|---------------------------------------------------------------------|"
37  <<std::endl;
38  return out;
39 }

◆ getTracks()

void InDet::GNNTrackReaderTool::getTracks ( uint32_t  runNumber,
uint32_t  eventNumber,
std::vector< std::vector< uint32_t > > &  tracks 
) const
finaloverridevirtual

Get track candidates from a CSV file named by runNumber and eventNumber.

Parameters
runNumberrun number of the event.
eventNumberevent number of the event.
tracksa list of track candidates in terms of spacepoint indices as read from the CSV file.

Definition at line 41 of file GNNTrackReaderTool.cxx.

43 {
44  std::string fileName = m_inputTracksDir + "/" + m_csvPrefix + "_" \
46 
47  trackCandidates.clear();
48  std::ifstream csvFile(fileName);
49 
50  if (!csvFile.is_open()) {
51  ATH_MSG_ERROR("Cannot open file " << fileName);
52  return;
53  } else {
54  ATH_MSG_INFO("File " << fileName << " is opened.");
55  }
56 
57  std::string line;
58  while(std::getline(csvFile, line)){
59  std::stringstream lineStream(line);
60  std::string cell;
61  std::vector<uint32_t> trackCandidate;
62  while(std::getline(lineStream, cell, ','))
63  {
64  uint32_t cellId = 0;
65  try {
66  cellId = std::stoi(cell);
67  } catch (const std::invalid_argument& ia) {
68  std::cout << "Invalid argument: " << ia.what() << " for cell " << cell << std::endl;
69  continue;
70  }
71 
72  if (std::find(trackCandidate.begin(), trackCandidate.end(), cellId) == trackCandidate.end()) {
73  trackCandidate.push_back(cellId);
74  }
75  }
76  trackCandidates.push_back(std::move(trackCandidate));
77  }
78 }

◆ operator=()

GNNTrackReaderTool& InDet::GNNTrackReaderTool::operator= ( const GNNTrackReaderTool )
protecteddelete

Member Data Documentation

◆ m_csvPrefix

StringProperty InDet::GNNTrackReaderTool::m_csvPrefix {this, "csvPrefix", "track"}
protected

Definition at line 63 of file GNNTrackReaderTool.h.

◆ m_inputTracksDir

StringProperty InDet::GNNTrackReaderTool::m_inputTracksDir {this, "inputTracksDir", "."}
protected

Definition at line 62 of file GNNTrackReaderTool.h.


The documentation for this class was generated from the following files:
checkFileSG.line
line
Definition: checkFileSG.py:75
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
InDet::GNNTrackReaderTool::m_csvPrefix
StringProperty m_csvPrefix
Definition: GNNTrackReaderTool.h:63
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
InDet::GNNTrackReaderTool::m_inputTracksDir
StringProperty m_inputTracksDir
Definition: GNNTrackReaderTool.h:62
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
InDet::GNNTrackReaderTool::dumpevent
MsgStream & dumpevent(MsgStream &out) const
Definition: GNNTrackReaderTool.cxx:30