ATLAS Offline Software
FileRoISeedTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2020-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Implementation file for class FileRoISeedTool (get RoI for low-pt tracking from a file)
8 // (c) ATLAS Detector software
10 
11 
13 
14 #include "TVector2.h"
15 
16 #include <map>
17 #include <sstream>
18 #include <fstream>
19 #include <string>
20 #include <filesystem>
21 
23 // Constructor
25 
27 (const std::string& t,const std::string& n,const IInterface* p)
28  : base_class(t,n,p)
29 {
30 }
31 
33 // Initialization
35 
37 {
39 
41 
43  ATH_MSG_ERROR( "RoI File DOES NOT Exist!");
44  return StatusCode::FAILURE;
45  }
46 
47  return sc;
48 }
49 
51 // Compute RoI
53 std::vector<InDet::IZWindowRoISeedTool::ZWindow> InDet::FileRoISeedTool::getRoIs(const EventContext& ctx) const
54 {
55 
56  // prepare output
57  std::vector<InDet::IZWindowRoISeedTool::ZWindow> listRoIs;
58  listRoIs.clear();
59 
60  unsigned long long evtN = 0;
61  int runN = 0;
62 
64  if ( eventInfo.isValid() ){
65  evtN = eventInfo->eventNumber();
66  runN = eventInfo->runNumber();
67  }
68 
69  std::string line;
70  std::ifstream inFile(m_filename.value());
71  if (inFile.is_open()){
72 
73  while (std::getline(inFile, line)){
74 
75  std::istringstream iss(line);
76 
77  int runnum;
78  unsigned long long eventnum;
79  float zref;
80 
81  while( iss >> runnum >> eventnum >> zref){
82  //no need to go past the right line
83  if(runnum == runN && eventnum == evtN) break;
84  }
85 
86  if(runnum == runN && eventnum == evtN){ //No need to fill if there isn't an ROI
88  readinref.zReference = zref;
89  readinref.zWindow[0] = zref -m_z0Window;
90  readinref.zWindow[1] = zref + m_z0Window;
91  listRoIs.push_back(readinref);
92  }
93 
94  }
95  }
96 
97  inFile.close();
98 
99  return listRoIs;
100 
101 }
102 
python.utils.AtlRunQueryDQUtils.runnum
runnum
Definition: AtlRunQueryDQUtils.py:214
checkFileSG.line
line
Definition: checkFileSG.py:75
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
initialize
void initialize()
Definition: run_EoverP.cxx:894
makeTOC.inFile
string inFile
Definition: makeTOC.py:5
InDet::FileRoISeedTool::m_z0Window
FloatProperty m_z0Window
Definition: FileRoISeedTool.h:65
FileRoISeedTool.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::IZWindowRoISeedTool::ZWindow
Definition: IZWindowRoISeedTool.h:46
InDet::FileRoISeedTool::initialize
virtual StatusCode initialize() override
Definition: FileRoISeedTool.cxx:36
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDet::FileRoISeedTool::FileRoISeedTool
FileRoISeedTool()=delete
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
InDet::IZWindowRoISeedTool::ZWindow::zWindow
float zWindow[2]
Definition: IZWindowRoISeedTool.h:49
InDet::FileRoISeedTool::getRoIs
virtual std::vector< ZWindow > getRoIs(const EventContext &ctx) const override
Compute RoI.
Definition: FileRoISeedTool.cxx:53
InDet::FileRoISeedTool::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: FileRoISeedTool.h:67
InDet::FileRoISeedTool::m_filename
StringProperty m_filename
Definition: FileRoISeedTool.h:64
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
InDet::IZWindowRoISeedTool::ZWindow::zReference
float zReference
Definition: IZWindowRoISeedTool.h:51