ATLAS Offline Software
FPGATrackSimSectorMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <iostream>
8 #include <fstream>
9 #include <cstdlib>
11 
12 using namespace std;
13 using namespace asg::msgUserCode;
14 
15 std::map<int,int> FPGATrackSimSectorMap::makeLookup(const char* fname)
16 {
17  std::map<int,int> secLookup;
18  ifstream inFile(fname);
19 
20  if (inFile.is_open()) {
21  ANA_MSG_FATAL("Unable to open file");
22  return secLookup;
23  }
24  int evt,reg;
25  while (inFile >> evt >> reg) {
26  secLookup[evt]=reg;
27  }
28  inFile.close();
29  return secLookup;
30 }
31 
32 void FPGATrackSimSectorMap::SetSector(int sec1, int sec2, int sec) {
33  m_data[sec1][sec2]=sec;
34 }
35 
36 int FPGATrackSimSectorMap::GetSector(int sec1, int sec2) {
37  if (m_data.find(sec1)!=m_data.end())
38  if (m_data[sec1].find(sec2)!=m_data[sec1].end())
39  return m_data[sec1][sec2];
40  return -1;
41 }
42 
44 
45  ifstream inFile(fname);
46  if (inFile.is_open()) {
47  ANA_MSG_FATAL("Unable to open file");
48  return;
49  }
50  ANA_MSG_DEBUG("Reading sector map data: " << fname);
51  int sec1,sec2,sec3;
52  while(inFile >> sec1 >> sec2 >> sec3) SetSector(sec1,sec2,sec3);
53  inFile.close();
54 }
55 
56 void FPGATrackSimSectorMap::CreateFile(const char *fname4,const char *fname8, const char *fname11) {
57  std::map<int,int> map4=FPGATrackSimSectorMap::makeLookup(fname4);
58  std::map<int,int> map8=FPGATrackSimSectorMap::makeLookup(fname8);
59 
60  ifstream inFile(fname11);
61  if (inFile.is_open()) {
62  ANA_MSG_FATAL("Unable to open file");
63  return;
64  }
65  int ev11, sec11;
66  while(inFile >> ev11 >> sec11) {
67  if(map4.find(ev11)!=map4.end() && map8.find(ev11)!=map8.end())
68  SetSector(map4[ev11], map8[ev11], sec11);
69  }
70  inFile.close();
71 }
72 
74  for (mapint2::iterator i = m_data.begin(); i != m_data.end();++i) {
75  for (mapint::iterator j = (*i).second.begin(); j != (*i).second.end();++j) {
76  ANA_MSG_DEBUG((*i).first << " " << (*j).first << " " << (*j).second);
77  }
78  }
79 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
FPGATrackSimSectorMap::CreateFile
void CreateFile(const char *, const char *, const char *)
Definition: FPGATrackSimSectorMap.cxx:56
m_data
std::vector< T > m_data
Definition: TrackTruthMatchingBaseAlg.cxx:660
makeTOC.inFile
string inFile
Definition: makeTOC.py:5
FPGATrackSimSectorMap.h
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
FPGATrackSimSectorMap::Dump
void Dump()
Definition: FPGATrackSimSectorMap.cxx:73
FPGATrackSimSectorMap::LoadFromFile
void LoadFromFile(const char *)
Definition: FPGATrackSimSectorMap.cxx:43
FPGATrackSimSectorMap::SetSector
void SetSector(int, int, int)
Definition: FPGATrackSimSectorMap.cxx:32
lumiFormat.i
int i
Definition: lumiFormat.py:85
MessageCheck.h
macros for messaging and checking status codes
ANA_MSG_FATAL
#define ANA_MSG_FATAL(xmsg)
Macro printing fatal messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:296
FPGATrackSimSectorMap::makeLookup
static std::map< int, int > makeLookup(const char *fname)
Definition: FPGATrackSimSectorMap.cxx:15
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
FPGATrackSimSectorMap::GetSector
int GetSector(int, int)
Definition: FPGATrackSimSectorMap.cxx:36
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288