SND@LHC Software
Loading...
Searching...
No Matches
ecalStructure.h
Go to the documentation of this file.
1
7#ifndef ECALSTRUCTURE_H
8#define ECALSTRUCTURE_H
9
10
11#include "ecalInf.h"
12#include "ecalModule.h"
13#include "ecalCell.h"
14
15#include "TMath.h"
16#include "TNamed.h"
17
18#include <vector>
19
20#define _DECALSTRUCT
21
23
24class ecalStructure : public TNamed
25{
26public:
27 ecalStructure(ecalInf* ecalinf);
28 void SetUseMC(Int_t mc=0) {fUseMC=mc;}
29 Int_t GetUseMC() const {return fUseMC;}
30 void Construct();
31 Int_t GetNumber(Int_t x, Int_t y) const;
32
33 Bool_t AddEnergy(Float_t x, Float_t y, Float_t energy, Bool_t isPS=kFALSE);
34 Float_t GetEnergy(Float_t x, Float_t y, Bool_t isPS=kFALSE) const;
35 ecalCell* GetCell(Float_t x, Float_t y) const;
36 ecalModule* GetModule(Float_t x, Float_t y) const;
37 Int_t GetModuleNumber(Float_t x, Float_t y) const;
38
39 Float_t GetX1() const {return fX1;};
40 Float_t GetY1() const {return fY1;};
41 Float_t GetX2() const;
42 Float_t GetY2() const;
43 inline ecalInf* GetEcalInf() const {return fEcalInf;}
44 inline void GetStructure(std::vector<ecalModule*>& stru) const {stru=fStructure;}
45 inline void GetCells(std::list<ecalCell*>& cells) const {cells=fCells;}
46 //Create neighbors lists
47 void CreateNLists(ecalCell* cell);
48 void ResetModules();
49
50 ecalModule* CreateModule(char type, Int_t number, Float_t x1, Float_t y1, Float_t x2, Float_t y2);
51 //Some usefull procedures for hit processing
52
53 //Converts (x,y) to hit Id
54 Int_t GetHitId(Float_t x, Float_t y) const;
55 //Hit Id -> (x,y)
56 void GetHitXY(const Int_t hitId, Float_t& x, Float_t& y) const;
57
58 // HitId -> in global cell coordinate
59 void GetGlobalCellXY(const Int_t hitId, Int_t& x, Int_t& y) const;
60
61 // HitId -> cell type
62 Int_t GetType(const Int_t hitId) const;
63
64 ecalCell* GetCell(Int_t fVolId, Int_t& ten, Bool_t& isPS);
65 //Hit It -> Cell
66 ecalCell* GetHitCell(const Int_t hitId) const;
67
68private:
69 Int_t GetNum(Int_t x, Int_t y) const;
70
71private:
73 void Serialize();
75 Int_t fUseMC;
77 Float_t fX1;
79 Float_t fY1;
83 std::vector<ecalModule*> fStructure;
85 std::list<ecalCell*> fCells;
87 std::vector<__ecalCellWrapper*> fHash;
88
91
93};
94
95inline ecalCell* ecalStructure::GetCell(Float_t x, Float_t y) const
96{
98 ecalModule* module=GetModule(x,y);
99 if (module) return module->FindCell(x,y);
100 return NULL;
101}
102
103inline ecalModule* ecalStructure::GetModule(Float_t x, Float_t y) const
104{
106 Int_t num=GetModuleNumber(x,y);
107 if (-1==num) return NULL; else return fStructure[num];
108}
109
110inline Int_t ecalStructure::GetModuleNumber(Float_t x, Float_t y) const
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}
117
118inline Int_t ecalStructure::GetNumber(Int_t x, Int_t y) const
119{
122 if (x>-1&&y>-1)
123 if (x<fEcalInf->GetXSize()&&y<fEcalInf->GetYSize())
124 return GetNum(x,y);
125 return -1;
126}
127
128inline Int_t ecalStructure::GetNum(Int_t x, Int_t y) const
129{
131 return y*fEcalInf->GetXSize()+x;
132}
133
134inline Float_t ecalStructure::GetX2() const
135{
137 return fEcalInf->GetXPos()+
139}
140
141inline Float_t ecalStructure::GetY2() const
142{
144 return fEcalInf->GetYPos()+
146}
147
148inline Bool_t ecalStructure::AddEnergy(Float_t x, Float_t y, Float_t energy, Bool_t isPS)
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}
162
163inline Float_t ecalStructure::GetEnergy(Float_t x, Float_t y, Bool_t isPS) const
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}
175
176//Converts (x,y) to hit Id
177inline Int_t ecalStructure::GetHitId(Float_t x, Float_t y) const
178{
179 ecalCell* cell=GetCell(x,y);
180 if (cell)
181 return cell->GetCellNumber();
182 else
183 return -1111;
184}
185
187{
188public:
190 Char_t isPsTen;
191};
192
193#endif
Int_t GetCellNumber() const
Definition ecalCell.h:40
void AddEnergy(Float_t energy)
Definition ecalCell.h:68
Float_t GetEnergy() const
Definition ecalCell.h:42
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
Int_t GetModuleNumber(Float_t x, Float_t y) const
ecalModule * GetModule(Float_t x, Float_t y) const
void SetUseMC(Int_t mc=0)
Float_t GetY1() const
Float_t GetEnergy(Float_t x, Float_t y, Bool_t isPS=kFALSE) const
ecalStructure(const ecalStructure &)
Int_t GetType(const Int_t hitId) const
Float_t GetY2() const
void GetCells(std::list< ecalCell * > &cells) const
ecalCell * GetCell(Float_t x, Float_t y) const
std::vector< __ecalCellWrapper * > fHash
Int_t GetUseMC() const
ClassDef(ecalStructure, 1)
ecalStructure & operator=(const ecalStructure &)
Int_t GetHitId(Float_t x, Float_t y) const
Int_t GetNumber(Int_t x, Int_t y) const
Float_t GetX2() const
void CreateNLists(ecalCell *cell)
ecalCell * GetHitCell(const Int_t hitId) const
ecalInf * fEcalInf
Int_t GetNum(Int_t x, Int_t y) const
std::vector< ecalModule * > fStructure
ecalInf * GetEcalInf() const
ecalModule * CreateModule(char type, Int_t number, Float_t x1, Float_t y1, Float_t x2, Float_t y2)
Float_t GetX1() const
void GetGlobalCellXY(const Int_t hitId, Int_t &x, Int_t &y) const
std::list< ecalCell * > fCells
Bool_t AddEnergy(Float_t x, Float_t y, Float_t energy, Bool_t isPS=kFALSE)
void GetHitXY(const Int_t hitId, Float_t &x, Float_t &y) const
void GetStructure(std::vector< ecalModule * > &stru) const