SND@LHC Software
Loading...
Searching...
No Matches
ecalLightMap Class Reference

#include <ecalLightMap.h>

Inheritance diagram for ecalLightMap:
Collaboration diagram for ecalLightMap:

Public Member Functions

 ecalLightMap ()
 
 ecalLightMap (const char *fname, const char *title="Light collection efficiency map")
 
Double_t Data (Double_t x, Double_t y)
 
Int_t GetNum (Double_t x, Double_t y)
 
virtual ~ecalLightMap ()
 

Private Member Functions

void Init (const char *filename)
 
void FillGaps ()
 
void Normalize ()
 
 ecalLightMap (const ecalLightMap &)
 
ecalLightMapoperator= (const ecalLightMap &)
 

Private Attributes

Double_t fSSide
 
Int_t fS
 
Int_t fSize
 
Double_t * fData
 

Detailed Description

Definition at line 6 of file ecalLightMap.h.

Constructor & Destructor Documentation

◆ ecalLightMap() [1/3]

ecalLightMap::ecalLightMap ( )
inline

Definition at line 9 of file ecalLightMap.h.

9: TNamed(), fSSide(0.), fS(0), fSize(0), fData(NULL) {};
Double_t fSSide
Double_t * fData

◆ ecalLightMap() [2/3]

ecalLightMap::ecalLightMap ( const char *  fname,
const char *  title = "Light collection efficiency map" 
)

Definition at line 13 of file ecalLightMap.cxx.

14 : TNamed(fname, title),
15 fSSide(-1111.), fS(-1111), fSize(0), fData(NULL)
16{
17 Init(fname);
18}
void Init(const char *filename)

◆ ~ecalLightMap()

virtual ecalLightMap::~ecalLightMap ( )
inlinevirtual

Definition at line 22 of file ecalLightMap.h.

22{delete fData;}

◆ ecalLightMap() [3/3]

ecalLightMap::ecalLightMap ( const ecalLightMap )
private

Member Function Documentation

◆ Data()

Double_t ecalLightMap::Data ( Double_t  x,
Double_t  y 
)
inline

Definition at line 11 of file ecalLightMap.h.

12 {Int_t n=GetNum(x,y); if (n<0) return n; return fData[n];}
Int_t GetNum(Double_t x, Double_t y)

◆ FillGaps()

void ecalLightMap::FillGaps ( )
private

Fix a light collection map

Definition at line 99 of file ecalLightMap.cxx.

100{
101 Int_t i;
102 Int_t j;
103 Double_t x;
104 Double_t y;
105 Int_t n[3];
106 Double_t v;
107 Int_t d;
108
109 for(i=0;i<fSize;i++)
110 if (fData[i]<0)
111 {
112 x=(i%fS)*fSSide-0.5+fSSide/2.0;
113 y=(i/fS)*fSSide-0.5+fSSide/2.0;
114 n[0]=GetNum( x,-y);
115 n[1]=GetNum(-x, y);
116 n[2]=GetNum(-x,-y);
117 v=0; d=0;
118 for(j=0;j<3;j++)
119 if (n[j]>=0&&fData[n[j]]>=0)
120 { d++; v+=fData[n[j]]; }
121 if (d>0)
122 {
123 v/=d; fData[i]=v;
124 if (fData[n[0]]<=0) fData[n[0]]=v;
125 if (fData[n[1]]<=0) fData[n[1]]=v;
126 if (fData[n[2]]<=0) fData[n[2]]=v;
127 }
128 else
129 Info("FillGaps","No data for (%f,%f)", x, y);
130 }
131}
int i
Definition ShipAna.py:86

◆ GetNum()

Int_t ecalLightMap::GetNum ( Double_t  x,
Double_t  y 
)
inline

Definition at line 13 of file ecalLightMap.h.

14 {
15 Double_t lx=x+0.5; Double_t ly=y+0.5;
16 if (lx<0) lx=0; if (ly<0) ly=0;
17 if (lx>1) lx=1; if (ly>1) ly=1;
18 Int_t ix=(Int_t)(lx/fSSide);
19 Int_t iy=(Int_t)(ly/fSSide);
20 return iy*fS+ix;
21 }

◆ Init()

void ecalLightMap::Init ( const char *  filename)
private

Read information from file

Definition at line 21 of file ecalLightMap.cxx.

22{
23 TString fn=filename;
24 gSystem->ExpandPathName(fn);
25 ifstream f(fn);
26 list<Double_t> lst;
27 string buf;
28 string token;
29 string message;
30 if (!f)
31 {
32 Fatal("Init","Can't open file %s.", filename);
33 return;
34 }
35
36 while(getline(f, buf))
37 {
38 if (buf.empty()) continue;
39 if (buf.find_first_not_of(" ")==string::npos) continue;
40 //Skipping initial spaces
41 message=buf.substr(buf.find_first_not_of(" "));
42 if (message.empty()) continue;
43 //Removing comments
44 message=message.substr(0,message.find("#"));
45 if (message.empty()) continue;
46 while(!message.empty())
47 {
48 token=message.substr(0,message.find_first_of(" "));
49 if (token.empty()) break;
50 lst.push_back(atof(token.c_str()));
51 if (token==message) break;
52 token=message.substr(message.find_first_of(" "));
53 if (token.empty()) break;
54 if (token.find_first_not_of(" ")==string::npos) break;
55 message=token.substr(token.find_first_not_of(" "));
56 }
57 }
58 f.close();
59
60 list<Double_t>::const_iterator p=lst.begin();
61 Double_t xsize;
62 Double_t ysize;
63 Double_t sqside;
64 Double_t l;
65 Double_t x;
66 Double_t y;
67 Double_t z;
68 Double_t v;
69 Int_t n;
70 Int_t i;
71
72 xsize=(*p); ++p; ysize=(*p); ++p; sqside=(*p); ++p;
73 fS=(Int_t)((xsize+0.00001)/sqside);
74 fSize=fS*fS; fSSide=sqside/xsize;
75 fData=new Double_t[fSize];
76 for(i=0;i<fSize;i++)
77 fData[i]=-1111;
78 for(;;)
79 {
80 if (p==lst.end()) break; l=(*p); ++p;
81 if (p==lst.end()) break; x=(*p); ++p;
82 if (p==lst.end()) break; y=(*p); ++p;
83 if (p==lst.end()) break; z=(*p); ++p;
84 if (p==lst.end()) break; v=(*p); ++p;
85 x/=xsize; y/=ysize;
86 n=GetNum(x ,y);
87 if (n>=fSize)
88 {
89 Info("Init","Data is not selfconsistent (%f, %f), %d", x, y, fSize);
90 }
91 fData[n]=v;
92 }
93 lst.clear();
94 FillGaps();
95 Normalize();
96}

◆ Normalize()

void ecalLightMap::Normalize ( )
private

Set average efficiency of light collection to 1.0

Definition at line 134 of file ecalLightMap.cxx.

135{
136 Int_t i;
137 Int_t n=0;
138 Double_t v=0;
139 for(i=0;i<fSize;i++)
140 if (fData[i]>0)
141 { v+=fData[i]; n++; }
142 v/=n;
143 for(i=0;i<fSize;i++)
144 if (fData[i]>0)
145 fData[i]/=v;
146}

◆ operator=()

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

Member Data Documentation

◆ fData

Double_t* ecalLightMap::fData
private

Light collection efficiency map

Definition at line 37 of file ecalLightMap.h.

◆ fS

Int_t ecalLightMap::fS
private

Size of side of the light map in steps

Definition at line 33 of file ecalLightMap.h.

◆ fSize

Int_t ecalLightMap::fSize
private

Size of the light map

Definition at line 35 of file ecalLightMap.h.

◆ fSSide

Double_t ecalLightMap::fSSide
private

Step of the light map

Definition at line 31 of file ecalLightMap.h.


The documentation for this class was generated from the following files: