1 |
/** |
2 |
* \file src/CaloLevel1.cpp |
3 |
* \author Emiliano Mocchiutti |
4 |
* |
5 |
**/ |
6 |
#include <TObject.h> |
7 |
#include <CaloLevel1.h> |
8 |
|
9 |
// |
10 |
ClassImp(CaloStrip); |
11 |
ClassImp(CaloLevel1); |
12 |
|
13 |
/** |
14 |
* CaloStrip default constructor |
15 |
**/ |
16 |
CaloStrip::CaloStrip() { |
17 |
c1 = 0; |
18 |
this->Clear(); |
19 |
}; |
20 |
|
21 |
/** |
22 |
* CaloStrip default constructor |
23 |
**/ |
24 |
CaloStrip::CaloStrip(CaloLevel1 *calo) { |
25 |
c1 = calo->GetCaloLevel1(); |
26 |
this->Clear(); |
27 |
}; |
28 |
|
29 |
/** |
30 |
* Clear variables |
31 |
**/ |
32 |
void CaloStrip::Clear() { |
33 |
fE = 0.; |
34 |
fX = 0.; |
35 |
fY = 0.; |
36 |
fZ = 0.; |
37 |
fView = 0; |
38 |
fPlane = 0; |
39 |
fStrip = 0; |
40 |
}; |
41 |
|
42 |
/** |
43 |
* Given a strip returns its position in the PAMELA reference system |
44 |
**/ |
45 |
void CaloStrip::Set(Int_t view, Int_t plane, Int_t strip) { |
46 |
// |
47 |
this->Clear(); |
48 |
// |
49 |
if ( view < 0 || view > 1 ){ |
50 |
printf(" ERROR: 0 =< view =< 1 \n"); |
51 |
return; |
52 |
}; |
53 |
if ( plane < 0 || plane > 21 ){ |
54 |
printf(" ERROR: 0 =< plane =< 21 \n"); |
55 |
return; |
56 |
}; |
57 |
if ( strip < 0 || strip > 95 ){ |
58 |
printf(" ERROR: 0 =< strip =< 95 \n"); |
59 |
return; |
60 |
}; |
61 |
// |
62 |
Float_t lShift = 0.; |
63 |
Float_t lPos = 0.; |
64 |
extern struct shift shift_; |
65 |
// |
66 |
// Find MIPs for that strip |
67 |
// |
68 |
if ( c1 ) fE = c1->GetEstrip(view, plane, strip); |
69 |
// |
70 |
fView = view + 1; |
71 |
fPlane = plane + 1; |
72 |
fStrip = strip + 1; |
73 |
if ( fPlane%2 ){ |
74 |
lShift = -0.5; |
75 |
} else { |
76 |
lShift = 0.5; |
77 |
}; |
78 |
// |
79 |
shift_.shift = lShift; |
80 |
// |
81 |
Float_t zplane[22]; |
82 |
zplane[0] = 0.; |
83 |
Int_t ii = 0; |
84 |
for ( Int_t i = 2; i < 23; i++){ |
85 |
ii = i-1; |
86 |
if ( i%2 ){ |
87 |
zplane[ii] = zplane[ii-1] - 10.09; |
88 |
} else { |
89 |
zplane[ii] = zplane[ii-1] - 8.09; |
90 |
}; |
91 |
}; |
92 |
// |
93 |
millim_(&fStrip,&lPos); |
94 |
// |
95 |
if ( fView == 1 ){ |
96 |
// |
97 |
// X view |
98 |
// |
99 |
fX = (lPos - CTX)/10.; |
100 |
fY = 0.; |
101 |
fZ = (zplane[fPlane-1] - 5.81 + CTZ)/10.; |
102 |
} else { |
103 |
// |
104 |
// Y view |
105 |
// |
106 |
fX = 0; |
107 |
fY = (lPos - CTY)/10.; |
108 |
fZ = (zplane[fPlane-1] + CTZ)/10.; |
109 |
}; |
110 |
// |
111 |
}; |
112 |
|
113 |
/** |
114 |
* Given a point in the space (PAMELA ref system) returns the closest strip |
115 |
**/ |
116 |
void CaloStrip::Set(Float_t X, Float_t Y, Float_t Z) { |
117 |
// |
118 |
// Float_t lShift = 0.; |
119 |
// Float_t lPos = 0.; |
120 |
// extern struct shift shift; |
121 |
// // |
122 |
// fView = view++; |
123 |
// fPlane = plane++; |
124 |
// fStrip = strip++; |
125 |
// if ( fPlane%2 ){ |
126 |
// lShift = -0.5; |
127 |
// } else { |
128 |
// lShift = 0.5; |
129 |
// }; |
130 |
// // |
131 |
// shift.shift = lShift; |
132 |
// // |
133 |
// Float_t zplane[22]; |
134 |
// zplane[0] = 0.; |
135 |
// Int_t ii = 0; |
136 |
// for ( Int_t i = 2; i < 23; i++){ |
137 |
// ii = i-1; |
138 |
// if ( i%2 ){ |
139 |
// zplane[ii] = zplane[ii-1] - 10.09 + CTZ; |
140 |
// } else { |
141 |
// zplane[ii] = zplane[ii-1] - 8.09 + CTZ; |
142 |
// }; |
143 |
// }; |
144 |
// // |
145 |
// millim_(&fStrip,&lPos); |
146 |
// // |
147 |
// if ( fView == 1 ){ |
148 |
// // |
149 |
// // X view |
150 |
// // |
151 |
// fX = lPos; |
152 |
// fY = 0.; |
153 |
// fZ = zplane[fPlane-1] - 5.81; |
154 |
// } else { |
155 |
// // |
156 |
// // Y view |
157 |
// // |
158 |
// fX = 0.; |
159 |
// fY = lPos; |
160 |
// fZ = zplane[fPlane-1]; |
161 |
// }; |
162 |
// |
163 |
}; |
164 |
// DISTY = PIANO(I) |
165 |
// YY(I) = DISTY * TG(2) + CY |
166 |
// BAR(M,I) = YY(I) |
167 |
// CBAR(M,I) = (-YALIG + YY(I))/10. |
168 |
// C |
169 |
// ENDIF |
170 |
// CALL LASTRISCIA(BAR(M,I),IBAR(M,I)) |
171 |
// CIBAR(M,I) = IBAR(M,I) |
172 |
// ENDDO |
173 |
// ENDIF |
174 |
// C |
175 |
// ENDDO |
176 |
|
177 |
|
178 |
|
179 |
/** |
180 |
* CaloLevel1 constructor |
181 |
**/ |
182 |
CaloLevel1::CaloLevel1() { |
183 |
// |
184 |
estrip = TArrayI(0,NULL); |
185 |
// |
186 |
this->Clear(); |
187 |
// |
188 |
}; |
189 |
|
190 |
/** |
191 |
* Clear the CaloLevel1 object |
192 |
**/ |
193 |
void CaloLevel1::Clear() { |
194 |
// |
195 |
istrip = 0; |
196 |
estrip.Reset(); |
197 |
// |
198 |
}; |
199 |
|
200 |
/** |
201 |
* Returns the detected energy for the given strip once loaded the event |
202 |
**/ |
203 |
Float_t CaloLevel1::GetEstrip(Int_t sview, Int_t splane, Int_t sstrip){ |
204 |
Int_t view = -1; |
205 |
Int_t plane = -1; |
206 |
Int_t strip = -1; |
207 |
Float_t mip = 0.; |
208 |
// |
209 |
if ( istrip == 0 ) return(0.); |
210 |
// |
211 |
for (Int_t i = 0; i<istrip; i++ ){ |
212 |
// |
213 |
mip = DecodeEstrip(i,view,plane,strip); |
214 |
// |
215 |
if ( view == sview && splane == plane && sstrip == strip ) return(mip); |
216 |
// |
217 |
// entry are ordered by strip, plane and view number. Go out if you pass the input strip |
218 |
// |
219 |
if ( view == sview && plane == splane && strip > sstrip ) return(0.); |
220 |
if ( view == sview && plane > splane ) return(0.); |
221 |
if ( view > sview ) return(0.); |
222 |
// |
223 |
}; |
224 |
return(0.); |
225 |
}; |
226 |
|
227 |
/** |
228 |
* Given estrip entry returns energy plus view, plane and strip numbers |
229 |
**/ |
230 |
Float_t CaloLevel1::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
231 |
// |
232 |
if ( entry>istrip ) return(0.); |
233 |
// |
234 |
// printf(" num lim %f \n",std::numeric_limits<Float_t>::max()); |
235 |
// printf(" estrip.At(%i) = %i \n",entry,estrip.At(entry)); |
236 |
// |
237 |
Int_t eval = 0; |
238 |
if ( estrip.At(entry) > 0. ){ |
239 |
view = 0; |
240 |
eval = estrip.At(entry); |
241 |
} else { |
242 |
view = 1; |
243 |
eval = -estrip.At(entry); |
244 |
}; |
245 |
// |
246 |
Int_t fbi = 0; |
247 |
fbi = (Int_t)truncf((Float_t)(eval/1000000000)); |
248 |
// |
249 |
Int_t plom = 0; |
250 |
plom = (Int_t)truncf((Float_t)((eval-fbi*1000000000)/10000000)); |
251 |
// |
252 |
Float_t tim = 100000.; |
253 |
plane = plom; |
254 |
if ( fbi == 1 ) tim = 10000.; |
255 |
if ( plom > 21 ){ |
256 |
plane = plom - 22; |
257 |
if ( fbi == 1 ){ |
258 |
tim = 1000.; |
259 |
} else { |
260 |
tim = 100.; |
261 |
}; |
262 |
}; |
263 |
if ( plom > 43 ){ |
264 |
plane = plom - 44; |
265 |
tim = 10.; |
266 |
}; |
267 |
if ( plom > 65 ){ |
268 |
plane = plom - 66; |
269 |
tim = 1.; |
270 |
}; |
271 |
// |
272 |
strip = (Int_t)truncf((Float_t)((eval - fbi*1000000000 -plom*10000000)/100000)); |
273 |
// |
274 |
Float_t mip = ((Float_t)(eval - fbi*1000000000 -plom*10000000 -strip*100000))/tim; |
275 |
// |
276 |
if ( mip > 0. && mip < 99999. ) return(mip); |
277 |
// |
278 |
printf(" WARNING: problems decoding value %i at entry %i \n",estrip.At(entry),entry); |
279 |
// |
280 |
view = -1; |
281 |
plane = -1; |
282 |
strip = -1; |
283 |
return(0.); |
284 |
} |
285 |
|