ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
MapEta Class Reference

#include <MapEta.h>

Collaboration diagram for MapEta:

Public Member Functions

 ~MapEta ()
 
 MapEta (int isampling)
 
void SetDirectory (const std::string &dir)
 
void Initialize (int isampling)
 
int Nx () const
 
int Ny () const
 
float Xmin () const
 
float Xmax () const
 
float Ymin () const
 
float Ymax () const
 
void GetData (double x, double y, double *resp, double *xt0, double *xt1, double *xt2) const
 
void GetData0 (double x, double y, double *resp) const
 

Private Attributes

std::string m_directory
 
int m_init
 
int m_nx
 
int m_ny
 
float m_xmin = 0.0F
 
float m_xmax = 0.0F
 
float m_ymin = 0.0F
 
float m_ymax = 0.0F
 
float m_deltax = 0.0F
 
float m_deltay = 0.0F
 
float * m_resp
 
float * m_xt0
 
float * m_xt1
 
float * m_xt2
 

Detailed Description

Definition at line 12 of file MapEta.h.

Constructor & Destructor Documentation

◆ ~MapEta()

MapEta::~MapEta ( )

Definition at line 28 of file MapEta.cxx.

29 {
30  if (m_resp) delete [] m_resp;
31  if (m_xt0) delete [] m_xt0;
32  if (m_xt1) delete [] m_xt1;
33  if (m_xt2) delete [] m_xt2;
34 }

◆ MapEta()

MapEta::MapEta ( int  isampling)

Definition at line 15 of file MapEta.cxx.

16  : m_directory ("/afs/cern.ch/atlas/offline/data/lar/calo_data"),
17  m_init (0),
18  m_nx (0),
19  m_ny (0),
20  m_resp (nullptr),
21  m_xt0 (nullptr),
22  m_xt1 (nullptr),
23  m_xt2 (nullptr)
24 {
25  Initialize(isampling);
26 }

Member Function Documentation

◆ GetData()

void MapEta::GetData ( double  x,
double  y,
double *  resp,
double *  xt0,
double *  xt1,
double *  xt2 
) const

Definition at line 105 of file MapEta.cxx.

106 {
107  *resp=1;
108  *xt0=1;
109  *xt1=0;
110  *xt2=0;
111  if (m_nx==0 || m_ny ==0) return;
112  if (x<m_xmin ) x=m_xmin+0.01*m_deltax;
113  if (x>=m_xmax) x=m_xmax-0.01*m_deltax;
114  if (y<m_ymin ) y=m_ymin+0.01*m_deltay;
115  if (y>=m_ymax) y=m_ymax-0.01*m_deltay;
116 
117  int ix,iy;
118  ix = (int) ((x-m_xmin)/m_deltax);
119  iy = (int) ((y-m_ymin)/m_deltay);
120  float x0 = ((float) ix)*m_deltax+m_xmin;
121  float x1 = x0+m_deltax;
122  float y0 = ((float) iy)*m_deltay+m_ymin;
123  float y1 = y0+m_deltay;
124 
125 
126  if (ix<0 || ix+1 >= m_nx || iy<0 || iy+1 >= m_ny) {
127  std::cout << "MapEta: Out of range " << ix << " " << iy << std::endl;
128  return;
129  }
130  double w[4];
131  w[0]=(x1-x)*(y1-y);
132  w[1]=(x-x0)*(y1-y);
133  w[2]=(x1-x)*(y-y0);
134  w[3]=(x-x0)*(y-y0);
135 
136  double sumw=0.;
137  *resp=0;
138  *xt0=0;
139  for (int i=0;i<2;i++) {
140  for (int j=0;j<2;j++) {
141  int n=ix+i+(iy+j)*m_nx;
142  int m=i+2*j;
143  sumw +=w[m];
144  *resp += m_resp[n]*w[m];
145  *xt0 += m_xt0[n]*w[m];
146  *xt1 += m_xt1[n]*w[m];
147  *xt2 += m_xt2[n]*w[m];
148  }
149  }
150  const double inv_sumw = 1. / sumw;
151  if (sumw>0.) {
152  *resp = *resp*inv_sumw;
153  *xt0 = *xt0*inv_sumw;
154  *xt1 = *xt1*inv_sumw;
155  *xt2 = *xt2*inv_sumw;
156  }
157 
158 }

◆ GetData0()

void MapEta::GetData0 ( double  x,
double  y,
double *  resp 
) const

Definition at line 159 of file MapEta.cxx.

160 {
161  *resp=1;
162  if (m_nx==0 || m_ny ==0) return;
163  if (x<m_xmin ) x=m_xmin+0.01*m_deltax;
164  if (x>=m_xmax) x=m_xmax-0.01*m_deltax;
165  if (y<m_ymin ) y=m_ymin+0.01*m_deltay;
166  if (y>=m_ymax) y=m_ymax-0.01*m_deltay;
167 
168  int ix,iy;
169  ix = (int) ((x-m_xmin)/m_deltax);
170  iy = (int) ((y-m_ymin)/m_deltay);
171  float x0 = ((float) ix)*m_deltax+m_xmin;
172  float x1 = x0+m_deltax;
173  float y0 = ((float) iy)*m_deltay+m_ymin;
174  float y1 = y0+m_deltay;
175 
176  if (ix<0 || ix+1 >= m_nx || iy<0 || iy+1 >= m_ny) {
177  std::cout << "MapEta: Out of range " << ix << " " << iy << std::endl;
178  return;
179  }
180  double w[4];
181  w[0]=(x1-x)*(y1-y);
182  w[1]=(x-x0)*(y1-y);
183  w[2]=(x1-x)*(y-y0);
184  w[3]=(x-x0)*(y-y0);
185 
186  double sumw=0.;
187  *resp = 0;
188  for (int i=0;i<2;i++) {
189  for (int j=0;j<2;j++) {
190  int n=ix+i+(iy+j)*m_nx;
191  int m=i+2*j;
192  sumw +=w[m];
193  *resp += m_resp[n]*w[m];
194  }
195  }
196  if (sumw>0.) *resp = *resp/sumw;
197  else *resp = 1;
198 
199 }

◆ Initialize()

void MapEta::Initialize ( int  isampling)

Definition at line 42 of file MapEta.cxx.

43 {
44  if (m_init==1) return;
45  if (isampling < 1 || isampling >3) return;
46  std::string filename{};
47  if (isampling==1) filename = "deta_strip.map";
48  if (isampling==2) filename = "deta_middle.map";
49  if (isampling==3) filename = "eta_trans.map";
50  std::string fileLocation;
51 #ifdef LARG4_STAND_ALONE
52  // The stand-alone program expects to find the file via AFS.
53  fileLocation = m_directory + "/" + filename;
54 #else
55  // In Athena, the PathResolver tool will find the file for us.
56  std::cout << "filename " << filename << std::endl;
57  //std::string larLocation = PathResolver::find_directory("lar","DATAPATH");
58  //fileLocation=larLocation+"/calo_data/"+filename;
59  std::string larLocation = PathResolver::find_directory("LArG4Barrel","ATLASCALDATA");
60  fileLocation=larLocation+"/"+filename;
61  std::cout << "fileLocation " << fileLocation << std::endl;
62 #endif
63 
64  std::ifstream in(fileLocation);
65  if (in)
66  {
68  if(m_nx>0 && m_ny>0 && m_nx<10000 && m_ny<10000){//coverity issue. This is a tainted variable protection, 10000 can be changed if required.
69  m_deltax=(m_xmax-m_xmin)/((float) m_nx);
70  m_deltay=(m_ymax-m_ymin)/((float) m_ny);
71  // what is written as xmax in the map is x of last point + delta x
72  // (such that npoint = (xmax-xmin)/deltax
73  // to get the real last point in the map we should subtract deltax
76  m_resp = new float[m_ny*m_nx];
77  m_xt0 = new float[m_ny*m_nx];
78  m_xt1 = new float[m_ny*m_nx];
79  m_xt2 = new float[m_ny*m_nx];
80  int ii,jj;
81  for (int ix=0;ix<m_nx;ix++) {
82  for (int iy=0;iy<m_ny;iy++) {
83  in>>ii>>jj>>m_resp[ix+iy*m_nx]>>m_xt0[ix+iy*m_nx]>>m_xt1[ix+iy*m_nx]>>m_xt2[ix+iy*m_nx];
84  if (ii != ix || jj != iy) std::cout << "MapEta: inconsistency when reading map..." << std::endl;
85  }
86  }
87 
88  std::cout << "Eta Map read " << " Nbins " << m_nx << " " << m_ny
89  << " bin size*1000 " << 1000*m_deltax << " " << 1000*m_deltay
90  << " X range " << m_xmin << " " << m_xmax
91  << " Y range " << m_ymin << " " << m_ymax << std::endl;
92  m_init=1;
93  }
94  else{
95  std::cout << "Error in MapEta::Initialize: nx or ny out of limits." << std::endl;
96  return;
97  }
98  }
99  else{
100  std::cout << "Error in MapEta::Initialize: The file could not be open." << std::endl;
101  return;
102  }
103 }

◆ Nx()

int MapEta::Nx ( ) const
inline

Definition at line 28 of file MapEta.h.

28 {return m_nx;}

◆ Ny()

int MapEta::Ny ( ) const
inline

Definition at line 29 of file MapEta.h.

29 {return m_ny;}

◆ SetDirectory()

void MapEta::SetDirectory ( const std::string &  dir)

Definition at line 37 of file MapEta.cxx.

38 {
40 }

◆ Xmax()

float MapEta::Xmax ( ) const
inline

Definition at line 31 of file MapEta.h.

31 {return m_xmax;}

◆ Xmin()

float MapEta::Xmin ( ) const
inline

Definition at line 30 of file MapEta.h.

30 {return m_xmin;}

◆ Ymax()

float MapEta::Ymax ( ) const
inline

Definition at line 33 of file MapEta.h.

33 {return m_ymax;}

◆ Ymin()

float MapEta::Ymin ( ) const
inline

Definition at line 32 of file MapEta.h.

32 {return m_ymin;}

Member Data Documentation

◆ m_deltax

float MapEta::m_deltax = 0.0F
private

Definition at line 18 of file MapEta.h.

◆ m_deltay

float MapEta::m_deltay = 0.0F
private

Definition at line 18 of file MapEta.h.

◆ m_directory

std::string MapEta::m_directory
private

Definition at line 14 of file MapEta.h.

◆ m_init

int MapEta::m_init
private

Definition at line 15 of file MapEta.h.

◆ m_nx

int MapEta::m_nx
private

Definition at line 16 of file MapEta.h.

◆ m_ny

int MapEta::m_ny
private

Definition at line 16 of file MapEta.h.

◆ m_resp

float* MapEta::m_resp
private

Definition at line 19 of file MapEta.h.

◆ m_xmax

float MapEta::m_xmax = 0.0F
private

Definition at line 17 of file MapEta.h.

◆ m_xmin

float MapEta::m_xmin = 0.0F
private

Definition at line 17 of file MapEta.h.

◆ m_xt0

float* MapEta::m_xt0
private

Definition at line 20 of file MapEta.h.

◆ m_xt1

float* MapEta::m_xt1
private

Definition at line 21 of file MapEta.h.

◆ m_xt2

float* MapEta::m_xt2
private

Definition at line 22 of file MapEta.h.

◆ m_ymax

float MapEta::m_ymax = 0.0F
private

Definition at line 17 of file MapEta.h.

◆ m_ymin

float MapEta::m_ymin = 0.0F
private

Definition at line 17 of file MapEta.h.


The documentation for this class was generated from the following files:
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MapEta::m_xmin
float m_xmin
Definition: MapEta.h:17
MapEta::m_xmax
float m_xmax
Definition: MapEta.h:17
MapEta::m_deltay
float m_deltay
Definition: MapEta.h:18
PathResolver::find_directory
static std::string find_directory(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:307
plotBeamSpotVxVal.sumw
int sumw
Definition: plotBeamSpotVxVal.py:236
x
#define x
MapEta::m_ymax
float m_ymax
Definition: MapEta.h:17
MapEta::m_xt2
float * m_xt2
Definition: MapEta.h:22
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
MapEta::m_xt0
float * m_xt0
Definition: MapEta.h:20
MapEta::m_init
int m_init
Definition: MapEta.h:15
MapEta::Initialize
void Initialize(int isampling)
Definition: MapEta.cxx:42
MapEta::m_resp
float * m_resp
Definition: MapEta.h:19
MuonR4::SegmentFit::ParamDefs::x0
@ x0
beamspotman.dir
string dir
Definition: beamspotman.py:623
MapEta::m_ny
int m_ny
Definition: MapEta.h:16
MapEta::m_xt1
float * m_xt1
Definition: MapEta.h:21
MapEta::m_directory
std::string m_directory
Definition: MapEta.h:14
MuonR4::SegmentFit::ParamDefs::y0
@ y0
MapEta::m_deltax
float m_deltax
Definition: MapEta.h:18
MapEta::m_nx
int m_nx
Definition: MapEta.h:16
MapEta::m_ymin
float m_ymin
Definition: MapEta.h:17
y
#define y
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
readCCLHist.float
float
Definition: readCCLHist.py:83