26 fModules =
new std::vector<EmcModule>;
53 std::cout <<
"Warning from BEmcRec::LoadProfile(): No acton defined for shower profile evaluation; should be defined in a detector specific module " <<
Name() << std::endl;
59 if (!outfile.is_open())
61 std::cout <<
"Error in BEmcRec::PrintTowerGeometry(): Failed to open file "
62 << fname << std::endl;
65 outfile <<
"Number of bins:" << std::endl;
66 outfile <<
fNx <<
" " <<
fNy << std::endl;
67 outfile <<
"ix iy x y z dx0 dy0 dz0 dx1 dy1 dz1" << std::endl;
70 std::map<int, TowerGeom>::iterator
it;
71 for (
int iy = 0; iy <
fNy; iy++)
73 for (
int ix = 0; ix <
fNx; ix++)
80 outfile << ix <<
" " << iy <<
" " << geom.
Xcenter <<
" "
82 << geom.
dY[0] <<
" " << geom.
dZ[0] <<
" " << geom.
dX[1] <<
" "
83 << geom.
dY[1] <<
" " << geom.
dZ[1] << std::endl;
92 if (ix < 0 || ix >=
fNx || iy < 0 || iy >=
fNy)
97 int ich = iy *
fNx + ix;
98 std::map<int, TowerGeom>::iterator
it =
fTowerGeom.find(ich);
110 if (ix < 0 || ix >=
fNx || iy < 0 || iy >=
fNy)
119 geom.
dX[0] = geom.
dX[1] = 0;
120 geom.
dY[0] = geom.
dY[1] = 0;
121 geom.
dZ[0] = geom.
dZ[1] = 0;
123 int ich = iy *
fNx + ix;
133 std::cout <<
"Error in BEmcRec::CalculateTowerSize(): Tower geometry not well setup (NX = "
134 <<
fNx <<
")" << std::endl;
139 int idx[nb] = {0, 1, 0, -1, -1, 1, 1, -1};
140 int idy[nb] = {-1, 0, 1, 0, -1, -1, 1, 1};
142 std::map<int, TowerGeom>::iterator
it;
154 while (inx < nb && (idx[inx] == 0 || !
GetTowerGeometry(ix + idx[inx], iy + idy[inx], geomx)))
160 std::cout <<
"Error in BEmcRec::CompleteTowerGeometry(): Error when locating neighbour for (ix,iy)=("
161 << ix <<
"," << iy <<
")" << std::endl;
168 while (iny < nb && (idy[iny] == 0 || !
GetTowerGeometry(ix + idx[iny], iy + idy[iny], geomy)))
174 std::cout <<
"Error in BEmcRec::CompleteTowerGeometry(): Error when locating neighbour for (ix,iy)=("
175 << ix <<
"," << iy <<
")" << std::endl;
194 float& xA,
float& yA,
float& zA)
200 bool flagDoSD =
true;
209 if (ix < 0 || ix >=
fNx)
211 std::cout <<
m_ThisName <<
" Error in BEmcRec::Tower2Global: wrong input x: " << ix << std::endl;
216 if (iy < 0 || iy >=
fNy)
218 std::cout <<
"Error in BEmcRec::Tower2Global: wrong input y: " << iy << std::endl;
228 const int idx[4] = {1, 0, -1, 0};
229 const int idy[4] = {0, 1, 0, -1};
237 std::cout <<
"Error in BEmcRec::Tower2Global: can not identify neighbour for tower ("
238 << ix <<
"," << iy <<
")" << std::endl;
241 float Xc = geom0.
Xcenter - idx[ii] * geom0.
dX[0] - idy[ii] * geom0.
dX[1];
242 float Yc = geom0.
Ycenter - idx[ii] * geom0.
dY[0] - idy[ii] * geom0.
dY[1];
243 float Zc = geom0.
Zcenter - idx[ii] * geom0.
dZ[0] - idy[ii] * geom0.
dZ[1];
249 float xt = geom0.
Xcenter + (xC - ix) * geom0.
dX[0] + (yC - iy) * geom0.
dX[1];
250 float yt = geom0.
Ycenter + (xC - ix) * geom0.
dY[0] + (yC - iy) * geom0.
dY[1];
251 float zt = geom0.
Zcenter + (xC - ix) * geom0.
dZ[0] + (yC - iy) * geom0.
dZ[1];
272 int idist = ix2 - ix1;
275 int idistr =
fNx - abs(idist);
276 if (idistr < abs(idist))
294 float dist = x2 - x1;
297 float distr =
fNx - fabs(dist);
298 if (distr < abs(dist))
322 int next,
ib, ie, iab, iae, last, LastCl, leng, ich;
328 std::vector<EmcModule>::iterator ph;
329 std::vector<EmcModule> hl;
331 (*fClusters).clear();
332 nhit = (*fModules).size();
346 LenCl =
new int[MaxLen];
352 ph = (*fModules).begin();
354 while (ph != (*fModules).end())
363 for (ich = 1; ich < nhit + 1; ich++)
372 if ((ia - vhit[ich - 1].ich > 1)
374 || (ia - ia /
fNx *
fNx == 0))
385 int* LenCltmp =
new int[MaxLen];
388 LenCl =
new int[MaxLen * 2];
396 LenCl[nCl - 1] = next -
ib;
405 for (
int iCl = LastCl; iCl >= 0; iCl--)
409 if (iab - vhit[last].ich >
fNx)
413 for (
int ichc = last; ichc >= last - leng + 1; ichc--)
418 if ((vhit[ichc].ich +
fNx <= iae && vhit[ichc].ich +
fNx >= iab) || (
bCYL && (iae %
fNx ==
fNx - 1) && (iae - vhit[ichc].ich ==
fNx - 1))
423 CopyVector(&vhit[last + 1], &vhit[last + 1 - leng], ib - 1 - last);
427 for (
int i = iCl;
i < nCl - 2;
i++)
429 LenCl[
i] = LenCl[
i + 1];
432 LenCl[nCl - 2] = LenCl[nCl - 1] + leng;
453 for (
int iCl = 0; iCl < nCl; iCl++)
457 for (ich = 0; ich < leng; ich++)
459 hl.push_back(vhit[ib + ich]);
476 float& py,
float& pxx,
float& pyy,
float& pyx,
481 float a,
x,
y,
e, xx, yy, yx;
482 std::vector<EmcModule>::iterator ph;
501 while (ph != phit->end())
517 int iymax = ichmax /
fNx;
518 int ixmax = ichmax - iymax *
fNx;
530 while (ph != phit->end())
535 int iy = ph->ich /
fNx;
536 int ix = ph->ich - iy *
fNx;
538 int idy = iy - iymax;
566 while (x >= fNx - 0.5)
600 float fPpar1, fPpar2, fPpar3, fPpar4;
635 dx = fabs(xc - fPshiftx);
636 dy = fabs(yc - fPshifty);
637 r2 = dx * dx + dy *
dy;
640 double e = fPpar1 * exp(-r3 / fPpar2) + fPpar3 * exp(-r1 / fPpar4);
658 while (xcg >=
fNx - 0.5)
663 int ixcg = int(xcg + 0.5);
664 int iycg = int(ycg + 0.5);
665 float ddx = fabs(xcg - ixcg);
666 float ddy = fabs(ycg - iycg);
668 float xg=0, yg=0, zg=0;
686 int idy = (iy - iycg) * isy;
689 if (idx == 0 && idy == 0)
693 else if (idx == 1 && idy == 0)
697 else if (idx == 1 && idy == 1)
701 else if (idx == 0 && idy == 1)
709 float dy = fabs(iy - ycg);
710 float rr = sqrt(dx * dx + dy * dy);
716 for (
int ip = 0; ip < 4; ip++)
725 eout = (ep[1] + ep[2]) / 2. + ep[3];
729 eout = (ep[0] - ep[2]) / 2. - ep[3];
733 eout = (ep[0] - ep[1]) / 2. - ep[3];
753 int nn = plist->size();
759 for (
int i = 0;
i < nn;
i++)
761 int ich = (*plist)[
i].ich;
764 if (iy == iyt && iz == izt)
766 return (*plist)[
i].amp;
773 float BEmcRec::GetProb(std::vector<EmcModule> HitList,
float en,
float xg,
float yg,
float zg,
float& chi2,
int& ndf)
793 int nn = HitList.size();
807 Momenta(&HitList, etot, zcg, ycg, zz, yy, yz, thresh);
809 int iz0cg = int(zcg + 0.5);
810 int iy0cg = int(ycg + 0.5);
811 float ddz = fabs(zcg - iz0cg);
812 float ddy = fabs(ycg - iy0cg);
828 float e1, e2, e3, e4;
851 float e1t = (e1 + e2 + e3 + e4) / etot;
852 float e2t = (e1 + e2 - e3 - e4) / etot;
853 float e3t = (e1 - e2 - e3 + e4) / etot;
854 float e4t = (e3) / etot;
861 for (
int ip = 0; ip <
NP; ip++)
870 err[ip] = sqrt(err[ip] * err[ip] + 4 * enoise * enoise / etot / etot);
874 err[ip] = sqrt(err[ip] * err[ip] + 1 * enoise * enoise / etot / etot);
879 chi2 += (ep[0] - e1t) * (ep[0] - e1t) / err[0] / err[0];
880 chi2 += (ep[1] - e2t) * (ep[1] - e2t) / err[1] / err[1];
881 chi2 += (ep[2] - e3t) * (ep[2] - e3t) / err[2] / err[2];
882 chi2 += (ep[3] - e4t) * (ep[3] - e4t) / err[3] / err[3];
887 float prob = TMath::Prob(chi2, ndf);
897 return (static_cast<const EmcModule*>(h1)->ich - static_cast<const EmcModule*>(h2)->ich);
904 float amp1 =
static_cast<const EmcModule*
>(
h1)->amp;
905 float amp2 =
static_cast<const EmcModule*
>(
h2)->amp;
906 return (amp1 < amp2) ? 1 : (amp1 > amp2) ? -1
915 for (
int i = 0;
i <
N;
i++)
926 for (
int i = 0;
i <
N;
i++)
937 for (
int i = 0;
i <
N;
i++)
953 for (
int i = 0;
i <
N;
i++)
967 for (
int i = 0;
i <
N;
i++)