SND@LHC Software
Loading...
Searching...
No Matches
hcalStructure.h
Go to the documentation of this file.
1
7#ifndef HCALSTRUCTURE_H
8#define HCALSTRUCTURE_H
9
10#include "hcalInf.h"
11#include "hcalModule.h"
12
13#include "TMath.h"
14#include "TNamed.h"
15
16#include <vector>
17
18#define _DHCALSTRUCT
19
20class hcalStructure : public TNamed
21{
22public:
23 hcalStructure(hcalInf* hcalinf);
24 void SetUseMC(Int_t mc=0) {fUseMC=mc;}
25 Int_t GetUseMC() const {return fUseMC;}
26 void Construct();
27 Int_t GetNumber(Int_t x, Int_t y) const;
28
29 Bool_t AddEnergy(Float_t x, Float_t y, Float_t energy, Float_t energy2);
30 Float_t GetEnergy(Float_t x, Float_t y, Int_t section=0) const;
31 hcalModule* GetModule(Float_t x, Float_t y) const;
32 Int_t GetModuleNumber(Float_t x, Float_t y) const;
33
34 Float_t GetX1() const {return fX1;};
35 Float_t GetY1() const {return fY1;};
36 Float_t GetX2() const;
37 Float_t GetY2() const;
38 inline hcalInf* GetHcalInf() const {return fHcalInf;}
39 inline void GetStructure(std::vector<hcalModule*>& stru) const {stru=fStructure;}
40 inline void GetModules(std::list<hcalModule*>& mdls) const {mdls=fModules;}
41 void ResetModules();
42
43 hcalModule* CreateModule(char type, Int_t number, Float_t x1, Float_t y1, Float_t x2, Float_t y2);
44 //Some usefull procedures for hit processing
45
46 //Converts (x,y) to hit Id
47 Int_t GetHitId(Float_t x, Float_t y) const;
48 //Hit Id -> (x,y)
49 void GetHitXY(const Int_t hitId, Float_t& x, Float_t& y) const;
50
51 hcalModule* GetModule(Int_t fVolId, Int_t& section);
52 //Hit It -> Cell
53 hcalModule* GetHitModule(const Int_t hitId) const;
54
55private:
56 Int_t GetNum(Int_t x, Int_t y) const;
57
58private:
60 void Serialize();
62 Int_t fUseMC;
64 Float_t fX1;
66 Float_t fY1;
70 std::vector<hcalModule*> fStructure;
72 std::list<hcalModule*> fModules;
74 std::vector<hcalModule*> fHash;
75
78
80};
81
82inline hcalModule* hcalStructure::GetModule(Float_t x, Float_t y) const
83{
85 Int_t num=GetModuleNumber(x,y);
86 if (-1==num) return NULL; else return fStructure[num];
87}
88
89inline Int_t hcalStructure::GetModuleNumber(Float_t x, Float_t y) const
90{
92 Int_t ix=(Int_t)TMath::Floor((x-GetX1())/fHcalInf->GetModuleSize());
93 Int_t iy=(Int_t)TMath::Floor((y-GetY1())/fHcalInf->GetModuleSize());
94 return GetNumber(ix,iy);
95}
96
97inline Int_t hcalStructure::GetNumber(Int_t x, Int_t y) const
98{
101 if (x>-1&&y>-1)
102 if (x<fHcalInf->GetXSize()&&y<fHcalInf->GetYSize())
103 return GetNum(x,y);
104 return -1;
105}
106
107inline Int_t hcalStructure::GetNum(Int_t x, Int_t y) const
108{
110 return y*fHcalInf->GetXSize()+x;
111}
112
113inline Float_t hcalStructure::GetX2() const
114{
117}
118
119inline Float_t hcalStructure::GetY2() const
120{
123}
124
125inline Bool_t hcalStructure::AddEnergy(Float_t x, Float_t y, Float_t energy, Float_t energy2)
126{
128 hcalModule* mdl=GetModule(x,y);
129 if (mdl)
130 {
131 mdl->AddEnergy(energy);
132 mdl->AddEnergy2(energy2);
133 }
134 else
135 return kFALSE;
136 return kTRUE;
137}
138
139inline Float_t hcalStructure::GetEnergy(Float_t x, Float_t y, Int_t section) const
140{
141 hcalModule* mdl=GetModule(x,y);
142 if (mdl)
143 {
144 if (section==1)
145 return mdl->GetEnergy2();
146 else
147 return mdl->GetEnergy();
148 }
149 return -1111;
150}
151
152//Converts (x,y) to hit Id
153inline Int_t hcalStructure::GetHitId(Float_t x, Float_t y) const
154{
155 hcalModule* mdl=GetModule(x,y);
156 if (mdl)
157 return mdl->GetNumber();
158 else
159 return -1111;
160}
161
162#endif
Double_t GetYPos() const
Definition hcalInf.h:33
Double_t GetModuleSize() const
Definition hcalInf.h:36
Double_t GetXPos() const
Definition hcalInf.h:32
Int_t GetYSize() const
Definition hcalInf.h:47
Int_t GetXSize() const
Definition hcalInf.h:46
Float_t GetEnergy() const
Definition hcalModule.h:41
Int_t GetNumber() const
Definition hcalModule.h:39
void AddEnergy2(Float_t energy)
Definition hcalModule.h:58
Float_t GetEnergy2() const
Definition hcalModule.h:42
void AddEnergy(Float_t energy)
Definition hcalModule.h:57
std::vector< hcalModule * > fStructure
hcalModule * GetModule(Float_t x, Float_t y) const
hcalModule * CreateModule(char type, Int_t number, Float_t x1, Float_t y1, Float_t x2, Float_t y2)
void GetHitXY(const Int_t hitId, Float_t &x, Float_t &y) const
Float_t GetY2() const
void SetUseMC(Int_t mc=0)
Int_t GetUseMC() const
hcalStructure & operator=(const hcalStructure &)
std::vector< hcalModule * > fHash
void GetStructure(std::vector< hcalModule * > &stru) const
Int_t GetModuleNumber(Float_t x, Float_t y) const
Int_t GetNum(Int_t x, Int_t y) const
Int_t GetHitId(Float_t x, Float_t y) const
hcalInf * GetHcalInf() const
hcalStructure(const hcalStructure &)
hcalInf * fHcalInf
std::list< hcalModule * > fModules
Float_t GetX1() const
Float_t GetEnergy(Float_t x, Float_t y, Int_t section=0) const
ClassDef(hcalStructure, 1)
Int_t GetNumber(Int_t x, Int_t y) const
hcalModule * GetHitModule(const Int_t hitId) const
Float_t GetY1() const
Float_t GetX2() const
Bool_t AddEnergy(Float_t x, Float_t y, Float_t energy, Float_t energy2)
void GetModules(std::list< hcalModule * > &mdls) const