ATLAS Offline Software
Loading...
Searching...
No Matches
AccMap.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "AccMap.h"
6#include <iostream>
7#include <sstream>
8#ifndef LARG4_STAND_ALONE
10#endif
11
13{
14 const int i1[10]={0,0,3,2,9,12,10,9,0,2}; // first fold
15 const int i2[10]={2,1,12,12,13,13,13,13,1,4}; // last fold for 10 electronic regions
16
17 m_xmin.resize(m_nmax);
18 m_xmax.resize(m_nmax);
19 m_ymin.resize(m_nmax);
20 m_ymax.resize(m_nmax);
21
22 const double xnorm=14.1591; // nA/MeV normalisation for accordion maps
23
24#ifndef LARG4_STAND_ALONE
25 //std::string larLocation = PathResolver::find_directory("lar","DATAPATH");
26 std::string larLocation = PathResolver::find_directory("LArG4Barrel","ATLASCALDATA");
27#endif
28
29 for (int iregion=0;iregion<10;iregion++) {
30 // accordion folds
31 for (int ifold=i1[iregion]; ifold<=i2[iregion]; ifold++) {
32 std::ostringstream fn;
33 fn << "fold"<<ifold<<"_region"<<iregion<<".map";
34 std::string filename = fn.str();
35 std::string fileLocation;
36#ifdef LARG4_STAND_ALONE
37 fileLocation=m_directory+"/"+filename;
38#else
39 //fileLocation=larLocation+"/calo_data/"+filename;
40 fileLocation=larLocation+"/"+filename;
41#endif
42 CurrMap* cm = new CurrMap(fileLocation,xnorm);
43 int code=10*ifold+iregion;
44 m_theMap[code]=cm;
45
46 // add some rounding safety in edges of map
47 m_xmin[ifold]=cm->GetXmin()+0.1;
48 m_xmax[ifold]=cm->GetXmax()-0.1;
49 m_ymin[ifold]=cm->GetYmin()+0.1;
50 m_ymax[ifold]=cm->GetYmax()-0.1;
51 }
52 // straight section
53 for (int istr=1; istr<=2; istr++) {
54 std::ostringstream fn;
55 fn << "straight"<<istr<<"_region"<<iregion<<".map";
56 std::string filename = fn.str();
57 std::string fileLocation;
58#ifdef LARG4_STAND_ALONE
59 fileLocation=m_directory+"/"+filename;
60#else
61 //fileLocation=larLocation+"/calo_data/"+filename;
62 fileLocation=larLocation+"/"+filename;
63#endif
64 CurrMap* cm = new CurrMap(fileLocation,xnorm);
65 int code=10*(20+istr)+iregion;
66 m_theMap[code]=cm;
67 }
68 }
69
70}
71
73{
74 static const AccMap instance;
75 return &instance;
76}
77
79{
80 curr_map::iterator it = m_theMap.begin();
81 while (it != m_theMap.end()) {
82 delete (*it).second;
83 m_theMap.erase(it++);
84 }
85}
86
87const CurrMap* AccMap::GetMap(int ifold, int region, int sampling, int eta) const
88{
89 return this->GetMap(ifold,this->Region(region,sampling,eta));
90}
91
92const CurrMap* AccMap::GetMap(int ifold, int ielecregion) const
93{
94 const int code=10*ifold+ielecregion;
95 const auto mapIter = m_theMap.find(code);
96 if (mapIter != m_theMap.end())
97 return mapIter->second;
98 else {
99 std::cout << " Code " << code << " not found in map ..." << std::endl;
100 return nullptr;
101 }
102}
103
104int AccMap::Region(int region, int sampling, int eta) const
105{
106 int elecregion=0;
107 // logic to compute region vs eta and sampling...
108 if (region==0) {
109 if (sampling==1) {
110 if (eta<256) elecregion=0;
111 else elecregion=1;
112 }
113 else if (sampling==2) {
114 if (eta<32) elecregion=2;
115 else elecregion=3;
116 }
117 else {
118 if (eta<9 || eta==26) elecregion=4;
119 if ((eta>8 && eta<13) || (eta>15 && eta<19)) elecregion=5;
120 if ((eta>12 && eta < 16) || (eta>18 && eta<21)) elecregion=6;
121 if ((eta>20 && eta < 26)) elecregion=7;
122 }
123 }
124 else {
125 if (sampling==1) elecregion=8;
126 else elecregion=9;
127 }
128 return elecregion;
129}
Scalar eta() const
pseudorapidity method
std::map< std::string, double > instance
std::vector< float > m_ymin
Definition AccMap.h:43
int Region(int region, int sampling, int eta) const
Definition AccMap.cxx:104
const CurrMap * GetMap(int ifold, int ielecregion) const
Definition AccMap.cxx:92
AccMap()
Definition AccMap.cxx:12
std::vector< float > m_ymax
Definition AccMap.h:44
std::vector< float > m_xmin
Definition AccMap.h:41
void Reset()
Definition AccMap.cxx:78
std::vector< float > m_xmax
Definition AccMap.h:42
curr_map m_theMap
Definition AccMap.h:39
const int m_nmax
Definition AccMap.h:40
static const AccMap * GetAccMap()
Definition AccMap.cxx:72
static std::string find_directory(const std::string &logical_file_name, const std::string &search_path)