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

#include <CurrMap.h>

Collaboration diagram for CurrMap:

Public Member Functions

 CurrMap (const std::string &filename, double xnorm)
 
 ~CurrMap ()
 
int GetNx () const
 
float GetXmin () const
 
float GetXmax () const
 
float GetDx () const
 
int GetNy () const
 
float GetYmin () const
 
float GetYmax () const
 
float GetDy () const
 
float GetGap (int ix, int iy) const
 
float GetCurr0 (int ix, int iy) const
 
float GetCurr1 (int ix, int iy) const
 
float GetCurr2 (int ix, int iy) const
 
void GetAll (double x, double y, double *gap, double *curr0, double *curr1, double *curr2) const
 

Private Member Functions

 CurrMap (const CurrMap &)
 
CurrMapoperator= (const CurrMap &)
 

Private Attributes

int m_nx
 
int m_ny
 
float m_xmin
 
float m_xmax
 
float m_dx
 
float m_ymin
 
float m_ymax
 
float m_dy
 
float * m_gap
 
float * m_curr0
 
float * m_curr1
 
float * m_curr2
 
float m_norm
 

Detailed Description

Definition at line 10 of file CurrMap.h.

Constructor & Destructor Documentation

◆ CurrMap() [1/2]

CurrMap::CurrMap ( const std::string &  filename,
double  xnorm 
)

Definition at line 10 of file CurrMap.cxx.

11 {
12  // normalisation to convert nA from the map back to MeV
13  // use average in straight section:
14  // this assumes that the electronic calibration is such
15  // that Sum ai*(ADC-PED) gives the initial current for a triangular
16  // signal of drift time ~475 ns
17  m_norm = xnorm;
18  m_nx=0;
19  m_ny=0;
20  m_xmin=0.;
21  m_xmax=0.;
22  m_dx=0.;
23  m_ymin=0.;
24  m_ymax=0.;
25  m_dy=0.;
26 
27  m_gap=nullptr;
28  m_curr0=nullptr;
29  m_curr1=nullptr;
30  m_curr2=nullptr;
31 
32 
33  FILE * fp = fopen(filename.c_str(),"r");
34  if(fp){
35  char line[81];
36  fgets(line,80,fp);
37  sscanf(&line[0],"%d%f%f%d%f%f",&m_nx,&m_xmin,&m_xmax,&m_ny,&m_ymin,&m_ymax);
38 
39  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.
40  m_dx = (m_xmax-m_xmin)/((float) m_nx);
41  m_dy = (m_ymax-m_ymin)/((float) m_ny);
42 
43  m_gap = new float[m_nx*m_ny];
44  m_curr0 = new float[m_nx*m_ny];
45  m_curr1 = new float[m_nx*m_ny];
46  m_curr2 = new float[m_nx*m_ny];
47 
48  for (int i=0; i<m_nx;i++)
49  {
50  for (int j=0; j<m_ny;j++) {
51  m_gap[j*m_nx+i]=0.;
52  m_curr0[j*m_nx+i]=0;
53  m_curr1[j*m_nx+i]=0;
54  m_curr2[j*m_nx+i]=0;
55  }
56  }
57 
58  int ix,iy;
59  float gap,cur1,cur2,cur3;
60  while (fgets(line,80,fp)) {
61  sscanf(&line[0],"%d%d%f%f%f%f",&ix,&iy,&gap,&cur1,&cur2,&cur3);
62  if(ix >= 0 && ix < m_nx && iy >= 0 && iy < m_ny){
63  m_gap[iy*m_nx+ix]=gap;
64  m_curr0[iy*m_nx+ix]=cur1/m_norm;
65  m_curr1[iy*m_nx+ix]=cur2/m_norm;
66  m_curr2[iy*m_nx+ix]=cur3/m_norm;
67  }
68  }
69  }
70  else{
71  std::cout << "Error in CurrMap::CurrMap: nx or ny out of limits." << std::endl;
72  }
73  fclose(fp);
74  }
75  else{
76 
77  std::cout << "Error in CurrMap::CurrMap: The file could not be open." << std::endl;
78  }
79 
80 
81 }

◆ ~CurrMap()

CurrMap::~CurrMap ( )

Definition at line 84 of file CurrMap.cxx.

85 {
86  if (m_gap) delete [] m_gap;
87  if (m_curr0) delete [] m_curr0;
88  if (m_curr1) delete [] m_curr1;
89  if (m_curr2) delete [] m_curr2;
90 }

◆ CurrMap() [2/2]

CurrMap::CurrMap ( const CurrMap )
private

Member Function Documentation

◆ GetAll()

void CurrMap::GetAll ( double  x,
double  y,
double *  gap,
double *  curr0,
double *  curr1,
double *  curr2 
) const

Definition at line 93 of file CurrMap.cxx.

94 {
95  *gap=0;
96  *curr0=0;
97  *curr1=0;
98  *curr2=0;
99 
100  if (m_nx==0 || m_ny ==0) return;
101  if (x<m_xmin ) x=m_xmin;
102  if (x>=m_xmax ) x=m_xmax-0.0001;
103  if (y<m_ymin ) y=m_ymin;
104  if (y>=m_ymax ) y=m_ymax-0.0001;
105 
106  int ix,iy;
107  ix = (int) ((x-m_xmin)/m_dx);
108  iy = (int) ((y-m_ymin)/m_dy);
109 
110  if ( (ix+1) < m_nx && (iy+1) < m_ny) {
111  float x0 = ((float) ix)*m_dx+m_xmin;
112  float x1 = x0+m_dx;
113  float y0 = ((float) iy)*m_dy+m_ymin;
114  float y1 = y0+m_dy;
115  float w[4];
116  w[0]=(x1-x)*(y1-y);
117  w[1]=(x-x0)*(y1-y);
118  w[2]=(x1-x)*(y-y0);
119  w[3]=(x-x0)*(y-y0);
120 
121  float sumw=0.;
122  for (int i=0;i<2;i++) {
123  for (int j=0;j<2;j++) {
124  int n=ix+i+(iy+j)*m_nx;
125  if (m_curr0[n]>0) {
126  int m=i+2*j;
127  sumw +=w[m];
128  *gap += m_gap[n]*w[m];
129  *curr0 += m_curr0[n]*w[m];
130  *curr1 += m_curr1[n]*w[m];
131  *curr2 += m_curr2[n]*w[m];
132  }
133  }
134  }
135  if (sumw>0.) {
136  *gap = *gap/sumw;
137  *curr0 = *curr0/sumw;
138  *curr1 = *curr1/sumw;
139  *curr2 = *curr2/sumw;
140  }
141  else {
142  // try to recover a non zero current by moving in the map
143  int jy=-1;
144  int jx=-1;
145  int idistm=100;
146  for (int iiy=iy-7;iiy<iy+8;iiy++) {
147  for (int iix=ix-7;iix<ix+8;iix++) {
148  if (iiy>=0 && iiy<m_ny && iix>=0 && iix<m_nx) {
149  if (m_curr0[iix+iiy*m_nx]>0) {
150  int idist=(iix-ix)*(iix-ix)+(iiy-iy)*(iiy-iy);
151  if(idist<idistm) {
152  idistm=idist;
153  jx=iix;
154  jy=iiy;
155  }
156  }
157  }
158  }
159  }
160  if (idistm<100 && jx>=0 && jy>=0) {
161  *gap = m_gap[jx+jy*m_nx];
162  *curr0 = m_curr0[jx+jy*m_nx];
163  *curr1 = m_curr1[jx+jy*m_nx];
164  *curr2 = m_curr2[jx+jy*m_nx];
165  } else {
166  *gap=0;
167  *curr0=0;
168  *curr1=0;
169  *curr2=0;
170  }
171  }
172  }
173  else {
174  // on the edges of the map, no linear interpolation
175  int n=ix+iy*m_nx;
176  if (m_curr0[n]<1e-6 && (ix+1) <m_nx) n=ix+1 +iy*m_nx;
177  if (m_curr0[n]<1e-6 && (ix-1) >0 ) n=ix-1 +iy*m_nx;
178  if (m_curr0[n]<1e-6 && (iy+1) <m_ny) n=ix+(iy+1)*m_nx;
179  if (m_curr0[n]<1e-6 && (iy-1) <0) n=ix+(iy-1)*m_nx;
180  if (m_curr0[n]<1e-6 && (ix+1) < m_nx && (iy+1) < m_ny) n=ix+1+(iy+1)*m_nx;
181  if (m_curr0[n]<1e-6 && (ix-1) >0 && (iy+1) < m_ny) n=ix-1+(iy+1)*m_nx;
182  if (m_curr0[n]<1e-6 && (ix+1) < m_nx && (iy-1) >0 ) n=ix+1+(iy-1)*m_nx;
183  if (m_curr0[n]<1e-6 && (ix-1) >0 && (iy-1) >0 ) n=ix-1+(iy-1)*m_nx;
184  *gap = m_gap[n];
185  *curr0 = m_curr0[n];
186  *curr1 = m_curr1[n];
187  *curr2 = m_curr2[n];
188  }
189 }

◆ GetCurr0()

float CurrMap::GetCurr0 ( int  ix,
int  iy 
) const
inline

Definition at line 23 of file CurrMap.h.

23 {return m_curr0[iy*m_nx+ix];}

◆ GetCurr1()

float CurrMap::GetCurr1 ( int  ix,
int  iy 
) const
inline

Definition at line 24 of file CurrMap.h.

24 {return m_curr1[iy*m_nx+ix];}

◆ GetCurr2()

float CurrMap::GetCurr2 ( int  ix,
int  iy 
) const
inline

Definition at line 25 of file CurrMap.h.

25 {return m_curr2[iy*m_nx+ix];}

◆ GetDx()

float CurrMap::GetDx ( ) const
inline

Definition at line 17 of file CurrMap.h.

17 { return m_dx;}

◆ GetDy()

float CurrMap::GetDy ( ) const
inline

Definition at line 21 of file CurrMap.h.

21 { return m_dy;}

◆ GetGap()

float CurrMap::GetGap ( int  ix,
int  iy 
) const
inline

Definition at line 22 of file CurrMap.h.

22 {return m_gap[iy*m_nx+ix];}

◆ GetNx()

int CurrMap::GetNx ( ) const
inline

Definition at line 14 of file CurrMap.h.

14 { return m_nx;}

◆ GetNy()

int CurrMap::GetNy ( ) const
inline

Definition at line 18 of file CurrMap.h.

18 { return m_ny;}

◆ GetXmax()

float CurrMap::GetXmax ( ) const
inline

Definition at line 16 of file CurrMap.h.

16 { return m_xmax;}

◆ GetXmin()

float CurrMap::GetXmin ( ) const
inline

Definition at line 15 of file CurrMap.h.

15 { return m_xmin;}

◆ GetYmax()

float CurrMap::GetYmax ( ) const
inline

Definition at line 20 of file CurrMap.h.

20 { return m_ymax;}

◆ GetYmin()

float CurrMap::GetYmin ( ) const
inline

Definition at line 19 of file CurrMap.h.

19 { return m_ymin;}

◆ operator=()

CurrMap& CurrMap::operator= ( const CurrMap )
private

Member Data Documentation

◆ m_curr0

float * CurrMap::m_curr0
private

Definition at line 32 of file CurrMap.h.

◆ m_curr1

float * CurrMap::m_curr1
private

Definition at line 32 of file CurrMap.h.

◆ m_curr2

float * CurrMap::m_curr2
private

Definition at line 32 of file CurrMap.h.

◆ m_dx

float CurrMap::m_dx
private

Definition at line 31 of file CurrMap.h.

◆ m_dy

float CurrMap::m_dy
private

Definition at line 31 of file CurrMap.h.

◆ m_gap

float* CurrMap::m_gap
private

Definition at line 32 of file CurrMap.h.

◆ m_norm

float CurrMap::m_norm
private

Definition at line 33 of file CurrMap.h.

◆ m_nx

int CurrMap::m_nx
private

Definition at line 30 of file CurrMap.h.

◆ m_ny

int CurrMap::m_ny
private

Definition at line 30 of file CurrMap.h.

◆ m_xmax

float CurrMap::m_xmax
private

Definition at line 31 of file CurrMap.h.

◆ m_xmin

float CurrMap::m_xmin
private

Definition at line 31 of file CurrMap.h.

◆ m_ymax

float CurrMap::m_ymax
private

Definition at line 31 of file CurrMap.h.

◆ m_ymin

float CurrMap::m_ymin
private

Definition at line 31 of file CurrMap.h.


The documentation for this class was generated from the following files:
CurrMap::m_curr0
float * m_curr0
Definition: CurrMap.h:32
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CurrMap::m_xmin
float m_xmin
Definition: CurrMap.h:31
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
checkFileSG.line
line
Definition: checkFileSG.py:75
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CurrMap::m_dx
float m_dx
Definition: CurrMap.h:31
CurrMap::m_curr1
float * m_curr1
Definition: CurrMap.h:32
plotBeamSpotVxVal.sumw
int sumw
Definition: plotBeamSpotVxVal.py:236
x
#define x
CaloSwCorrections.gap
def gap(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:212
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
CurrMap::m_nx
int m_nx
Definition: CurrMap.h:30
CurrMap::m_ymin
float m_ymin
Definition: CurrMap.h:31
CurrMap::m_norm
float m_norm
Definition: CurrMap.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
trigmenu_modify_prescale_json.fp
fp
Definition: trigmenu_modify_prescale_json.py:53
beamspotman.n
n
Definition: beamspotman.py:731
CurrMap::m_ny
int m_ny
Definition: CurrMap.h:30
MuonR4::SegmentFit::ParamDefs::x0
@ x0
MuonR4::SegmentFit::ParamDefs::y0
@ y0
CurrMap::m_curr2
float * m_curr2
Definition: CurrMap.h:32
y
#define y
CurrMap::m_gap
float * m_gap
Definition: CurrMap.h:32
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
CurrMap::m_ymax
float m_ymax
Definition: CurrMap.h:31
CurrMap::m_dy
float m_dy
Definition: CurrMap.h:31
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
readCCLHist.float
float
Definition: readCCLHist.py:83
CurrMap::m_xmax
float m_xmax
Definition: CurrMap.h:31