ATLAS Offline Software
GNNTrackReaderTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GNNTrackReaderTool.h"
6 
7 // Framework include(s).
9 #include <cmath>
10 #include <fstream>
11 
13  const std::string& type, const std::string& name, const IInterface* parent):
14  base_class(type, name, parent)
15 {
16  declareInterface<IGNNTrackReaderTool>(this);
17 }
18 
19 MsgStream& InDet::GNNTrackReaderTool::dump( MsgStream& out ) const
20 {
21  out<<std::endl;
22  return dumpevent(out);
23 }
24 
25 std::ostream& InDet::GNNTrackReaderTool::dump( std::ostream& out ) const
26 {
27  return out;
28 }
29 
30 MsgStream& InDet::GNNTrackReaderTool::dumpevent( MsgStream& out ) const
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 }
40 
42  std::vector<std::vector<uint32_t> >& trackCandidates) const
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 }
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
GNNTrackReaderTool.h
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
PathResolver.h
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
InDet::GNNTrackReaderTool::GNNTrackReaderTool
GNNTrackReaderTool()=delete
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
InDet::GNNTrackReaderTool::dump
virtual MsgStream & dump(MsgStream &out) const override
Definition: GNNTrackReaderTool.cxx:19
InDet::GNNTrackReaderTool::getTracks
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.
Definition: GNNTrackReaderTool.cxx:41
InDet::GNNTrackReaderTool::dumpevent
MsgStream & dumpevent(MsgStream &out) const
Definition: GNNTrackReaderTool.cxx:30