ATLAS Offline Software
Loading...
Searching...
No Matches
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
12using namespace std;
13using namespace asg::msgUserCode;
14
15std::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
32void FPGATrackSimSectorMap::SetSector(int sec1, int sec2, int sec) {
33 m_data[sec1][sec2]=sec;
34}
35
36int 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
43void FPGATrackSimSectorMap::LoadFromFile(const char *fname) {
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
56void 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}
macros for messaging and checking status codes
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
#define ANA_MSG_FATAL(xmsg)
Macro printing fatal messages.
void CreateFile(const char *, const char *, const char *)
static std::map< int, int > makeLookup(const char *fname)
void SetSector(int, int, int)
void LoadFromFile(const char *)
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
STL namespace.