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 |
|
|
estrip = TArrayF(0,NULL); |
150 |
|
|
}; |
151 |
|
|
|
152 |
mocchiut |
1.1 |
/** |
153 |
|
|
* Gives the detected energy for the given strip once loaded the event |
154 |
|
|
**/ |
155 |
|
|
Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){ |
156 |
|
|
Int_t splane = 0; |
157 |
|
|
Int_t sstrip = 0; |
158 |
|
|
// |
159 |
|
|
if ( nstrip == 0 ) return(0.); |
160 |
|
|
// |
161 |
|
|
for (Int_t i = 0; i<nstrip; i++ ){ |
162 |
|
|
if ( view == 0 ){ |
163 |
|
|
if ( estrip.At(i) > 0. ){ |
164 |
|
|
splane = (Int_t)trunc(estrip.At(i)/1000000.); |
165 |
|
|
sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
166 |
|
|
if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
167 |
|
|
}; |
168 |
|
|
} else { |
169 |
|
|
if ( estrip.At(i) < 0. ){ |
170 |
|
|
splane = (Int_t)trunc(-estrip.At(i)/1000000.); |
171 |
|
|
sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
172 |
|
|
if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
173 |
|
|
}; |
174 |
|
|
}; |
175 |
|
|
}; |
176 |
|
|
return(0.); |
177 |
|
|
}; |
178 |
|
|
|
179 |
|
|
/** |
180 |
|
|
* Given estrip entry returns energy and strip |
181 |
|
|
**/ |
182 |
|
|
Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
183 |
|
|
if ( entry>nstrip ) return(0.); |
184 |
|
|
// |
185 |
|
|
if ( estrip.At(entry) > 0. ){ |
186 |
|
|
view = 0; |
187 |
|
|
plane = (Int_t)trunc(estrip.At(entry)/1000000.); |
188 |
|
|
strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
189 |
|
|
return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
190 |
|
|
}; |
191 |
|
|
if ( estrip.At(entry) < 0. ){ |
192 |
|
|
view = 1; |
193 |
|
|
plane = (Int_t)trunc(-estrip.At(entry)/1000000.); |
194 |
|
|
strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
195 |
|
|
return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
196 |
|
|
}; |
197 |
|
|
// |
198 |
|
|
printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry); |
199 |
|
|
// |
200 |
|
|
view = -1; |
201 |
|
|
plane = -1; |
202 |
|
|
strip = -1; |
203 |
|
|
return(0.); |
204 |
|
|
} |
205 |
|
|
|
206 |
|
|
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
207 |
|
|
if ( nstrip == 0 ) return; |
208 |
|
|
energy = qtot * 40.82 * 0.000106; |
209 |
|
|
sigma = 0.; |
210 |
|
|
if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); |
211 |
|
|
return; |
212 |
|
|
}; |
213 |
|
|
|
214 |
|
|
/** |
215 |
|
|
* Returns pointer to the set of track-related variables "itrk" |
216 |
|
|
**/ |
217 |
|
|
CaloTrkVar *CaloLevel2::GetCaloTrkVar(Int_t itrk){ |
218 |
|
|
// |
219 |
|
|
if(itrk >= ntrk()){ |
220 |
|
|
printf(" CaloLevel2 ERROR: track related variables set %i does not exists! \n",itrk); |
221 |
|
|
printf(" stored track related variables = %i \n",ntrk()); |
222 |
|
|
return(NULL); |
223 |
|
|
} |
224 |
|
|
TClonesArray &t = *(CaloTrk); |
225 |
|
|
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
226 |
|
|
return calotrack; |
227 |
|
|
} |