25 std::vector<inputType*> hitData;
27 for (
auto& elem : hitsRow1) {
28 hitData.push_back(&elem);
30 for (
auto& elem : hitsRow2) {
31 hitData.push_back(&elem);
38 for (
size_t ih = 0; ih < hitData.size(); ih++) {
39 Hit* h0 = &hitData[ih]->first;
40 std::vector<DigiRec>* h0digis = &hitData[ih]->second;
42 if (h0->
IsUsed())
continue;
44 for (
size_t jh = ih + 1; jh < hitData.size(); jh++) {
45 Hit* h1 = &hitData[jh]->first;
46 std::vector<DigiRec>* h1digis = &hitData[jh]->second;
48 if (h1->
IsUsed())
continue;
51 if (h1->
Time() < 4000 - h0->
Time())
continue;
53 if (h1->
Time() > 10000 + h0->
Time())
break;
63 if (a0 == 0)
continue;
65 auto [hitFlag, hitF] =
ProjectDigis(a0 < 0 ? h0digis : h1digis, a0 < 0 ? h1digis : h0digis);
75 std::remove_if(hitsRow1.begin(), hitsRow1.end(), [](
const auto& obj) { return obj.first.IsUsed(); });
76 hitsRow1.erase(ret1, hitsRow1.end());
79 std::remove_if(hitsRow2.begin(), hitsRow2.end(), [](
const auto& obj) { return obj.first.IsUsed(); });
80 hitsRow2.erase(ret2, hitsRow2.end());
82 return std::make_pair(std::move(hitsRow1), std::move(hitsRow2));
95 int vc[2] = {-1, -1}, vm[2] = {0};
96 double M[2] = {-1., -1.}, S[2] = {0.};
97 vector<DigiRec>::const_iterator jp[2];
99 for (
int rowId(0); rowId < 2; rowId++) {
102 const std::vector<DigiRec>* vcid[2] = {cid, cjd};
103 for (
auto id = vcid[rowId]->begin();
id != vcid[rowId]->end();
id++) {
108 const double t = (*id).GetTiltCharge(on);
109 if (on && t > rtMax) {
114 const double r = (*id).GetRectCharge(on);
115 if (on && r > rtMax) {
128 auto jd = std::next(
id);
130 if (jd != vcid[rowId]->end()) T = (*jd).GetTiltCharge(on);
134 if (std::abs(m) > 0.) d = 1.e2 * d / m;
143 int rowMax = M[0] > M[1] ? 0 : 1;
146 const int dc = vc[1] - vc[0];
147 if (dc < 0 || dc > 1)
return 0;
151 if (!vm[0] && !vm[1]) {
156 if (jp[1] != cjd->end()) jp[1]++;
157 if (jp[1] != cjd->end()) {
158 r = (*jp[1]).GetRectCharge(on);
160 if (jp[1] != cjd->end()) T = (*jp[1]).GetTiltCharge(on);
163 M[1] = 0.5 * (r + T);
170 if (jp[0] != cid->begin()) jp[0]--;
171 if (jp[0] != cid->begin()) {
172 r = (*jp[0]).GetRectCharge(on);
173 t = (*jp[0]).GetTiltCharge(on);
176 M[0] = 0.5 * (t + r);
180 rowMax = M[0] > M[1] ? 0 : 1;
183 const float mM = M[rowMax ? 0 : 1] / M[rowMax];
184 const float mS = std::abs(S[rowMax]), mM_l[3] = {0.15, 0.5, 1}, mM_r[3] = {0, 0.28, 1}, mS_r[3] = {43, 27, 20};
185 float dSdM[2], S0[2];
187 for (
int i(0); i < 2; i++) {
188 dSdM[i] = (mS_r[i + 1] - mS_r[i]) / (mM_r[i + 1] - mM_r[i]);
189 S0[i] = mS_r[i] - dSdM[i] * mM_r[i];
191 const int irange = mM < mM_r[1] ? 0 : 1;
192 if (mS > S0[irange] + dSdM[irange] * mM)
return 0;
194 for (
int ia(0); ia < 3; ia++) {
195 if (mM < mM_l[ia])
return (rowMax ? 1 : -1) * (3 - ia);
204 int n0(hitF.
fSignal.size() - 2);
205 auto [dx, dy] = hitF.
GetDxDy(n0);
212 int xmap = hitF.
vyM & 0xff;
218 xcorrBias += (xmap == 53 || xmap == 80 || xmap == 113 || xmap == 117 ? -0.176 : 0.12);
223 if (xmap == 50 || xmap == 58 || xmap == 146 || xmap == 154) {
261 if (typ) xcorrBias += (dx < 0 ? 1 : -1) * 0.0293;
265 double edx(1), edy(1), edt(60), time(-21), tdrift(100), e(200);
266 CalibrateHit(
h, dx, dy, edx, edy, edt, time, tdrift, e, hitF);
273 const double edt,
const double time,
const double tdrift,
const double eloss,
277 const ROOT::Math::XYZVector local(local_pad.X() + dx, local_pad.Y() + dy, local_pad.Z());
303 L_(debug) <<
"TrdModuleRec2D::ProjectDigis : Request cl id " << cid <<
" not found.";
308 std::vector<HitFactory2D::signal>& hitSig = hitF.
fSignal;
320 const double re = 100.;
321 const double te = 100.;
323 int j(0), col(-1), col0(0), col1(0), step(0), row1;
326 if (cid ==
nullptr || cjd ==
nullptr || cid->empty() || cjd->empty()) {
327 L_(debug) <<
"TrdModuleRec2D::ProjectDigis : Requested cluster not found.";
331 vector<DigiRec>::const_iterator i1 = cjd->begin();
333 for (
auto i = cid->begin(); i != cid->end(); i++, j++) {
352 if ((dg0 = (i1 != cjd->end()) ? &(*i1) :
nullptr)) {
354 if (!step) step = hitF.
vrM - row1;
362 if (step == 1 && i1 != cjd->begin()) {
363 const auto dg1 = &(*(i1 - 1));
365 if (col1 == col0 - 1) {
366 t += dg1->GetTiltCharge(on);
370 if (step == -1 && i1 != cjd->end() && i1 + 1 != cjd->end()) {
371 const auto dg1 = &(*(i1 + 1));
373 if (col1 == col0 + 1) {
374 t += dg1->GetTiltCharge(on);
383 if (ddt < dt0) dt0 = ddt;
385 if (nt > 1) t *= 0.5;
386 err = te * (nt > 1 ? 0.707 : 1);
395 hitF.
viM = hitSig.size();
401 hitSig.emplace_back(t, err, ddt, xc, 0.035);
406 if (ddt < dt0) dt0 = ddt;
409 if (nr > 1) r *= 0.5;
410 err = re * (nr > 1 ? 0.707 : 1);
419 hitF.
viM = hitSig.size();
425 hitSig.emplace_back(r, err, ddt, xc, 0.);
434 if (std::abs(hitSig[0].s) > 1.e-3) {
436 char ddt = hitSig[0].t;
437 hitSig.emplace(hitSig.begin(), 0., 300., ddt, xc - 0.5, 0.);
440 int n(hitSig.size() - 1);
441 if (std::abs(hitSig[n].s) > 1.e-3) {
442 xc = hitSig[n].x + 0.5;
443 char ddt = hitSig[n].t;
444 hitSig.emplace_back(0., 300., ddt, xc, 0.035);
447 n0 = hitSig.size() - 2;
449 int nR = n0 + 1 - hitF.
viM;
450 if (nR == hitF.
viM) {
452 if (hitSig.size() % 2) {
453 double LS(0.), RS(0.);
454 for (UChar_t idx(0); idx < hitF.
viM; idx++)
456 for (uint idx(hitF.
viM + 1); idx < hitSig.size(); idx++)
465 else if (hitF.
viM > nR)
470 for (
auto& sig : hitSig) {
477 const int nmissX = 2 * nsr - NR;
480 for (UChar_t idx(1); idx < hitF.
viM; idx++) {
481 if (hitSig[idx].xe > 0.)
continue;
484 if (hitSig[hitF.
viM].xe <= 0. && hitSig[hitF.
viM].se > re * 0.8) hitF.
SetBiasXmid(1);
485 for (UChar_t idx(hitF.
viM + 1); idx < hitSig.size() - 1; idx++) {
486 if (hitSig[idx].xe > 0.)
continue;
494 const int nmissY = 2 * n0 - 2 * nsr - NT;
497 for (UChar_t idx(1); idx < hitF.
viM; idx++) {
498 if (hitSig[idx].xe > 0. && hitSig[idx].se > te * 0.8) hitF.
SetBiasYleft(1);
500 if (hitSig[hitF.
viM].xe > 0. && hitSig[hitF.
viM].se > te * 0.8) hitF.
SetBiasYmid(1);
501 for (UChar_t idx(hitF.
viM + 1); idx < hitSig.size() - 1; idx++) {
502 if (hitSig[idx].xe > 0. && hitSig[idx].se > te * 0.8) hitF.
SetBiasYright(1);
509 if (ovf < 0) hitF.
SetOvf();
510 return std::make_pair(ovf * (hitSig.size() - 2), hitF);
friend fscal max(fscal x, fscal y)
Data class with information on a STS local track.
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.
double GetTiltCharge(bool &on) const
Return calibrated tilt signal.
double GetTiltTime() const
Return calibrated tilt time [ns].
double GetRectCharge(bool &on) const
Return calibrated rect signal.
double GetRectTime() const
Return calibrated rect time [ns].
void RecenterXoffset(double &dx)
void SetBiasY(bool set=1)
void SetBiasXmid(bool set=1)
std::pair< double, double > GetDxDy(const int n0)
void SetBiasYright(bool set=1)
std::pair< double, double > CorrectPosition(double dx, double dy, const double xcorr, const double padSizeX, const double padSizeY)
Shift graph representation to [-0.5, 0.5].
void SetBiasYleft(bool set=1)
void SetMaxTilt(bool set=1)
void SetBiasYmid(bool set=1)
void SetSymmHit(bool set=1)
void SetBiasXright(bool set=1)
uint16_t vyM
index of maximum signal in the projection
std::vector< signal > fSignal
void SetLeftSgn(bool set=1)
uint8_t vcM
start time of current hit [clk]
int GetHitRcClass(int a0) const
Hit classification wrt signal bias.
void SetBiasXleft(bool set=1)
int GetHitClass() const
Hit classification wrt center pad.
double GetXcorr(double dx, int typ, int cls=0) const
void SetLeftHit(bool set=1)
void SetBiasX(bool set=1)
HitFinder2DModPar fParams
Parameter container.
void CalibrateHit(Hit *h, const double dx, const double dy, const double edx, const double edy, const double edt, const double time, const double tdrift, const double eloss, const HitFactory2D &hitF)
bool MergeHits(Hit *h, int a0, HitFactory2D &hitF)
Algorithm for hit merging.
std::pair< std::vector< inputType >, std::vector< inputType > > outputType
outputType operator()(std::vector< inputType > &hitsRow1, std::vector< inputType > &hitsRow2)
Steering routine for building hits.
std::pair< int, HitFactory2D > ProjectDigis(std::vector< DigiRec > *cid, std::vector< DigiRec > *cjd)
HitMerger2D()
Default constructor.
int GetPadRowCol(int address, int &c)
Addressing ASIC on module based on id.
int CheckMerge(std::vector< DigiRec > *cid, std::vector< DigiRec > *cjd)
Implement topologic cuts for hit merging.
A light-weight TRD hit class for online reconstruction, based on CbmTrdHit. .
void SetRowCross(bool set=true)
Mark hit reconstructed between pad rows.
ROOT::Math::Rotation3D rotation
std::vector< HitFinder2DRowPar > rowPar
ROOT::Math::XYZVector translation