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

#include <ecalStructure.h>

Inheritance diagram for ecalStructure:
Collaboration diagram for ecalStructure:

Public Member Functions

 ecalStructure (ecalInf *ecalinf)
 
void SetUseMC (Int_t mc=0)
 
Int_t GetUseMC () const
 
void Construct ()
 
Int_t GetNumber (Int_t x, Int_t y) const
 
Bool_t AddEnergy (Float_t x, Float_t y, Float_t energy, Bool_t isPS=kFALSE)
 
Float_t GetEnergy (Float_t x, Float_t y, Bool_t isPS=kFALSE) const
 
ecalCellGetCell (Float_t x, Float_t y) const
 
ecalModuleGetModule (Float_t x, Float_t y) const
 
Int_t GetModuleNumber (Float_t x, Float_t y) const
 
Float_t GetX1 () const
 
Float_t GetY1 () const
 
Float_t GetX2 () const
 
Float_t GetY2 () const
 
ecalInfGetEcalInf () const
 
void GetStructure (std::vector< ecalModule * > &stru) const
 
void GetCells (std::list< ecalCell * > &cells) const
 
void CreateNLists (ecalCell *cell)
 
void ResetModules ()
 
ecalModuleCreateModule (char type, Int_t number, Float_t x1, Float_t y1, Float_t x2, Float_t y2)
 
Int_t GetHitId (Float_t x, Float_t y) const
 
void GetHitXY (const Int_t hitId, Float_t &x, Float_t &y) const
 
void GetGlobalCellXY (const Int_t hitId, Int_t &x, Int_t &y) const
 
Int_t GetType (const Int_t hitId) const
 
ecalCellGetCell (Int_t fVolId, Int_t &ten, Bool_t &isPS)
 
ecalCellGetHitCell (const Int_t hitId) const
 

Private Member Functions

Int_t GetNum (Int_t x, Int_t y) const
 
void Serialize ()
 
 ecalStructure (const ecalStructure &)
 
ecalStructureoperator= (const ecalStructure &)
 
 ClassDef (ecalStructure, 1)
 

Private Attributes

Int_t fUseMC
 
Float_t fX1
 
Float_t fY1
 
ecalInffEcalInf
 
std::vector< ecalModule * > fStructure
 
std::list< ecalCell * > fCells
 
std::vector< __ecalCellWrapper * > fHash
 

Detailed Description

Definition at line 24 of file ecalStructure.h.

Constructor & Destructor Documentation

◆ ecalStructure() [1/2]

ecalStructure::ecalStructure ( ecalInf ecalinf)

Definition at line 71 of file ecalStructure.cxx.

72 : TNamed("ecalStructure", "Calorimeter structure"),
73 fUseMC(0),
74 fX1(0.),
75 fY1(0.),
76 fEcalInf(ecalinf),
77 fStructure(),
78 fCells(),
79 fHash()
80{
85}
Double_t GetModuleSize() const
Definition ecalInf.h:36
Int_t GetYSize() const
Definition ecalInf.h:46
Int_t GetXSize() const
Definition ecalInf.h:45
Double_t GetXPos() const
Definition ecalInf.h:32
Double_t GetYPos() const
Definition ecalInf.h:33
std::vector< __ecalCellWrapper * > fHash
ecalInf * fEcalInf
std::vector< ecalModule * > fStructure
std::list< ecalCell * > fCells

◆ ecalStructure() [2/2]

ecalStructure::ecalStructure ( const ecalStructure )
private

Member Function Documentation

◆ AddEnergy()

Bool_t ecalStructure::AddEnergy ( Float_t  x,
Float_t  y,
Float_t  energy,
Bool_t  isPS = kFALSE 
)
inline

Add preshower or calorimeter energy to a cell with coordinate (x,y)

Definition at line 148 of file ecalStructure.h.

149{
151 ecalCell* cell=GetCell(x,y);
152 if (cell)
153 {
154 if (isPS) ; // cell->AddPSEnergy(energy); Preshower removed
155 else
156 cell->AddEnergy(energy);
157 }
158 else
159 return kFALSE;
160 return kTRUE;
161}
void AddEnergy(Float_t energy)
Definition ecalCell.h:68
ecalCell * GetCell(Float_t x, Float_t y) const

◆ ClassDef()

ecalStructure::ClassDef ( ecalStructure  ,
 
)
private

◆ Construct()

void ecalStructure::Construct ( )

Definition at line 88 of file ecalStructure.cxx.

89{
90 if (!fEcalInf) return;
91
92 Float_t x1=GetX1();
93 Float_t y1=GetY1();
94 Float_t x;
95 Float_t y;
96 Float_t dx;
97 Float_t dy;
98 Int_t i;
99 Int_t j;
100 Int_t k;
101 Int_t number;
102 char type;
103
104 fStructure.resize(fEcalInf->GetXSize()*fEcalInf->GetYSize(), NULL);
105
108 //Creating ECAL Matrix
109 for(i=0;i<fEcalInf->GetXSize();i++)
110 for(j=0;j<fEcalInf->GetYSize();j++) {
111 type=fEcalInf->GetType(i,j);
112 if (type) {
113 x=x1+i*dx;
114 y=y1+j*dy;
115 number=(i*100+j)*100;
116 fStructure[GetNum(i,j)]=CreateModule(type,number,x,y,x+dx,y+dy);
117 }
118 else
119 fStructure[GetNum(i,j)]=NULL;
120 }
121#ifdef _DECALSTRUCT
122 cerr << "-I- ecalStructure::Construct(): calorimeter matrix created." << endl;
123#endif
124 //Now ECAL matrix created
125 list<ecalCell*> neib;
126 vector<ecalCell*> cl;
127 vector<ecalCell*>::const_iterator pcl;
128
129 Int_t num;
130 //We want neighbors for ecalModules be ecalModules
131 for(i=0;i<fEcalInf->GetXSize();i++)
132 for(j=0;j<fEcalInf->GetYSize();j++)
133 if (fStructure[GetNum(i,j)]) {
134 neib.clear();
135
136 num=GetNumber(i-1,j);
137 if (-1!=num) {
138 neib.push_back(fStructure[num]);
139 }
140
141 num=GetNumber(i-1,j+1);
142 if (-1!=num) {
143 neib.push_back(fStructure[num]);
144 }
145
146 num=GetNumber(i,j+1);
147 if (-1!=num) {
148 neib.push_back(fStructure[num]);
149 }
150
151 num=GetNumber(i+1,j+1);
152 if (-1!=num) {
153 neib.push_back(fStructure[num]);
154 }
155
156 num=GetNumber(i+1,j);
157 if (-1!=num) {
158 neib.push_back(fStructure[num]);
159 }
160
161 num=GetNumber(i+1,j-1);
162 if (-1!=num) {
163 neib.push_back(fStructure[num]);
164 }
165
166 num=GetNumber(i,j-1);
167 if (-1!=num) {
168 neib.push_back(fStructure[num]);
169 }
170
171 num=GetNumber(i-1,j-1);
172 if (-1!=num) {
173 neib.push_back(fStructure[num]);
174 }
175
176 num=GetNumber(i,j);
177 fStructure[num]->SetNeighborsList(neib);
178 cl=fStructure[num]->GetCells();
179 for(pcl=cl.begin();pcl!=cl.end();++pcl)
180 CreateNLists(*pcl);
181 }
182 Serialize();
183}
char GetType(Int_t x, Int_t y) const
Definition ecalInf.h:155
Float_t GetY1() const
Int_t GetNumber(Int_t x, Int_t y) const
void CreateNLists(ecalCell *cell)
Int_t GetNum(Int_t x, Int_t y) const
ecalModule * CreateModule(char type, Int_t number, Float_t x1, Float_t y1, Float_t x2, Float_t y2)
Float_t GetX1() const
int i
Definition ShipAna.py:86

◆ CreateModule()

ecalModule * ecalStructure::CreateModule ( char  type,
Int_t  number,
Float_t  x1,
Float_t  y1,
Float_t  x2,
Float_t  y2 
)

Definition at line 65 of file ecalStructure.cxx.

66{
67 return new ecalModule(type, number, x1, y1, x2, y2, fUseMC);
68}

◆ CreateNLists()

void ecalStructure::CreateNLists ( ecalCell cell)

Definition at line 211 of file ecalStructure.cxx.

212{
213 Float_t x=cell->GetCenterX();
214 Float_t y=cell->GetCenterY();
215 Float_t dx=(cell->GetX2()-cell->GetX1())/2.0;
216 Float_t dy=(cell->GetX2()-cell->GetX1())/2.0;
217 Float_t x1;
218 Float_t x2;
219 Float_t y1;
220 Float_t y2;
221 Float_t mx1=cell->GetX1();
222 Float_t mx2=cell->GetX2();
223 Float_t my1=cell->GetY1();
224 Float_t my2=cell->GetY2();
225 Float_t cx;
226 Float_t cy;
227 Float_t d=0.1;
228 Float_t dd=1e-6;
229 list<ecalCell*> neib;
230 list<ecalCell*> tl;
231 list<ecalModule*> tml;
232 list<ecalModule*>::const_iterator ptml;
233 list<ecalCell*>::const_iterator ptl;
234 Int_t i;
235
236 neib.clear();
237
238 tml.clear();
239 _add_not_null(GetModule(x-2*dx,y-2*dy),tml);
240 _add_not_null(GetModule(x-2*dx,y ),tml);
241 _add_not_null(GetModule(x-2*dx,y+2*dy),tml);
242 _add_not_null(GetModule(x ,y-2*dy),tml);
243 _add_not_null(GetModule(x ,y ),tml);
244 _add_not_null(GetModule(x ,y+2*dy),tml);
245 _add_not_null(GetModule(x+2*dx,y-2*dy),tml);
246 _add_not_null(GetModule(x+2*dx,y ),tml);
247 _add_not_null(GetModule(x+2*dx,y+2*dy),tml);
248 if (tml.empty()) {
249 cerr << "Error during creating neighbors lists." << endl;
250 cerr << "Can't' find any modules neighbors to cell." << endl;
251 cerr << "Cell: CenterX=" << x << ", CenterY=" << y << "." << endl;
252 return;
253 }
254 tl.empty();
255 for(ptml=tml.begin();ptml!=tml.end();++ptml) {
256 _add_not_null((*ptml)->GetCellsY(y-dy-d),tl);
257 _add_not_null((*ptml)->GetCellsY(y+dy+d),tl);
258 _add_not_null((*ptml)->GetCellsX(x-dx-d),tl);
259 _add_not_null((*ptml)->GetCellsX(x+dx+d),tl);
260 }
261 if (tl.empty()) {
262 cerr << "Error during creating neighbors lists." << endl;
263 cerr << "Can't' find any cells neighbors to cell." << endl;
264 cerr << "Cell: CenterX=" << x << ", CenterY=" << y << "." << endl;
265 return;
266 }
267 for(ptl=tl.begin();ptl!=tl.end();++ptl) {
268 x1=(*ptl)->GetX1();
269 x2=(*ptl)->GetX2();
270 y1=(*ptl)->GetY1();
271 y2=(*ptl)->GetY2();
272 cx=(*ptl)->GetCenterX();
273 cy=(*ptl)->GetCenterY();
274 if (fabs(mx1-x2)<dd) {
275 if ((cy-y+2*dy>-dd&&cy-y-dy/2<dd)||fabs(y-dy-y1)<dd||fabs(y-dy-y2)<dd) {
276 _add_not_null((*ptl),neib);
277 }
278 if ((cy-y-2*dy<dd&&cy-y+dy/2>-dd)||fabs(y+dy-y1)<dd||fabs(y+dy-y2)<dd) {
279 _add_not_null((*ptl),neib);
280 }
281 }
282 if (fabs(my1-y2)<dd) {
283 if ((cx-x+2*dx>-dd&&cx-x-dx/2<dd)||fabs(x-dx-x1)<dd||fabs(x-dx-x2)<dd) {
284 _add_not_null((*ptl),neib);
285 }
286 if ((cx-x-2*dx<dd&&cx-x+dx/2>-dd)||fabs(x+dx-x1)<dd||fabs(x+dx-x2)<dd) {
287 _add_not_null((*ptl),neib);
288 }
289 }
290 if (fabs(mx2-x1)<dd) {
291 if ((cy-y+2*dy>-dd&&cy-y-dy/2<dd)||fabs(y-dy-y1)<dd||fabs(y-dy-y2)<dd) {
292 _add_not_null((*ptl),neib);
293 }
294 if ((cy-y-2*dy<dd&&cy-y+dy/2>-dd)||fabs(y+dy-y1)<dd||fabs(y+dy-y2)<dd) {
295 _add_not_null((*ptl),neib);
296 }
297 }
298 if (fabs(my2-y1)<dd) {
299 if ((cx-x+2*dx>-dd&&cx-x-dx/2<dd)||fabs(x-dx-x1)<dd||fabs(x-dx-x2)<dd) {
300 _add_not_null((*ptl),neib);
301 }
302 if ((cx-x-2*dx<dd&&cx-x+dx/2>-dd)||fabs(x+dx-x1)<dd||fabs(x+dx-x2)<dd) {
303 _add_not_null((*ptl),neib);
304 }
305 }
306
307 }
308 cell->SetNeighborsList(neib);
309}
void SetNeighborsList(std::list< ecalCell * > &neib)
Definition ecalCell.h:52
Float_t GetCenterX() const
Definition ecalCell.h:35
Float_t GetX2() const
Definition ecalCell.h:33
Float_t GetY1() const
Definition ecalCell.h:32
Float_t GetY2() const
Definition ecalCell.h:34
Float_t GetCenterY() const
Definition ecalCell.h:36
Float_t GetX1() const
Definition ecalCell.h:31
ecalModule * GetModule(Float_t x, Float_t y) const
void _add_not_null(ecalModule *mod, list< ecalModule * > &lst)

◆ GetCell() [1/2]

ecalCell * ecalStructure::GetCell ( Float_t  x,
Float_t  y 
) const
inline

get ECAL cell by known cell center coordinate (x,y)

Definition at line 95 of file ecalStructure.h.

96{
98 ecalModule* module=GetModule(x,y);
99 if (module) return module->FindCell(x,y);
100 return NULL;
101}

◆ GetCell() [2/2]

ecalCell * ecalStructure::GetCell ( Int_t  fVolId,
Int_t &  ten,
Bool_t &  isPS 
)

Definition at line 21 of file ecalStructure.cxx.

22{
23 UInt_t i;
24 static Int_t volidmax = 0;
25 volidmax=10000000;
26
27 if ((Int_t)fHash.size()<volidmax)
28 {
29 fHash.resize(volidmax);
30 for(i=0;i<fHash.size();i++)
31 fHash[i]=NULL;
32 }
33 if (volId>volidmax)
34 return NULL;
35 if (fHash[volId]==NULL)
36 {
37 Bool_t lisPS;
38 Int_t iten;
39 Float_t x;
40 Float_t y;
41 fHash[volId]=new __ecalCellWrapper();
42 lisPS=ecal::GetCellCoordInf(volId, x, y, iten);
43 fHash[volId]->cell=GetCell(x+0.025,y+0.025);
44 fHash[volId]->isPsTen=iten*2;
45 if (lisPS) fHash[volId]->isPsTen+=1;
46 }
47 ten=fHash[volId]->isPsTen/2;
48 isPS=fHash[volId]->isPsTen%2;
49 return fHash[volId]->cell;
50}
static Bool_t GetCellCoordInf(Int_t fVolumeID, Float_t &x, Float_t &y, Int_t &tenergy)
Definition ecal.cxx:1264

◆ GetCells()

void ecalStructure::GetCells ( std::list< ecalCell * > &  cells) const
inline

Definition at line 45 of file ecalStructure.h.

45{cells=fCells;}

◆ GetEcalInf()

ecalInf * ecalStructure::GetEcalInf ( ) const
inline

Definition at line 43 of file ecalStructure.h.

43{return fEcalInf;}

◆ GetEnergy()

Float_t ecalStructure::GetEnergy ( Float_t  x,
Float_t  y,
Bool_t  isPS = kFALSE 
) const
inline

Definition at line 163 of file ecalStructure.h.

164{
165 ecalCell* cell=GetCell(x,y);
166 if (cell)
167 {
168 if (isPS)
169 return 0; // return cell->GetPSEnergy(); Preshower removed
170 else
171 return cell->GetEnergy();
172 }
173 return -1111;
174}
Float_t GetEnergy() const
Definition ecalCell.h:42

◆ GetGlobalCellXY()

void ecalStructure::GetGlobalCellXY ( const Int_t  hitId,
Int_t &  x,
Int_t &  y 
) const

Definition at line 383 of file ecalStructure.cxx.

384{
385
386
387 Int_t modulenum = hitId/100;
388 Int_t cellx = modulenum/100;
389 Int_t celly = modulenum%100;
390
391 Int_t innernum = hitId%100;
392 Int_t iny = innernum/10;
393 Int_t inx = innernum%10;
394 Int_t msize = fEcalInf->GetType(cellx,celly);
395
396
397 x = (cellx-1)* msize + inx;
398 y = (celly-1)* msize + iny;
399
400}

◆ GetHitCell()

ecalCell * ecalStructure::GetHitCell ( const Int_t  hitId) const

Hit Id -> Cell

Definition at line 356 of file ecalStructure.cxx.

357{
360 // Some translation from x*100+y to y*sizex+x coding...
361
362 Int_t mnum=hitId/100;
363 Int_t cellx = mnum/100;
364 Int_t celly = mnum%100;
365 mnum = GetNum(cellx, celly);
366
367 // end translation
368
369 ecalModule* module=fStructure[mnum];
370
371 Int_t cellnum=hitId%100;
372 Int_t cx=cellnum%10-1;
373 Int_t cy=cellnum/10-1;
374
375 if (module==NULL||cx<0||cy<0||cx>=module->GetType()||cy>=module->GetType())
376 return NULL;
377// cout << hitId << " --- " << module->At(cx,cy)->GetCellNumber() << endl;
378 return module->At(cx,cy);
379}

◆ GetHitId()

Int_t ecalStructure::GetHitId ( Float_t  x,
Float_t  y 
) const
inline

Definition at line 177 of file ecalStructure.h.

178{
179 ecalCell* cell=GetCell(x,y);
180 if (cell)
181 return cell->GetCellNumber();
182 else
183 return -1111;
184}
Int_t GetCellNumber() const
Definition ecalCell.h:40

◆ GetHitXY()

void ecalStructure::GetHitXY ( const Int_t  hitId,
Float_t &  x,
Float_t &  y 
) const

Hit Id -> (x,y)

Definition at line 328 of file ecalStructure.cxx.

329{
332 // Some translation from x*100+y to y*sizex+x coding...
333
334 Int_t mnum=hitId/100;
335 Int_t cellx = mnum/100;
336 Int_t celly = mnum%100;
337 mnum = GetNum(cellx, celly);
338
339 // end translation
340
341 ecalModule* module=fStructure[mnum];
342 ecalCell* cell;
343
344 Int_t cellnum=hitId%100;
345 // change place
346 Int_t cx=cellnum%10-1;
347 Int_t cy=cellnum/10-1;
348
349 if (module==NULL||cx<0||cy<0||cx>=module->GetType()||cy>=module->GetType()) {x=0; y=0; return;}
350 cell=module->At(cx,cy);
351 x=cell->GetCenterX();
352 y=cell->GetCenterY();
353}

◆ GetModule()

ecalModule * ecalStructure::GetModule ( Float_t  x,
Float_t  y 
) const
inline

get ECAL module by known module center coordinate (x,y)

Definition at line 103 of file ecalStructure.h.

104{
106 Int_t num=GetModuleNumber(x,y);
107 if (-1==num) return NULL; else return fStructure[num];
108}
Int_t GetModuleNumber(Float_t x, Float_t y) const

◆ GetModuleNumber()

Int_t ecalStructure::GetModuleNumber ( Float_t  x,
Float_t  y 
) const
inline

get ECAL module by known module center coordinate (x,y)

Definition at line 110 of file ecalStructure.h.

111{
113 Int_t ix=(Int_t)TMath::Floor((x-GetX1())/fEcalInf->GetModuleSize());
114 Int_t iy=(Int_t)TMath::Floor((y-GetY1())/fEcalInf->GetModuleSize());
115 return GetNumber(ix,iy);
116}

◆ GetNum()

Int_t ecalStructure::GetNum ( Int_t  x,
Int_t  y 
) const
inlineprivate

get ECAL absolute module number by known module relative number (x,y)

Definition at line 128 of file ecalStructure.h.

129{
131 return y*fEcalInf->GetXSize()+x;
132}

◆ GetNumber()

Int_t ecalStructure::GetNumber ( Int_t  x,
Int_t  y 
) const
inline

get ECAL absolute module number by known module relative number (x,y) with check for the ECAL boundaries

Definition at line 118 of file ecalStructure.h.

119{
122 if (x>-1&&y>-1)
123 if (x<fEcalInf->GetXSize()&&y<fEcalInf->GetYSize())
124 return GetNum(x,y);
125 return -1;
126}

◆ GetStructure()

void ecalStructure::GetStructure ( std::vector< ecalModule * > &  stru) const
inline

Definition at line 44 of file ecalStructure.h.

44{stru=fStructure;}

◆ GetType()

Int_t ecalStructure::GetType ( const Int_t  hitId) const

Definition at line 402 of file ecalStructure.cxx.

403{
404 Int_t modulenum = hitId/100;
405 Int_t cellx = modulenum/100;
406 Int_t celly = modulenum%100;
407
408 Int_t msize = fEcalInf->GetType(cellx,celly);
409 return msize;
410}

◆ GetUseMC()

Int_t ecalStructure::GetUseMC ( ) const
inline

Definition at line 29 of file ecalStructure.h.

29{return fUseMC;}

◆ GetX1()

Float_t ecalStructure::GetX1 ( ) const
inline

Definition at line 39 of file ecalStructure.h.

39{return fX1;};

◆ GetX2()

Float_t ecalStructure::GetX2 ( ) const
inline

get ECAL right edge coordinate in cm

Definition at line 134 of file ecalStructure.h.

135{
137 return fEcalInf->GetXPos()+
139}

◆ GetY1()

Float_t ecalStructure::GetY1 ( ) const
inline

Definition at line 40 of file ecalStructure.h.

40{return fY1;};

◆ GetY2()

Float_t ecalStructure::GetY2 ( ) const
inline

get ECAL upper edge coordinate in cm

Definition at line 141 of file ecalStructure.h.

142{
144 return fEcalInf->GetYPos()+
146}

◆ operator=()

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

◆ ResetModules()

void ecalStructure::ResetModules ( )

Definition at line 312 of file ecalStructure.cxx.

313{
314 list<ecalCell*>::const_iterator p=fCells.begin();
315 if (fUseMC==0)
316 {
317 for(;p!=fCells.end();++p)
318 (*p)->ResetEnergyFast();
319 }
320 else
321 {
322 for(;p!=fCells.end();++p)
323 ((ecalCellMC*)(*p))->ResetEnergy();
324 }
325}

◆ Serialize()

void ecalStructure::Serialize ( )
private

Creates fCells lists

Definition at line 53 of file ecalStructure.cxx.

54{
55 fCells.clear();
56 for(UInt_t i=0;i<fStructure.size();i++)
57 if (fStructure[i])
58 {
59 vector<ecalCell*> cells=fStructure[i]->GetCells();
60 copy(cells.begin(),cells.end(), back_inserter(fCells));
61 }
62}

◆ SetUseMC()

void ecalStructure::SetUseMC ( Int_t  mc = 0)
inline

Definition at line 28 of file ecalStructure.h.

Member Data Documentation

◆ fCells

std::list<ecalCell*> ecalStructure::fCells
private

All ECAL cells

Definition at line 85 of file ecalStructure.h.

◆ fEcalInf

ecalInf* ecalStructure::fEcalInf
private

ECAL geometry container

Definition at line 81 of file ecalStructure.h.

◆ fHash

std::vector<__ecalCellWrapper*> ecalStructure::fHash
private

MCPoint id -> ECAL cell

Definition at line 87 of file ecalStructure.h.

◆ fStructure

std::vector<ecalModule*> ecalStructure::fStructure
private

total list of ECAL modules

Definition at line 83 of file ecalStructure.h.

◆ fUseMC

Int_t ecalStructure::fUseMC
private

Use store MC information in cells

Definition at line 75 of file ecalStructure.h.

◆ fX1

Float_t ecalStructure::fX1
private

X coordibate of left bottom angle of ECAL

Definition at line 77 of file ecalStructure.h.

◆ fY1

Float_t ecalStructure::fY1
private

Y coordibate of left bottom angle of ECAL

Definition at line 79 of file ecalStructure.h.


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