SND@LHC Software
Loading...
Searching...
No Matches
ecalModule.cxx
Go to the documentation of this file.
1
8#include "ecalModule.h"
9
10#include "ecalCellMC.h"
11
12#include "TMath.h"
13
14using std::list;
15using std::vector;
16
17//-----------------------------------------------------------------------------
18ecalModule::ecalModule(char type, Int_t cellnumber, Float_t x1, Float_t y1, Float_t x2, Float_t y2, Int_t mc, Float_t energy)
19 : ecalCell(cellnumber, x1,y1,x2,y2, type, energy),
20 fDx(x2-x1),
21 fDy(y2-y1),
22 fCells()
23{
24 if (GetType()<1) return;
25
26 Int_t i;
27 Int_t j;
28 Int_t mt;
29 Int_t num;
30
31 mt=type;
32 fCells.resize(mt*mt,NULL);
33
34 num=cellnumber/100;
35
36 if (mc==0)
37 for(i=0;i<mt;i++)
38 for(j=0;j<mt;j++)
39 fCells[i*mt+j]=new ecalCell((num*10+i+1)*10+j+1, x1+j*fDx/mt, y1+i*fDy/mt, x1+(j+1)*fDx/mt, y1+(i+1)*fDy/mt, type);
40 else
41 for(i=0;i<mt;i++)
42 for(j=0;j<mt;j++)
43 fCells[i*mt+j]=new ecalCellMC((num*10+i+1)*10+j+1, x1+j*fDx/mt, y1+i*fDy/mt, x1+(j+1)*fDx/mt, y1+(i+1)*fDy/mt, type);
44}
45
46//-----------------------------------------------------------------------------
47ecalCell* ecalModule::Locate(Int_t x, Int_t y) const
48{
49 if (x<0||y<0||x>=GetType()||y>=GetType()) return NULL;
50 return fCells[y*GetType()+x];
51}
52
53//-----------------------------------------------------------------------------
54ecalCell* ecalModule::FindCell(Float_t x, Float_t y) const
55{
56 Int_t ix=(Int_t)TMath::Floor( (x-GetX1())/GetDX()*GetType() );
57 Int_t iy=(Int_t)TMath::Floor( (y-GetY1())/GetDY()*GetType() );
58 if (ix<0) ix=0; if (ix>=GetType()) ix=GetType()-1;
59 if (iy<0) iy=0; if (iy>=GetType()) iy=GetType()-1;
60 return At(ix,iy);
61}
62
63//-----------------------------------------------------------------------------
64void ecalModule::AddEnergy(Float_t x, Float_t y, Float_t energy)
65{
66 ecalCell* tmp=FindCell(x,y);
67 if (!tmp) return;
68 tmp->AddEnergy(energy);
69 ecalCell::AddEnergy(energy);
70}
71
72//-----------------------------------------------------------------------------
73list<ecalCell*> ecalModule::GetCellsX(Float_t x) const
74{
75 list<ecalCell*> tmp;
76 vector<ecalCell*>::const_iterator p;
77
78 for(p=fCells.begin();p!=fCells.end();++p)
79 if (x>(*p)->GetX1()&&x<(*p)->GetX2()) tmp.push_back(*p);
80 return tmp;
81}
82
83//-----------------------------------------------------------------------------
84list<ecalCell*> ecalModule::GetCellsY(Float_t y) const
85{
86 list<ecalCell*> tmp;
87 vector<ecalCell*>::const_iterator p;
88
89 for(p=fCells.begin();p!=fCells.end();++p)
90 if (y>(*p)->GetY1()&&y<(*p)->GetY2()) tmp.push_back(*p);
91 return tmp;
92}
Char_t GetType() const
Definition ecalCell.h:26
void AddEnergy(Float_t energy)
Definition ecalCell.h:68
Float_t GetY1() const
Definition ecalCell.h:32
Float_t GetX1() const
Definition ecalCell.h:31
ecalModule(char type=1, Int_t cellnumber=-1, Float_t x1=0, Float_t y1=0, Float_t x2=0, Float_t y2=0, Int_t mc=0, Float_t energy=0)
ecalCell * FindCell(Float_t x, Float_t y) const
void AddEnergy(Float_t x, Float_t y, Float_t energy)
Float_t GetDX() const
Definition ecalModule.h:37
ecalCell * Locate(Int_t x, Int_t y) const
std::vector< ecalCell * > fCells
Definition ecalModule.h:52
ecalCell * At(Int_t x, Int_t y) const
Definition ecalModule.h:26
std::list< ecalCell * > GetCellsY(Float_t y) const
Float_t fDx
Definition ecalModule.h:48
std::list< ecalCell * > GetCellsX(Float_t x) const
Float_t GetDY() const
Definition ecalModule.h:38
Float_t fDy
Definition ecalModule.h:50