1054 UInt_t uChanUId = 0x00002806;
1056 const Double_t dHitTot = 2.;
1061 LOG(debug) << Form(
"Add fake diamond digis 0x%08x mode with t = %7.3f", uChanUId, dHitTime);
1069 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
1073 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
1074 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
1078 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
1079 for (Int_t iSide = 0; iSide < iNbSides; iSide++) {
1080 Int_t iNbDigis =
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide].size();
1083 Int_t iNbTracks = 0;
1084 std::vector<Int_t> vPrevTrackIdList;
1087 for (Int_t iDigi = 0; iDigi < iNbDigis; iDigi++) {
1089 " Create match for Digi %d(%d), addr 0x%08x; %d", iDigi, iNbDigis,
1090 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi].
first->GetAddress(),
1091 fStorDigiMatch[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi]);
1095 fStorDigiMatch[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi],
1098 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi].second = digiMatch;
1101 std::sort(
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide].begin(),
1102 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide].end(),
CompTExp);
1112 if (0 ==
fStorDigiMatch[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide].
size()) {
1113 LOG(error) << Form(
" cannot add digiMatch for (%d,%d,%d,%d,%d) at pos %d", iSmType, iSm, iRpc, iCh,
1119 digiMatch =
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi0].second;
1122 "Now apply deadtime %f for %d digis, "
1123 "digi0=%d for adress 0x%08x ",
1125 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi0].first->GetAddress());
1127 for (Int_t iDigi = 1; iDigi < iNbDigis; iDigi++) {
1129 if ((
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi].
first->GetTime()
1130 -
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi0].first->GetTime())
1133 digiMatch =
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi0].second;
1136 if (nL != 1) LOG(fatal) <<
"Invalid number of Links " << nL;
1139 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi].second->GetLink(0);
1150 new CbmMatch(*(
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi0].second));
1159 for (Int_t iL = 0; iL < nL; iL++) {
1162 Bool_t bTrackFound = kFALSE;
1163 for (UInt_t uTrkId = 0; uTrkId < vPrevTrackIdList.size(); uTrkId++)
1164 if (vPrevTrackIdList[uTrkId]
1166 bTrackFound = kTRUE;
1169 if (kFALSE == bTrackFound) {
1175 vPrevTrackIdList.clear();
1190 new CbmMatch(*(
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi0].second));
1197 for (Int_t iL = 0; iL < nL; iL++) {
1200 Bool_t bTrackFound = kFALSE;
1201 for (UInt_t uTrkId = 0; uTrkId < vPrevTrackIdList.size(); uTrkId++)
1203 bTrackFound = kTRUE;
1206 if (kFALSE == bTrackFound) {
1212 vPrevTrackIdList.clear();
1217 for (Int_t iDigi = 0; iDigi < iNbDigis; iDigi++) {
1218 CbmTofDigi* tmpDigi =
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi].first;
1219 CbmMatch* tmpMatch =
fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide][iDigi].second;
1220 if (tmpDigi)
delete tmpDigi;
1221 if (tmpMatch)
delete tmpMatch;
1225 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide].clear();
1226 fStorDigiMatch[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide].clear();
1337 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1347 Int_t iNbTofTracks = 0;
1348 Int_t iNbTofTracksPrim = 0;
1350 LOG(debug1) <<
"CbmTofDigitize::DigitizeDirectClusterSize: " << nTofPoint <<
" points in Tof for this event with "
1351 << nMcTracks <<
" MC tracks ";
1352 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1359 LOG(debug1) <<
"CbmTofDigitize::DigitizeDirectClusterSize: " << iNbTofTracks <<
" tracks in Tof ";
1360 LOG(debug1) <<
"CbmTofDigitize::DigitizeDirectClusterSize: " << iNbTofTracksPrim <<
" tracks in Tof from vertex";
1364 Int_t iDetId, iSmType, iSM, iRpc, iChannel, iGap;
1365 Int_t iTrackID, iChanId;
1369 Double_t dClustCharge;
1375 Int_t iNbSm, iNbRpc, iNbCh;
1389 Double_t dStartJitter = 0.;
1392 for (Int_t iPntInd = 0; iPntInd < nTofPoint; iPntInd++) {
1395 if (NULL == pPoint) {
1396 LOG(warning) <<
"CbmTofDigitize::DigitizeDirectClusterSize => Be "
1397 "careful: hole in the CbmTofPoint TClonesArray!";
1402 iDetId = pPoint->GetDetectorID();
1412 iTrackID = pPoint->GetTrackID();
1418 Int_t iTrkId = pPoint->GetTrackID();
1424 LOG(fatal) <<
"CbmTofDigitize::DigitizeDirectClusterSize => TofPoint without "
1425 "valid MC track Index, "
1426 <<
" track was probably cut at the transport level! "
1427 <<
" Pnt Idx: " << iPntInd <<
" Trk Idx: " << iTrkId <<
"\n"
1428 <<
"=============> To allow this kind of points and simply jump "
1430 <<
"call CbmTofDigitize::AllowPointsWithoutTrack() in your macro!!";
1442 if (iSmType < 0. || iNbSmTypes <= iSmType || iSM < 0. || iNbSm <= iSM || iRpc < 0. || iNbRpc <= iRpc
1443 || iChannel < 0. || iNbCh <= iChannel) {
1444 LOG(error) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId) <<
" SMType: " << iSmType;
1445 LOG(error) <<
" SModule: " << iSM <<
" of " << iNbSm + 1;
1446 LOG(error) <<
" Module: " << iRpc <<
" of " << iNbRpc + 1;
1447 LOG(error) <<
" Gap: " << iGap;
1448 LOG(fatal) <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
1456 Bool_t bFoundIt = kFALSE;
1463 for (UInt_t uTrkMainCh = 0; uTrkMainCh <
fvlTrckChAddr[iTrkId].size(); uTrkMainCh++)
1469 if (kTRUE == bFoundIt)
continue;
1492 pPoint->Position(vPntPos);
1496 LOG(debug1) << Form(
" TofDigitizerBDF:: (%3d,%3d,%3d,%3d) - node at "
1497 "(%6.1f,%6.1f,%6.1f) : 0x%p Pos(%6.1f,%6.1f,%6.1f)",
1499 fNode, vPntPos.X(), vPntPos.Y(), vPntPos.Z());
1500 gGeoManager->GetCurrentNode();
1501 gGeoManager->GetCurrentMatrix();
1503 Double_t poipos[3] = {vPntPos.X(), vPntPos.Y(), vPntPos.Z()};
1504 Double_t poipos_local[3];
1505 Double_t poipos_local_man[3];
1506 gGeoManager->MasterToLocal(poipos, poipos_local_man);
1508 for (Int_t i = 0; i < 3; i++)
1509 if (poipos_local[i] != poipos_local_man[i])
1510 LOG(fatal) <<
"Inconsistent M2L result " << i <<
": " << poipos_local[i] <<
" != " << poipos_local_man[i];
1513 LOG(error) <<
"CbmTofDigitize::DigitizeDirectClusterSize => This method "
1514 <<
"is not available for pads!!";
1522 Int_t iNbStripsSideA;
1523 Int_t iNbStripsSideB;
1524 if (1 == iClusterSize % 2) {
1526 iNbStripsSideA = (iClusterSize - 1) / 2;
1527 iNbStripsSideB = (iClusterSize - 1) / 2;
1532 iNbStripsSideA = iClusterSize / 2;
1533 iNbStripsSideB = iClusterSize / 2;
1552 Double_t dCentralTime;
1556 Bool_t bFoundIt = kFALSE;
1557 UInt_t uTrkRpcPair = 0;
1558 for (uTrkRpcPair = 0; uTrkRpcPair <
fvlTrckRpcAddr[iTrkId].size(); uTrkRpcPair++)
1564 if (kTRUE == bFoundIt) dCentralTime =
fvlTrckRpcTime[iTrkId][uTrkRpcPair];
1581 TF1* f1ChargeGauss =
new TF1(
"f1ChargeDist",
"[0]*TMath::Gaus(x,[1],[2])", poipos_local[1] - 2 * iClusterSize,
1582 poipos_local[1] + 2 * iClusterSize);
1593 f1ChargeGauss->SetParameters(dClustCharge / (TMath::Sqrt(2.0 * TMath::Pi() * iClusterSize / 6.0)),
1594 poipos_local[1], 0.5 * iClusterSize / 3.0);
1598 f1ChargeGauss->CalcGaussLegendreSamplingPoints(
kiNbIntPts,
x, w, 1e-12);
1601 for (Int_t iStripInd = iChannel - iNbStripsSideA; iStripInd <= iChannel + iNbStripsSideB; iStripInd++)
1602 if (0 <= iStripInd && iStripInd < iNbCh) {
1603 Int_t iCh1 = iStripInd;
1609 Double_t dStripCharge =
1615 < dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1] / 2.0) {
1616 Double_t dTimeA = dCentralTime;
1618#ifdef FULL_PROPAGATION_TIME
1625 iSM, iRpc, iChannel, dTimeA,
1626 dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0, 1, iSmType);
1628 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1629 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(data);
1630 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(iPntInd);
1632 LOG(debug) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, valA %d, MCt %d", iSmType, iSM, iRpc, iChannel,
1637 < dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd] / 2.0) {
1638 Double_t dTimeB = dCentralTime;
1640#ifdef FULL_PROPAGATION_TIME
1647 iSM, iRpc, iChannel, dTimeB,
1648 dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0, 0, iSmType);
1650 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1651 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(data);
1652 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(iPntInd);
1653 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, valB %d, MCt %d", iSmType, iSM, iRpc, iChannel,
1659 delete f1ChargeGauss;
1668 TF1* f1ChargeGauss =
new TF1(
"f1ChargeDist",
"[0]*TMath::Gaus(x,[1],[2])", poipos_local[0] - 2 * iClusterSize,
1669 poipos_local[0] + 2 * iClusterSize);
1678 f1ChargeGauss->SetParameters(dClustCharge / (TMath::Sqrt(2.0 * TMath::Pi()) * iClusterSize / 6.0),
1679 poipos_local[0], 0.5 * iClusterSize / 3.0);
1683 f1ChargeGauss->CalcGaussLegendreSamplingPoints(
kiNbIntPts,
x, w, 1e-12);
1686 for (Int_t iStripInd = iChannel - iNbStripsSideA; iStripInd <= iChannel + iNbStripsSideB; iStripInd++)
1687 if (0 <= iStripInd && iStripInd < iNbCh) {
1688 Int_t iCh1 = iStripInd;
1694 Double_t dStripCharge =
1700 < dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1] / 2.0) {
1701 Double_t dTimeA = dCentralTime;
1703#ifdef FULL_PROPAGATION_TIME
1709 LOG(debug) <<
"Create DigiA TSRC " << iSmType << iSM << iRpc << iStripInd
1710 << Form(
"at %f, ypos %f", dTimeA, poipos_local[1]);
1712 iSM, iRpc, iStripInd, dTimeA,
1713 dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1] / 2.0, 1, iSmType);
1715 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1716 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1].push_back(data);
1717 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1].push_back(iPntInd);
1718 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, valC %d, MCt %d", iSmType, iSM, iRpc, iChannel,
1723 < dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd] / 2.0) {
1724 Double_t dTimeB = dCentralTime;
1726#ifdef FULL_PROPAGATION_TIME
1732 LOG(debug) <<
"Create DigiB TSRC " << iSmType << iSM << iRpc << iStripInd
1733 << Form(
"at %f, ypos %f", dTimeB, poipos_local[1]);
1735 iSM, iRpc, iStripInd, dTimeB,
1736 dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd] / 2.0, 0, iSmType);
1738 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1739 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd].push_back(data);
1740 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd].push_back(iPntInd);
1741 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, valE %d, MCt %d", iSmType, iSM, iRpc, iChannel,
1746 delete f1ChargeGauss;
1754 for (UInt_t uTrkInd = 0; uTrkInd <
fvlTrckChAddr.size(); uTrkInd++) {
1787 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1797 Int_t iNbTofTracks = 0;
1798 Int_t iNbTofTracksPrim = 0;
1800 LOG(debug1) <<
"CbmTofDigitize::DigitizeFlatDisc: " << nTofPoint <<
" points in Tof for this event with "
1801 << nMcTracks <<
" MC tracks ";
1802 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1809 LOG(debug1) <<
"CbmTofDigitize::DigitizeFlatDisc: " << iNbTofTracks <<
" tracks in Tof ";
1810 LOG(debug1) <<
"CbmTofDigitize::DigitizeFlatDisc: " << iNbTofTracksPrim <<
" tracks in Tof from vertex";
1814 Int_t iDetId, iSmType, iSM, iRpc, iChannel, iGap;
1815 Int_t iTrackID, iChanId;
1818 Double_t dClusterSize;
1819 Double_t dClustCharge;
1825 Int_t iNbSm, iNbRpc, iNbCh;
1839 Double_t dStartJitter = 0.;
1842 for (Int_t iPntInd = 0; iPntInd < nTofPoint; iPntInd++) {
1845 if (NULL == pPoint) {
1846 LOG(warning) <<
"CbmTofDigitize::DigitizeFlatDisc => Be careful: hole in "
1847 "the CbmTofPoint TClonesArray!"
1853 iDetId = pPoint->GetDetectorID();
1862 iTrackID = pPoint->GetTrackID();
1868 Int_t iTrkId = pPoint->GetTrackID();
1874 LOG(fatal) <<
"CbmTofDigitize::DigitizeDirectClusterSize => TofPoint without "
1875 "valid MC track Index, "
1876 <<
" track was probably cut at the transport level! "
1877 <<
" Pnt Idx: " << iPntInd <<
" Trk Idx: " << iTrkId <<
"\n"
1878 <<
"=============> To allow this kind of points and simply jump "
1880 <<
"call CbmTofDigitize::AllowPointsWithoutTrack() in your macro!!";
1888 <<
", SMType: " << iSmType <<
" SModule: " << iSM <<
" of " << iNbSm + 1 <<
" Module: " << iRpc
1889 <<
" of " << iNbRpc + 1 <<
" Gap: " << iGap <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
1900 if (iSmType < 0. || iNbSmTypes <= iSmType || iSM < 0. || iNbSm <= iSM || iRpc < 0. || iNbRpc <= iRpc
1901 || iChannel < 0. || iNbCh <= iChannel) {
1903 <<
", SMType: " << iSmType;
1904 LOG(error) <<
" SModule: " << iSM <<
" of " << iNbSm + 1;
1905 LOG(error) <<
" Module: " << iRpc <<
" of " << iNbRpc + 1;
1906 LOG(error) <<
" Gap: " << iGap;
1907 LOG(fatal) <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
1910 LOG(debug2) <<
"CbmTofDigitize::DigitizeFlatDisc => Check Point " << iPntInd <<
" Sm type " << iSmType <<
" SM "
1911 << iSM <<
" Rpc " << iRpc <<
" Channel " << iChannel <<
" Type " << iChType <<
" Orient. "
1918 Bool_t bFoundIt = kFALSE;
1925 for (UInt_t uTrkMainCh = 0; uTrkMainCh <
fvlTrckChAddr[iTrkId].size(); uTrkMainCh++)
1931 if (kTRUE == bFoundIt)
continue;
1956 pPoint->Position(vPntPos);
1959 LOG(warning) <<
"CbmTofDigitize::DigitizeFlatDisc: No DigPar for iChanId = "
1960 << Form(
"0x%08x, addr 0x%08x", iChanId, (
unsigned int) iDetId);
1966 LOG(debug1) << Form(
" TofDigitizerBDF:: (%3d,%3d,%3d,%3d) - node at "
1967 "(%6.1f,%6.1f,%6.1f) : %p Pos(%6.1f,%6.1f,%6.1f)",
1969 fNode, vPntPos.X(), vPntPos.Y(), vPntPos.Z());
1970 gGeoManager->GetCurrentNode();
1971 gGeoManager->GetCurrentMatrix();
1974 Double_t refpos_local[3];
1975 gGeoManager->MasterToLocal(refpos, refpos_local);
1976 Double_t poipos[3] = {vPntPos.X(), vPntPos.Y(), vPntPos.Z()};
1977 Double_t poipos_local[3];
1978 gGeoManager->MasterToLocal(poipos, poipos_local);
1979 LOG(debug1) << Form(
" TofDigitizerBDF:: DetId 0x%08x, ChanId 0x%08x, local "
1980 "pos (%5.1f,%5.1f,%5.1f) refpos (%5.1f,%5.1f,%5.1f) ",
1981 iDetId, iChanId, poipos_local[0], poipos_local[1], poipos_local[2], refpos_local[0],
1982 refpos_local[1], refpos_local[2]);
1983 for (Int_t i = 0; i < 3; i++)
1984 poipos_local[i] -= refpos_local[i];
1991 while (dClusterSize < 0.0001 || 3.0 < dClusterSize)
2000 Double_t dClustArea = dClusterSize * dClusterSize * TMath::Pi();
2003 Double_t dChargeCentral =
2005 LOG(debug2) <<
"CbmTofDigitize::DigitizeFlatDisc: ChargeCentral " << dChargeCentral <<
", " << dClustCharge
2006 << Form(
", 0x%08x", iChanId) <<
", " << dClusterSize <<
", " << poipos_local[0] <<
", "
2007 << poipos_local[1] <<
", " << poipos_local[2];
2009 dChargeCentral /= dClustArea;
2010 if (dClustCharge + 0.0000001 < dChargeCentral) {
2011 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Central Charge " << dChargeCentral <<
" " << dClustCharge
2012 <<
" " << dClustCharge - dChargeCentral <<
" "
2015 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Check Point " << iPntInd <<
" Sm type " << iSmType <<
" SM "
2016 << iSM <<
" Rpc " << iRpc <<
" Channel " << iChannel <<
" Type " << iChType <<
" Orient. "
2021 Double_t dCentralTime;
2025 Bool_t bFoundIt = kFALSE;
2026 UInt_t uTrkRpcPair = 0;
2027 for (uTrkRpcPair = 0; uTrkRpcPair <
fvlTrckRpcAddr[iTrkId].size(); uTrkRpcPair++)
2033 if (kTRUE == bFoundIt) dCentralTime =
fvlTrckRpcTime[iTrkId][uTrkRpcPair];
2062 Double_t dTimeA = dCentralTime;
2063 Double_t dTimeB = dCentralTime;
2067#ifdef FULL_PROPAGATION_TIME
2074#ifdef FULL_PROPAGATION_TIME
2084#ifdef FULL_PROPAGATION_TIME
2092#ifdef FULL_PROPAGATION_TIME
2101 <= dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0) {
2103 iSM, iRpc, iChannel, dTimeA,
2104 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0, 1, iSmType);
2107 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2108 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(data);
2109 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(iPntInd);
2110 LOG(debug1) << Form(
2111 "Digimatch (%d,%d,%d,%d): size %zu, MCp %d, MCt %d, TA %6.2f, TotA "
2112 "%6.1f, Ypos %6.1f, Vsig %6.1f ",
2113 iSmType, iSM, iRpc, iChannel,
fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd,
2114 iTrackID, dTimeA, dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0,
2119 <= dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0) {
2122 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0, 0, iSmType);
2124 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2125 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(data);
2126 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(iPntInd);
2127 LOG(debug1) << Form(
2128 "Digimatch (%d,%d,%d,%d): size %zu, MCp %d, MCt %d, TB %6.2f, TotB "
2130 iSmType, iSM, iRpc, iChannel,
fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd,
2131 iTrackID, dTimeB, dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0);
2156 Double_t dClustToReadout = 0.0;
2157 Double_t dPadTime = dCentralTime;
2159 if (iChannel < iNbCh / 2.0) {
2163 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2166 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2173 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2176 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2184 new CbmTofDigi(iSM, iRpc, iChannel, dPadTime,
2185 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChannel], 0, iSmType);
2187 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2188 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(data);
2189 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(iPntInd);
2190 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): MCpi %zu, valE %d, MCti %d", iSmType, iSM, iRpc, iChannel,
2191 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd, iTrackID);
2206 Int_t iMinChanInd = iChannel - 1;
2207 Int_t iMaxChanInd = iChannel + 1;
2209 Double_t dClusterDist = 0.0;
2212 while (0 <= iMinChanInd) {
2213 dClusterDist = TMath::Abs(poipos_local[1] - (+
fChannelInfo->
GetSizey() * (iMinChanInd - iChannel + 0.5)));
2214 if (dClusterDist < dClusterSize) iMinChanInd--;
2218 while (iMaxChanInd < iNbCh) {
2219 dClusterDist = TMath::Abs(poipos_local[1] - (+
fChannelInfo->
GetSizey() * (iMaxChanInd - iChannel - 0.5)));
2220 if (dClusterDist < dClusterSize) iMaxChanInd++;
2227 while (0 <= iMinChanInd) {
2228 dClusterDist = TMath::Abs(poipos_local[0] - (+
fChannelInfo->
GetSizex() * (iMinChanInd - iChannel + 0.5)));
2229 if (dClusterDist < dClusterSize) iMinChanInd--;
2233 while (iMaxChanInd < iNbCh) {
2234 dClusterDist = TMath::Abs(poipos_local[0] - (+
fChannelInfo->
GetSizex() * (iMaxChanInd - iChannel - 0.5)));
2235 if (dClusterDist < dClusterSize) iMaxChanInd++;
2243 for (Int_t iChanInd = iMinChanInd + 1; iChanInd < iMaxChanInd; iChanInd++) {
2244 if (iChanInd == iChannel)
continue;
2249 Int_t iCh1 = iChanInd;
2257 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc: Invalid channel " << iSideChId <<
" " << iSmType <<
" "
2258 << iSM <<
" " << iRpc <<
" " << iChanInd + 1;
2263 Double_t dChargeSideCh =
2265 dChargeSideCh /= dClustArea;
2266 if (dClustCharge + 0.0000001 < dChargeSideCh) {
2267 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Side Charge " << dChargeSideCh <<
" " << dClustCharge
2268 <<
" " << dClustArea;
2269 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Check Point " << iPntInd <<
" Sm type " << iSmType
2270 <<
" SM " << iSM <<
" Rpc " << iRpc <<
" Channel " << iChanInd <<
" Type " << iChType
2275 Double_t dTimeA = dCentralTime;
2276 Double_t dTimeB = dCentralTime;
2278 LOG(debug1) << Form(
" TofDigitizerBDF:: chrg %7.1f, times %5.1f,%5.1f, "
2279 "pos %5.1f,%5.1f,%5.1f ",
2280 dChargeCentral, dTimeA, dTimeB, poipos_local[0], poipos_local[1], poipos_local[2]);
2285#ifdef FULL_PROPAGATION_TIME
2292#ifdef FULL_PROPAGATION_TIME
2303#ifdef FULL_PROPAGATION_TIME
2311#ifdef FULL_PROPAGATION_TIME
2319 LOG(debug1) << Form(
" TofDigitizerBDF:: chrg %7.1f, gain %7.1f, thr %7.1f times "
2321 dChargeCentral,
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1],
2325 <= dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1] / 2.0) {
2327 iSM, iRpc, iChanInd, dTimeA,
2328 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1] / 2.0, 1, iSmType);
2330 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2331 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1].push_back(data);
2332 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1].push_back(iPntInd);
2333 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, MCpA %d, MCtt %d", iSmType, iSM, iRpc, iChanInd,
2334 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1].
size(), iPntInd, iTrackID);
2338 <= dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd] / 2.0) {
2341 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd] / 2.0, 0, iSmType);
2343 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2344 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd].push_back(data);
2345 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd].push_back(iPntInd);
2346 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, MCpB %d, MCtB %d", iSmType, iSM, iRpc, iChanInd,
2347 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1].
size(), iPntInd, iTrackID);
2375 Int_t iMinChanInd = iChannel;
2376 Int_t iMaxChanInd = iChannel;
2378 Double_t dClusterDist = 0;
2380 Bool_t bCheckOtherRow = kFALSE;
2381 if (iChannel < iNbCh / 2.0) iRow = 0;
2387 while (dClusterDist < dClusterSize && iRow * iNbCh / 2.0 < iMinChanInd) {
2390 TMath::Abs(poipos_local[1] - (+
fChannelInfo->
GetSizey() * (iMinChanInd - iChannel + (1 - 2 * iRow) / 2)));
2393 while (dClusterDist < dClusterSize && iMaxChanInd < (1 + iRow) * iNbCh / 2.0 - 1) {
2396 TMath::Abs(poipos_local[1] - (+
fChannelInfo->
GetSizey() * (iMaxChanInd - iChannel - (1 - 2 * iRow) / 2)));
2402 if (dClusterDist < dClusterSize) bCheckOtherRow = kTRUE;
2406 while (dClusterDist < dClusterSize && iRow * iNbCh / 2.0 < iMinChanInd) {
2409 TMath::Abs(poipos_local[0] - (+
fChannelInfo->
GetSizex() * (iMinChanInd - iChannel + (1 - 2 * iRow) / 2)));
2412 while (dClusterDist < dClusterSize && iMaxChanInd < (1 + iRow) * iNbCh / 2.0 - 1) {
2415 TMath::Abs(poipos_local[0] - (+
fChannelInfo->
GetSizex() * (iMaxChanInd - iChannel - (1 - 2 * iRow) / 2)));
2421 if (dClusterDist < dClusterSize) bCheckOtherRow = kTRUE;
2426 for (Int_t iChanInd = iMinChanInd + 1; iChanInd < iMaxChanInd; iChanInd++) {
2427 if (iChanInd == iChannel)
continue;
2431 Int_t iCh1 = iChanInd;
2440 Double_t dChargeSideCh =
2442 dChargeSideCh /= dClustArea;
2448 Double_t dClustToReadout = 0.0;
2449 Double_t dPadTime = dCentralTime;
2454 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2458 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2464 new CbmTofDigi(iSM, iRpc, iChanInd, dPadTime,
2465 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChanInd], 0, iSmType);
2467 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2468 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(data);
2469 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(iPntInd);
2470 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, MCpP %d, MCtP %d", iSmType, iSM, iRpc, iChannel,
2471 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd, iTrackID);
2475 if (kTRUE == bCheckOtherRow)
2476 for (Int_t iChanInd = iMinChanInd + 1 + (1 - 2 * iRow) * iNbCh / 2.0;
2477 iChanInd < iMaxChanInd + (1 - 2 * iRow) * iNbCh / 2.0; iChanInd++) {
2480 Int_t iCh1 = iChanInd;
2489 Double_t dChargeSideCh =
2496 Double_t dClustToReadout = 0.0;
2497 Double_t dPadTime = dCentralTime;
2502 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2506 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2512 new CbmTofDigi(iSM, iRpc, iChanInd, dPadTime,
2513 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChanInd], 0, iSmType);
2515 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2516 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(data);
2517 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(iPntInd);
2518 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, MCpX %d, MCtX %d", iSmType, iSM, iRpc, iChannel,
2519 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd, iTrackID);
2528 for (UInt_t uTrkInd = 0; uTrkInd <
fvlTrckChAddr.size(); uTrkInd++) {
2561 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
2571 Int_t iNbTofTracks = 0;
2572 Int_t iNbTofTracksPrim = 0;
2574 LOG(debug1) <<
"CbmTofDigitize::DigitizeGaussCharge: " << nTofPoint <<
" points in Tof for this event with "
2575 << nMcTracks <<
" MC tracks ";
2576 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
2583 LOG(debug1) <<
"CbmTofDigitize::DigitizeGaussCharge: " << iNbTofTracks <<
" tracks in Tof ";
2584 LOG(debug1) <<
"CbmTofDigitize::DigitizeGaussCharge: " << iNbTofTracksPrim <<
" tracks in Tof from vertex";
2588 Int_t iDetId, iSmType, iSM, iRpc, iChannel, iGap;
2589 Int_t iTrackID, iChanId;
2592 Double_t dClusterSize;
2593 Double_t dClustCharge;
2599 Int_t iNbSm, iNbRpc, iNbCh;
2613 Double_t dStartJitter = 0.;
2616 for (Int_t iPntInd = 0; iPntInd < nTofPoint; iPntInd++) {
2619 if (NULL == pPoint) {
2620 LOG(warning) <<
"CbmTofDigitize::DigitizeGaussCharge => Be careful: hole "
2621 "in the CbmTofPoint TClonesArray!"
2627 iDetId = pPoint->GetDetectorID();
2635 iTrackID = pPoint->GetTrackID();
2641 Int_t iTrkId = pPoint->GetTrackID();
2647 LOG(fatal) <<
"CbmTofDigitize::DigitizeDirectClusterSize => TofPoint without "
2648 "valid MC track Index, "
2649 <<
" track was probably cut at the transport level! "
2650 <<
" Pnt Idx: " << iPntInd <<
" Trk Idx: " << iTrkId <<
"\n"
2651 <<
"=============> To allow this kind of points and simply jump "
2653 <<
"call CbmTofDigitize::AllowPointsWithoutTrack() in your macro!!";
2665 if (iSmType < 0. || iNbSmTypes < iSmType || iSM < 0. || iNbSm < iSM || iRpc < 0. || iNbRpc < iRpc || iChannel < 0.
2666 || iNbCh < iChannel) {
2667 LOG(error) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId) <<
" SMType: " << iSmType;
2668 LOG(error) <<
" SModule: " << iSM <<
" of " << iNbSm + 1;
2669 LOG(error) <<
" Module: " << iRpc <<
" of " << iNbRpc + 1;
2670 LOG(error) <<
" Gap: " << iGap;
2671 LOG(error) <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
2679 Bool_t bFoundIt = kFALSE;
2686 for (UInt_t uTrkMainCh = 0; uTrkMainCh <
fvlTrckChAddr[iTrkId].size(); uTrkMainCh++)
2692 if (kTRUE == bFoundIt)
continue;
2715 pPoint->Position(vPntPos);
2719 LOG(debug1) << Form(
" TofDigitizerBDF:: (%3d,%3d,%3d,%3d) - node at "
2720 "(%6.1f,%6.1f,%6.1f) : 0x%p Pos(%6.1f,%6.1f,%6.1f)",
2722 fNode, vPntPos.X(), vPntPos.Y(), vPntPos.Z());
2723 gGeoManager->GetCurrentNode();
2724 gGeoManager->GetCurrentMatrix();
2725 Double_t poipos[3] = {vPntPos.X(), vPntPos.Y(), vPntPos.Z()};
2726 Double_t poipos_local[3];
2727 gGeoManager->MasterToLocal(poipos, poipos_local);
2731 while (dClusterSize < 0.0001)
2741 TF2* f2ChargeDist =
new TF2(
"ChargeDist",
"[0]*TMath::Gaus(x,[1],[2])*TMath::Gaus(y,[3],[4])", -5.0 * dClusterSize,
2742 5.0 * dClusterSize, -5.0 * dClusterSize, 5.0 * dClusterSize);
2743 f2ChargeDist->SetParameters(dClustCharge / (TMath::Sqrt(2.0 * TMath::Pi()) * dClusterSize / 3.0), poipos_local[0],
2744 dClusterSize / 3.0, poipos_local[1], dClusterSize / 3.0);
2747 Double_t dChargeCentral = f2ChargeDist->Integral(
2752 Double_t dCentralTime;
2756 Bool_t bFoundIt = kFALSE;
2757 UInt_t uTrkRpcPair = 0;
2758 for (uTrkRpcPair = 0; uTrkRpcPair <
fvlTrckRpcAddr[iTrkId].size(); uTrkRpcPair++)
2764 if (kTRUE == bFoundIt) dCentralTime =
fvlTrckRpcTime[iTrkId][uTrkRpcPair];
2789 Double_t dTimeA = dCentralTime;
2790 Double_t dTimeB = dCentralTime;
2794#ifdef FULL_PROPAGATION_TIME
2801#ifdef FULL_PROPAGATION_TIME
2811#ifdef FULL_PROPAGATION_TIME
2818#ifdef FULL_PROPAGATION_TIME
2827 iSM, iRpc, iChannel, dTimeA,
2828 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0, 1, iSmType);
2830 std::pair<CbmTofDigi*, CbmMatch*> data1(tofDigi,
nullptr);
2831 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(data1);
2832 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(iPntInd);
2833 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val1 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
2834 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd, iTrackID);
2838 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0, 0, iSmType);
2840 std::pair<CbmTofDigi*, CbmMatch*> data2(tofDigi,
nullptr);
2841 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(data2);
2842 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(iPntInd);
2843 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val2 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
2844 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].
size(), iPntInd, iTrackID);
2868 Double_t dClustToReadout = 0.0;
2869 Double_t dPadTime = dCentralTime;
2871 if (iChannel < iNbCh / 2.0) {
2875 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2878 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2885 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2888 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2896 new CbmTofDigi(iSM, iRpc, iChannel, dPadTime,
2897 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChannel], 0, iSmType);
2899 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2900 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(data);
2901 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(iPntInd);
2902 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val3 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
2911 Int_t iSideChInd = iChannel - 1;
2915 Int_t iCh1 = iSideChInd;
2924 Double_t dChargeSideCh = f2ChargeDist->Integral(
2930 Double_t dTimeA = dCentralTime;
2931 Double_t dTimeB = dCentralTime;
2935#ifdef FULL_PROPAGATION_TIME
2942#ifdef FULL_PROPAGATION_TIME
2952#ifdef FULL_PROPAGATION_TIME
2959#ifdef FULL_PROPAGATION_TIME
2968 iSM, iRpc, iSideChInd, dTimeA,
2969 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1] / 2.0, 1, iSmType);
2971 std::pair<CbmTofDigi*, CbmMatch*> data1(tofDigi,
nullptr);
2972 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(data1);
2973 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(iPntInd);
2974 tofDigi =
new CbmTofDigi(iSM, iRpc, iSideChInd, dTimeB,
2975 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd] / 2.0, 0,
2978 std::pair<CbmTofDigi*, CbmMatch*> data2(tofDigi,
nullptr);
2979 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(data2);
2980 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(iPntInd);
2981 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val4 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
2982 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].
size(), iPntInd, iTrackID);
2991 Int_t iCh2 = iSideChInd;
2993 xDetInfo.
fCell = iCh2;
3007 if (iChannel < iNbCh - 1) {
3008 Int_t iSideChInd = iChannel + 1;
3012 Int_t iCh1 = iSideChInd;
3021 Double_t dChargeSideCh = f2ChargeDist->Integral(
3027 Double_t dTimeA = dCentralTime;
3028 Double_t dTimeB = dCentralTime;
3032#ifdef FULL_PROPAGATION_TIME
3039#ifdef FULL_PROPAGATION_TIME
3049#ifdef FULL_PROPAGATION_TIME
3056#ifdef FULL_PROPAGATION_TIME
3065 iSM, iRpc, iSideChInd, dTimeA,
3066 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1] / 2.0, 1, iSmType);
3068 std::pair<CbmTofDigi*, CbmMatch*> data1(tofDigi,
nullptr);
3069 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(data1);
3070 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(iPntInd);
3071 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val5 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3075 tofDigi =
new CbmTofDigi(iSM, iRpc, iSideChInd, dTimeB,
3076 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd] / 2.0, 0,
3079 std::pair<CbmTofDigi*, CbmMatch*> data2(tofDigi,
nullptr);
3080 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(data2);
3081 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(iPntInd);
3082 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val6 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3083 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].
size(), iPntInd, iTrackID);
3090 xDetInfo.
fCell = iSideChInd + 1;
3126 Int_t iMinChanInd = iChannel;
3127 Int_t iMaxChanInd = iChannel;
3132 if (iChannel < iNbCh / 2.0) iRow = 0;
3137 if (iRow * iNbCh / 2.0 < iChannel) {
3138 Int_t iSideChInd = iChannel - 1;
3142 Int_t iCh1 = iSideChInd;
3151 Double_t dChargeSideCh = f2ChargeDist->Integral(
3156 iMinChanInd = iSideChInd;
3158 Double_t dClustToReadout = 0.0;
3159 Double_t dPadTime = dCentralTime;
3164 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
3168 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
3174 new CbmTofDigi(iSM, iRpc, iSideChInd, dPadTime,
3175 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iSideChInd], 0, iSmType);
3177 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3178 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(data);
3179 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(iPntInd);
3180 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val7 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3181 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].
size(), iPntInd, iTrackID);
3189 xDetInfo.
fCell = iSideChInd + 1;
3203 if (iChannel < (1 + iRow) * iNbCh / 2.0 - 1) {
3204 Int_t iSideChInd = iChannel + 1;
3208 Int_t iCh1 = iSideChInd;
3217 Double_t dChargeSideCh = f2ChargeDist->Integral(
3222 iMaxChanInd = iSideChInd;
3224 Double_t dClustToReadout = 0.0;
3225 Double_t dPadTime = dCentralTime;
3230 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
3234 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
3240 new CbmTofDigi(iSM, iRpc, iSideChInd, dPadTime,
3241 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iSideChInd], 0, iSmType);
3243 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3244 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(data);
3245 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(iPntInd);
3246 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val8 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3254 xDetInfo.
fCell = iSideChInd + 1;
3273 Int_t iCh1 = iChannel;
3280 Double_t dChargeSideCh = f2ChargeDist->Integral(
3287 for (Int_t iChanInd = iMinChanInd + (1 - 2 * iRow) * iNbCh / 2.0;
3288 iChanInd <= iMaxChanInd + (1 - 2 * iRow) * iNbCh / 2.0; iChanInd++) {
3291 xDetInfo.
fCell = iChanInd + 1;
3302 Double_t dClustToReadout = 0.0;
3303 Double_t dPadTime = dCentralTime;
3308 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
3312 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
3318 new CbmTofDigi(iSM, iRpc, iChanInd, dPadTime,
3319 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChanInd], 0, iSmType);
3321 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3322 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(data);
3323 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(iPntInd);
3324 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val9 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3332 delete f2ChargeDist;
3337 for (UInt_t uTrkInd = 0; uTrkInd <
fvlTrckChAddr.size(); uTrkInd++) {
3352 Double_t dClustCentY)
3354 Double_t dCornersX[4];
3355 Double_t dCornersY[4];
3356 Double_t dCornersR[4];
3359 Double_t dChanCentPosX = 0.;
3360 Double_t dChanCentPosY = 0.;
3365 dCornersX[0] = dChanCentPosX - dEdgeCentDistX;
3366 dCornersY[0] = dChanCentPosY + dEdgeCentDistY;
3367 dCornersR[0] = TMath::Sqrt(TMath::Power(dCornersX[0] - dClustCentX, 2) + TMath::Power(dCornersY[0] - dClustCentY, 2));
3369 dCornersX[1] = dChanCentPosX + dEdgeCentDistX;
3370 dCornersY[1] = dChanCentPosY + dEdgeCentDistY;
3371 dCornersR[1] = TMath::Sqrt(TMath::Power(dCornersX[1] - dClustCentX, 2) + TMath::Power(dCornersY[1] - dClustCentY, 2));
3373 dCornersX[2] = dChanCentPosX + dEdgeCentDistX;
3374 dCornersY[2] = dChanCentPosY - dEdgeCentDistY;
3375 dCornersR[2] = TMath::Sqrt(TMath::Power(dCornersX[2] - dClustCentX, 2) + TMath::Power(dCornersY[2] - dClustCentY, 2));
3377 dCornersX[3] = dChanCentPosX - dEdgeCentDistX;
3378 dCornersY[3] = dChanCentPosY - dEdgeCentDistY;
3379 dCornersR[3] = TMath::Sqrt(TMath::Power(dCornersX[3] - dClustCentX, 2) + TMath::Power(dCornersY[3] - dClustCentY, 2));
3381 Int_t iNbCornersIn = (dCornersR[0] < dClustRadius ? 1 : 0) + (dCornersR[1] < dClustRadius ? 1 : 0)
3382 + (dCornersR[2] < dClustRadius ? 1 : 0) + (dCornersR[3] < dClustRadius ? 1 : 0);
3384 LOG(debug3) <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => Check " << iNbCornersIn <<
" Radius " << dClustRadius
3385 <<
" " << dCornersR[0] <<
" " << dCornersR[1] <<
" " << dCornersR[2] <<
" " << dCornersR[3];
3387 switch (iNbCornersIn) {
3393 dEdgeR[0] = dChanCentPosX - dEdgeCentDistX - dClustCentX;
3394 dEdgeR[1] = dChanCentPosX + dEdgeCentDistX - dClustCentX;
3395 dEdgeR[2] = dChanCentPosY - dEdgeCentDistY - dClustCentY;
3396 dEdgeR[3] = dChanCentPosY + dEdgeCentDistY - dClustCentY;
3397 if ((0.0 >= dEdgeR[0]) && (0.0 <= dEdgeR[1]) && (0.0 >= dEdgeR[2]) && (0.0 <= dEdgeR[3])) {
3401 Double_t dArea = dClustRadius * dClustRadius * TMath::Pi();
3403 LOG(debug3) <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => CC in Ch " << dArea;
3408 if (TMath::Abs(dEdgeR[0]) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR[0]));
3409 if (TMath::Abs(dEdgeR[1]) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR[1]));
3410 if (TMath::Abs(dEdgeR[2]) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR[2]));
3411 if (TMath::Abs(dEdgeR[3]) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR[3]));
3413 LOG(error) <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => Neg. area! " << dArea <<
" Radius "
3414 << dClustRadius <<
" " << dEdgeR[0] <<
" " << dEdgeR[1] <<
" " << dEdgeR[2] <<
" " << dEdgeR[3];
3423 LOG(debug3) <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => CC out Ch " << dClustRadius <<
" " << dEdgeR[0]
3424 <<
" " << dEdgeR[1] <<
" " << dEdgeR[2] <<
" " << dEdgeR[3];
3426 if (TMath::Abs(dEdgeR[0]) < dClustRadius)
return DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR[0]));
3427 else if (TMath::Abs(dEdgeR[1]) < dClustRadius)
3429 else if (TMath::Abs(dEdgeR[2]) < dClustRadius)
3431 else if (TMath::Abs(dEdgeR[3]) < dClustRadius)
3445 Double_t dIntPtX[2] = {0., 0.};
3446 Double_t dIntPtY[2] = {0., 0.};
3447 Double_t dArea = 0.;
3449 if (dCornersR[0] < dClustRadius) {
3452 dIntPtX[0] = dCornersX[0];
3453 dIntPtY[0] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3456 dIntPtY[1] = dCornersY[0];
3459 dArea =
TriangleArea(dCornersX[0], dCornersY[0], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3461 else if (dCornersR[1] < dClustRadius) {
3464 dIntPtX[0] = dCornersX[1];
3468 dIntPtY[1] = dCornersY[1];
3471 dArea =
TriangleArea(dCornersX[1], dCornersY[1], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3473 else if (dCornersR[2] < dClustRadius) {
3476 dIntPtX[0] = dCornersX[2];
3479 dIntPtX[1] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3480 dIntPtY[1] = dCornersY[2];
3483 dArea =
TriangleArea(dCornersX[2], dCornersY[2], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3485 else if (dCornersR[3] < dClustRadius) {
3488 dIntPtX[0] = dCornersX[3];
3489 dIntPtY[0] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3491 dIntPtX[1] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3492 dIntPtY[1] = dCornersY[3];
3495 dArea =
TriangleArea(dCornersX[3], dCornersY[3], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3500 Double_t dSecBaseD =
DistanceCircleToBase(dClustRadius, dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3519 Bool_t bFirstCorner = kTRUE;
3524 if (dCornersR[0] < dClustRadius) {
3527 bFirstCorner = kFALSE;
3529 if (dCornersR[1] < dClustRadius) {
3531 if (kTRUE == bFirstCorner) {
3533 bFirstCorner = kFALSE;
3538 if (dCornersR[2] < dClustRadius) {
3540 if (kTRUE == bFirstCorner) {
3542 bFirstCorner = kFALSE;
3547 if (dCornersR[3] < dClustRadius) {
3553 LOG(debug3) <<
"Corners In check " << (iCorners[0]) <<
" " << (iCorners[1]);
3555 Double_t dIntPtX[2] = {0., 0.};
3556 Double_t dIntPtY[2] = {0., 0.};
3557 Double_t dEdgeR = 0.;
3558 Int_t iOppCorner = 0;
3559 if (0 == iCorners[0] && 1 == iCorners[1]) {
3560 LOG(debug3) <<
"Test upper edge";
3563 dIntPtX[0] = dCornersX[0];
3564 dIntPtY[0] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3566 dIntPtX[1] = dCornersX[1];
3571 dEdgeR = dChanCentPosY - dEdgeCentDistY - dClustCentY;
3573 else if (1 == iCorners[0] && 2 == iCorners[1]) {
3574 LOG(debug3) <<
"Test right edge";
3578 dIntPtY[0] = dCornersY[1];
3580 dIntPtX[1] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3581 dIntPtY[1] = dCornersY[2];
3585 dEdgeR = dChanCentPosX - dEdgeCentDistX - dClustCentX;
3587 else if (2 == iCorners[0] && 3 == iCorners[1]) {
3588 LOG(debug3) <<
"Test lower edge";
3591 dIntPtX[0] = dCornersX[2];
3594 dIntPtX[1] = dCornersX[3];
3595 dIntPtY[1] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3599 dEdgeR = dChanCentPosY + dEdgeCentDistY - dClustCentY;
3601 else if (0 == iCorners[0] && 3 == iCorners[1]) {
3602 LOG(debug3) <<
"Test left edge";
3605 dIntPtX[0] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3606 dIntPtY[0] = dCornersY[3];
3609 dIntPtY[1] = dCornersY[0];
3613 dEdgeR = dChanCentPosX + dEdgeCentDistX - dClustCentX;
3617 Double_t dArea =
TriangleArea(dCornersX[iCorners[0]], dCornersY[iCorners[0]], dCornersX[iCorners[1]],
3618 dCornersY[iCorners[1]], dIntPtX[0], dIntPtY[0]);
3621 TriangleArea(dCornersX[iOppCorner], dCornersY[iOppCorner], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3625 Double_t dSecBaseD =
DistanceCircleToBase(dClustRadius, dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3634 if (TMath::Abs(dEdgeR) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR));
3646 Int_t iOutCorner = 0;
3647 Double_t dIntPtX[2] = {0., 0.};
3648 Double_t dIntPtY[2] = {0., 0.};
3650 if (dCornersR[0] > dClustRadius) {
3655 dIntPtY[0] = dCornersY[0];
3657 dIntPtX[1] = dCornersX[0];
3658 dIntPtY[1] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3660 else if (dCornersR[1] > dClustRadius) {
3665 dIntPtY[0] = dCornersY[1];
3667 dIntPtX[1] = dCornersX[1];
3670 else if (dCornersR[2] > dClustRadius) {
3674 dIntPtX[0] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3675 dIntPtY[0] = dCornersY[2];
3677 dIntPtX[1] = dCornersX[2];
3680 else if (dCornersR[3] > dClustRadius) {
3684 dIntPtX[0] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3685 dIntPtY[0] = dCornersY[3];
3687 dIntPtX[1] = dCornersX[3];
3688 dIntPtY[1] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3696 TriangleArea(dCornersX[iOutCorner], dCornersY[iOutCorner], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3700 Double_t dSecBaseD =
DistanceCircleToBase(dClustRadius, dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);