1 |
mocchiut |
1.1 |
/** |
2 |
|
|
* \file src/CaloLevel2.cpp |
3 |
|
|
* \author Emiliano Mocchiutti |
4 |
|
|
* |
5 |
|
|
**/ |
6 |
|
|
#include <TObject.h> |
7 |
|
|
#include <CaloLevel2.h> |
8 |
|
|
ClassImp(CaloTrkVar); |
9 |
|
|
ClassImp(CaloLevel2); |
10 |
|
|
|
11 |
|
|
/** |
12 |
|
|
* CaloTrkVar constructor |
13 |
|
|
**/ |
14 |
|
|
CaloTrkVar::CaloTrkVar() { |
15 |
|
|
trkseqno = 0; |
16 |
|
|
noint = 0; |
17 |
|
|
ncore = 0; |
18 |
|
|
qcore = 0.; |
19 |
|
|
ncyl = 0; |
20 |
|
|
qcyl = 0.; |
21 |
|
|
qtrack = 0.; |
22 |
|
|
qtrackx = 0.; |
23 |
|
|
qtracky = 0.; |
24 |
|
|
dxtrack = 0.; |
25 |
|
|
dytrack = 0.; |
26 |
|
|
qlast = 0.; |
27 |
|
|
nlast = 0; |
28 |
|
|
qpre = 0.; |
29 |
|
|
npre = 0; |
30 |
|
|
qpresh = 0.; |
31 |
|
|
npresh = 0; |
32 |
|
|
qtr = 0.; |
33 |
|
|
ntr = 0; |
34 |
|
|
planetot = 0; |
35 |
|
|
qmean = 0.; |
36 |
|
|
qlow = 0.; |
37 |
|
|
nlow = 0; |
38 |
|
|
dX0l = 0.; |
39 |
|
|
for (Int_t i = 0; i<2 ; i++){ |
40 |
|
|
for ( Int_t j = 0; j<22; j++){ |
41 |
|
|
tibar[j][i] = 0; |
42 |
|
|
tbar[j][i] = 0.; |
43 |
|
|
}; |
44 |
|
|
}; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* Copies from t to this |
49 |
|
|
**/ |
50 |
|
|
CaloTrkVar::CaloTrkVar(const CaloTrkVar &t){ |
51 |
|
|
trkseqno = t.trkseqno; |
52 |
|
|
noint = t.noint; |
53 |
|
|
ncore = t.ncore; |
54 |
|
|
qcore = t.qcore; |
55 |
|
|
ncyl = t.ncyl; |
56 |
|
|
qcyl = t.qcyl; |
57 |
|
|
qtrack = t.qtrack; |
58 |
|
|
qtrackx = t.qtrackx; |
59 |
|
|
qtracky = t.qtracky; |
60 |
|
|
dxtrack = t.dxtrack; |
61 |
|
|
dytrack = t.dytrack; |
62 |
|
|
qlast = t.qlast; |
63 |
|
|
nlast = t.nlast; |
64 |
|
|
qpre = t.qpre; |
65 |
|
|
npre = t.npre; |
66 |
|
|
qpresh = t.qpresh; |
67 |
|
|
npresh = t.npresh; |
68 |
|
|
qtr = t.qtr; |
69 |
|
|
ntr = t.ntr; |
70 |
|
|
planetot = t.planetot; |
71 |
|
|
qmean = t.qmean; |
72 |
|
|
dX0l = t.dX0l; |
73 |
|
|
qlow = t.qlow; |
74 |
|
|
nlow = t.nlow; |
75 |
|
|
memcpy(tibar,t.tibar,sizeof(tibar)); |
76 |
|
|
memcpy(tbar,t.tbar,sizeof(tbar)); |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
/** |
80 |
|
|
* CaloLevel2 constructor |
81 |
|
|
**/ |
82 |
|
|
CaloLevel2::CaloLevel2() { |
83 |
|
|
// |
84 |
|
|
CaloTrk = new TClonesArray("CaloTrkVar",1); |
85 |
|
|
// |
86 |
|
|
nstrip = 0; |
87 |
|
|
qtot = 0.; |
88 |
|
|
impx = 0.; |
89 |
|
|
impy = 0.; |
90 |
|
|
tanx = 0.; |
91 |
|
|
tany = 0.; |
92 |
|
|
qmax = 0.; |
93 |
|
|
nx22 = 0; |
94 |
|
|
qx22 = 0.; |
95 |
|
|
elen = 0.; |
96 |
|
|
selen = 0.; |
97 |
|
|
for (Int_t i = 0; i<4 ; i++){ |
98 |
|
|
qq[i] = 0.; |
99 |
|
|
perr[i] = 0; |
100 |
|
|
swerr[i] = 0; |
101 |
|
|
crc[i] = 0; |
102 |
|
|
if ( i < 2 ){ |
103 |
|
|
planemax[i] = 0; |
104 |
|
|
varcfit[i] = 0.; |
105 |
|
|
npcfit[i] = 0; |
106 |
|
|
for ( Int_t j = 0; j<22; j++){ |
107 |
|
|
cibar[j][i] = 0; |
108 |
|
|
cbar[j][i] = 0.; |
109 |
|
|
}; |
110 |
|
|
}; |
111 |
|
|
}; |
112 |
|
|
good = 0; |
113 |
|
|
selftrigger = 0; |
114 |
|
|
estrip = TArrayF(0,NULL); |
115 |
|
|
}; |
116 |
|
|
|
117 |
mocchiut |
1.2 |
void CaloLevel2::Clear() { |
118 |
|
|
// |
119 |
|
|
CaloTrk->Clear(); |
120 |
|
|
// |
121 |
|
|
nstrip = 0; |
122 |
|
|
qtot = 0.; |
123 |
|
|
impx = 0.; |
124 |
|
|
impy = 0.; |
125 |
|
|
tanx = 0.; |
126 |
|
|
tany = 0.; |
127 |
|
|
qmax = 0.; |
128 |
|
|
nx22 = 0; |
129 |
|
|
qx22 = 0.; |
130 |
|
|
elen = 0.; |
131 |
|
|
selen = 0.; |
132 |
|
|
for (Int_t i = 0; i<4 ; i++){ |
133 |
|
|
qq[i] = 0.; |
134 |
|
|
perr[i] = 0; |
135 |
|
|
swerr[i] = 0; |
136 |
|
|
crc[i] = 0; |
137 |
|
|
if ( i < 2 ){ |
138 |
|
|
planemax[i] = 0; |
139 |
|
|
varcfit[i] = 0.; |
140 |
|
|
npcfit[i] = 0; |
141 |
|
|
for ( Int_t j = 0; j<22; j++){ |
142 |
|
|
cibar[j][i] = 0; |
143 |
|
|
cbar[j][i] = 0.; |
144 |
|
|
}; |
145 |
|
|
}; |
146 |
|
|
}; |
147 |
|
|
good = 0; |
148 |
|
|
selftrigger = 0; |
149 |
mocchiut |
1.3 |
// estrip = TArrayF(0,NULL); |
150 |
|
|
estrip.Reset(); |
151 |
mocchiut |
1.2 |
}; |
152 |
|
|
|
153 |
mocchiut |
1.1 |
/** |
154 |
|
|
* Gives the detected energy for the given strip once loaded the event |
155 |
|
|
**/ |
156 |
|
|
Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){ |
157 |
|
|
Int_t splane = 0; |
158 |
|
|
Int_t sstrip = 0; |
159 |
|
|
// |
160 |
|
|
if ( nstrip == 0 ) return(0.); |
161 |
|
|
// |
162 |
|
|
for (Int_t i = 0; i<nstrip; i++ ){ |
163 |
|
|
if ( view == 0 ){ |
164 |
|
|
if ( estrip.At(i) > 0. ){ |
165 |
|
|
splane = (Int_t)trunc(estrip.At(i)/1000000.); |
166 |
|
|
sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
167 |
|
|
if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
168 |
|
|
}; |
169 |
|
|
} else { |
170 |
|
|
if ( estrip.At(i) < 0. ){ |
171 |
|
|
splane = (Int_t)trunc(-estrip.At(i)/1000000.); |
172 |
|
|
sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
173 |
|
|
if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
174 |
|
|
}; |
175 |
|
|
}; |
176 |
|
|
}; |
177 |
|
|
return(0.); |
178 |
|
|
}; |
179 |
|
|
|
180 |
|
|
/** |
181 |
|
|
* Given estrip entry returns energy and strip |
182 |
|
|
**/ |
183 |
|
|
Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
184 |
|
|
if ( entry>nstrip ) return(0.); |
185 |
|
|
// |
186 |
|
|
if ( estrip.At(entry) > 0. ){ |
187 |
|
|
view = 0; |
188 |
|
|
plane = (Int_t)trunc(estrip.At(entry)/1000000.); |
189 |
|
|
strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
190 |
|
|
return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
191 |
|
|
}; |
192 |
|
|
if ( estrip.At(entry) < 0. ){ |
193 |
|
|
view = 1; |
194 |
|
|
plane = (Int_t)trunc(-estrip.At(entry)/1000000.); |
195 |
|
|
strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
196 |
|
|
return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
197 |
|
|
}; |
198 |
|
|
// |
199 |
|
|
printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry); |
200 |
|
|
// |
201 |
|
|
view = -1; |
202 |
|
|
plane = -1; |
203 |
|
|
strip = -1; |
204 |
|
|
return(0.); |
205 |
|
|
} |
206 |
|
|
|
207 |
|
|
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
208 |
|
|
if ( nstrip == 0 ) return; |
209 |
|
|
energy = qtot * 40.82 * 0.000106; |
210 |
|
|
sigma = 0.; |
211 |
|
|
if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); |
212 |
|
|
return; |
213 |
|
|
}; |
214 |
|
|
|
215 |
|
|
/** |
216 |
|
|
* Returns pointer to the set of track-related variables "itrk" |
217 |
|
|
**/ |
218 |
|
|
CaloTrkVar *CaloLevel2::GetCaloTrkVar(Int_t itrk){ |
219 |
|
|
// |
220 |
|
|
if(itrk >= ntrk()){ |
221 |
|
|
printf(" CaloLevel2 ERROR: track related variables set %i does not exists! \n",itrk); |
222 |
|
|
printf(" stored track related variables = %i \n",ntrk()); |
223 |
|
|
return(NULL); |
224 |
|
|
} |
225 |
|
|
TClonesArray &t = *(CaloTrk); |
226 |
|
|
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
227 |
|
|
return calotrack; |
228 |
|
|
} |