5 |
**/ |
**/ |
6 |
#include <TObject.h> |
#include <TObject.h> |
7 |
#include <CaloLevel2.h> |
#include <CaloLevel2.h> |
8 |
|
|
9 |
|
// |
10 |
ClassImp(CaloTrkVar); |
ClassImp(CaloTrkVar); |
11 |
ClassImp(CaloLevel2); |
ClassImp(CaloLevel2); |
12 |
|
|
14 |
* CaloTrkVar constructor |
* CaloTrkVar constructor |
15 |
**/ |
**/ |
16 |
CaloTrkVar::CaloTrkVar() { |
CaloTrkVar::CaloTrkVar() { |
17 |
|
this->Clear(); |
18 |
|
}; |
19 |
|
|
20 |
|
/** |
21 |
|
* Clear variables |
22 |
|
**/ |
23 |
|
void CaloTrkVar::Clear() { |
24 |
trkseqno = 0; |
trkseqno = 0; |
25 |
noint = 0; |
noint = 0; |
26 |
ncore = 0; |
ncore = 0; |
45 |
qlow = 0.; |
qlow = 0.; |
46 |
nlow = 0; |
nlow = 0; |
47 |
dX0l = 0.; |
dX0l = 0.; |
48 |
for (Int_t i = 0; i<2 ; i++){ |
memset(tbar, 0, 2*22*sizeof(Float_t)); |
49 |
for ( Int_t j = 0; j<22; j++){ |
memset(tibar, 0, 2*22*sizeof(Int_t)); |
|
tibar[j][i] = 0; |
|
|
tbar[j][i] = 0.; |
|
|
}; |
|
|
}; |
|
50 |
} |
} |
51 |
|
|
52 |
/** |
/** |
88 |
// |
// |
89 |
CaloTrk = new TClonesArray("CaloTrkVar",1); |
CaloTrk = new TClonesArray("CaloTrkVar",1); |
90 |
// |
// |
91 |
nstrip = 0; |
this->Clear(); |
92 |
qtot = 0.; |
// |
|
impx = 0.; |
|
|
impy = 0.; |
|
|
tanx = 0.; |
|
|
tany = 0.; |
|
|
qmax = 0.; |
|
|
nx22 = 0; |
|
|
qx22 = 0.; |
|
|
elen = 0.; |
|
|
selen = 0.; |
|
|
for (Int_t i = 0; i<4 ; i++){ |
|
|
qq[i] = 0.; |
|
|
perr[i] = 0; |
|
|
swerr[i] = 0; |
|
|
crc[i] = 0; |
|
|
if ( i < 2 ){ |
|
|
planemax[i] = 0; |
|
|
varcfit[i] = 0.; |
|
|
npcfit[i] = 0; |
|
|
for ( Int_t j = 0; j<22; j++){ |
|
|
cibar[j][i] = 0; |
|
|
cbar[j][i] = 0.; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
good = 0; |
|
|
selftrigger = 0; |
|
|
estrip = TArrayF(0,NULL); |
|
93 |
}; |
}; |
94 |
|
|
95 |
|
/** |
96 |
|
* Clear the CaloLevel2 object |
97 |
|
**/ |
98 |
void CaloLevel2::Clear() { |
void CaloLevel2::Clear() { |
99 |
// |
// |
100 |
CaloTrk->Clear(); |
CaloTrk->Clear(); |
110 |
qx22 = 0.; |
qx22 = 0.; |
111 |
elen = 0.; |
elen = 0.; |
112 |
selen = 0.; |
selen = 0.; |
113 |
for (Int_t i = 0; i<4 ; i++){ |
memset(perr, 0, 4*sizeof(Int_t)); |
114 |
qq[i] = 0.; |
memset(swerr, 0, 4*sizeof(Int_t)); |
115 |
perr[i] = 0; |
memset(crc, 0, 4*sizeof(Int_t)); |
116 |
swerr[i] = 0; |
memset(qq, 0, 4*sizeof(Int_t)); |
117 |
crc[i] = 0; |
memset(varcfit, 0, 2*sizeof(Float_t)); |
118 |
if ( i < 2 ){ |
memset(npcfit, 0, 2*sizeof(Int_t)); |
119 |
planemax[i] = 0; |
memset(planemax, 0, 2*sizeof(Int_t)); |
120 |
varcfit[i] = 0.; |
memset(cibar, 0, 2*22*sizeof(Int_t)); |
121 |
npcfit[i] = 0; |
memset(cbar, 0, 2*22*sizeof(Float_t)); |
|
for ( Int_t j = 0; j<22; j++){ |
|
|
cibar[j][i] = 0; |
|
|
cbar[j][i] = 0.; |
|
|
}; |
|
|
}; |
|
|
}; |
|
122 |
good = 0; |
good = 0; |
123 |
selftrigger = 0; |
selftrigger = 0; |
124 |
estrip = TArrayF(0,NULL); |
// |
125 |
}; |
}; |
126 |
|
|
127 |
|
|
128 |
/** |
/** |
129 |
* Gives the detected energy for the given strip once loaded the event |
* Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common). |
130 |
**/ |
*/ |
131 |
Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){ |
void CaloLevel2::GetLevel2Struct(cCaloLevel2 *l2) const { |
132 |
Int_t splane = 0; |
|
133 |
Int_t sstrip = 0; |
l2->good = good; |
134 |
// |
l2->selftrigger = selftrigger; |
135 |
if ( nstrip == 0 ) return(0.); |
l2->nstrip = nstrip; |
136 |
// |
l2->nx22 = nx22; |
137 |
for (Int_t i = 0; i<nstrip; i++ ){ |
l2->qtot = qtot; |
138 |
if ( view == 0 ){ |
l2->qx22 = qx22; |
139 |
if ( estrip.At(i) > 0. ){ |
l2->qmax = qmax; |
140 |
splane = (Int_t)trunc(estrip.At(i)/1000000.); |
l2->impx = impx; |
141 |
sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
l2->impy = impy; |
142 |
if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
l2->tanx = tanx; |
143 |
}; |
l2->tany = tany; |
144 |
} else { |
l2->elen = elen; |
145 |
if ( estrip.At(i) < 0. ){ |
l2->selen = selen; |
146 |
splane = (Int_t)trunc(-estrip.At(i)/1000000.); |
|
147 |
sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
for(Int_t i=0;i<2;i++){ |
148 |
if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
l2->planemax[i] = planemax[i]; |
149 |
}; |
l2->varcfit[i] = varcfit[i]; |
150 |
|
l2->npcfit[i] = npcfit[i]; |
151 |
|
} |
152 |
|
for(Int_t i=0;i<4;i++){ |
153 |
|
l2->perr[i] = perr[i]; |
154 |
|
l2->swerr[i] = swerr[i]; |
155 |
|
l2->calcrc[i] = crc[i]; |
156 |
|
l2->qq[i] = qq[i]; |
157 |
|
} |
158 |
|
|
159 |
|
l2->calntrk = CaloTrk->GetEntries(); |
160 |
|
|
161 |
|
for(Int_t i=0;i<l2->calntrk;i++){ |
162 |
|
l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno; |
163 |
|
l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore; |
164 |
|
l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint; |
165 |
|
l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl; |
166 |
|
l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast; |
167 |
|
l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre; |
168 |
|
l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh; |
169 |
|
l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr; |
170 |
|
l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot; |
171 |
|
l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow; |
172 |
|
l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ; |
173 |
|
l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl; |
174 |
|
l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast; |
175 |
|
l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre; |
176 |
|
l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh; |
177 |
|
l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr; |
178 |
|
l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack; |
179 |
|
l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx; |
180 |
|
l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky; |
181 |
|
l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack; |
182 |
|
l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack; |
183 |
|
l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean; |
184 |
|
l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow; |
185 |
|
l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l; |
186 |
|
for (Int_t j=0; j<2; j++){ |
187 |
|
for (Int_t k=0; k<22; k++){ |
188 |
|
l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j]; |
189 |
|
}; |
190 |
}; |
}; |
191 |
}; |
} |
|
return(0.); |
|
|
}; |
|
192 |
|
|
|
/** |
|
|
* Given estrip entry returns energy and strip |
|
|
**/ |
|
|
Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
|
|
if ( entry>nstrip ) return(0.); |
|
|
// |
|
|
if ( estrip.At(entry) > 0. ){ |
|
|
view = 0; |
|
|
plane = (Int_t)trunc(estrip.At(entry)/1000000.); |
|
|
strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
|
|
return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
|
|
}; |
|
|
if ( estrip.At(entry) < 0. ){ |
|
|
view = 1; |
|
|
plane = (Int_t)trunc(-estrip.At(entry)/1000000.); |
|
|
strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
|
|
return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
|
|
}; |
|
|
// |
|
|
printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry); |
|
|
// |
|
|
view = -1; |
|
|
plane = -1; |
|
|
strip = -1; |
|
|
return(0.); |
|
193 |
} |
} |
194 |
|
|
195 |
|
/** |
196 |
|
* Should return the energy in GeV if the particle would be an electron |
197 |
|
* using a parametrization taken from Monte Carlo simulation |
198 |
|
**/ |
199 |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
200 |
if ( nstrip == 0 ) return; |
if ( nstrip == 0 ) return; |
201 |
energy = qtot * 40.82 * 0.000106; |
energy = qtot * 40.82 * 0.000106; |