ATLAS Offline Software
Loading...
Searching...
No Matches
AccMap.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "AccMap.h"
6#include <iostream>
7#include <format>
8#ifndef LARG4_STAND_ALONE
10#endif
11
13 // Fold ranges for the 10 electronic regions
14 static constexpr std::array<int, 10> i1 = {0, 0, 3, 2, 9, 12, 10, 9, 0, 2};
15 static constexpr std::array<int, 10> i2 = {2, 1, 12, 12, 13, 13, 13, 13, 1, 4};
16 static constexpr double xnorm = 14.1591;
17
18#ifndef LARG4_STAND_ALONE
19 const std::string larLocation = PathResolver::find_directory("LArG4Barrel", "ATLASCALDATA");
20#endif
21
22 for (int iregion = 0; iregion < MAX_REGIONS; ++iregion) {
23
24 // 1. Process Accordion Folds
25 for (int ifold = i1[iregion]; ifold <= i2[iregion]; ++ifold) {
26 // Using std::format for cleaner filename generation
27 std::string filename = std::format("fold{}_region{}.map", ifold, iregion);
28
29 std::string fileLocation =
30#ifdef LARG4_STAND_ALONE
31 std::format("{}/{}", m_directory, filename);
32#else
33 std::format("{}/{}", larLocation, filename);
34#endif
35
36 auto cm = std::make_unique<CurrMap>(fileLocation, xnorm);
37
38 // Add rounding safety for primary folds
39 if (ifold < N_MAX_VEC) {
40 m_xmin[ifold] = cm->GetXmin() + 0.1f;
41 m_xmax[ifold] = cm->GetXmax() - 0.1f;
42 m_ymin[ifold] = cm->GetYmin() + 0.1f;
43 m_ymax[ifold] = cm->GetYmax() - 0.1f;
44 }
45 m_fastMap[ifold][iregion] = std::move(cm);
46 }
47
48 // 2. Process Straight Sections
49 for (int istr = 1; istr <= 2; ++istr) {
50 int ifold = 20 + istr; // Mapping istr 1,2 to index 21,22
51
52 std::string filename = std::format("straight{}_region{}.map", istr, iregion);
53
54 std::string fileLocation =
55#ifdef LARG4_STAND_ALONE
56 std::format("{}/{}", m_directory, filename);
57#else
58 std::format("{}/{}", larLocation, filename);
59#endif
60 m_fastMap[ifold][iregion] = std::make_unique<CurrMap>(fileLocation, xnorm);
61 }
62 }
63}
64
66{
67 static const AccMap instance;
68 return &instance;
69}
70
71const CurrMap* AccMap::GetMap(int ifold, int region, int sampling, int eta) const noexcept
72{
73 return this->GetMap(ifold,this->Region(region,sampling,eta));
74}
75
76const CurrMap* AccMap::GetMap(int ifold, int ielecregion) const noexcept {
77 // Direct O(1) lookup with bounds safety
78 if (ifold >= 0 && ifold < MAX_FOLDS && ielecregion >= 0 && ielecregion < MAX_REGIONS) {
79 return m_fastMap[ifold][ielecregion].get();
80 }
81 std::cout << "Fold " << ifold << " Region " << ielecregion << " out of bounds." << std::endl;
82 return nullptr;
83}
84
85int AccMap::Region(int region, int sampling, int eta) const noexcept
86{
87 int elecregion=0;
88 // logic to compute region vs eta and sampling...
89 if (region==0) {
90 if (sampling==1) {
91 if (eta<256) elecregion=0;
92 else elecregion=1;
93 }
94 else if (sampling==2) {
95 if (eta<32) elecregion=2;
96 else elecregion=3;
97 }
98 else {
99 if (eta<9 || eta==26) elecregion=4;
100 if ((eta>8 && eta<13) || (eta>15 && eta<19)) elecregion=5;
101 if ((eta>12 && eta < 16) || (eta>18 && eta<21)) elecregion=6;
102 if ((eta>20 && eta < 26)) elecregion=7;
103 }
104 }
105 else {
106 if (sampling==1) elecregion=8;
107 else elecregion=9;
108 }
109 return elecregion;
110}
Scalar eta() const
pseudorapidity method
std::map< std::string, double > instance
const CurrMap * GetMap(int ifold, int ielecregion) const noexcept
Definition AccMap.cxx:76
static constexpr int N_MAX_VEC
Definition AccMap.h:21
AccMap()
Definition AccMap.cxx:12
std::array< float, N_MAX_VEC > m_ymin
Definition AccMap.h:35
std::array< float, N_MAX_VEC > m_ymax
Definition AccMap.h:36
std::array< float, N_MAX_VEC > m_xmax
Definition AccMap.h:34
int Region(int region, int sampling, int eta) const noexcept
Definition AccMap.cxx:85
static constexpr int MAX_REGIONS
Definition AccMap.h:20
std::array< std::array< std::unique_ptr< CurrMap >, MAX_REGIONS >, MAX_FOLDS > m_fastMap
Definition AccMap.h:32
static const AccMap * GetAccMap()
Definition AccMap.cxx:65
std::array< float, N_MAX_VEC > m_xmin
Definition AccMap.h:33
static std::string find_directory(const std::string &logical_file_name, const std::string &search_path)