| 12 |
* CaloTrkVar constructor |
* CaloTrkVar constructor |
| 13 |
**/ |
**/ |
| 14 |
CaloTrkVar::CaloTrkVar() { |
CaloTrkVar::CaloTrkVar() { |
| 15 |
|
this->Clear(); |
| 16 |
|
}; |
| 17 |
|
|
| 18 |
|
/** |
| 19 |
|
* Clear variables |
| 20 |
|
**/ |
| 21 |
|
void CaloTrkVar::Clear() { |
| 22 |
trkseqno = 0; |
trkseqno = 0; |
| 23 |
noint = 0; |
noint = 0; |
| 24 |
ncore = 0; |
ncore = 0; |
| 43 |
qlow = 0.; |
qlow = 0.; |
| 44 |
nlow = 0; |
nlow = 0; |
| 45 |
dX0l = 0.; |
dX0l = 0.; |
| 46 |
for (Int_t i = 0; i<2 ; i++){ |
memset(tbar, 0, 2*22*sizeof(Float_t)); |
| 47 |
for ( Int_t j = 0; j<22; j++){ |
memset(tibar, 0, 2*22*sizeof(Int_t)); |
|
tibar[j][i] = 0; |
|
|
tbar[j][i] = 0.; |
|
|
}; |
|
|
}; |
|
| 48 |
} |
} |
| 49 |
|
|
| 50 |
/** |
/** |
| 85 |
CaloLevel2::CaloLevel2() { |
CaloLevel2::CaloLevel2() { |
| 86 |
// |
// |
| 87 |
CaloTrk = new TClonesArray("CaloTrkVar",1); |
CaloTrk = new TClonesArray("CaloTrkVar",1); |
| 88 |
|
estrip = TArrayI(0,NULL); |
| 89 |
|
// |
| 90 |
|
this->Clear(); |
| 91 |
// |
// |
|
nstrip = 0; |
|
|
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); |
|
| 92 |
}; |
}; |
| 93 |
|
|
| 94 |
|
/** |
| 95 |
|
* Clear the CaloLevel2 object |
| 96 |
|
**/ |
| 97 |
void CaloLevel2::Clear() { |
void CaloLevel2::Clear() { |
| 98 |
// |
// |
| 99 |
CaloTrk->Clear(); |
CaloTrk->Clear(); |
| 109 |
qx22 = 0.; |
qx22 = 0.; |
| 110 |
elen = 0.; |
elen = 0.; |
| 111 |
selen = 0.; |
selen = 0.; |
| 112 |
for (Int_t i = 0; i<4 ; i++){ |
memset(perr, 0, 4*sizeof(Int_t)); |
| 113 |
qq[i] = 0.; |
memset(swerr, 0, 4*sizeof(Int_t)); |
| 114 |
perr[i] = 0; |
memset(crc, 0, 4*sizeof(Int_t)); |
| 115 |
swerr[i] = 0; |
memset(qq, 0, 4*sizeof(Int_t)); |
| 116 |
crc[i] = 0; |
memset(varcfit, 0, 2*sizeof(Float_t)); |
| 117 |
if ( i < 2 ){ |
memset(npcfit, 0, 2*sizeof(Int_t)); |
| 118 |
planemax[i] = 0; |
memset(planemax, 0, 2*sizeof(Int_t)); |
| 119 |
varcfit[i] = 0.; |
memset(cibar, 0, 2*22*sizeof(Int_t)); |
| 120 |
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.; |
|
|
}; |
|
|
}; |
|
|
}; |
|
| 121 |
good = 0; |
good = 0; |
| 122 |
selftrigger = 0; |
selftrigger = 0; |
| 123 |
estrip = TArrayF(0,NULL); |
estrip.Reset(); |
| 124 |
}; |
}; |
| 125 |
|
|
| 126 |
|
|
| 127 |
/** |
/** |
| 128 |
* 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). |
| 129 |
|
*/ |
| 130 |
|
void CaloLevel2::GetLevel2Struct(cCaloLevel2 *l2) const { |
| 131 |
|
|
| 132 |
|
l2->good = good; |
| 133 |
|
l2->selftrigger = selftrigger; |
| 134 |
|
l2->nstrip = nstrip; |
| 135 |
|
l2->nx22 = nx22; |
| 136 |
|
l2->qtot = qtot; |
| 137 |
|
l2->qx22 = qx22; |
| 138 |
|
l2->qmax = qmax; |
| 139 |
|
l2->impx = impx; |
| 140 |
|
l2->impy = impy; |
| 141 |
|
l2->tanx = tanx; |
| 142 |
|
l2->tany = tany; |
| 143 |
|
l2->elen = elen; |
| 144 |
|
l2->selen = selen; |
| 145 |
|
|
| 146 |
|
for(Int_t i=0;i<2;i++){ |
| 147 |
|
l2->planemax[i] = planemax[i]; |
| 148 |
|
l2->varcfit[i] = varcfit[i]; |
| 149 |
|
l2->npcfit[i] = npcfit[i]; |
| 150 |
|
} |
| 151 |
|
for(Int_t i=0;i<4;i++){ |
| 152 |
|
l2->perr[i] = perr[i]; |
| 153 |
|
l2->swerr[i] = swerr[i]; |
| 154 |
|
l2->calcrc[i] = crc[i]; |
| 155 |
|
l2->qq[i] = qq[i]; |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
l2->calntrk = CaloTrk->GetEntries(); |
| 159 |
|
|
| 160 |
|
for(Int_t i=0;i<l2->calntrk;i++){ |
| 161 |
|
l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno; |
| 162 |
|
l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore; |
| 163 |
|
l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint; |
| 164 |
|
l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl; |
| 165 |
|
l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast; |
| 166 |
|
l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre; |
| 167 |
|
l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh; |
| 168 |
|
l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr; |
| 169 |
|
l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot; |
| 170 |
|
l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow; |
| 171 |
|
l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ; |
| 172 |
|
l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl; |
| 173 |
|
l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast; |
| 174 |
|
l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre; |
| 175 |
|
l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh; |
| 176 |
|
l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr; |
| 177 |
|
l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack; |
| 178 |
|
l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx; |
| 179 |
|
l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky; |
| 180 |
|
l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack; |
| 181 |
|
l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack; |
| 182 |
|
l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean; |
| 183 |
|
l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow; |
| 184 |
|
l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l; |
| 185 |
|
for (Int_t j=0; j<2; j++){ |
| 186 |
|
for (Int_t k=0; k<22; k++){ |
| 187 |
|
l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j]; |
| 188 |
|
}; |
| 189 |
|
}; |
| 190 |
|
} |
| 191 |
|
|
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
/** |
| 195 |
|
* Returns the detected energy for the given strip once loaded the event |
| 196 |
**/ |
**/ |
| 197 |
Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){ |
Float_t CaloLevel2::GetEstrip(Int_t sview, Int_t splane, Int_t sstrip){ |
| 198 |
Int_t splane = 0; |
Int_t view = -1; |
| 199 |
Int_t sstrip = 0; |
Int_t plane = -1; |
| 200 |
|
Int_t strip = -1; |
| 201 |
|
Float_t mip = 0.; |
| 202 |
// |
// |
| 203 |
if ( nstrip == 0 ) return(0.); |
if ( nstrip == 0 ) return(0.); |
| 204 |
// |
// |
| 205 |
for (Int_t i = 0; i<nstrip; i++ ){ |
for (Int_t i = 0; i<nstrip; i++ ){ |
| 206 |
if ( view == 0 ){ |
// |
| 207 |
if ( estrip.At(i) > 0. ){ |
mip = DecodeEstrip(i,view,plane,strip); |
| 208 |
splane = (Int_t)trunc(estrip.At(i)/1000000.); |
// |
| 209 |
sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
if ( view == sview && splane == plane && sstrip == strip ) return(mip); |
| 210 |
if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
// |
| 211 |
}; |
// entry are ordered by strip, plane and view number. Go out if you pass the input strip |
| 212 |
} else { |
// |
| 213 |
if ( estrip.At(i) < 0. ){ |
if ( view == sview && plane == splane && strip > sstrip ) return(0.); |
| 214 |
splane = (Int_t)trunc(-estrip.At(i)/1000000.); |
if ( view == sview && plane > splane ) return(0.); |
| 215 |
sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.); |
if ( view > sview ) return(0.); |
| 216 |
if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.); |
// |
|
}; |
|
|
}; |
|
| 217 |
}; |
}; |
| 218 |
return(0.); |
return(0.); |
| 219 |
}; |
}; |
| 220 |
|
|
| 221 |
/** |
/** |
| 222 |
* Given estrip entry returns energy and strip |
* Given estrip entry returns energy plus view, plane and strip numbers |
| 223 |
**/ |
**/ |
| 224 |
Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){ |
| 225 |
|
// |
| 226 |
if ( entry>nstrip ) return(0.); |
if ( entry>nstrip ) return(0.); |
| 227 |
// |
// |
| 228 |
|
// printf(" num lim %f \n",std::numeric_limits<Float_t>::max()); |
| 229 |
|
// printf(" estrip.At(%i) = %i \n",entry,estrip.At(entry)); |
| 230 |
|
// |
| 231 |
|
Int_t eval = 0; |
| 232 |
if ( estrip.At(entry) > 0. ){ |
if ( estrip.At(entry) > 0. ){ |
| 233 |
view = 0; |
view = 0; |
| 234 |
plane = (Int_t)trunc(estrip.At(entry)/1000000.); |
eval = estrip.At(entry); |
| 235 |
strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
} else { |
|
return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
|
|
}; |
|
|
if ( estrip.At(entry) < 0. ){ |
|
| 236 |
view = 1; |
view = 1; |
| 237 |
plane = (Int_t)trunc(-estrip.At(entry)/1000000.); |
eval = -estrip.At(entry); |
| 238 |
strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.); |
}; |
| 239 |
return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.); |
// |
| 240 |
}; |
Int_t fbi = 0; |
| 241 |
|
fbi = (Int_t)truncf((Float_t)(eval/1000000000)); |
| 242 |
|
// |
| 243 |
|
Int_t plom = 0; |
| 244 |
|
plom = (Int_t)truncf((Float_t)((eval-fbi*1000000000)/10000000)); |
| 245 |
|
// |
| 246 |
|
Float_t tim = 100000.; |
| 247 |
|
plane = plom; |
| 248 |
|
if ( fbi == 1 ) tim = 10000.; |
| 249 |
|
if ( plom > 21 ){ |
| 250 |
|
plane = plom - 22; |
| 251 |
|
if ( fbi == 1 ){ |
| 252 |
|
tim = 1000.; |
| 253 |
|
} else { |
| 254 |
|
tim = 100.; |
| 255 |
|
}; |
| 256 |
|
}; |
| 257 |
|
if ( plom > 43 ){ |
| 258 |
|
plane = plom - 44; |
| 259 |
|
tim = 10.; |
| 260 |
|
}; |
| 261 |
|
if ( plom > 65 ){ |
| 262 |
|
plane = plom - 66; |
| 263 |
|
tim = 1.; |
| 264 |
|
}; |
| 265 |
|
// |
| 266 |
|
strip = (Int_t)truncf((Float_t)((eval - fbi*1000000000 -plom*10000000)/100000)); |
| 267 |
|
// |
| 268 |
|
Float_t mip = ((Float_t)(eval - fbi*1000000000 -plom*10000000 -strip*100000))/tim; |
| 269 |
// |
// |
| 270 |
printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry); |
if ( mip > 0. && mip < 99999. ) return(mip); |
| 271 |
|
// |
| 272 |
|
printf(" WARNING: problems decoding value %i at entry %i \n",estrip.At(entry),entry); |
| 273 |
// |
// |
| 274 |
view = -1; |
view = -1; |
| 275 |
plane = -1; |
plane = -1; |
| 277 |
return(0.); |
return(0.); |
| 278 |
} |
} |
| 279 |
|
|
| 280 |
|
/** |
| 281 |
|
* Should return the energy in GeV if the particle would be an electron |
| 282 |
|
* using a parametrization taken from Monte Carlo simulation |
| 283 |
|
**/ |
| 284 |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
| 285 |
if ( nstrip == 0 ) return; |
if ( nstrip == 0 ) return; |
| 286 |
energy = qtot * 40.82 * 0.000106; |
energy = qtot * 40.82 * 0.000106; |