11 #include "TGeoMatrix.h"
13 #include <TClonesArray.h>
20 #include <FairLogger.h>
28 SetNameTitle(
"TrdModuleRecR",
"Reconstructor for rectangular pad TRD module");
33 :
CbmTrdModuleRec(mod, ly, rot), fDigiCounter(0), fDigiMap(), fClusterMap() {
34 SetNameTitle(Form(
"TrdModuleRecR%02d", mod),
35 "Reconstructor for rectangular pad TRD module");
45 fDigiMap.push_back(std::make_tuple(
id,
false, digi));
52 if (strcmp(opt,
"cls") == 0) {
63 std::deque<std::tuple<Int_t, Bool_t, const CbmTrdDigi*>>::iterator
66 std::deque<std::tuple<Int_t, Bool_t, const CbmTrdDigi*>>::iterator
78 std::deque<std::tuple<Int_t, Bool_t, const CbmTrdDigi*>>::iterator
90 std::deque<std::tuple<Int_t, Bool_t, const CbmTrdDigi*>>::iterator
105 Double_t lasttime = 0;
106 Double_t timediff = -1000;
108 Int_t Clustercount = 0;
110 Bool_t print =
false;
117 std::cout <<
fDigiMap.size() << std::endl;
120 Double_t ptime = digi->
GetTime();
128 std::cout <<
" module: " <<
fModAddress <<
" time: " << ptime
129 <<
" charge: " << Charge <<
" col: " << channel % ncols
130 <<
" row: " << channel / ncols <<
" trigger: " << triggerId
131 <<
" ncols: " << ncols << std::endl;
143 if (lasttime > 0) timediff = time - lasttime;
146 if (timediff > interval && lasttime > 0) { start = mainit; }
148 if (timediff > interval) {
153 if (timediff < interval) stop = mainit;
156 Bool_t marked = std::get<1>(*mainit);
163 Int_t digiId = std::get<0>(*mainit);
168 Int_t lowcol = channel;
169 Int_t highcol = channel;
170 Int_t lowrow = channel;
171 Int_t highrow = channel;
180 Int_t counterrow = 1;
181 Int_t countertop = 0;
182 Int_t counterbot = 0;
183 Double_t buffertop[3] = {0, 0, 0};
184 Double_t bufferbot[3] = {0, 0, 0};
185 Double_t bufferrow[3] = {Charge, 0, 0};
189 Double_t CoGtop = 0.;
190 Double_t CoGbot = 0.;
191 Double_t CoGrow = 0.;
192 std::tuple<const CbmTrdDigi*, const CbmTrdDigi*, const CbmTrdDigi*>
195 std::tuple<const CbmTrdDigi*, const CbmTrdDigi*, const CbmTrdDigi*> botdigi;
205 Bool_t sealbotcol =
false;
206 Bool_t sealtoprow =
false;
207 Bool_t sealbotrow =
false;
208 Bool_t rowchange =
false;
209 Bool_t addtop =
false;
210 Bool_t addbot =
false;
213 std::deque<std::pair<Int_t, const CbmTrdDigi*>> cluster;
214 cluster.push_back(std::make_pair(digiId, digi));
216 std::cout <<
" module: " <<
fModAddress <<
" time: " << time
217 <<
" charge: " << Charge <<
" col: " << channel % ncols
218 <<
" row: " << channel / ncols <<
" trigger: " << triggerId
219 <<
" ncols: " << ncols << std::endl;
223 std::get<1>(*mainit) =
true;
226 Bool_t mergerow =
true;
232 for (FNit = start; FNit !=
fDigiMap.end(); FNit++) {
239 Double_t newtime =
d->GetTime();
240 Double_t dt = newtime - time;
241 Bool_t filled = std::get<1>(*FNit);
242 if (filled)
continue;
243 if (dt < -interval)
continue;
244 if (dt > interval)
break;
247 Double_t charge =
d->GetCharge();
249 Int_t digiid = std::get<0>(*FNit);
250 Int_t ch =
d->GetAddressChannel();
251 Int_t col = ch % ncols;
252 Int_t trigger =
d->GetTriggerType();
258 if (ch == channel - ncols && !rowchange
261 bufferbot[0] = charge;
263 std::get<0>(botdigi) =
d;
265 if (ch == (channel - ncols) - 1 && rowchange && !std::get<1>(*FNit)) {
266 bufferbot[1] = charge;
268 std::get<1>(botdigi) =
d;
270 if (ch == (channel - ncols) + 1 && rowchange && !std::get<1>(*FNit)) {
271 bufferbot[2] = charge;
273 std::get<2>(botdigi) =
d;
275 if (ch == channel + ncols && !rowchange
278 buffertop[0] = charge;
280 std::get<0>(topdigi) =
d;
282 if (ch == (channel + ncols) - 1 && rowchange && !std::get<1>(*FNit)) {
283 buffertop[1] = charge;
285 std::get<1>(topdigi) =
d;
287 if (ch == (channel + ncols) + 1 && rowchange && !std::get<1>(*FNit)) {
288 buffertop[2] = charge;
290 std::get<2>(topdigi) =
d;
293 if (ch == channel - 1) {
294 bufferrow[1] = charge;
296 std::get<1>(topdigi) =
d;
298 if (ch == channel + 1) {
299 bufferrow[2] = charge;
301 std::get<2>(topdigi) =
d;
306 if (countertop == 3) {
308 (buffertop[2] / buffertop[0]) - (buffertop[1] / buffertop[0]);
310 if (counterbot == 3) {
312 (bufferbot[2] / bufferbot[0]) - (bufferbot[1] / bufferbot[0]);
314 if (counterrow == 3) {
316 (bufferrow[2] / bufferrow[0]) - (bufferrow[1] / bufferrow[0]);
318 if (countertop == 3 && counterrow == 3 && !addtop
319 && TMath::Abs((CoGtop - CoGrow)) < 0.25 * CoGrow) {
322 if (counterbot == 3 && counterrow == 3 && !addbot
323 && TMath::Abs((CoGbot - CoGrow)) < 0.25 * CoGrow) {
331 && !std::get<1>(*FNit)) {
332 cluster.push_back(std::make_pair(digiid,
d));
335 std::get<1>(*FNit) =
true;
337 std::cout <<
" time: " << newtime <<
" charge: " << charge
338 <<
" col: " << col <<
" row: " << ch / ncols
339 <<
" trigger: " << trigger << std::endl;
342 && !std::get<1>(*FNit)) {
343 cluster.push_back(std::make_pair(digiid,
d));
346 std::get<1>(*FNit) =
true;
348 std::cout <<
" time: " << newtime <<
" charge: " << charge
349 <<
" col: " << col <<
" row: " << ch / ncols
350 <<
" trigger: " << trigger << std::endl;
353 && !std::get<1>(*FNit) && !sealtopcol) {
354 cluster.push_back(std::make_pair(digiid,
d));
357 std::get<1>(*FNit) =
true;
359 std::cout <<
" time: " << newtime <<
" charge: " << charge
360 <<
" col: " << col <<
" row: " << ch / ncols
361 <<
" trigger: " << trigger << std::endl;
364 && !std::get<1>(*FNit) && !sealbotcol) {
365 cluster.push_back(std::make_pair(digiid,
d));
368 std::get<1>(*FNit) =
true;
370 std::cout <<
" time: " << newtime <<
" charge: " << charge
371 <<
" col: " << col <<
" row: " << ch / ncols
372 <<
" trigger: " << trigger << std::endl;
374 if (col == ncols) { sealtopcol =
true; }
375 if (col == 0) { sealbotcol =
true; }
379 if (ch == channel - ncols && addbot && !std::get<1>(*FNit)) {
380 cluster.push_back(std::make_pair(digiid,
d));
384 std::get<1>(*FNit) =
true;
386 if (ch == channel + ncols && addtop && !std::get<1>(*FNit)) {
387 cluster.push_back(std::make_pair(digiid,
d));
391 std::get<1>(*FNit) =
true;
393 if (rowchange && ch == lowrow - 1 && lowrow != channel
395 cluster.push_back(std::make_pair(digiid,
d));
398 std::get<1>(*FNit) =
true;
400 if (rowchange && ch == highrow + 1 && highrow != channel
402 cluster.push_back(std::make_pair(digiid,
d));
405 std::get<1>(*FNit) =
true;
407 if (rowchange && ch == highrow + 1 && highrow != channel
410 cluster.push_back(std::make_pair(digiid,
d));
413 std::get<1>(*FNit) =
true;
415 if (rowchange && ch == lowrow - 1 && lowrow != channel
418 cluster.push_back(std::make_pair(digiid,
d));
421 std::get<1>(*FNit) =
true;
427 if (((sealbotcol && sealtopcol) && !rowchange) || dmain == 0)
429 if ((sealbotcol && sealtopcol && sealtoprow && sealbotrow) || dmain == 0)
432 if (print) std::cout << dmain << std::endl;
434 if (print) std::cout << dmain << std::endl;
435 if (print) std::cout << std::endl;
454 std::deque<std::pair<Int_t, const CbmTrdDigi*>> cluster) {
456 std::vector<Int_t> digiIndices(cluster.size());
461 for (std::deque<std::pair<Int_t, const CbmTrdDigi*>>::iterator iDigi =
463 iDigi != cluster.end();
466 digiIndices[idigi] = iDigi->first;
473 Int_t size =
fClusters->GetEntriesFast();
490 std::vector<const CbmTrdDigi*>* digis) {
493 TVector3 local_pad_posV;
494 TVector3 local_pad_dposV;
495 for (Int_t iDim = 0; iDim < 3; iDim++) {
496 hit_posV[iDim] = 0.0;
497 local_pad_posV[iDim] = 0.0;
498 local_pad_dposV[iDim] = 0.0;
503 Double_t totalCharge = 0;
508 Int_t errorclass = 0.;
511 for (std::vector<const CbmTrdDigi*>::iterator
id = digis->begin();
517 std::cout <<
" no digi " << std::endl;
527 if (digiCharge <= 0.05) {
continue; }
537 Double_t xMin = local_pad_posV[0] - local_pad_dposV[0];
538 Double_t xMax = local_pad_posV[0] + local_pad_dposV[0];
539 xVar += (xMax * xMax + xMax * xMin + xMin * xMin) * digiCharge;
541 Double_t yMin = local_pad_posV[1] - local_pad_dposV[1];
542 Double_t yMax = local_pad_posV[1] + local_pad_dposV[1];
543 yVar += (yMax * yMax + yMax * yMin + yMin * yMin) * digiCharge;
545 for (Int_t iDim = 0; iDim < 3; iDim++) {
546 hit_posV[iDim] += local_pad_posV[iDim] * digiCharge;
549 time /= digis->size();
551 if (totalCharge <= 0)
return NULL;
554 for (Int_t iDim = 0; iDim < 3; iDim++) {
555 hit_posV[iDim] /= totalCharge;
556 hit_pos[iDim] = hit_posV[iDim];
571 TVector3 cluster_pad_dposV(xVar, yVar, 0);
579 global[0] = global[0] + (0.00214788 + global[0] * 0.000195394);
580 global[1] = global[1] + (0.00370566 + global[1] * 0.000213235);
592 Int_t nofHits =
fHits->GetEntriesFast();
597 return new ((*fHits)[nofHits])
610 std::pair<Double_t, Double_t> res[12] = {std::make_pair(0.5, 0.4),
611 std::make_pair(1, 0.35),
612 std::make_pair(2, 0.3),
613 std::make_pair(2.5, 0.3),
614 std::make_pair(3.5, 0.28),
615 std::make_pair(4.5, 0.26),
616 std::make_pair(5.5, 0.26),
617 std::make_pair(6.5, 0.26),
618 std::make_pair(7.5, 0.26),
619 std::make_pair(8.5, 0.26),
620 std::make_pair(8.5, 0.26),
621 std::make_pair(9.5, 0.26)};
623 Double_t selval = 0.;
625 for (Int_t n = 0; n < 12; n++) {
626 if (val < res[0].
first) selval = res[0].second;
628 selval = res[11].second;
631 if (val >= res[n].
first && val <= res[n + 1].
first) {
632 Double_t dx = res[n + 1].first - res[n].first;
633 Double_t dy = res[n + 1].second - res[n].second;
634 Double_t slope = dy / dx;
635 selval = (val - res[n].first) * slope + res[n].second;