ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
TCS::TopoASCIIReader Class Reference

#include <TopoASCIIReader.h>

Collaboration diagram for TCS::TopoASCIIReader:

Public Member Functions

 TopoASCIIReader (int verbose=0)
 
 ~TopoASCIIReader ()
 
void loadInput (const std::string &input)
 
void validateInput ()
 
void setVerbosity (int verbosity)
 
void setInputEvent (TCS::TopoInputEvent *evt)
 
bool getNextEvent ()
 
void printEvent ()
 
void printFileSummary ()
 
void reset ()
 

Private Attributes

std::ifstream m_fs
 
std::string m_inputFile { "" }
 
TCS::TopoInputEventm_event { nullptr }
 
int m_verbosity { 0 }
 
int m_nEvents { 0 }
 

Detailed Description

Definition at line 27 of file TopoASCIIReader.h.

Constructor & Destructor Documentation

◆ TopoASCIIReader()

TCS::TopoASCIIReader::TopoASCIIReader ( int  verbose = 0)

Definition at line 13 of file TopoASCIIReader.cxx.

13  :
15 {
16 }

◆ ~TopoASCIIReader()

TCS::TopoASCIIReader::~TopoASCIIReader ( )

Definition at line 19 of file TopoASCIIReader.cxx.

19  {
20  m_fs.close();
21 }

Member Function Documentation

◆ getNextEvent()

bool TCS::TopoASCIIReader::getNextEvent ( )

Definition at line 42 of file TopoASCIIReader.cxx.

42  {
43 
44  // clear info from previous event
45  string type = "default";
46  string currentLine;
47  m_event->clear();
48 
49  // run through single event
50  while((currentLine != "<end_file>") && (currentLine != "</file>")) {
51 
52  // get next data line
53  std::getline(m_fs, currentLine);
54  if(m_verbosity>0)
55  cout << currentLine << endl;
56 
57  // process these lines
58 
59  if(currentLine == "<end_file>" || currentLine == "</file>") return false;
60  if(currentLine == "<end_event>" || currentLine == "</event>") break;
61  if(currentLine == "<cluster>" || currentLine == "<eEm>" || currentLine == "<eTau>" || currentLine == "<jet>" || currentLine == "<jTau>" || currentLine == "<jEm>" || currentLine == "<jLJet>" || currentLine == "<gLJet>" || currentLine == "<jJet>" || currentLine == "<gJet>" || currentLine == "<muon>" || currentLine == "<lateMuon>" || currentLine == "<muonNextBC>" || currentLine == "<tau>" || currentLine == "<met>" || currentLine == "<info>") type = currentLine;
62  if(currentLine == "</cluster>" || currentLine == "</eEm>" || currentLine == "</eTau>" || currentLine == "</jet>" || currentLine == "</jTau>" || currentLine == "</jEm>" || currentLine == "</jLJet>" || currentLine == "</gLJet>" || currentLine == "</jJet>" || currentLine == "</gJet>" || currentLine == "</muon>" || currentLine == "</lateMuon>" || currentLine == "</muonNextBC>" || currentLine == "</tau>" || currentLine == "</met>" || currentLine == "</info>") { type = ""; continue; }
63  if(currentLine == "<begin_file>" || currentLine == "<file>" || currentLine == "<begin_event>" || currentLine == "<event>" || currentLine == "<cluster>" || currentLine == "<eEm>" || currentLine == "<eTau>" || currentLine == "<jet>" || currentLine == "<jTau>" || currentLine == "<jEm>" || currentLine == "<jLJet>" || currentLine == "<gLJet>" || currentLine == "<jJet>" || currentLine == "<gJet>" || currentLine == "<muon>" || currentLine == "<lateMuon>" || currentLine == "<muonNextBC>" || currentLine == "<tau>" || currentLine == "<met>" || currentLine == "<info>") continue;
64 
65  // use stream iterators to copy the stream to a vector as whitespace separated strings
66  std::stringstream ss(currentLine);
67  std::istream_iterator<std::string> it(ss);
68  std::istream_iterator<std::string> end;
69  std::vector<std::string> results(it, end);
70 
71  //std::cout << results.size() << std::endl;
72  // skip over whitespace
73  if(results.size() == 0) continue;
74 
75  // convert whitespace separated strings of results into ints
76  if(type == "<cluster>") {
77  TCS::ClusterTOB cl( TCS::ClusterTOB(atoi(results.at(0).c_str()),atoi(results.at(1).c_str()),atoi(results.at(2).c_str()),atoi(results.at(3).c_str())));
78  if(results.size()==6) {
79  cl.setEtaDouble( atof(results.at(4).c_str()) );
80  cl.setPhiDouble( atof(results.at(5).c_str()) );
81  }
83  } else if(type == "<eEm>") {
84  TCS::eEmTOB eEm( TCS::eEmTOB( atoi(results.at(0).c_str()),atoi(results.at(4).c_str()),atoi(results.at(5).c_str()) ));
85  if(results.size()==8) {
86  eEm.setEtaDouble( atof(results.at(6).c_str()) );
87  eEm.setPhiDouble( atof(results.at(7).c_str()) );
88  eEm.setReta( atof(results.at(1).c_str()) );
89  eEm.setRhad( atof(results.at(2).c_str()) );
90  eEm.setWstot( atof(results.at(3).c_str()) );
91  }
92  m_event->addeEm(eEm);
93  } else if(type == "<eTau>") {
94  TCS::eTauTOB eTau( atoi(results.at(0).c_str()),atoi(results.at(3).c_str()),atoi(results.at(4).c_str()) );
95  if(results.size()==7) {
96  eTau.setEtaDouble( atof(results.at(5).c_str()) );
97  eTau.setPhiDouble( atof(results.at(6).c_str()) );
98  eTau.setRCore( atof(results.at(1).c_str()) );
99  eTau.setRHad( atof(results.at(2).c_str()) );
100  }
101  m_event->addeTau(eTau);
102  } else if(type == "<tau>") {
103  TCS::ClusterTOB tau( TCS::ClusterTOB(atoi(results.at(0).c_str()),atoi(results.at(1).c_str()),atoi(results.at(2).c_str()),atoi(results.at(3).c_str())));
104  if(results.size()==6) {
105  tau.setEtaDouble( atof(results.at(4).c_str()) );
106  tau.setPhiDouble( atof(results.at(5).c_str()) );
107  }
108  m_event->addTau(tau);
109  } else if(type == "<jet>") {
110  TCS::JetTOB jet( atoi(results.at(0).c_str()),atoi(results.at(1).c_str()),atoi(results.at(2).c_str()),atoi(results.at(3).c_str()) );
111  if(results.size()==6) {
112  jet.setEtaDouble( atof(results.at(4).c_str()) );
113  jet.setPhiDouble( atof(results.at(5).c_str()) );
114  }
115  m_event->addJet( jet );
116  } else if(type == "<jTau>") {
117  TCS::jTauTOB tau( atoi(results.at(0).c_str()),0,atoi(results.at(1).c_str()),atoi(results.at(2).c_str()) );
118  if(results.size()==5) {
119  tau.setEtaDouble( atof(results.at(3).c_str()) );
120  tau.setPhiDouble( atof(results.at(4).c_str()) );
121  }
122  m_event->addjTau( tau );
123  } else if(type == "<jEm>") {
124  TCS::jEmTOB jEm( atoi(results.at(0).c_str()), atoi(results.at(1).c_str()), atoi(results.at(2).c_str()));
125  if(results.size()==5){
126  jEm.setEtaDouble(atof(results.at(3).c_str()));
127  jEm.setPhiDouble(atof(results.at(4).c_str()));
128  }
129  m_event->addjEm( jEm );
130  } else if(type == "<jLJet>") {
131  TCS::jLJetTOB jet( atoi(results.at(0).c_str()),atoi(results.at(1).c_str()),atoi(results.at(2).c_str()) );
132  if(results.size()==5) {
133  jet.setEtaDouble( atof(results.at(3).c_str()) );
134  jet.setPhiDouble( atof(results.at(4).c_str()) );
135  }
136  m_event->addjLJet( jet );
137  } else if(type == "<gLJet>") {
138  TCS::gLJetTOB jet( atoi(results.at(0).c_str()),atoi(results.at(1).c_str()),atoi(results.at(2).c_str()) );
139  if(results.size()==5) {
140  jet.setEtaDouble( atof(results.at(3).c_str()) );
141  jet.setPhiDouble( atof(results.at(4).c_str()) );
142  }
143  m_event->addgLJet( jet );
144  } else if(type == "<jJet>") {
145  TCS::jJetTOB jet( atoi(results.at(0).c_str()),atoi(results.at(1).c_str()),atoi(results.at(2).c_str()) );
146  if(results.size()==5) {
147  jet.setEtaDouble( atof(results.at(3).c_str()) );
148  jet.setPhiDouble( atof(results.at(4).c_str()) );
149  }
150  m_event->addjJet( jet );
151  } else if(type == "<gJet>") {
152  TCS::gJetTOB jet( atoi(results.at(0).c_str()),atoi(results.at(1).c_str()),atoi(results.at(2).c_str()) );
153  if(results.size()==5) {
154  jet.setEtaDouble( atof(results.at(3).c_str()) );
155  jet.setPhiDouble( atof(results.at(4).c_str()) );
156  }
157  m_event->addgJet( jet );
158  } else if(type == "<muon>") {
159  unsigned int et = atoi(results.at(0).c_str());
160  int eta = atoi(results.at(1).c_str());
161  int phi = atoi(results.at(2).c_str());
162  TCS::MuonTOB muon( et, 0, eta, static_cast<unsigned int>(phi) );
163  if(results.size()==5) {
164  muon.setEtaDouble( atof(results.at(3).c_str()) );
165  muon.setPhiDouble( atof(results.at(4).c_str()) );
166  }
167  m_event->addMuon( muon );
168  } else if(type == "<lateMuon>") {
169  unsigned int et = atoi(results.at(0).c_str());
170  int eta = atoi(results.at(1).c_str());
171  int phi = atoi(results.at(2).c_str());
172  TCS::LateMuonTOB latemuon( et, 0, eta, phi );
173  if(results.size()==5) {
174  latemuon.setEtaDouble( atof(results.at(3).c_str()) );
175  latemuon.setPhiDouble( atof(results.at(4).c_str()) );
176  }
177  m_event->addLateMuon( latemuon );
178  } else if(type == "<muonNextBC>") {
179  unsigned int et = atoi(results.at(0).c_str());
180  int eta = atoi(results.at(1).c_str());
181  int phi = atoi(results.at(2).c_str());
182  TCS::MuonNextBCTOB nextbcmuon( et, 0, eta, phi );
183  if(results.size()==5) {
184  nextbcmuon.setEtaDouble( atof(results.at(3).c_str()) );
185  nextbcmuon.setPhiDouble( atof(results.at(4).c_str()) );
186  }
187  m_event->addMuonNextBC( nextbcmuon );
188  } else if(type == "<met>") {
189  int ex = atoi(results.at(0).c_str());
190  int ey = atoi(results.at(1).c_str());
191  int et = atoi(results.at(2).c_str());
192  TCS::MetTOB met( ex, ey, et );
193  m_event->setMET( met );
194  } else if(type == "<info>") {
195  uint32_t runNo = atol(results.at(0).c_str());
196  uint32_t evtNo = atol(results.at(1).c_str());
197  uint32_t lumiB = atol(results.at(2).c_str());
198  uint32_t BCID = atol(results.at(3).c_str());
199  m_event->setEventInfo(runNo, evtNo, lumiB, BCID);
200  } else {
201  TCS_EXCEPTION( "TOB for this event is of unknown type " << type<<": '"<<currentLine<<"'");
202 
203  }
204  } // end read event
205 
206  m_nEvents+=1;
207 
208  return true;
209 }

◆ loadInput()

void TCS::TopoASCIIReader::loadInput ( const std::string &  input)

Definition at line 24 of file TopoASCIIReader.cxx.

24  {
25  if(input=="") {
26  TCS_EXCEPTION("Specify the location of the ascii input file");
27  }
28 
29  cout << "TopoASCIIReader: Opening file " << input << endl;
30  m_fs.open(input.c_str());
32 }

◆ printEvent()

void TCS::TopoASCIIReader::printEvent ( )

Definition at line 211 of file TopoASCIIReader.cxx.

211  {
212  cout << "Print Event" << endl;
213  if(m_event != NULL) {
214  cout << *m_event << endl;
215  } else {
216  TCS_EXCEPTION( "event returns NULL value(s) wehn trying to print!" );
217  }
218 }

◆ printFileSummary()

void TCS::TopoASCIIReader::printFileSummary ( )

Definition at line 220 of file TopoASCIIReader.cxx.

220  {
221  cout << "File summary for" << m_inputFile << endl;
222  cout << "Number of Events: " << m_nEvents << endl;
223 }

◆ reset()

void TCS::TopoASCIIReader::reset ( )

Definition at line 225 of file TopoASCIIReader.cxx.

225  {
226  cout << "TopoASCIIReader reset" << endl;
227  m_fs.close();
228  m_inputFile="";
229  m_event=NULL;
230  m_verbosity=0;
231  m_nEvents=0;
232 }

◆ setInputEvent()

void TCS::TopoASCIIReader::setInputEvent ( TCS::TopoInputEvent evt)
inline

Definition at line 45 of file TopoASCIIReader.h.

45 { m_event = evt; }

◆ setVerbosity()

void TCS::TopoASCIIReader::setVerbosity ( int  verbosity)
inline

Definition at line 43 of file TopoASCIIReader.h.

◆ validateInput()

void TCS::TopoASCIIReader::validateInput ( )

Definition at line 34 of file TopoASCIIReader.cxx.

34  {
35  if(!m_fs) {
36  TCS_EXCEPTION("Error opening input file!");
37  } else {
38  cout << "File " << m_inputFile << " loaded and ready to parse." << endl;
39  }
40 }

Member Data Documentation

◆ m_event

TCS::TopoInputEvent* TCS::TopoASCIIReader::m_event { nullptr }
private

Definition at line 63 of file TopoASCIIReader.h.

◆ m_fs

std::ifstream TCS::TopoASCIIReader::m_fs
private

Definition at line 61 of file TopoASCIIReader.h.

◆ m_inputFile

std::string TCS::TopoASCIIReader::m_inputFile { "" }
private

Definition at line 62 of file TopoASCIIReader.h.

◆ m_nEvents

int TCS::TopoASCIIReader::m_nEvents { 0 }
private

Definition at line 67 of file TopoASCIIReader.h.

◆ m_verbosity

int TCS::TopoASCIIReader::m_verbosity { 0 }
private

Definition at line 64 of file TopoASCIIReader.h.


The documentation for this class was generated from the following files:
TCS::LateMuonTOB
Definition: LateMuonTOB.h:13
TCS::TopoInputEvent::addLateMuon
StatusCode addLateMuon(const LateMuonTOB &muon)
Definition: TopoInputEvent.cxx:127
TCS::TopoInputEvent::clear
StatusCode clear()
Definition: TopoInputEvent.cxx:430
test_pyathena.eta
eta
Definition: test_pyathena.py:10
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
et
Extra patterns decribing particle interation process.
verify_menu_config.results
results
Definition: verify_menu_config.py:67
TCS::MuonTOB
Definition: MuonTOB.h:14
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TCS::TopoASCIIReader::m_inputFile
std::string m_inputFile
Definition: TopoASCIIReader.h:62
TCS::MetTOB
Definition: MetTOB.h:13
TCS::TopoInputEvent::addCluster
StatusCode addCluster(const ClusterTOB &cluster)
Definition: TopoInputEvent.cxx:46
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
TCS::TopoInputEvent::setEventInfo
StatusCode setEventInfo(const uint32_t runNo, const uint32_t evtNo, const uint32_t lumiB, const uint32_t BCID)
Definition: TopoInputEvent.cxx:215
TCS::TopoASCIIReader::m_event
TCS::TopoInputEvent * m_event
Definition: TopoASCIIReader.h:63
TCS::TopoInputEvent::addjJet
StatusCode addjJet(const jJetTOB &jet)
Definition: TopoInputEvent.cxx:112
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
TCS::TopoInputEvent::addgJet
StatusCode addgJet(const gJetTOB &jet)
Definition: TopoInputEvent.cxx:117
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
PixelByteStreamErrors::BCID
@ BCID
Definition: PixelByteStreamErrors.h:13
TCS::TopoInputEvent::addeTau
StatusCode addeTau(const eTauTOB &eTau)
Definition: TopoInputEvent.cxx:61
TCS::TopoInputEvent::addTau
StatusCode addTau(const ClusterTOB &tau)
Definition: TopoInputEvent.cxx:77
TCS::jJetTOB
Definition: jJetTOB.h:16
met
Definition: IMETSignificance.h:24
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
TCS::eTauTOB
Definition: eTauTOB.h:13
TCS::jLJetTOB
Definition: jLJetTOB.h:16
TCS::TopoInputEvent::addgLJet
StatusCode addgLJet(const gLJetTOB &jet)
Definition: TopoInputEvent.cxx:107
TCS::TopoASCIIReader::m_nEvents
int m_nEvents
Definition: TopoASCIIReader.h:67
TCS::eEmTOB
Definition: eEmTOB.h:13
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TCS::TopoInputEvent::addMuon
StatusCode addMuon(const MuonTOB &muon)
Definition: TopoInputEvent.cxx:122
TCS::TopoInputEvent::addjTau
StatusCode addjTau(const jTauTOB &tau)
Definition: TopoInputEvent.cxx:87
TCS::jTauTOB
Definition: jTauTOB.h:16
TCS::MuonNextBCTOB
Definition: MuonNextBCTOB.h:13
TCS_EXCEPTION
#define TCS_EXCEPTION(MSG)
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/L1TopoCommon/Exception.h:14
TCS::TopoInputEvent::addMuonNextBC
StatusCode addMuonNextBC(const MuonNextBCTOB &muon)
Definition: TopoInputEvent.cxx:132
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition: Control/CxxUtils/Root/StringUtils.cxx:91
TCS::TopoASCIIReader::m_verbosity
int m_verbosity
Definition: TopoASCIIReader.h:64
covarianceTool.verbosity
verbosity
Definition: covarianceTool.py:513
TCS::TopoInputEvent::addeEm
StatusCode addeEm(const eEmTOB &eEm)
Definition: TopoInputEvent.cxx:51
TCS::gLJetTOB
Definition: gLJetTOB.h:18
TCS::jEmTOB
Definition: jEmTOB.h:16
TCS::gJetTOB
Definition: gJetTOB.h:18
TCS::TopoInputEvent::setMET
StatusCode setMET(const MetTOB &met)
Definition: TopoInputEvent.cxx:137
TCS::JetTOB
Definition: JetTOB.h:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
TCS::TopoInputEvent::addJet
StatusCode addJet(const JetTOB &jet)
Definition: TopoInputEvent.cxx:82
TCS::TopoInputEvent::addjEm
StatusCode addjEm(const jEmTOB &jEm)
Definition: TopoInputEvent.cxx:56
TCS::TopoASCIIReader::m_fs
std::ifstream m_fs
Definition: TopoASCIIReader.h:61
TCS::ClusterTOB
Definition: ClusterTOB.h:13
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
TCS::TopoInputEvent::addjLJet
StatusCode addjLJet(const jLJetTOB &jet)
Definition: TopoInputEvent.cxx:102