17#include <TClonesArray.h>
19#include <TGeoPhysicalNode.h>
20#include <TGraphErrors.h>
39 SetNameTitle(Form(
"Trd2dReco%d", mod),
"Reconstructor for triangular pads.");
55 uint16_t chT = pad << 1, chR = chT + 1;
58 LOG(warn) << GetName() <<
"::AddDigi: Failed to retrieve calibration for FASP channels allocated to pad " << pad;
63 cout <<
"\nadd @" <<
id <<
" " << d->
ToString();
67 cout <<
"\n[T] not installed.";
71 cout <<
"\n[R] not installed.";
76 if (dtime < 0) tm += dtime;
86 else if (!daqFaspChT->IsMasked())
91 printf(
"row[%2d] col[%2d] tm[%2d] chT[%4d] chR[%4d]\n", row, col, tm,
92 chT * (daqFaspChT && daqFaspChT->IsMasked() ? -1 : 1),
93 chR * (daqFaspChR && daqFaspChR->
IsMasked() ? -1 : 1));
97 std::map<Int_t, std::list<CbmTrdCluster*>>::iterator it =
fBuffer.find(row);
100 Bool_t kINSERT(kFALSE);
101 std::list<CbmTrdCluster*>::iterator itc =
fBuffer[row].begin();
102 for (; itc !=
fBuffer[row].end(); itc++) {
105 UShort_t tc = (*itc)->GetStartTime();
111 if (
CWRITE(0)) printf(
"match time dt=%d\n", dt);
112 if ((*itc)->IsChannelInRange(chT, chR) == 0) {
113 if (!(*itc)->AddDigi(
id, chT, chR, dt))
break;
115 if (
CWRITE(0)) cout <<
" => Cl (Ad) " << (*itc)->ToString();
120 if (
CWRITE(0)) printf(
"break for time dt=%d\n", dt);
129 if (
CWRITE(0)) cout <<
" => Cl (I) ";
133 if (
CWRITE(0)) cout <<
" => Cl (Pb) ";
153 for (std::map<Int_t, std::list<CbmTrdCluster*>>::const_iterator ir =
fBuffer.cbegin(); ir !=
fBuffer.cend(); ir++) {
154 for (std::list<CbmTrdCluster*>::const_iterator itc = (*ir).second.cbegin(); itc != (*ir).second.cend(); itc++)
155 nch += (*itc)->GetNCols();
166 LOG(error) << GetName() <<
"::GetFaspChCalibrator : Could not find FASP params for address=" << faspAddress
176 bool left =
false, right = !left;
177 int nchRow = 2 *
GetNcols(), nchAdd(0);
202 int ncl0(0), ncl(0), mcl(0);
203 std::list<CbmTrdCluster*>::iterator itc0, itc1, itc;
205 if (
CWRITE(0)) cout <<
"\nrow=" << clRow.first <<
" ncl=" << clRow.second.size() << endl;
207 if (clRow.second.size() > 1) {
208 itc0 = clRow.second.begin();
211 itc = std::prev(clRow.second.end());
212 while (itc0 != itc) {
213 if (
CWRITE(0)) cout <<
"->BASE cl[0] : " << (*itc0)->ToString();
216 itc1 = std::next(itc0);
217 while (itc1 != clRow.second.end()) {
218 if (
CWRITE(0)) cout <<
" + cl[1] : " << (*itc1)->ToString();
219 if ((*itc0)->Merge((*itc1))) {
220 if (
CWRITE(0)) cout <<
" SUM : " << (*itc0)->ToString();
223 itc1 = clRow.second.erase(itc1);
224 itc = std::prev(clRow.second.end());
232 mcl += clRow.second.size();
236 for (itc = clRow.second.begin(); itc != clRow.second.end();) {
244 itc = clRow.second.erase(itc);
250 ncl0 += clRow.second.size();
251 if (
CWRITE(0)) printf(
"FindClusters() cls_found = %d cls_write = %d cls_keep = %d\n", mcl, ncl, ncl0);
266 Int_t nhits =
fHits->GetEntriesFast();
267 if (
CWRITE(1)) LOG(info) << GetName() <<
"::PreProcessHits(" << nhits <<
")";
270 for (Int_t ih(0); ih < nhits; ih++) {
275 nhits =
fHits->GetEntriesFast();
276 if (
CWRITE(1)) LOG(info) << GetName() <<
"::Deconvolute(" << nhits <<
")";
294 Int_t a0, nhits =
fHits->GetEntriesFast();
296 for (Int_t ih(0); ih < nhits; ih++) {
298 if (h0->IsUsed())
continue;
300 for (Int_t jh(ih + 1); jh < nhits; jh++) {
302 if (h1->
IsUsed())
continue;
305 if (h1->
GetTime() < 4000 - h0->GetTime())
continue;
307 if (h1->
GetTime() > 10000 + h0->GetTime())
break;
310 if (TMath::Abs(h1->
GetY() - h0->GetY()) > Dy)
continue;
313 if (TMath::Abs(h1->
GetX() - h0->GetX()) > Dx)
continue;
318 ProjectDigis(a0 < 0 ? h0->GetRefId() : h1->
GetRefId(), a0 < 0 ? h1->GetRefId() : h0->GetRefId());
321 if (
MergeHits(h0, a0)) h0->SetRowCross(h1);
323 cout << ih <<
" : " << h0->ToString();
324 cout << jh <<
" : " << h1->
ToString();
325 cout <<
"\n" << endl;
330 for (Int_t ih(0); ih <
fHits->GetEntriesFast(); ih++) {
332 if (!h0->IsUsed())
continue;
339 for (map<Int_t, vector<CbmTrdDigiRec*>>::iterator ic =
fDigis.begin(); ic !=
fDigis.end(); ic++) {
340 for (vector<CbmTrdDigiRec*>::iterator
id = ic->second.begin();
id != ic->second.end();
id++)
346 if (
CWRITE(1)) LOG(info) << GetName() <<
"::MergeHits(" << nhits <<
")";
360 Int_t col, rowMax(0), vc[2] = {-1, -1}, vm[2] = {0}, vcid[2] = {cid, cjd};
361 Double_t t(0.), r(0.), rtMax(0.), T(0.), m, d, mdMax(0.), M[2] = {-1., -1.}, S[2] = {0.};
362 vector<CbmTrdDigiRec*>::iterator id, jd, jp[2];
363 for (Int_t rowId(0); rowId < 2; rowId++) {
366 for (
id =
fDigis[vcid[rowId]].begin();
id !=
fDigis[vcid[rowId]].end();
id++) {
371 t = (*id)->GetTiltCharge(on);
372 if (on && t > rtMax) {
377 r = (*id)->GetRectCharge(on);
378 if (on && r > rtMax) {
393 if (jd !=
fDigis[vcid[rowId]].end()) T = (*jd)->GetTiltCharge(on);
398 if (TMath::Abs(m) > 0.) d = 1.e2 * d / m;
408 rowMax = M[0] > M[1] ? 0 : 1;
411 Int_t dc = vc[1] - vc[0];
412 if (dc < 0 || dc > 1)
return 0;
416 if (!vm[0] && !vm[1]) {
420 if (jp[1] !=
fDigis[cjd].end()) jp[1]++;
421 if (jp[1] !=
fDigis[cjd].end()) {
422 r = (*jp[1])->GetRectCharge(on);
424 if (jp[1] !=
fDigis[cjd].end()) T = (*jp[1])->GetTiltCharge(on);
427 M[1] = 0.5 * (r + T);
433 if (jp[0] !=
fDigis[cid].begin()) jp[0]--;
434 if (jp[0] !=
fDigis[cid].begin()) {
435 r = (*jp[0])->GetRectCharge(on);
436 t = (*jp[0])->GetTiltCharge(on);
439 M[0] = 0.5 * (t + r);
443 rowMax = M[0] > M[1] ? 0 : 1;
446 Float_t mM = M[rowMax ? 0 : 1] / M[rowMax];
454 Float_t mS = TMath::Abs(S[rowMax]), mM_l[3] = {0.15, 0.5, 1}, mM_r[3] = {0, 0.28, 1}, mS_r[3] = {43, 27, 20}, dSdM[2],
456 for (Int_t i(0); i < 2; i++) {
457 dSdM[i] = (mS_r[i + 1] - mS_r[i]) / (mM_r[i + 1] - mM_r[i]);
458 S0[i] = mS_r[i] - dSdM[i] * mM_r[i];
460 Int_t irange = mM < mM_r[1] ? 0 : 1;
461 if (mS > S0[irange] + dSdM[irange] * mM)
return 0;
463 for (Int_t ia(0); ia < 3; ia++) {
464 if (mM < mM_l[ia])
return (rowMax ? 1 : -1) * (3 - ia);
473 Int_t n0(
vs.size() - 2);
474 Double_t dx(0.), dy(0.);
489 dx =
viM == 1 ? 0. : -1;
499 dx =
viM == 1 ? 0. : -1;
512 dy =
viM == 1 ? -0.5 : 0.5;
527 Int_t xmap =
vyM & 0xff;
533 xcorrBias += (xmap == 53 || xmap == 80 || xmap == 113 || xmap == 117 ? -0.176 : 0.12);
538 if (xmap == 50 || xmap == 58 || xmap == 146 || xmap == 154) {
576 if (typ) xcorrBias += (dx < 0 ? 1 : -1) * 0.0293;
582 if (dy < -0.5 || dy > 0.5) printf(
"!!! dy = %f r[%d]\n", dy,
vrM);
590 TVector3 local_pad, local_pad_err;
594 Double_t edx(1), edy(1), edt(60), time(-21), tdrift(100), e(200);
595 Double_t local[3] = {local_pad[0] + dx, local_pad[1] + dy, local_pad[2]}, global[3];
612 printf(
"-> loc[%6.2f %6.2f %6.2f] err[%6.2f %6.2f %6.2f]\n", local_pad[0], local_pad[1], local_pad[2],
613 local_pad_err[0], local_pad_err[1], local_pad_err[2]);
614 printf(
"REC col[%2d] row[%2d] dx[%7.3f(pw) %7.3f(cm)] x[%7.2f] y[%7.2f] dy[%5.2f] t0[%llu]\n",
vcM,
vrM,
624 Int_t n0(
vs.size() - 2);
625 Double_t dx(0.), dy(0.);
640 dx =
viM == 1 ? 0. : -1;
650 dx =
viM == 1 ? 0. : -1;
663 dy =
viM == 1 ? -0.5 : 0.5;
679 if (dy < -0.5 || dy > 0.5) printf(
"!!! dy = %f r[%d]\n", dy,
vrM);
690 for (; ia <=
NANODE; ia++) {
691 ya = -1.35 + ia * 0.3;
692 if (dy > ya + 0.15)
continue;
704 Double_t parX[] = {0.713724, -0.318667, 0.0366036};
705 Double_t parY[] = {0.0886413, 0., 0.0435141};
706 Int_t nex = TMath::Min(n0, 7);
707 Double_t edx = parX[0] + parX[1] * nex + parX[2] * nex * nex, edy = parY[0] + parY[2] * dy * dy,
718 TVector3 local_pad, local_pad_err;
722 Double_t local[3] = {local_pad[0] + dx, local_pad[1] + dy, local_pad[2]}, global[3];
727 Double_t t_avg(0.), e_avg(0.);
728 for (Int_t idx(1); idx <= n0; idx++) {
733 fgT->SetPoint(idx - 1,
vx[idx],
vt[idx] - dtFEE);
735 t_avg += (
vt[idx] - dtFEE);
738 if (
fgT !=
nullptr) {
740 for (Int_t ip(n0); ip <
fgT->GetN(); ip++) {
741 fgT->SetPoint(ip, xc, 0);
745 Double_t time(-21.), tdrift(100);
747 if (
fgT !=
nullptr && (
fgT->Fit(
"pol1",
"QC",
"goff") == 0)) {
748 TF1* f =
fgT->GetFunction(
"pol1");
749 time = f->GetParameter(0) -
fgDT[2];
750 if (TMath::IsNaN(time)) time = -21;
757 for (UInt_t idx(0); idx <
vs.size(); idx++) {
768 for (Int_t ip(
vs.size()); ip < fgEdep->GetN(); ip++) {
771 fgEdep->SetPoint(ip, xc, 0);
772 fgEdep->SetPointError(ip, 0., 300);
777 Double_t e(0.), xlo(*
vx.begin()), xhi(*
vx.rbegin());
781 fgPRF->SetParameter(2, 0.65);
782 fgPRF->SetParLimits(2, 0.45, 10.5);
783 fgEdep->Fit(
fgPRF,
"QBN",
"goff", xlo - 0.5, xhi + 0.5);
784 if (!
fgPRF->GetNDF())
return false;
786 e =
fgPRF->Integral(xlo - 0.5, xhi + 0.5);
789 Float_t gain0 = 210.21387;
804 Float_t gain = gain0;
819 h->SetELoss(e * 1.e-9);
825 printf(
"-> loc[%6.2f %6.2f %6.2f] err[%6.2f %6.2f %6.2f]\n", local_pad[0], local_pad[1], local_pad[2],
826 local_pad_err[0], local_pad_err[1], local_pad_err[2]);
827 printf(
"REC col[%2d] row[%2d] x[%7.2f] dx[%5.2f] y[%7.2f] dy[%5.2f] t0[%llu]\n",
vcM,
vrM, global[0], dx, global[1],
840 LOG(debug) << GetName() <<
"::MakeHit: Hybrid cluster SPADIC/Trd2d. Skipped for the moment.";
847 LOG(info) << GetName() <<
"::MakeHit: Init static helpers. ";
848 fgEdep =
new TGraphErrors;
849 fgEdep->SetLineColor(kBlue);
851 fgT =
new TGraphErrors;
852 fgT->SetLineColor(kBlue);
853 fgT->SetLineWidth(2);
854 fgPRF =
new TF1(
"prf",
"[0]*exp(-0.5*((x-[1])/[2])**2)", -10, 10);
855 fgPRF->SetLineColor(kRed);
856 fgPRF->SetParNames(
"E",
"x",
"prf");
859 TCanvas* cvs(
nullptr);
861 cvs =
new TCanvas(
"c",
"TRD Anode Hypothesis", 10, 600, 1000, 500);
862 cvs->Divide(2, 1, 1.e-5, 1.e-5);
863 TVirtualPad* vp = cvs->cd(1);
864 vp->SetLeftMargin(0.06904908);
865 vp->SetRightMargin(0.009969325);
866 vp->SetTopMargin(0.01402806);
868 vp->SetLeftMargin(0.06904908);
869 vp->SetRightMargin(0.009969325);
870 vp->SetTopMargin(0.01402806);
871 hf =
new TH1I(
"hf",
";x [pw];s [ADC chs]", 100, -3, 3);
872 hf->GetYaxis()->SetRangeUser(-50, 4500);
877 if (!
LoadDigis(digis, ic))
return nullptr;
879 Int_t nofHits =
fHits->GetEntriesFast();
898 Int_t n0(
vs.size() - 2);
902 else if (n0 > 5 &&
HasOvf())
910 Int_t a0m = TMath::Abs(a0);
911 UChar_t xmap =
vyM & 0xff;
930 Double_t dx(0.), R(0.);
931 Int_t n(n0 ? n0 :
vs.size());
932 for (Int_t ir(0); ir < n; ir++) {
933 if (
vxe[ir] > 0)
continue;
935 dx +=
vs[ir] *
vx[ir];
937 if (TMath::Abs(R) > 0)
return dx / R;
938 LOG(debug) << GetName() <<
"::GetXoffset : Null total charge for hit size " << n;
945 Double_t dy(0.), T(0.);
946 Int_t n(n0 ? n0 :
vs.size());
947 for (Int_t it(0); it < n; it++) {
950 dy +=
vs[it] *
vx[it];
953 if (TMath::Abs(T) > 0)
return dy / T;
954 LOG(debug) << GetName() <<
"::GetYoffset : Null total charge for hit size " << n;
967 if (typ < 0 || typ > 2) {
971 Double_t dx = TMath::Abs(dxIn);
972 Int_t ii = TMath::Max(0, TMath::Nint(dx /
fgCorrXdx) - 1), i0;
975 LOG(warn) << GetName() <<
"::GetXcorr : LUT idx " << ii <<
" out of range for dx=" << dxIn;
979 i0 = TMath::Max(0, ii - 1);
992 Double_t DDx = (xval[1] - xval[0]), a = DDx /
fgCorrXdx, b = xval[0] - DDx * (i0 + 0.5);
993 return (dxIn > 0 ? 1 : -1) * b + a * dxIn;
1002 Float_t fdy(1.), yoff(0.);
1003 Int_t n0(
vs.size() - 2);
1010 yoff = (dy > 0 ? -1 : 1) * 1.56;
1014 yoff = (dy > 0 ? -1 : 1) * 1.06;
1045 return dy * fdy + yoff;
1054 if (dx >= -0.5 && dx < 0.5)
return;
1055 Int_t ishift = Int_t(dx - 0.5) + (dx > 0.5 ? 1 : 0);
1056 if (
vcM + ishift < 0)
1060 LOG(debug) << GetName() <<
"::RecenterXoffset : shift dx offset by " << ishift <<
" from dx=" << dx <<
" to "
1061 << dx - ishift <<
" center col from " << (Int_t)
vcM <<
" to " << Int_t(
vcM + ishift);
1064 for (UInt_t idx(0); idx <
vx.size(); idx++)
1075 if (dy >= -0.5 && dy < 0.5)
return;
1076 Int_t ishift = Int_t(dy - 0.5) + (dy > 0.5 ? 1 : 0);
1079 LOG(debug) << GetName() <<
"::RecenterYoffset : shift dy offset by " << ishift <<
" from dy=" << dy <<
" to "
1094 Int_t col(-1), colT(-1), colR(-1);
1095 const CbmTrdDigi *dgT(
nullptr), *dgR(
nullptr);
1096 for (vector<const CbmTrdDigi*>::iterator i = din->begin(), j = i + 1; i != din->end(); i++) {
1101 if (col >= 0 && colT != col + 1) {
1102 LOG(error) << GetName() <<
"::LoadDigis : digis in cluster " << cid <<
" not in increasing order !";
1108 if (j != din->end()) {
1113 if (colR == colT && dgR != NULL) {
1120 if (j != din->end()) j++;
1122 return fDigis[cid].size();
1134 LOG(warn) << GetName() <<
"::ProjectDigis : Request cl id " << cid <<
" not found.";
1150 Int_t n0(0), nsr(0),
1157 Double_t r, re(100.),
1162 Int_t j(0), col(-1), col0(0), col1(0), step(0), row1;
1165 vector<CbmTrdDigiRec*>::iterator i1;
1168 LOG(warn) << GetName() <<
"::ProjectDigis : Request cl id " << cjd <<
" not found. Skip second row.";
1172 i1 =
fDigis[cjd].begin();
1175 const CbmTrdDigiRec *dg(
nullptr), *dg0(
nullptr), *dg1(
nullptr);
1176 for (vector<CbmTrdDigiRec*>::iterator i =
fDigis[cid].begin(); i !=
fDigis[cid].end(); i++, j++) {
1185 vt0 = dg->GetTimeDAQ();
1191 t = dg->GetTiltCharge(on);
1193 r = dg->GetRectCharge(on);
1197 if ((dg0 = (i1 !=
fDigis[cjd].end()) ? (*i1) :
nullptr)) {
1199 if (!step) step =
vrM - row1;
1201 r += dg0->GetRectCharge(on);
1207 if (step == 1 && i1 !=
fDigis[cjd].begin()) {
1210 if (col1 == col0 - 1) {
1217 if (step == -1 && i1 !=
fDigis[cjd].end() && i1 + 1 !=
fDigis[cjd].end()) {
1220 if (col1 == col0 + 1) {
1230 if (dg0) cout <<
"dgR :" << dg0->ToString();
1231 if (dg1) cout <<
"dgT :" << dg1->
ToString();
1236 ddt = dg->GetTiltTime() -
vt0;
1237 if (ddt < dt0) dt0 = ddt;
1239 if (nt > 1) t *= 0.5;
1240 err = te * (nt > 1 ? 0.707 : 1);
1241 if (dg->HasTiltOvf()) {
1258 vxe.push_back(0.035);
1262 ddt = dg->GetRectTime() -
vt0;
1263 if (ddt < dt0) dt0 = ddt;
1266 if (nr > 1) r *= 0.5;
1267 err = re * (nr > 1 ? 0.707 : 1);
1268 if (dg->HasRectOvf()) {
1292 if (TMath::Abs(
vs[0]) > 1.e-3) {
1295 vs.insert(
vs.begin(), 0);
1296 vse.insert(
vse.begin(), 300);
1297 vt.insert(
vt.begin(), ddt);
1298 vx.insert(
vx.begin(), xc - 0.5);
1299 vxe.insert(
vxe.begin(), 0);
1302 Int_t n(
vs.size() - 1);
1303 if (TMath::Abs(
vs[n]) > 1.e-3) {
1310 vxe.push_back(0.035);
1315 Int_t nR = n0 + 1 -
viM;
1318 if (
vs.size() % 2) {
1319 Double_t LS(0.), RS(0.);
1320 for (UChar_t idx(0); idx <
viM; idx++)
1322 for (UInt_t idx(
viM + 1); idx <
vx.size(); idx++)
1336 for (UInt_t idx(0); idx <
vx.size(); idx++) {
1343 Int_t nmiss = 2 * nsr - NR;
1344 if (cjd >= 0 && nmiss) {
1346 for (UChar_t idx(1); idx <
viM; idx++) {
1347 if (
vxe[idx] > 0.)
continue;
1351 for (UChar_t idx(
viM + 1); idx <
vs.size() - 1; idx++) {
1352 if (
vxe[idx] > 0.)
continue;
1358 nmiss = 2 * n0 - 2 * nsr - NT;
1359 if (cjd >= 0 && nmiss) {
1361 for (UChar_t idx(1); idx <
viM; idx++) {
1365 for (UChar_t idx(
viM + 1); idx <
vs.size() - 1; idx++) {
1373 printf(
"t0[clk]=%llu col[%2d] row[%2d] sz[%d] OVF[%c] %c",
vt0,
vcM,
vrM, Int_t(
vs.size() - 2),
1374 (ovf < 0 ?
'y' :
'n'),
IsOpenLeft() ?
'(' :
'[');
1382 printf(
"%s",
IsLeftHit() ?
"<<" :
">>");
1385 for (UInt_t idx(0); idx <
vs.size(); idx++) {
1386 printf(
"%2d dt[%2d] s[ADC]=%6.1f+-%6.1f x[pw]=%5.2f+-%5.2f ", idx,
vt[idx],
vs[idx],
vse[idx],
vx[idx],
vxe[idx]);
1387 if (idx ==
viM) printf(
"[%s]", (
IsMaxTilt() ?
"//" :
"||"));
1393 return ovf * (
vs.size() - 2);
1398 ULong64_t& t0, Int_t& cM)
1419 Double_t r, re(100.),
1424 Int_t j(0), col0(-1), col1(0);
1426 vector<CbmTrdDigi*>::iterator idgM = vdgM->begin();
1427 for (vector<const CbmTrdDigi*>::iterator i = digis->begin(); i != digis->end(); i++, j++) {
1433 if (
CWRITE(1)) cout << dg->ToString();
1434 r = dg->GetCharge(t, dt);
1435 if (t0 == 0) t0 = dg->GetTimeDAQ();
1436 if (col0 < 0)
GetPadRowCol(dg->GetAddressChannel(), col0);
1437 ddt = dg->GetTimeDAQ() - t0;
1438 if (ddt < dt0) dt0 = ddt;
1442 if (col0 + j != col1) {
1443 LOG(error) << GetName() <<
"::LoadDigis : digis in cluster not in increasing order !";
1467 vxe.push_back(0.035);
1472 if (ddt < dt0) dt0 = ddt;
1497 if (idgM != vdgM->end()) LOG(warn) << GetName() <<
"::LoadDigis : not all merged digis have been consumed !";
1498 for (idgM = vdgM->begin(); idgM != vdgM->end(); idgM++)
1502 if (TMath::Abs(
vs[0]) > 1.e-3) {
1505 vs.insert(
vs.begin(), 0);
1506 vse.insert(
vse.begin(), 300);
1507 vt.insert(
vt.begin(), ddt);
1508 vx.insert(
vx.begin(), xc - 0.5);
1509 vxe.insert(
vxe.begin(), 0);
1511 Int_t n(
vs.size() - 1);
1512 if (TMath::Abs(
vs[n]) > 1.e-3) {
1519 vxe.push_back(0.035);
1523 for (UInt_t idx(0); idx <
vx.size(); idx++) {
1533 ULong64_t& t0, Int_t& cM)
1558 Double_t r, R, re(100.),
1563 Int_t j(0), row, col, col0(-1), col1(0);
1566 vector<const CbmTrdDigi*>::iterator i0, i1, ix0, ix1;
1567 i0 = digis->begin();
1571 if (col0 < 0) col0 = col1;
1576 }
while (i1 != digis->end());
1585 i1 = digis->begin();
1592 if (
CWRITE(1)) printf(
"col0[%d] col1[%d] step[%2d]\n", col0, col1, step);
1593 const CbmTrdDigi *dg0(
nullptr), *dg1(
nullptr), *dg10(
nullptr);
1596 for (; i0 != ix0; i0++, j++) {
1602 r = dg0->GetCharge(t, dt);
1606 if (t0 == 0) t0 = dg0->GetTimeDAQ();
1607 ddt = dg0->GetTimeDAQ() - t0;
1608 if (ddt < dt0) dt0 = ddt;
1612 if (col + j != col0) {
1613 LOG(error) << GetName() <<
"::LoadDigisRC : digis in cluster not in increasing order " << col0 <<
" !";
1618 if ((dg1 = (i1 != ix1) ? (*i1) :
nullptr)) {
1621 R = dg1->GetCharge(T, dT);
1627 if (step == 1 && i1 != digis->begin()) {
1630 if (col1 == col0 - 1) {
1637 if (step == -1 && i1 != ix1 && i1 + 1 != ix1) {
1640 if (col1 == col0 + 1) {
1650 if (dg1) cout <<
"dgR :" << dg1->ToString();
1651 if (dg10) cout <<
"dgT :" << dg10->
ToString();
1652 cout <<
"-------------------------------------" << endl;
1670 vxe.push_back(0.035);
1674 if (ddt < dt0) dt0 = ddt;
1698 if (TMath::Abs(
vs[0]) > 1.e-3) {
1701 vs.insert(
vs.begin(), 0);
1702 vse.insert(
vse.begin(), 300);
1703 vt.insert(
vt.begin(), ddt);
1704 vx.insert(
vx.begin(), xc - 1);
1705 vxe.insert(
vxe.begin(), 0);
1707 Int_t n(
vs.size() - 1);
1708 if (TMath::Abs(
vs[n]) > 1.e-3) {
1715 vxe.push_back(0.035);
1721 else if (cM + col < 0)
1724 for (UInt_t idx(0); idx <
vx.size(); idx++) {
1741 if (digis->size() < 2) {
1742 LOG(warn) << GetName() <<
"::MergeDigis : Bad digi config for cluster :";
1747 Int_t colR, colT, dt, contor(0);
1749 for (vector<const CbmTrdDigi*>::iterator idig = digis->begin(), jdig = idig + 1; jdig != digis->end();
1750 idig++, jdig++, contor++) {
1756 if (colR != colT)
continue;
1766 cout <<
"MERGE" << endl;
1769 cout <<
"TO" << endl;
1771 cout <<
"..." << endl;
1775 vdgM->push_back(dgM);
1776 (*vmask)[contor] = 1;
1777 jdig = digis->erase(jdig);
1778 if (jdig == digis->end())
break;
1782 LOG(warn) << GetName() <<
"::MergeDigis : Digi to pads matching failed for cluster :";
1790 {-0.001, -0.001, -0.002, -0.002, -0.003, -0.003, -0.003, -0.004, -0.004, -0.006, -0.006, -0.006, -0.007,
1791 -0.007, -0.008, -0.008, -0.008, -0.009, -0.009, -0.011, -0.011, -0.011, -0.012, -0.012, -0.012, -0.012,
1792 -0.013, -0.013, -0.013, -0.013, -0.014, -0.014, -0.014, -0.014, -0.014, -0.016, -0.016, -0.016, -0.016,
1793 -0.017, -0.017, -0.017, -0.018, -0.018, -0.018, -0.018, -0.018, 0.000, 0.000, 0.000},
1794 {0.467, 0.430, 0.396, 0.364, 0.335, 0.312, 0.291, 0.256, 0.234, 0.219, 0.207, 0.191, 0.172,
1795 0.154, 0.147, 0.134, 0.123, 0.119, 0.109, 0.122, 0.113, 0.104, 0.093, 0.087, 0.079, 0.073,
1796 0.067, 0.063, 0.058, 0.053, 0.049, 0.046, 0.042, 0.038, 0.036, 0.032, 0.029, 0.027, 0.024,
1797 0.022, 0.019, 0.017, 0.014, 0.013, 0.011, 0.009, 0.007, 0.004, 0.003, 0.001},
1798 {0.001, 0.001, 0.001, 0.001, 0.002, 0.002, 0.001, 0.002, 0.004, 0.003, 0.002, 0.002, 0.002,
1799 0.002, 0.002, 0.002, 0.003, 0.004, 0.003, 0.004, 0.004, 0.007, 0.003, 0.004, 0.002, 0.002,
1800 -0.011, -0.011, -0.012, -0.012, -0.012, -0.013, -0.013, -0.013, -0.014, -0.014, -0.014, -0.016, -0.016,
1801 -0.016, -0.017, -0.017, -0.017, -0.018, -0.018, -0.018, -0.019, 0.029, 0.018, 0.001}};
1803 {0.629389, -0.215285},
1805 {0.151913, 0.054404}};
1807 {-0.00050, -0.00050, -0.00150, -0.00250, -0.00250, -0.00350, -0.00450, -0.00450, -0.00550, -0.00650,
1808 -0.00650, -0.00750, -0.00850, -0.00850, -0.00850, -0.00950, -0.00950, -0.00950, -0.01050, -0.01150,
1809 -0.01150, -0.01150, -0.01250, -0.01250, -0.01250, -0.01250, -0.01350, -0.01350, -0.01350, -0.01350,
1810 -0.01450, -0.01450, -0.01450, -0.01550, -0.01550, -0.01550, -0.01550, -0.01650, -0.01650, -0.01550,
1811 -0.01650, -0.01614, -0.01620, -0.01624, -0.01626, -0.01627, -0.01626, -0.01624, -0.01620, -0.01615},
1812 {0.36412, 0.34567, 0.32815, 0.31152, 0.29574, 0.28075, 0.26652, 0.25302, 0.24020, 0.22803, 0.21647, 0.21400, 0.19400,
1813 0.18520, 0.17582, 0.16600, 0.14600, 0.13800, 0.14280, 0.14200, 0.13400, 0.12600, 0.12200, 0.11000, 0.10200, 0.09400,
1814 0.09000, 0.08600, 0.08200, 0.07400, 0.07000, 0.06600, 0.06600, 0.06200, 0.05800, 0.05400, 0.05400, 0.05000, 0.04600,
1815 0.04600, 0.04200, 0.03800, 0.03800, 0.03400, 0.03400, 0.03000, 0.03000, 0.02600, 0.02200, 0.02200}};
1817 {0.00100, 0.00260, 0.00540, 0.00740, 0.00900, 0.01060, 0.01300, 0.01460, 0.01660, 0.01900, 0.02060, 0.02260, 0.02420,
1818 0.02700, 0.02860, 0.02980, 0.03220, 0.03340, 0.03540, 0.03620, 0.03820, 0.04020, 0.04180, 0.04340, 0.04460, 0.04620,
1819 0.04740, 0.04941, 0.05088, 0.05233, 0.05375, 0.05515, 0.05653, 0.05788, 0.05921, 0.06052, 0.06180, 0.06306, 0.06430,
1820 0.06551, 0.06670, 0.06786, 0.06901, 0.07012, 0.07122, 0.07229, 0.07334, 0.07436, 0.07536, 0.07634},
1821 {0.00100, 0.00380, 0.00780, 0.00900, 0.01220, 0.01460, 0.01860, 0.01940, 0.02260, 0.02540, 0.02820, 0.03060, 0.03220,
1822 0.03660, 0.03980, 0.04094, 0.04420, 0.04620, 0.04824, 0.04980, 0.05298, 0.05532, 0.05740, 0.05991, 0.06217, 0.06500,
1823 0.06540, 0.06900, 0.07096, 0.07310, 0.07380, 0.07729, 0.07935, 0.08139, 0.08340, 0.08538, 0.08734, 0.08928, 0.08900,
1824 0.09307, 0.09493, 0.09340, 0.09858, 0.09620, 0.09740, 0.10386, 0.09980, 0.10726, 0.10892, 0.11056},
1825 {0.00011, 0.00140, 0.00340, 0.00420, 0.00500, 0.00620, 0.00820, 0.00860, 0.01060, 0.01100, 0.01220, 0.01340, 0.01500,
1826 0.01540, 0.01700, 0.01820, 0.01900, 0.02060, 0.02180, 0.02260, 0.02340, 0.02420, 0.02500, 0.02500, 0.02660, 0.02740,
1827 0.02820, 0.02900, 0.03020, 0.03180, 0.03300, 0.03260, 0.03380, 0.03460, 0.03500, 0.03580, 0.03780, 0.03820, 0.03860,
1828 0.03900, 0.04100, 0.04180, 0.04060, 0.04300, 0.04340, 0.04340, 0.04380, 0.04460, 0.04580, 0.04540}};
ClassImp(CbmConverterManager)
Data Container for TRD clusters.
Class for hits in TRD detector.
friend fscal max(fscal x, fscal y)
Generates beam ions for transport simulation.
void SetAddress(int32_t address)
void SetRefId(int32_t refId)
Data Container for TRD clusters.
bool AddChannel(bool r=true)
Append a channel to cluster edge. The usage is to account for the masked channels....
bool HasFaspDigis() const
virtual std::string ToString() const
Extended functionality.
void SetFaspDigis(bool set=true)
uint16_t GetStartCh() const
uint16_t GetEndCh() const
Extend the TRD(2D) digi class to incorporate FEE calibration.
Double_t GetTiltCharge(Bool_t &on) const
Return calibrated tilt signal.
void SetTriggerType(const eTriggerType triggerType)
Set digi trigger type.
int32_t GetTriggerType() const
Channel trigger type. SPADIC specific see CbmTrdTriggerType.
std::string ToString() const
String representation of a TRD digi. Account for digi type and specific information.
uint64_t GetTimeDAQ() const
Getter for global DAQ time [clk]. Differs for each ASIC. In FASP case DAQ time is already stored in f...
int32_t GetAddressChannel() const
Getter read-out id.
static float Clk(eCbmTrdAsicType ty)
DAQ clock accessor for each ASIC.
eCbmTrdAsicType GetType() const
Channel FEE SPADIC/FASP according to CbmTrdAsicType.
double GetCharge() const
Common purpose charge getter.
void SetCharge(float c)
Charge setter for SPADIC ASIC.
static Float_t GetBaselineCorr()
Return the baseline value in ADC ch.
data class for a reconstructed Energy-4D measurement in the TRD
virtual std::string ToString() const
Inherited from CbmBaseHit.
virtual Int_t GetNcols() const
Shortcut getter column size.
const CbmTrdParModDigi * fDigiPar
read-out description of module
virtual void LocalToMaster(Double_t in[3], Double_t out[3])
UShort_t fModAddress
unique identifier for current module
CbmTrdParModAsic * fAsicPar
the set of ASIC operating on the module (owned)
virtual Int_t GetPadRowCol(Int_t address, Int_t &c) const
Addressing read-out pads based on module address.
Cluster finding and hit reconstruction algorithms for the TRD(2D) module.
static Float_t fgCorrYval[NBINSCORRY][2]
discretized correction LUT
void SetSymmHit(Bool_t set=1)
void SetBiasYright(Bool_t set=1)
std::vector< Char_t > vt
working copy of signal errors from cluster
void SetBiasXleft(Bool_t set=1)
Bool_t Deconvolute(CbmTrdHit *h)
Algorithm for cluster spliting.
int fHitTimeOff
bit map for cluster topology classification
Bool_t CWRITE(int level) const
virtual Int_t GetOverThreshold() const
Count RO channels (R or T) with data.
Bool_t MergeHits(CbmTrdHit *h, Int_t a0)
Algorithm for hit merging.
std::map< Int_t, vector< CbmTrdDigiRec * > > fDigis
UShort_t vyM
index of maximum signal in the projection
void SetLeftSgn(Bool_t set=1)
std::map< Int_t, std::list< CbmTrdCluster * > > fBuffer
time interval to still keep clusters in buffer [clk]
void SetMaxTilt(Bool_t set=1)
CbmTrdModuleRec2D()
Default constructor.
Bool_t IsOpenRight() const
Double_t GetYcorr(Double_t dy, Int_t cls=0) const
y position correction based on LUT
std::vector< Double_t > vxe
working copy of signal relative positions
Bool_t IsBiasXmid() const
static Float_t fgCorrXval[3][NBINSCORRX]
step of the discretized correction LUT
virtual ~CbmTrdModuleRec2D()
std::vector< Double_t > vse
working copy of signals from cluster
ULong64_t fT0
task configuration settings
void SetBiasY(Bool_t set=1)
void SetBiasYmid(Bool_t set=1)
virtual CbmTrdHit * MakeHit(Int_t cId, const CbmTrdCluster *c, std::vector< const CbmTrdDigi * > *digis)
Steering routine for converting cluster to hit.
virtual void DrawHit(CbmTrdHit *) const
void RecenterXoffset(Double_t &dx)
Shift graph representation to [-0.5, 0.5].
Bool_t CheckConvolution(CbmTrdHit *h) const
Implement cuts for hit convolution definition.
Bool_t IsOpenLeft() const
Bool_t HasLeftSgn() const
Bool_t BuildHit(CbmTrdHit *h)
void SetBiasYleft(Bool_t set=1)
std::vector< Double_t > vs
hit time offset for synchronization
UInt_t fTimeLast
start time of event/time slice [clk]
UChar_t vcM
start time of current hit [clk]
static TGraphErrors * fgT
fitter for cluster PRF
UInt_t fTimeWinKeep
time of last digi processed in module [clk]
Int_t LoadDigis(vector< const CbmTrdDigi * > *din, Int_t cid)
Load RAW digis into working array of RECO digis.
void SetBiasX(Bool_t set=1)
Int_t CheckMerge(Int_t cid, Int_t cjd)
Implement topologic cuts for hit merging.
void SetOvf(Bool_t set=1)
Int_t GetHitRcClass(Int_t a0) const
Hit classification wrt signal bias.
virtual Int_t FindClusters(bool clr)
Finalize clusters.
Int_t ProjectDigis(Int_t cid, Int_t cjd=-1)
ULong64_t vt0
cluster-wise organized calibrated digi
static Float_t fgCorrRcXbiasXval[3][NBINSCORRX]
discretized correction LUT
Int_t LoadDigisRC(vector< const CbmTrdDigi * > *digis, const Int_t r0, const Int_t a0, ULong64_t &t0, Int_t &cM)
virtual Bool_t PostProcessHits()
Finalize hits (merge RC hits, etc)
Bool_t IsBiasYleft() const
void RecenterYoffset(Double_t &dy)
Shift graph representation to [-0.5, 0.5].
Double_t GetXcorr(Double_t dx, Int_t typ, Int_t cls=0) const
x position correction based on LUT
static Float_t fgCorrRcXval[2][NBINSCORRX]
discretized correction params
Double_t GetYoffset(Int_t n0=0) const
void SetLeftHit(Bool_t set=1)
Bool_t MergeDigis(std::vector< const CbmTrdDigi * > *digis, std::vector< CbmTrdDigi * > *vdgM, std::vector< Bool_t > *vmask)
Merge R/T signals to digis if topological conditions in cluster are fulfilled.
virtual Bool_t AddDigi(const CbmTrdDigi *d, Int_t id)
Add digi to local module.
void SetBiasXmid(Bool_t set=1)
virtual Bool_t PreProcessHits()
Check hit quality (deconvolute pile-ups, etc)
Bool_t IsBiasXleft() const
static TGraphErrors * fgEdep
FASP delay wrt signal.
Int_t GetHitClass() const
Hit classification wrt center pad.
virtual Bool_t MakeHits()
Steering routine for building hits.
static Float_t fgCorrXdx
working copy of signal relative position errors
void SetBiasXright(Bool_t set=1)
const CbmTrdParFaspChannel * GetFaspChCalibrator(uint16_t ch) const
Retrive FASP ch calibrator by RO ch number in the module.
Bool_t IsBiasXright() const
std::vector< Double_t > vx
working copy of signal relative timing
int AddClusterEdges(CbmTrdCluster *cl)
Add left and right edge channels to the cluster in case this are masked channels.
static TF1 * fgPRF
data handler for cluster PRF
static Double_t fgDT[3]
discretized correction LUT
Double_t GetXoffset(Int_t n0=0) const
Abstract class for module wise cluster finding and hit reconstruction.
TClonesArray * fHits
module wise storage of reconstructed hits
Definition of FASP channel calibration container.
void Print(Option_t *opt="") const
Definition of FASP parameters.
const CbmTrdParFaspChannel * GetChannel(Int_t pad_address, UChar_t pair) const
Query the calibration for one FASP RO channel.
virtual Int_t GetAsicAddress(Int_t chAddress) const
Look for the ASIC which operates on a specific channel It applies to the list of ASICs.
virtual const CbmTrdParAsic * GetAsicPar(Int_t address) const
Look for the ASIC parameters of a given DAQ id It applies to the list of ASICs.
bool GetFaspChannelPar(int pad, const CbmTrdParFaspChannel *&tilt, const CbmTrdParFaspChannel *&rect) const
Access the calibration objects describing the two FASP channels allocated to a pad....
Int_t GetSectorRow(Int_t growId, Int_t &srowId) const
Find the sector wise row given the module row. Inverse of GetModuleRow()
void GetPadPosition(const Int_t sector, const Int_t col, const Int_t row, TVector3 &padPos, TVector3 &padPosErr) const
Double_t GetPadSizeY(Int_t i) const
Double_t GetPadSizeX(Int_t i) const
Int_t GetNofColumns() const