17 #include <FairLogger.h>
20 #include <TClonesArray.h>
21 #include <TGeoManager.h>
24 #include <TStopwatch.h>
38 , fSigma_noise_keV(0.2)
39 , fMinimumChargeTH(.5e-06)
62 , fDistributionMode(4)
63 , fCrosstalkLevel(0.01)
68 , nofPointsAboveThreshold(0)
81 FairRootManager* ioman = FairRootManager::Instance();
85 SetNameTitle(Form(
"TrdSimR%d", mod),
"Simulator for rectangular read-out.");
87 TFile* oldFile = gFile;
89 TString dir = getenv(
"VMCWORKDIR");
90 TString filename = dir +
"/parameters/trd/FeatureExtractionLookup.root";
91 TFile*
f =
new TFile(filename,
"OPEN");
112 Double_t weighting = charge;
114 TVector3 padPos, padPosErr;
117 sqrt(pow(
fXYZ[0] - padPos[0], 2) + pow(
fXYZ[1] - padPos[1], 2));
118 weighting = 1. / distance;
129 for (Int_t isec(0); isec < sec; isec++)
131 channel += ncols * row + col;
133 std::map<Int_t, std::pair<CbmTrdDigi*, CbmMatch*>>::iterator it =
149 fDigiMap[address] = std::make_pair(digi, digiMatch);
156 it->second.first->AddCharge(charge * 1e6);
157 it->second.second->AddLink(
165 std::vector<std::pair<CbmTrdDigi*, CbmMatch*>> analog =
167 std::vector<std::pair<CbmTrdDigi*, CbmMatch*>>::iterator it;
173 Float_t digicharge = 0;
175 for (it = analog.begin(); it != analog.end(); it++) {
176 digicharge += it->first->GetCharge();
177 digiMatch->
AddLink(it->second->GetLink(0));
187 fDigiMap[address] = std::make_pair(digi, digiMatch);
195 Bool_t MultiCall =
false,
199 std::map<Int_t, std::pair<std::vector<Double_t>,
CbmMatch*>>::iterator iBuff =
201 std::map<Int_t, Double_t>::iterator tBuff =
fTimeBuffer.find(address);
207 if (trigger == 0 && !FNcall) {
return; }
208 if (trigger == 1 && FNcall) { FNcall =
false; }
215 for (Int_t isec(0); isec < sec; isec++)
217 channel += ncols * row + col;
221 std::vector<Int_t> temp;
224 Int_t cross =
AddCrosstalk(address,
i, sec, row, col, ncols);
237 if (
fDebug && trigger == 1)
239 if (
fDebug && trigger == 0)
252 if (
fTimeBuffer[address] + corr - shift < fTimeSlice->GetStartTime()) {
275 Int_t shiftcut =
fShiftQA[address] * 10;
276 Float_t timeshift = shiftcut / 10;
280 std::vector<CbmLink> links =
fPulseBuffer[address].second->GetLinks();
282 for (UInt_t iLinks = 0; iLinks < links.size(); iLinks++) {
283 digiMatch->
AddLink(links[iLinks]);
293 fQA->
Fill(
"T res", shift - timeshift);
304 if (trigger == 1 && MultiCall && digi->
GetCharge() > 0.)
309 if (trigger == 1 && !MultiCall) {
317 fQA->
CreateHist(
"Charge Max", 200, 0., 50.0, 512, -12., 500.);
321 fQA->
CreateHist(
"Links Res Self", 400., -1., 1., 5, -0.5, 4.5);
333 if (
fLinkQA[address].size() == 2
334 &&
fLinkQA[address][1][
"Event"] !=
fLinkQA[address][0][
"Event"]) {
335 fQA->
CreateHist(
"Links QA time", 400., -1., 1., 500, 0., 2000.);
349 if (Links == 2 && links[0].GetEntry() == links[1].GetEntry()) {
354 if (Links == 2 && links[0].GetEntry() != links[1].GetEntry()) {
364 fQA->
CreateHist(
"E FN MC max", 512, -12., 500., 200, 0., 50.);
371 fQA->
CreateHist(
"Links Res FN", 400., -1., 1., 5, -0.5, 4.5);
382 if (
fLinkQA[address].size() == 2
383 &&
fLinkQA[address][1][
"Event"] !=
fLinkQA[address][0][
"Event"]) {
384 fQA->
CreateHist(
"Links QA time FN", 400., -1., 1., 500, 0., 2000.);
399 fMCQA.erase(address);
416 std::cout <<
"main call charge: " << digi->
GetCharge()
419 <<
" trigger: " << trigger <<
" time: " << digi->
GetTime()
422 std::cout <<
"FN call charge: " << digi->
GetCharge()
425 <<
" trigger: " << trigger <<
" time: " << digi->
GetTime()
431 fDigiMap[address] = std::make_pair(digi, digiMatch);
435 if (!FNcall && !MultiCall && trigger == 1) {
453 if (col < (ncols - 1))
468 if (!FNcall && MultiCall && trigger == 1) {
485 if (col < (ncols - 1))
508 Double_t weighting = charge;
510 TVector3 padPos, padPosErr;
513 sqrt(pow(
fXYZ[0] - padPos[0], 2) + pow(
fXYZ[1] - padPos[1], 2));
514 weighting = 1. / distance;
518 Bool_t eventtime =
false;
519 if (time > 0.000) eventtime =
true;
533 for (Int_t isec(0); isec < sec; isec++)
535 channel += ncols * row + col;
551 fAnalogBuffer[address].push_back(std::make_pair(digi, digiMatch));
566 Double_t weighting = charge *
fepoints;
568 TVector3 padPos, padPosErr;
571 sqrt(pow(
fXYZ[0] - padPos[0], 2) + pow(
fXYZ[1] - padPos[1], 2));
572 weighting = 1. / distance;
580 if (gotMulti)
fMCBuffer[address].clear();
592 for (
auto ini = 0; ini < 3; ini++) {
593 std::vector<Int_t>
v;
596 std::vector<Double_t> pulse;
599 if (pulse.size() < 32)
return;
601 Bool_t found =
false;
602 for (Int_t links = 0; links <
fPulseBuffer[address].second->GetNofLinks();
610 std::map<TString, Int_t> LinkQA;
614 LinkQA[
"Charge"] = charge * 1e6 *
fepoints;
617 fLinkQA[address].push_back(LinkQA);
622 pulse =
MakePulse(charge, pulse, address);
628 std::vector<std::map<TString, Int_t>> vecLink;
629 std::map<TString, Int_t> LinkQA;
633 LinkQA[
"Charge"] = charge * 1e6 *
fepoints;
636 vecLink.push_back(LinkQA);
649 std::vector<Double_t> pulse,
653 for (Int_t
i = 0;
i < 32;
i++)
663 for (Int_t
i = 0;
i < 32;
i++) {
681 for (Int_t
i = 0;
i < 32;
i++) {
682 pulse.push_back(sample[
i]);
694 std::vector<Double_t> pulse) {
697 std::vector<Double_t> temppulse;
698 for (Int_t
i = 0;
i < 32;
i++)
699 temppulse.push_back(pulse[
i]);
702 Double_t timeshift = ((Int_t)((dt + reldrift) * 10)
705 if (startbin > 31 || dt < 0.)
return;
708 for (Int_t
i = 0;
i < 32;
i++) {
710 pulse[
i] = temppulse[
i];
737 if (comptrigger == 0 && trigger == 1) {
738 for (Int_t
i = 0;
i < 32;
i++) {
744 pulse[
i] = temppulse[
i + startbin];
748 Int_t shift = startbin +
i;
787 std::vector<Double_t> pulse) {
789 Bool_t processed =
false;
799 Double_t timeshift = ((Int_t)(
fMultiBuffer[address].second * 10)
803 std::vector<Double_t> temppulse;
804 std::map<Int_t, std::vector<Double_t>> templow;
805 std::map<Int_t, std::vector<Double_t>> temphigh;
808 for (Int_t
i = 0;
i < 32;
i++) {
810 fQA->
CreateHist(
"Multi self", 32, -0.5, 31.5, 512, -12., 500.);
812 if (
i >= shift) pulse[
i] = 0.;
822 Double_t FNshift = 0;
823 std::vector<Double_t> FNpulse =
fPulseBuffer[address].first;
833 while (FNtrigger == 1 && FNaddress != 0) {
845 templow[FNaddress] = FNpulse;
849 for (Int_t
i = 0;
i < 32;
i++) {
850 if (
i >= FNshift) FNpulse[
i] = 0.;
861 if (col < (ncols - 1))
870 while (FNtrigger == 1 && FNaddress != 0) {
871 if (col < (ncols - 1))
882 temphigh[FNaddress] = FNpulse;
886 for (Int_t
i = 0;
i < 32;
i++) {
887 if (
i >= FNshift) FNpulse[
i] = 0.;
891 if (col == ncols - 1)
break;
895 for (Int_t
i = 0;
i < 32;
i++) {
933 for (Int_t
i = 0;
i < 32;
i++) {
935 fQA->
CreateHist(
"Multi self after", 32, -0.5, 31.5, 512, -12., 500.);
951 while (FNtrigger == 1 && FNaddress != 0) {
952 if (col < (ncols - 1))
963 for (Int_t
i = 0;
i < 32;
i++) {
964 if (
i <
fPresamples && temphigh[FNaddress].size() > 0.) {
969 if ((
size_t) shift +
i -
fPresamples < temphigh[FNaddress].size())
985 if ((
size_t) shift +
i -
fPresamples < temphigh[FNaddress].size())
1014 for (UInt_t links = 0; links <
fMCBuffer[FNaddress][0].size(); links++)
1021 std::vector<std::map<TString, Int_t>> vecLink;
1022 std::map<TString, Int_t> LinkQA;
1027 vecLink.push_back(LinkQA);
1035 if (col == ncols - 1)
break;
1047 while (FNtrigger == 1 && FNaddress != 0) {
1059 for (Int_t
i = 0;
i < 32;
i++) {
1060 if (
i <
fPresamples && templow[FNaddress].size() > 0.) {
1065 if ((
size_t) shift +
i -
fPresamples < templow[FNaddress].size())
1081 if ((
size_t) shift +
i -
fPresamples < templow[FNaddress].size())
1098 for (UInt_t links = 0; links <
fMCBuffer[FNaddress][0].size(); links++)
1105 std::vector<std::map<TString, Int_t>> vecLink;
1106 std::map<TString, Int_t> LinkQA;
1111 vecLink.push_back(LinkQA);
1119 if (col == 0)
break;
1124 for (UInt_t links = 0; links <
fMCBuffer[address][0].size(); links++)
1131 std::vector<std::map<TString, Int_t>> vecLink;
1132 std::map<TString, Int_t> LinkQA;
1137 vecLink.push_back(LinkQA);
1148 Bool_t trigger =
false;
1149 Bool_t falling =
false;
1150 Bool_t multihit =
false;
1151 for (
size_t i = 0;
i < pulse.size();
i++) {
1152 if (
i < pulse.size() - 1) slope = pulse[
i + 1] - pulse[
i];
1154 if (slope < 0 && trigger) falling =
true;
1159 if (!trigger && !multihit)
return 0;
1160 if (trigger && !multihit)
return 1;
1161 if (trigger && multihit)
return 2;
1170 Bool_t trigger =
false;
1171 Bool_t falling =
false;
1172 for (
size_t i = 0;
i < pulse.size();
i++) {
1173 if (
i < 31) slope = pulse[
i + 1] - pulse[
i];
1175 if (slope < 0 && trigger) falling =
true;
1187 Double_t SqrtK3 =
sqrt(K3);
1190 -1. / (2. * atan(SqrtK3))
1192 * tanh(
TMath::Pi() * (-2. + SqrtK3) * (W + 2. *
x) / (8. *
h)))
1194 * tanh(
TMath::Pi() * (-2. + SqrtK3) * (W - 2. *
x) / (8. *
h)))));
1201 return (t /
fTau) * TMath::Exp(-(t /
fTau));
1203 return (t /
fTau) * (t /
fTau) * TMath::Exp(-(t /
fTau));
1208 Double_t pointout[3],
1213 for (Int_t
i = 0;
i < 3;
i++) {
1215 pointin[
i] + (0.01) * delta[
i] + 0.95 * delta[
i] /
fepoints * ipoints;
1220 for (Int_t
i = 0;
i < 3;
i++) {
1221 pos[
i] = pointin[
i] + 0.5 * delta[
i];
1228 Double_t lastpos[3] = {pointin[0], pointin[1], pointin[2]};
1229 Double_t dist_gas = TMath::Sqrt(delta[0] * delta[0] + delta[1] * delta[1]
1230 + delta[2] * delta[2]);
1232 for (Int_t
i = 0;
i < 3;
i++)
1233 lastpos[
i] =
pos[
i];
1234 Double_t roll = gRandom->Integer(100);
1235 Double_t s = (
GetStep(dist_gas, roll) / dist_gas) / 2;
1239 || (lastpos[2] + s * delta[2]) >= pointout[2]) {
1240 for (Int_t
i = 0;
i < 3;
i++) {
1241 pos[
i] = lastpos[
i];
1245 for (Int_t
i = 0;
i < 3;
i++)
1246 pos[
i] = lastpos[
i] + s * delta[
i];
1252 for (Int_t
i = 0;
i < 3;
i++) {
1253 pos[
i] = pointin[
i] + (0.5 + ipoints) * delta[
i];
1271 std::vector<Int_t> recomask;
1273 recomask.push_back(
i);
1282 TString dir = getenv(
"VMCWORKDIR");
1283 TString filename = dir +
"/parameters/trd/FeatureExtractionLookup.root";
1300 const Double_t nClusterPerCm = 1.0;
1302 Double_t point_out[3] = {
1304 Double_t local_point_out[3];
1305 Double_t local_point_in[3];
1307 gGeoManager->MasterToLocal(point_in, local_point_in);
1308 gGeoManager->MasterToLocal(point_out, local_point_out);
1311 for (Int_t
i = 0;
i < 3;
i++)
1313 for (Int_t
i = 0;
i < 3;
i++)
1320 Double_t ELoss(0.), ELossTR(0.), ELossdEdX(point->GetEnergyLoss());
1327 }
else if (point_out[2]
1330 point->Momentum(mom);
1334 ELoss = ELossTR + ELossdEdX;
1343 Double_t cluster_delta
1346 Double_t trackLength = 0;
1348 for (Int_t
i = 0;
i < 3;
i++) {
1349 cluster_delta[
i] = (local_point_out[
i] - local_point_in[
i]);
1350 trackLength += cluster_delta[
i] * cluster_delta[
i];
1352 trackLength = TMath::Sqrt(trackLength);
1354 trackLength / nClusterPerCm
1361 if (nCluster < 1) {
return kFALSE; }
1364 for (Int_t
i = 0;
i < 3;
i++) {
1365 cluster_delta[
i] /= Double_t(nCluster);
1368 Double_t clusterELoss = ELoss / Double_t(nCluster);
1369 Double_t clusterELossTR = ELossTR / Double_t(nCluster);
1379 std::vector<Double_t> vec;
1380 std::pair<Int_t, std::vector<Double_t>> steps = std::make_pair(0, vec);
1382 Double_t dist_gas = TMath::Sqrt(cluster_delta[0] * cluster_delta[0]
1383 + cluster_delta[1] * cluster_delta[1]
1384 + cluster_delta[2] * cluster_delta[2]);
1385 steps = (
GetTotalSteps(local_point_in, local_point_out, dist_gas));
1386 epoints = steps.first;
1391 if (
fDebug)
fQA->
Fill(
"Dist Ionization", steps.first, dist_gas);
1395 clusterELoss = ELoss / epoints;
1396 clusterELossTR = ELossTR / epoints;
1400 for (Int_t ipoints = 0; ipoints < epoints; ipoints++) {
1402 local_point_in, local_point_out, cluster_delta, cluster_pos, ipoints);
1405 for (Int_t
i = 0;
i < 3;
i++)
1406 cluster_pos[
i] = steps.second[
i + ipoints * 3];
1410 printf(
"-> nC %i/%i x: %7.3f y: %7.3f \n",
1415 for (Int_t
i = 0;
i < 3;
i++)
1416 printf(
" (%i) | in: %7.3f + delta: %7.3f * cluster: %i/%i = "
1417 "cluster_pos: %7.3f out: %7.3f g_in:%f g_out:%f\n",
1430 Int_t noiserate = gRandom->Uniform(0, 3);
1432 for (Int_t ndigi = 0; ndigi < noiserate; ndigi++) {
1439 cluster_pos, 0., clusterELoss, clusterELossTR, epoints, ipoints);
1443 Double_t driftcomp = 10000;
1445 Double_t Ionizations[epoints][3];
1447 for (Int_t ipoints = 0; ipoints < epoints; ipoints++) {
1449 local_point_in, local_point_out, cluster_delta, cluster_pos, ipoints);
1452 for (Int_t
i = 0;
i < 3;
i++)
1453 cluster_pos[
i] = steps.second[
i + ipoints * 3];
1454 for (Int_t
i = 0;
i < 3;
i++)
1455 Ionizations[ipoints][
i] = cluster_pos[
i];
1459 printf(
"-> nC %i/%i x: %7.3f y: %7.3f \n",
1464 for (Int_t
i = 0;
i < 3;
i++)
1465 printf(
" (%i) | in: %7.3f + delta: %7.3f * cluster: %i/%i = "
1466 "cluster_pos: %7.3f out: %7.3f g_in:%f g_out:%f\n",
1479 Int_t relz = 239 - (cluster_pos[2] - local_point_in[2]) / 0.005;
1480 if (relz > 239 || relz < 0) relz = 239;
1483 TMath::Abs(
double(
int(cluster_pos[0] * 1000000)
1487 if (TMath::Abs(
AddDrifttime(Drift_x, cluster_pos[2])) < driftcomp
1488 && TMath::Abs(
AddDrifttime(Drift_x, cluster_pos[2])) > 0.) {
1489 driftcomp = TMath::Abs(
AddDrifttime(Drift_x, cluster_pos[2]));
1494 if (start == -1)
return false;
1495 for (Int_t
i = 0;
i < 3;
i++)
1496 cluster_pos[
i] = Ionizations[start][
i];
1498 Int_t relz = 239 - (cluster_pos[2] - local_point_in[2]) / 0.005;
1499 if (relz > 239 || relz < 0) relz = 239;
1501 TMath::Abs(
double(
int(cluster_pos[0] * 1000000)
1505 TMath::Abs(
AddDrifttime(Drift_x, cluster_pos[2]) - driftcomp) * 1000;
1508 if (reldrift < 250.)
1510 cluster_pos, 0., clusterELoss, clusterELossTR, epoints, start);
1513 for (Int_t ipoints = 0; ipoints < epoints; ipoints++) {
1514 if (ipoints == start)
continue;
1515 for (Int_t
i = 0;
i < 3;
i++)
1516 cluster_pos[
i] = Ionizations[ipoints][
i];
1518 relz = 239 - (cluster_pos[2] - local_point_in[2]) / 0.005;
1519 if (relz > 239 || relz < 0) relz = 239;
1520 Drift_x = TMath::Abs(
double(
int(cluster_pos[0] * 1000000)
1524 TMath::Abs(
AddDrifttime(Drift_x, cluster_pos[2]) - driftcomp) * 1000;
1525 if (reldrift < 250.)
1547 Double_t clusterELoss,
1548 Double_t clusterELossTR,
1551 Int_t sectorId(-1), columnId(-1), rowId(-1);
1553 if (sectorId < 0 && columnId < 0 && rowId < 0) {
1556 for (Int_t
i = 0;
i < sectorId;
i++) {
1562 Double_t displacement_x(0), displacement_y(0);
1571 Int_t startRow(rowId - maxRow / 2);
1573 Int_t secRow(-1), targCol(-1), targRow(-1), targSec(-1), address(-1),
1576 for (Int_t iRow = startRow; iRow <= rowId + maxRow / 2; iRow++) {
1577 Int_t iCol = columnId;
1578 if (((iCol >= 0) && (iCol <= fnCol - 1))
1579 && ((iRow >= 0) && (iRow <= fnRow - 1))) {
1592 }
else if (iCol > fnCol - 1) {
1593 targCol = fnCol - 1;
1597 }
else if (iRow > fnRow - 1) {
1598 targRow = fnRow - 1;
1610 Bool_t print =
false;
1613 Float_t chargeFraction = 0;
1620 chargeFraction =
CalcPRF((iCol - columnId) * W - displacement_x, W,
h)
1621 *
CalcPRF((iRow - rowId) * H - displacement_y, H,
h);
1623 sum += chargeFraction;
1625 ch = chargeFraction * clusterELoss;
1626 tr = chargeFraction * clusterELossTR;
1628 Bool_t lowerend =
false;
1629 Bool_t upperend =
false;
1641 std::cout <<
" time: " <<
fCurrentTime <<
" col: " << iCol
1642 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1643 <<
" charge: " << ch * 1e6 <<
" 1 " << std::endl;
1650 address, reldrift, ch, tr,
fCurrentTime, Int_t(1), epoints, ipoint);
1654 address, reldrift, ch, tr,
fCurrentTime, Int_t(1), epoints, ipoint);
1655 std::cout <<
" time: " <<
fCurrentTime <<
" col: " << iCol
1656 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1657 <<
" charge: " << ch * 1e6 <<
" 1 " << std::endl;
1662 if ((((iCol - collow) >= 0) && ((iCol - collow) <= fnCol - 1))
1663 && ((iRow >= 0) && (iRow <= fnRow - 1))) {
1677 CalcPRF(((iCol - collow) - columnId) * W - displacement_x, W,
h)
1678 *
CalcPRF((iRow - rowId) * H - displacement_y, H,
h);
1679 sum += chargeFraction;
1680 ch = chargeFraction * clusterELoss;
1681 tr = chargeFraction * clusterELossTR;
1696 std::cout <<
" time: " <<
fCurrentTime <<
" col: " << iCol - collow
1697 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1698 <<
" charge: " << ch * 1e6 <<
" 1 " << std::endl;
1704 std::cout <<
" time: " <<
fCurrentTime <<
" col: " << iCol - collow
1705 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1706 <<
" charge: " << ch * 1e6 <<
" 0 " << std::endl;
1746 std::cout <<
" time: " <<
fCurrentTime <<
" col: " << iCol - collow
1747 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1748 <<
" charge: " << ch * 1e6 <<
" 1 " << std::endl;
1760 std::cout <<
" time: " <<
fCurrentTime <<
" col: " << iCol - collow
1761 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1762 <<
" charge: " << ch * 1e6 <<
" 0 " << std::endl;
1777 if ((((iCol + colhigh) >= 0) && ((iCol + colhigh) <= fnCol - 1))
1778 && ((iRow >= 0) && (iRow <= fnRow - 1))) {
1792 CalcPRF(((iCol + colhigh) - columnId) * W - displacement_x, W,
h)
1793 *
CalcPRF((iRow - rowId) * H - displacement_y, H,
h);
1794 sum += chargeFraction;
1795 ch = chargeFraction * clusterELoss;
1796 tr = chargeFraction * clusterELossTR;
1811 <<
" col: " << iCol + colhigh
1812 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1813 <<
" charge: " << ch * 1e6 <<
" 1 " << std::endl;
1820 <<
" col: " << iCol + colhigh
1821 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1822 <<
" charge: " << ch * 1e6 <<
" 0 " << std::endl;
1850 if (ipoint == epoints - 1 && epoints > 1)
1859 if (ipoint != epoints - 1 && epoints > 1)
1882 <<
" col: " << iCol + colhigh
1883 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1884 <<
" charge: " << ch * 1e6 <<
" 1 " << std::endl;
1897 <<
" col: " << iCol + colhigh
1898 <<
" row: " << iRow - rowId <<
" secrow: " << secRow
1899 <<
" charge: " << ch * 1e6 <<
" 0 " << std::endl;
1900 if (ipoint == epoints - 1 && epoints > 1)
1909 if (ipoint != epoints - 1 && epoints > 1)
1931 if (print) std::cout << std::endl;
1945 LOG(warn) << GetName() <<
"::SetAsicPar : No Digi params for module "
1946 <<
fModAddress <<
". Try calling first CbmTrdModSim::SetDigiPar.";
1951 LOG(warn) << GetName() <<
"::SetAsicPar : The list for module "
1958 Int_t iFebGroup = 0;
1966 Int_t rowId(0), isecId(0), irowId(0), iAsic(0);
1973 if ((rowId % gRow[iFebGroup]) == 0) {
1974 if ((c % gCol[iFebGroup]) == 0) {
1975 xAsic = c + gCol[iFebGroup] / 2.;
1976 yAsic = r + gRow[iFebGroup] / 2.;
1978 Double_t local_point[3];
1984 local_point[0] = ((Int_t)(xAsic + 0.5) * padsizex);
1985 local_point[1] = ((Int_t)(yAsic + 0.5) * padsizey);
1995 iAsic, iFebGroup, local_point[0] - fDx, local_point[1] - fDy);
1997 if (local_point[0] > 2 * fDx) {
1998 LOG(error) <<
"CbmTrdModuleSimR::SetAsicPar: asic position x="
1999 << local_point[0] <<
" is out of bounds [0," << 2 * fDx
2003 if (local_point[1] > 2 * fDy) {
2004 LOG(error) <<
"CbmTrdModuleSimR::SetAsicPar: asic position y="
2005 << local_point[1] <<
" is out of bounds [0," << 2 * fDy
2009 for (Int_t ir = rowId; ir < rowId + gRow[iFebGroup]; ir++) {
2010 for (Int_t ic = c; ic < c + gCol[iFebGroup]; ic++) {
2012 LOG(error) <<
"CbmTrdModuleSimR::SetAsicPar: ir " << ir
2013 <<
" is out of bounds!";
2015 LOG(error) <<
"CbmTrdModuleSimR::SetAsicPar: ic " << ic
2016 <<
" is out of bounds!";
2026 printf(
" M:%10i(%4i) s: %i irowId: %4i ic: "
2027 "%4i r: %4i c: %4i address:%10i\n",
2051 for (Int_t r = 0; r < nRow; r++) {
2052 for (Int_t c = 0; c < nCol; c++) {
2056 LOG(error) <<
"CbmTrdModuleSimR::SetAsicPar: Channel address:"
2058 <<
" is not or multible initialized in module "
2061 <<
"(s:" << s <<
", r:" << r <<
", c:" << c <<
")";
2114 if (row % 2 == 0) row += 1;
2123 Double_t noise = gRandom->Gaus(
2140 Int_t noise = gRandom->Gaus(0,
fAdcNoise);
2147 std::vector<Double_t>
2169 Double_t cross = 0.;
2171 Int_t FNaddress = 0;
2183 if (col < (ncols - 1))
2200 std::map<Int_t, Double_t>::iterator timeit;
2201 std::vector<Int_t> toBeErased;
2203 Bool_t done =
false;
2208 Int_t add = timeit->first;
2215 toBeErased.push_back(add);
2218 std::vector<Double_t> pulse;
2238 for (
auto& address : toBeErased) {
2245 Bool_t closeTS(kFALSE);
2251 if (closeTS || time == 0) {
2252 std::map<Int_t, Double_t>::iterator timeit;
2253 Bool_t done =
false;
2259 Int_t add = timeit->first;
2262 std::vector<Double_t> pulse;
2275 std::map<Int_t, std::pair<std::vector<Double_t>,
CbmMatch*>>::iterator
2294 std::map<Int_t, Double_t>::iterator timeit;
2296 std::vector<Int_t> erase_list;
2300 Int_t add = timeit->first;
2304 erase_list.push_back(add);
2309 erase_list.push_back(add);
2314 for (UInt_t
i = 0;
i < erase_list.size();
i++) {
2328 std::map<Int_t, Double_t>::iterator timeit;
2371 Double_t drifttime[241] = {
2372 0.11829, 0.11689, 0.11549, 0.11409, 0.11268, 0.11128, 0.10988,
2373 0.10847, 0.10707, 0.10567, 0.10427, 0.10287, 0.10146, 0.10006,
2374 0.09866, 0.09726, 0.095859, 0.094459, 0.09306, 0.091661, 0.090262,
2375 0.088865, 0.087467, 0.086072, 0.084677, 0.083283, 0.08189, 0.080499,
2376 0.07911, 0.077722, 0.076337, 0.074954, 0.073574, 0.072197, 0.070824,
2377 0.069455, 0.06809, 0.066731, 0.065379, 0.064035, 0.0627, 0.061376,
2378 0.060063, 0.058764, 0.05748, 0.056214, 0.054967, 0.053743, 0.052544,
2379 0.051374, 0.05024, 0.049149, 0.048106, 0.047119, 0.046195, 0.045345,
2380 0.044583, 0.043925, 0.043403, 0.043043, 0.042872, 0.042932, 0.043291,
2381 0.044029, 0.045101, 0.04658, 0.048452, 0.050507, 0.052293, 0.053458,
2382 0.054021, 0.053378, 0.052139, 0.53458, 0.050477, 0.048788, 0.047383,
2383 0.046341, 0.045631, 0.045178, 0.045022, 0.045112, 0.045395, 0.045833,
2384 0.046402, 0.047084, 0.047865, 0.048726, 0.049651, 0.050629, 0.051654,
2385 0.052718, 0.053816, 0.054944, 0.056098, 0.057274, 0.058469, 0.059682,
2386 0.060909, 0.062149, 0.0634, 0.064661, 0.06593, 0.067207, 0.06849,
2387 0.069778, 0.07107, 0.072367, 0.073666, 0.074968, 0.076272, 0.077577,
2388 0.078883, 0.080189, 0.081495, 0.082801, 0.084104, 0.085407, 0.086707,
2389 0.088004, 0.089297, 0.090585, 0.091867, 0.093142, 0.094408, 0.095664,
2390 0.096907, 0.098134, 0.099336, 0.10051, 0.10164, 0.10273, 0.10375,
2391 0.10468, 0.10548, 0.10611, 0.10649, 0.10655, 0.10608, 0.10566,
2392 0.1072, 0.10799, 0.10875, 0.11103, 0.11491, 0.11819, 0.12051,
2393 0.12211, 0.12339, 0.12449, 0.12556, 0.12663, 0.12771, 0.12881,
2394 0.12995, 0.13111, 0.13229, 0.13348, 0.13468, 0.13589, 0.13711,
2395 0.13834, 0.13957, 0.1408, 0.14204, 0.14328, 0.14452, 0.14576,
2396 0.14701, 0.14825, 0.1495, 0.15075, 0.152, 0.15325, 0.1545,
2397 0.15576, 0.15701, 0.15826, 0.15952, 0.16077, 0.16203, 0.16328,
2398 0.16454, 0.16579, 0.16705, 0.1683, 0.16956, 0.17082, 0.17207,
2399 0.17333, 0.17458, 0.17584, 0.1771, 0.17835, 0.17961, 0.18087,
2400 0.18212, 0.18338, 0.18464, 0.18589, 0.18715, 0.18841, 0.18966,
2401 0.19092, 0.19218, 0.19343, 0.19469, 0.19595, 0.19721, 0.19846,
2402 0.19972, 0.20098, 0.20223, 0.20349, 0.20475, 0.20601, 0.20726,
2403 0.20852, 0.20978, 0.21103, 0.21229, 0.21355, 0.2148, 0.21606,
2404 0.21732, 0.21857, 0.21983, 0.22109, 0.22234, 0.2236, 0.22486,
2405 0.22612, 0.22737, 0.22863, 0.22989, 0.23114, 0.2324, 0.23366,
2406 0.23491, 0.23617, 0.2363};
2411 return drifttime[Int_t(
x)];
2419 Double_t CalcGamma = 0.;
2421 std::pair<Double_t, Double_t> bethe[12] = {std::make_pair(1.5, 1.5),
2422 std::make_pair(2, 1.1),
2423 std::make_pair(3, 1.025),
2424 std::make_pair(4, 1),
2425 std::make_pair(10, 1.1),
2426 std::make_pair(20, 1.2),
2427 std::make_pair(100, 1.5),
2428 std::make_pair(200, 1.6),
2429 std::make_pair(300, 1.65),
2430 std::make_pair(400, 1.675),
2431 std::make_pair(500, 1.7),
2432 std::make_pair(1000, 1.725)};
2434 for (Int_t n = 0; n < 12; n++) {
2435 if (
fGamma < bethe[0].
first) CalcGamma = bethe[0].second;
2437 CalcGamma = bethe[11].second;
2442 Double_t dx = bethe[n + 1].first - bethe[n].first;
2443 Double_t dy = bethe[n + 1].second - bethe[n].second;
2444 Double_t slope = dy / dx;
2445 CalcGamma = (
fGamma - bethe[n].first) * slope + bethe[n].second;
2451 Double_t D = 1 / (20.5 * CalcGamma);
2452 for (Int_t
i = 1;
i < steps;
i++) {
2453 s = (dist / steps) *
i;
2454 prob = (1 - TMath::Exp(-s / D)) * 100;
2455 if (prob >= roll)
return s;
2461 std::pair<Int_t, std::vector<Double_t>>
2467 Double_t CalcGamma = 0.;
2468 Double_t roll = gRandom->Integer(100);
2470 std::pair<Double_t, Double_t> bethe[12] = {std::make_pair(1.5, 1.5),
2471 std::make_pair(2, 1.1),
2472 std::make_pair(3, 1.025),
2473 std::make_pair(4, 1),
2474 std::make_pair(10, 1.1),
2475 std::make_pair(20, 1.2),
2476 std::make_pair(100, 1.5),
2477 std::make_pair(200, 1.6),
2478 std::make_pair(300, 1.65),
2479 std::make_pair(400, 1.675),
2480 std::make_pair(500, 1.7),
2481 std::make_pair(1000, 1.725)};
2483 for (Int_t n = 0; n < 12; n++) {
2484 if (
fGamma < bethe[0].
first) CalcGamma = bethe[0].second;
2486 CalcGamma = bethe[11].second;
2491 Double_t dx = bethe[n + 1].first - bethe[n].first;
2492 Double_t dy = bethe[n + 1].second - bethe[n].second;
2493 Double_t slope = dy / dx;
2494 CalcGamma = (
fGamma - bethe[n].first) * slope + bethe[n].second;
2499 Double_t
pos[3] = {In[0], In[1], In[2]};
2500 Double_t lastpos[3] = {In[0], In[1], In[2]};
2501 Int_t pointcount = 0;
2502 std::vector<Double_t> posvec;
2503 Double_t D = 1 / (20.5 * CalcGamma);
2506 for (Int_t
i = 0;
i < 3;
i++)
2507 delta[
i] = (Out[
i] - In[
i]);
2509 roll = gRandom->Integer(100);
2510 for (Int_t
i = 1;
i < steps;
i++) {
2511 s = (dist / steps) *
i;
2512 prob = (1 - TMath::Exp(-s / D)) * 100;
2514 Double_t move = 2 * (s / dist);
2515 for (Int_t n = 0; n < 3; n++)
2516 pos[n] = lastpos[n] + move * delta[n];
2517 for (Int_t n = 0; n < 3; n++)
2518 lastpos[n] =
pos[n];
2522 posvec.push_back(
pos[0]);
2523 posvec.push_back(
pos[1]);
2524 posvec.push_back(
pos[2]);
2527 roll = gRandom->Integer(100);
2538 return std::make_pair(pointcount, posvec);