423 LOG(info) << fName <<
": Load beamtime values from " <<
fsBeamInputFile;
428 if (fair::Logger::Logging(fair::Severity::debug))
fDigiBdfPar->printParams();
431 LOG(fatal) <<
"CbmTofDigitize::LoadBeamtimeValues: Cluster properties from "
432 "testbeam could not be loaded! ";
448 LOG(debug2) <<
"CbmTofDigitize::LoadBeamtimeValues: ini gain values for SmTypes " << iNbSmTypes;
452 TRandom3 randFeeGain;
461 for (
Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
462 LOG(debug2) <<
"CbmTofDigitize::LoadBeamtimeValues => Gain for SM type " << iSmType;
470 if (iSmType == 5 && iNbSm > 0) {
472 LOG(info) <<
"Generate Fake Beam Counter digis";
475 for (
Int_t iSm = 0; iSm < iNbSm; iSm++) {
477 for (
Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
478 if (0.0 <
fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc))
483 LOG(debug) <<
"Init signal velocity of TSR " << iSmType << iSm << iRpc <<
" to "
488 for (
Int_t iSm = 0; iSm < iNbSm; iSm++) {
491 for (
Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
492 LOG(debug2) <<
"CbmTofDigitize::LoadBeamtimeValues => Gain for SM/Rpc " << iSm <<
"/" << iRpc;
501 fdChannelGain[iSmType][iSm * iNbRpc + iRpc].resize(iNbCh * iNbSides);
503 for (
Int_t iCh = 0; iCh < iNbCh; iCh++)
504 for (
Int_t iSide = 0; iSide < iNbSides; iSide++) {
506 fdChannelGain[iSmType][iSm * iNbRpc + iRpc][iCh * iNbSides + iSide] =
508 if (
fdChannelGain[iSmType][iSm * iNbRpc + iRpc][iCh * iNbSides + iSide] < 0.0)
509 LOG(error) <<
"CbmTofDigitize::LoadBeamtimeValues => Neg. Gain "
511 << iSm <<
"/" << iRpc <<
" "
512 <<
fdChannelGain[iSmType][iSm * iNbRpc + iRpc][iCh * iNbSides + iSide];
515 fdChannelGain[iSmType][iSm * iNbRpc + iRpc][iCh * iNbSides + iSide] = 1;
522 TDirectory* oldir = gDirectory;
528 for (
Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
529 LOG(debug2) <<
"CbmTofDigitize::LoadBeamtimeValues => SM type " << iSmType;
534 new TH1D(Form(
"ClusterSizeProb%03d", iSmType),
"Random throw to Cluster size mapping", 10000, 0.0, 1.0);
535 TH1* hClusterSize =
fDigiBdfPar->GetClustSizeHist(iSmType);
536 Int_t iNbBinsSize = hClusterSize->GetNbinsX();
539 Double_t dIntegral = 0.;
550 Double_t dIntSize = hClusterSize->Integral();
551 Double_t dSizeVal = 0.;
553 for (
Int_t iBin = 1; iBin <= iNbBinsSize; iBin++) {
554 dIntegral += hClusterSize->GetBinContent(iBin);
555 if ((Double_t) iProbBin / dNbBinsProb < dIntegral / dIntSize) dSizeVal = hClusterSize->GetBinCenter(iBin);
556 while ((Double_t) iProbBin / dNbBinsProb < dIntegral / dIntSize) {
569 LOG(debug) <<
"CbmTofDigitize::LoadBeamtimeValues => SM type " << iSmType <<
" Mean Cluster Size "
577 LOG(debug) <<
"CbmTofDigitize::LoadBeamtimeValues => SM type " << iSmType <<
" Mean Cluster Size "
590 new TH1D(Form(
"ClusterTotProb%03d", iSmType),
"Random throw to Cluster Tot mapping", 10000, 0.0, 1.0);
591 TH1* hClusterTot =
fDigiBdfPar->GetClustTotHist(iSmType);
592 Int_t iNbBinsTot = hClusterTot->GetNbinsX();
595 Double_t dIntegral = 0.;
606 Double_t dIntTot = hClusterTot->Integral();
607 Double_t dTotVal = 0.;
608 Double_t dPsToNs = 1e3;
610 for (
Int_t iBin = 1; iBin <= iNbBinsTot; iBin++) {
611 dIntegral += hClusterTot->GetBinContent(iBin);
612 if ((Double_t) iProbBin / dNbBinsProb < dIntegral / dIntTot) dTotVal = hClusterTot->GetBinLowEdge(iBin) / dPsToNs;
613 while ((Double_t) iProbBin / dNbBinsProb < dIntegral / dIntTot) {
620 gDirectory->cd(oldir->GetPath());
625 for (
Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
628 fStorDigi[iSmType].resize(iNbSm * iNbRpc);
630 for (
Int_t iSm = 0; iSm < iNbSm; iSm++)
631 for (
Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
634 fStorDigi[iSmType][iSm * iNbRpc + iRpc].resize(iNbCh * iNbSides);
635 fStorDigiMatch[iSmType][iSm * iNbRpc + iRpc].resize(iNbCh * iNbSides);
639 LOG(debug) <<
"CbmTofDigitize::LoadBeamtimeValues: GeoVersion " <<
fGeoHandler->GetGeoVersion();
643 Int_t iMinSmType = 17;
644 Int_t iMaxSmType = -1;
651 Int_t iMinCell = 257;
653 for (
Int_t iCellInd = 0; iCellInd < iNbGeantChannels; iCellInd++) {
656 if (iMinSmType >
fTofId->GetSMType(iCellId)) iMinSmType =
fTofId->GetSMType(iCellId);
657 if (iMaxSmType < fTofId->GetSMType(iCellId)) iMaxSmType =
fTofId->GetSMType(iCellId);
659 if (iMinSm >
fTofId->GetSModule(iCellId)) iMinSm =
fTofId->GetSModule(iCellId);
660 if (iMaxSm < fTofId->GetSModule(iCellId)) iMaxSm =
fTofId->GetSModule(iCellId);
662 if (iMinRpc >
fTofId->GetCounter(iCellId)) iMinRpc =
fTofId->GetCounter(iCellId);
663 if (iMaxRpc < fTofId->GetCounter(iCellId)) iMaxRpc =
fTofId->GetCounter(iCellId);
665 if (iMinGap >
fTofId->GetGap(iCellId)) iMinGap =
fTofId->GetGap(iCellId);
666 if (iMaxGap < fTofId->GetGap(iCellId)) iMaxGap =
fTofId->GetGap(iCellId);
668 if (iMinCell >
fTofId->GetCell(iCellId)) iMinCell =
fTofId->GetCell(iCellId);
669 if (iMaxCell < fTofId->GetCell(iCellId)) iMaxCell =
fTofId->GetCell(iCellId);
671 LOG(debug) <<
"SM type min " << iMinSmType <<
" max " << iMaxSmType;
672 LOG(debug) <<
"SM min " << iMinSm <<
" max " << iMaxSm;
673 LOG(debug) <<
"Rpc min " << iMinRpc <<
" max " << iMaxRpc;
674 LOG(debug) <<
"Gap min " << iMinGap <<
" max " << iMaxGap;
675 LOG(debug) <<
"Chan min " << iMinCell <<
" max " << iMaxCell;
1358 for (
Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1368 Int_t iNbTofTracks = 0;
1369 Int_t iNbTofTracksPrim = 0;
1371 LOG(debug1) <<
"CbmTofDigitize::DigitizeDirectClusterSize: " << nTofPoint <<
" points in Tof for this event with "
1372 << nMcTracks <<
" MC tracks ";
1373 for (
Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1380 LOG(debug1) <<
"CbmTofDigitize::DigitizeDirectClusterSize: " << iNbTofTracks <<
" tracks in Tof ";
1381 LOG(debug1) <<
"CbmTofDigitize::DigitizeDirectClusterSize: " << iNbTofTracksPrim <<
" tracks in Tof from vertex";
1385 Int_t iDetId, iSmType, iSM, iRpc, iChannel, iGap;
1386 Int_t iTrackID, iChanId;
1390 Double_t dClustCharge;
1396 Int_t iNbSm, iNbRpc, iNbCh;
1410 Double_t dStartJitter = 0.;
1412 dStartJitter = gRandom->Gaus(0.0,
fDigiBdfPar->GetStartTimeRes());
1415 for (
Int_t iPntInd = 0; iPntInd < nTofPoint; iPntInd++) {
1418 if (NULL == pPoint) {
1419 LOG(warning) <<
"CbmTofDigitize::DigitizeDirectClusterSize => Be "
1420 "careful: hole in the CbmTofPoint TClonesArray!";
1425 iDetId = pPoint->GetDetectorID();
1435 iTrackID = pPoint->GetTrackID();
1440 iChType =
fDigiBdfPar->GetChanType(iSmType, iRpc);
1441 Int_t iTrkId = pPoint->GetTrackID();
1448 LOG(fatal) <<
"CbmTofDigitize::DigitizeDirectClusterSize => TofPoint without "
1449 "valid MC track Index, "
1450 <<
" track was probably cut at the transport level! "
1451 <<
" Pnt Idx: " << iPntInd <<
" Trk Idx: " << iTrkId <<
"\n"
1452 <<
"=============> To allow this kind of points and simply jump "
1454 <<
"call CbmTofDigitize::AllowPointsWithoutTrack() in your macro!!";
1466 if (iSmType < 0. || iNbSmTypes <= iSmType || iSM < 0. || iNbSm <= iSM || iRpc < 0. || iNbRpc <= iRpc
1467 || iChannel < 0. || iNbCh <= iChannel) {
1468 LOG(error) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId) <<
" SMType: " << iSmType;
1469 LOG(error) <<
" SModule: " << iSM <<
" of " << iNbSm + 1;
1470 LOG(error) <<
" Module: " << iRpc <<
" of " << iNbRpc + 1;
1471 LOG(error) <<
" Gap: " << iGap;
1472 LOG(fatal) <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
1480 Bool_t bFoundIt = kFALSE;
1487 for (UInt_t uTrkMainCh = 0; uTrkMainCh <
fvlTrckChAddr[iTrkId].size(); uTrkMainCh++)
1493 if (kTRUE == bFoundIt)
continue;
1509 if (
fDigiBdfPar->GetGapEfficiency(iSmType, iRpc) < gRandom->Uniform(1))
continue;
1516 pPoint->Position(vPntPos);
1520 LOG(debug1) << Form(
" TofDigitizerBDF:: (%3d,%3d,%3d,%3d) - node at "
1521 "(%6.1f,%6.1f,%6.1f) : 0x%p Pos(%6.1f,%6.1f,%6.1f)",
1523 fNode, vPntPos.X(), vPntPos.Y(), vPntPos.Z());
1524 gGeoManager->GetCurrentNode();
1525 gGeoManager->GetCurrentMatrix();
1527 Double_t poipos[3] = {vPntPos.X(), vPntPos.Y(), vPntPos.Z()};
1528 Double_t poipos_local[3];
1529 Double_t poipos_local_man[3];
1530 gGeoManager->MasterToLocal(poipos, poipos_local_man);
1531 fDigiPar->GetNode(iChanId)->MasterToLocal(poipos, poipos_local);
1532 for (
Int_t i = 0; i < 3; i++)
1533 if (poipos_local[i] != poipos_local_man[i])
1534 LOG(fatal) <<
"Inconsistent M2L result " << i <<
": " << poipos_local[i] <<
" != " << poipos_local_man[i];
1537 LOG(error) <<
"CbmTofDigitize::DigitizeDirectClusterSize => This method "
1538 <<
"is not available for pads!!";
1546 Int_t iNbStripsSideA;
1547 Int_t iNbStripsSideB;
1548 if (1 == iClusterSize % 2) {
1550 iNbStripsSideA = (iClusterSize - 1) / 2;
1551 iNbStripsSideB = (iClusterSize - 1) / 2;
1556 iNbStripsSideA = iClusterSize / 2;
1557 iNbStripsSideB = iClusterSize / 2;
1559 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
1566 else if (poipos_local[0] <
fChannelInfo->GetSizex() / 2.0)
1576 Double_t dCentralTime;
1580 Bool_t bFoundIt = kFALSE;
1581 UInt_t uTrkRpcPair = 0;
1582 for (uTrkRpcPair = 0; uTrkRpcPair <
fvlTrckRpcAddr[iTrkId].size(); uTrkRpcPair++)
1588 if (kTRUE == bFoundIt)
1591 dCentralTime = pPoint->GetTime() + gRandom->Gaus(0.0,
fDigiBdfPar->GetResolution(iSmType))
1598 dCentralTime = pPoint->GetTime() + gRandom->Gaus(0.0,
fDigiBdfPar->GetResolution(iSmType))
1601 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
1606 TF1* f1ChargeGauss =
new TF1(
"f1ChargeDist",
"[0]*TMath::Gaus(x,[1],[2])", poipos_local[1] - 2 * iClusterSize,
1607 poipos_local[1] + 2 * iClusterSize);
1618 f1ChargeGauss->SetParameters(dClustCharge / (TMath::Sqrt(2.0 * TMath::Pi() * iClusterSize / 6.0)),
1619 poipos_local[1], 0.5 * iClusterSize / 3.0);
1623 f1ChargeGauss->CalcGaussLegendreSamplingPoints(
kiNbIntPts,
x, w, 1e-12);
1626 for (
Int_t iStripInd = iChannel - iNbStripsSideA; iStripInd <= iChannel + iNbStripsSideB; iStripInd++)
1627 if (0 <= iStripInd && iStripInd < iNbCh) {
1628 Int_t iCh1 = iStripInd;
1631 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
1634 Double_t dStripCharge =
1640 < dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1] / 2.0) {
1641 Double_t dTimeA = dCentralTime;
1643#ifdef FULL_PROPAGATION_TIME
1644 + TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() / 2.0))
1650 iSM, iRpc, iChannel, dTimeA,
1651 dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0, 1, iSmType);
1653 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1654 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(data);
1655 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(iPntInd);
1657 LOG(debug) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, valA %d, MCt %d", iSmType, iSM, iRpc, iChannel,
1662 < dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd] / 2.0) {
1663 Double_t dTimeB = dCentralTime;
1665#ifdef FULL_PROPAGATION_TIME
1666 + TMath::Abs(poipos_local[0] - (-
fChannelInfo->GetSizex() / 2.0))
1672 iSM, iRpc, iChannel, dTimeB,
1673 dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0, 0, iSmType);
1675 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1676 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(data);
1677 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(iPntInd);
1678 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, valB %d, MCt %d", iSmType, iSM, iRpc, iChannel,
1684 delete f1ChargeGauss;
1693 TF1* f1ChargeGauss =
new TF1(
"f1ChargeDist",
"[0]*TMath::Gaus(x,[1],[2])", poipos_local[0] - 2 * iClusterSize,
1694 poipos_local[0] + 2 * iClusterSize);
1703 f1ChargeGauss->SetParameters(dClustCharge / (TMath::Sqrt(2.0 * TMath::Pi()) * iClusterSize / 6.0),
1704 poipos_local[0], 0.5 * iClusterSize / 3.0);
1708 f1ChargeGauss->CalcGaussLegendreSamplingPoints(
kiNbIntPts,
x, w, 1e-12);
1711 for (
Int_t iStripInd = iChannel - iNbStripsSideA; iStripInd <= iChannel + iNbStripsSideB; iStripInd++)
1712 if (0 <= iStripInd && iStripInd < iNbCh) {
1713 Int_t iCh1 = iStripInd;
1716 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
1719 Double_t dStripCharge =
1725 < dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1] / 2.0) {
1726 Double_t dTimeA = dCentralTime;
1728#ifdef FULL_PROPAGATION_TIME
1729 + TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() / 2.0))
1734 LOG(debug) <<
"Create DigiA TSRC " << iSmType << iSM << iRpc << iStripInd
1735 << Form(
"at %f, ypos %f", dTimeA, poipos_local[1]);
1737 iSM, iRpc, iStripInd, dTimeA,
1738 dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1] / 2.0, 1, iSmType);
1740 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1741 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1].push_back(data);
1742 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1].push_back(iPntInd);
1743 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, valC %d, MCt %d", iSmType, iSM, iRpc, iChannel,
1748 < dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd] / 2.0) {
1749 Double_t dTimeB = dCentralTime;
1751#ifdef FULL_PROPAGATION_TIME
1752 + TMath::Abs(poipos_local[1] - (-
fChannelInfo->GetSizey() / 2.0))
1757 LOG(debug) <<
"Create DigiB TSRC " << iSmType << iSM << iRpc << iStripInd
1758 << Form(
"at %f, ypos %f", dTimeB, poipos_local[1]);
1760 iSM, iRpc, iStripInd, dTimeB,
1761 dStripCharge *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd] / 2.0, 0, iSmType);
1763 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1764 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd].push_back(data);
1765 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd].push_back(iPntInd);
1766 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, valE %d, MCt %d", iSmType, iSM, iRpc, iChannel,
1771 delete f1ChargeGauss;
1779 for (UInt_t uTrkInd = 0; uTrkInd <
fvlTrckChAddr.size(); uTrkInd++) {
1812 for (
Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1822 Int_t iNbTofTracks = 0;
1823 Int_t iNbTofTracksPrim = 0;
1825 LOG(debug1) <<
"CbmTofDigitize::DigitizeFlatDisc: " << nTofPoint <<
" points in Tof for this event with "
1826 << nMcTracks <<
" MC tracks ";
1827 for (
Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1834 LOG(debug1) <<
"CbmTofDigitize::DigitizeFlatDisc: " << iNbTofTracks <<
" tracks in Tof ";
1835 LOG(debug1) <<
"CbmTofDigitize::DigitizeFlatDisc: " << iNbTofTracksPrim <<
" tracks in Tof from vertex";
1839 Int_t iDetId, iSmType, iSM, iRpc, iChannel, iGap;
1840 Int_t iTrackID, iChanId;
1843 Double_t dClusterSize;
1844 Double_t dClustCharge;
1850 Int_t iNbSm, iNbRpc, iNbCh;
1864 Double_t dStartJitter = 0.;
1866 dStartJitter = gRandom->Gaus(0.0,
fDigiBdfPar->GetStartTimeRes());
1869 for (
Int_t iPntInd = 0; iPntInd < nTofPoint; iPntInd++) {
1872 if (NULL == pPoint) {
1873 LOG(warning) <<
"CbmTofDigitize::DigitizeFlatDisc => Be careful: hole in "
1874 "the CbmTofPoint TClonesArray!"
1880 iDetId = pPoint->GetDetectorID();
1889 iTrackID = pPoint->GetTrackID();
1894 iChType =
fDigiBdfPar->GetChanType(iSmType, iRpc);
1895 Int_t iTrkId = pPoint->GetTrackID();
1902 LOG(fatal) <<
"CbmTofDigitize::DigitizeDirectClusterSize => TofPoint without "
1903 "valid MC track Index, "
1904 <<
" track was probably cut at the transport level! "
1905 <<
" Pnt Idx: " << iPntInd <<
" Trk Idx: " << iTrkId <<
"\n"
1906 <<
"=============> To allow this kind of points and simply jump "
1908 <<
"call CbmTofDigitize::AllowPointsWithoutTrack() in your macro!!";
1915 LOG(debug1) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId) <<
", GeoVersion " <<
fGeoHandler->GetGeoVersion()
1916 <<
", SMType: " << iSmType <<
" SModule: " << iSM <<
" of " << iNbSm + 1 <<
" Module: " << iRpc
1917 <<
" of " << iNbRpc + 1 <<
" Gap: " << iGap <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
1928 if (iSmType < 0. || iNbSmTypes <= iSmType || iSM < 0. || iNbSm <= iSM || iRpc < 0. || iNbRpc <= iRpc
1929 || iChannel < 0. || iNbCh <= iChannel) {
1930 LOG(error) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId) <<
", GeoVersion " <<
fGeoHandler->GetGeoVersion()
1931 <<
", SMType: " << iSmType;
1932 LOG(error) <<
" SModule: " << iSM <<
" of " << iNbSm + 1;
1933 LOG(error) <<
" Module: " << iRpc <<
" of " << iNbRpc + 1;
1934 LOG(error) <<
" Gap: " << iGap;
1935 LOG(fatal) <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
1938 LOG(debug2) <<
"CbmTofDigitize::DigitizeFlatDisc => Check Point " << iPntInd <<
" Sm type " << iSmType <<
" SM "
1939 << iSM <<
" Rpc " << iRpc <<
" Channel " << iChannel <<
" Type " << iChType <<
" Orient. "
1946 Bool_t bFoundIt = kFALSE;
1953 for (UInt_t uTrkMainCh = 0; uTrkMainCh <
fvlTrckChAddr[iTrkId].size(); uTrkMainCh++)
1959 if (kTRUE == bFoundIt)
continue;
1975 LOG(debug2) <<
"CbmTofDigitize::DigitizeFlatDisc => Eff = " <<
fDigiBdfPar->GetGapEfficiency(iSmType, iRpc);
1977 if (
fDigiBdfPar->GetGapEfficiency(iSmType, iRpc) < gRandom->Uniform(1))
continue;
1984 pPoint->Position(vPntPos);
1987 LOG(warning) <<
"CbmTofDigitize::DigitizeFlatDisc: No DigPar for iChanId = "
1988 << Form(
"0x%08x, addr 0x%08x", iChanId, (
unsigned int) iDetId);
1994 LOG(debug1) << Form(
" TofDigitizerBDF:: (%3d,%3d,%3d,%3d) - node at "
1995 "(%6.1f,%6.1f,%6.1f) : %p Pos(%6.1f,%6.1f,%6.1f)",
1997 fNode, vPntPos.X(), vPntPos.Y(), vPntPos.Z());
1998 gGeoManager->GetCurrentNode();
1999 gGeoManager->GetCurrentMatrix();
2002 Double_t refpos_local[3];
2003 gGeoManager->MasterToLocal(refpos, refpos_local);
2004 Double_t poipos[3] = {vPntPos.X(), vPntPos.Y(), vPntPos.Z()};
2005 Double_t poipos_local[3];
2006 gGeoManager->MasterToLocal(poipos, poipos_local);
2007 LOG(debug1) << Form(
" TofDigitizerBDF:: DetId 0x%08x, ChanId 0x%08x, local "
2008 "pos (%5.1f,%5.1f,%5.1f) refpos (%5.1f,%5.1f,%5.1f) ",
2009 iDetId, iChanId, poipos_local[0], poipos_local[1], poipos_local[2], refpos_local[0],
2010 refpos_local[1], refpos_local[2]);
2011 for (
Int_t i = 0; i < 3; i++)
2012 poipos_local[i] -= refpos_local[i];
2019 while (dClusterSize < 0.0001 || 3.0 < dClusterSize)
2028 Double_t dClustArea = dClusterSize * dClusterSize * TMath::Pi();
2031 Double_t dChargeCentral =
2033 LOG(debug2) <<
"CbmTofDigitize::DigitizeFlatDisc: ChargeCentral " << dChargeCentral <<
", " << dClustCharge
2034 << Form(
", 0x%08x", iChanId) <<
", " << dClusterSize <<
", " << poipos_local[0] <<
", "
2035 << poipos_local[1] <<
", " << poipos_local[2];
2037 dChargeCentral /= dClustArea;
2038 if (dClustCharge + 0.0000001 < dChargeCentral) {
2039 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Central Charge " << dChargeCentral <<
" " << dClustCharge
2040 <<
" " << dClustCharge - dChargeCentral <<
" "
2043 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Check Point " << iPntInd <<
" Sm type " << iSmType <<
" SM "
2044 << iSM <<
" Rpc " << iRpc <<
" Channel " << iChannel <<
" Type " << iChType <<
" Orient. "
2049 Double_t dCentralTime;
2053 Bool_t bFoundIt = kFALSE;
2054 UInt_t uTrkRpcPair = 0;
2055 for (uTrkRpcPair = 0; uTrkRpcPair <
fvlTrckRpcAddr[iTrkId].size(); uTrkRpcPair++)
2061 if (kTRUE == bFoundIt)
2064 dCentralTime = pPoint->GetTime() + gRandom->Gaus(0.0,
fDigiBdfPar->GetResolution(iSmType))
2071 dCentralTime = pPoint->GetTime() + gRandom->Gaus(0.0,
fDigiBdfPar->GetResolution(iSmType))
2091 Double_t dTimeA = dCentralTime;
2092 Double_t dTimeB = dCentralTime;
2093 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
2096#ifdef FULL_PROPAGATION_TIME
2097 + TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() / 2.0))
2103#ifdef FULL_PROPAGATION_TIME
2104 + TMath::Abs(poipos_local[0] - (-
fChannelInfo->GetSizex() / 2.0))
2113#ifdef FULL_PROPAGATION_TIME
2114 + TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() / 2.0))
2121#ifdef FULL_PROPAGATION_TIME
2122 + TMath::Abs(poipos_local[1] - (-
fChannelInfo->GetSizey() / 2.0))
2130 <= dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0) {
2132 iSM, iRpc, iChannel, dTimeA,
2133 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0, 1, iSmType);
2136 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2137 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(data);
2138 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(iPntInd);
2139 LOG(debug1) << Form(
2140 "Digimatch (%d,%d,%d,%d): size %zu, MCp %d, MCt %d, TA %6.2f, TotA "
2141 "%6.1f, Ypos %6.1f, Vsig %6.1f ",
2142 iSmType, iSM, iRpc, iChannel,
fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd,
2143 iTrackID, dTimeA, dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0,
2148 <= dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0) {
2151 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0, 0, iSmType);
2153 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2154 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(data);
2155 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(iPntInd);
2156 LOG(debug1) << Form(
2157 "Digimatch (%d,%d,%d,%d): size %zu, MCp %d, MCt %d, TB %6.2f, TotB "
2159 iSmType, iSM, iRpc, iChannel,
fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd,
2160 iTrackID, dTimeB, dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0);
2185 Double_t dClustToReadout = 0.0;
2186 Double_t dPadTime = dCentralTime;
2188 if (iChannel < iNbCh / 2.0) {
2190 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc))
2192 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2193 + TMath::Power(poipos_local[0] - (+
fChannelInfo->GetSizex() / 2.0), 2));
2195 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2196 + TMath::Power(poipos_local[1] - (-
fChannelInfo->GetSizey() / 2.0), 2));
2200 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc))
2202 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2203 + TMath::Power(poipos_local[0] - (-
fChannelInfo->GetSizex() / 2.0), 2));
2205 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2206 + TMath::Power(poipos_local[1] - (+
fChannelInfo->GetSizey() / 2.0), 2));
2213 new CbmTofDigi(iSM, iRpc, iChannel, dPadTime,
2214 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChannel], 0, iSmType);
2216 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2217 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(data);
2218 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(iPntInd);
2219 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): MCpi %zu, valE %d, MCti %d", iSmType, iSM, iRpc, iChannel,
2220 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd, iTrackID);
2235 Int_t iMinChanInd = iChannel - 1;
2236 Int_t iMaxChanInd = iChannel + 1;
2238 Double_t dClusterDist = 0.0;
2239 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
2241 while (0 <= iMinChanInd) {
2242 dClusterDist = TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() * (iMinChanInd - iChannel + 0.5)));
2243 if (dClusterDist < dClusterSize)
2248 while (iMaxChanInd < iNbCh) {
2249 dClusterDist = TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() * (iMaxChanInd - iChannel - 0.5)));
2250 if (dClusterDist < dClusterSize)
2258 while (0 <= iMinChanInd) {
2259 dClusterDist = TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() * (iMinChanInd - iChannel + 0.5)));
2260 if (dClusterDist < dClusterSize)
2265 while (iMaxChanInd < iNbCh) {
2266 dClusterDist = TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() * (iMaxChanInd - iChannel - 0.5)));
2267 if (dClusterDist < dClusterSize)
2276 for (
Int_t iChanInd = iMinChanInd + 1; iChanInd < iMaxChanInd; iChanInd++) {
2277 if (iChanInd == iChannel)
continue;
2282 Int_t iCh1 = iChanInd;
2285 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
2290 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc: Invalid channel " << iSideChId <<
" " << iSmType <<
" "
2291 << iSM <<
" " << iRpc <<
" " << iChanInd + 1;
2296 Double_t dChargeSideCh =
2298 dChargeSideCh /= dClustArea;
2299 if (dClustCharge + 0.0000001 < dChargeSideCh) {
2300 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Side Charge " << dChargeSideCh <<
" " << dClustCharge
2301 <<
" " << dClustArea;
2302 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Check Point " << iPntInd <<
" Sm type " << iSmType
2303 <<
" SM " << iSM <<
" Rpc " << iRpc <<
" Channel " << iChanInd <<
" Type " << iChType
2304 <<
" Orient. " <<
fDigiBdfPar->GetChanOrient(iSmType, iRpc);
2308 Double_t dTimeA = dCentralTime;
2309 Double_t dTimeB = dCentralTime;
2311 LOG(debug1) << Form(
" TofDigitizerBDF:: chrg %7.1f, times %5.1f,%5.1f, "
2312 "pos %5.1f,%5.1f,%5.1f ",
2313 dChargeCentral, dTimeA, dTimeB, poipos_local[0], poipos_local[1], poipos_local[2]);
2315 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
2318#ifdef FULL_PROPAGATION_TIME
2319 + TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() / 2.0))
2325#ifdef FULL_PROPAGATION_TIME
2326 + TMath::Abs(poipos_local[0] - (-
fChannelInfo->GetSizex() / 2.0))
2336#ifdef FULL_PROPAGATION_TIME
2337 + TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() / 2.0))
2344#ifdef FULL_PROPAGATION_TIME
2345 + TMath::Abs(poipos_local[1] - (-
fChannelInfo->GetSizey() / 2.0))
2352 LOG(debug1) << Form(
" TofDigitizerBDF:: chrg %7.1f, gain %7.1f, thr %7.1f times "
2354 dChargeCentral,
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1],
2358 <= dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1] / 2.0) {
2360 iSM, iRpc, iChanInd, dTimeA,
2361 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1] / 2.0, 1, iSmType);
2363 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2364 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1].push_back(data);
2365 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1].push_back(iPntInd);
2366 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, MCpA %d, MCtt %d", iSmType, iSM, iRpc, iChanInd,
2367 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1].
size(), iPntInd, iTrackID);
2371 <= dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd] / 2.0) {
2374 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd] / 2.0, 0, iSmType);
2376 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2377 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd].push_back(data);
2378 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd].push_back(iPntInd);
2379 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, MCpB %d, MCtB %d", iSmType, iSM, iRpc, iChanInd,
2380 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1].
size(), iPntInd, iTrackID);
2408 Int_t iMinChanInd = iChannel;
2409 Int_t iMaxChanInd = iChannel;
2411 Double_t dClusterDist = 0;
2413 Bool_t bCheckOtherRow = kFALSE;
2414 if (iChannel < iNbCh / 2.0)
2419 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
2421 while (dClusterDist < dClusterSize && iRow * iNbCh / 2.0 < iMinChanInd) {
2424 TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() * (iMinChanInd - iChannel + (1 - 2 * iRow) / 2)));
2427 while (dClusterDist < dClusterSize && iMaxChanInd < (1 + iRow) * iNbCh / 2.0 - 1) {
2430 TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() * (iMaxChanInd - iChannel - (1 - 2 * iRow) / 2)));
2435 dClusterDist = TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() * (2 * iRow - 1) / 2));
2436 if (dClusterDist < dClusterSize) bCheckOtherRow = kTRUE;
2440 while (dClusterDist < dClusterSize && iRow * iNbCh / 2.0 < iMinChanInd) {
2443 TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() * (iMinChanInd - iChannel + (1 - 2 * iRow) / 2)));
2446 while (dClusterDist < dClusterSize && iMaxChanInd < (1 + iRow) * iNbCh / 2.0 - 1) {
2449 TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() * (iMaxChanInd - iChannel - (1 - 2 * iRow) / 2)));
2454 dClusterDist = TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() * (1 - 2 * iRow) / 2));
2455 if (dClusterDist < dClusterSize) bCheckOtherRow = kTRUE;
2460 for (
Int_t iChanInd = iMinChanInd + 1; iChanInd < iMaxChanInd; iChanInd++) {
2461 if (iChanInd == iChannel)
continue;
2465 Int_t iCh1 = iChanInd;
2469 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
2474 Double_t dChargeSideCh =
2476 dChargeSideCh /= dClustArea;
2482 Double_t dClustToReadout = 0.0;
2483 Double_t dPadTime = dCentralTime;
2485 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc))
2488 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2489 + TMath::Power(poipos_local[0] - (+(1 - 2 * iRow) *
fChannelInfo->GetSizex() / 2.0), 2));
2492 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2493 + TMath::Power(poipos_local[1] - (-(1 - 2 * iRow) *
fChannelInfo->GetSizey() / 2.0), 2));
2498 new CbmTofDigi(iSM, iRpc, iChanInd, dPadTime,
2499 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChanInd], 0, iSmType);
2501 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2502 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(data);
2503 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(iPntInd);
2504 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, MCpP %d, MCtP %d", iSmType, iSM, iRpc, iChannel,
2505 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd, iTrackID);
2509 if (kTRUE == bCheckOtherRow)
2510 for (
Int_t iChanInd = iMinChanInd + 1 + (1 - 2 * iRow) * iNbCh / 2.0;
2511 iChanInd < iMaxChanInd + (1 - 2 * iRow) * iNbCh / 2.0; iChanInd++) {
2514 Int_t iCh1 = iChanInd;
2518 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
2523 Double_t dChargeSideCh =
2530 Double_t dClustToReadout = 0.0;
2531 Double_t dPadTime = dCentralTime;
2533 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc))
2536 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2537 + TMath::Power(poipos_local[0] - (+(1 - 2 * iRow) *
fChannelInfo->GetSizex() / 2.0), 2));
2540 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2541 + TMath::Power(poipos_local[1] - (-(1 - 2 * iRow) *
fChannelInfo->GetSizey() / 2.0), 2));
2546 new CbmTofDigi(iSM, iRpc, iChanInd, dPadTime,
2547 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChanInd], 0, iSmType);
2549 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2550 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(data);
2551 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(iPntInd);
2552 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, MCpX %d, MCtX %d", iSmType, iSM, iRpc, iChannel,
2553 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd, iTrackID);
2562 for (UInt_t uTrkInd = 0; uTrkInd <
fvlTrckChAddr.size(); uTrkInd++) {
2595 for (
Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
2605 Int_t iNbTofTracks = 0;
2606 Int_t iNbTofTracksPrim = 0;
2608 LOG(debug1) <<
"CbmTofDigitize::DigitizeGaussCharge: " << nTofPoint <<
" points in Tof for this event with "
2609 << nMcTracks <<
" MC tracks ";
2610 for (
Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
2617 LOG(debug1) <<
"CbmTofDigitize::DigitizeGaussCharge: " << iNbTofTracks <<
" tracks in Tof ";
2618 LOG(debug1) <<
"CbmTofDigitize::DigitizeGaussCharge: " << iNbTofTracksPrim <<
" tracks in Tof from vertex";
2622 Int_t iDetId, iSmType, iSM, iRpc, iChannel, iGap;
2623 Int_t iTrackID, iChanId;
2626 Double_t dClusterSize;
2627 Double_t dClustCharge;
2633 Int_t iNbSm, iNbRpc, iNbCh;
2647 Double_t dStartJitter = 0.;
2649 dStartJitter = gRandom->Gaus(0.0,
fDigiBdfPar->GetStartTimeRes());
2652 for (
Int_t iPntInd = 0; iPntInd < nTofPoint; iPntInd++) {
2655 if (NULL == pPoint) {
2656 LOG(warning) <<
"CbmTofDigitize::DigitizeGaussCharge => Be careful: hole "
2657 "in the CbmTofPoint TClonesArray!"
2663 iDetId = pPoint->GetDetectorID();
2671 iTrackID = pPoint->GetTrackID();
2676 iChType =
fDigiBdfPar->GetChanType(iSmType, iRpc);
2677 Int_t iTrkId = pPoint->GetTrackID();
2684 LOG(fatal) <<
"CbmTofDigitize::DigitizeDirectClusterSize => TofPoint without "
2685 "valid MC track Index, "
2686 <<
" track was probably cut at the transport level! "
2687 <<
" Pnt Idx: " << iPntInd <<
" Trk Idx: " << iTrkId <<
"\n"
2688 <<
"=============> To allow this kind of points and simply jump "
2690 <<
"call CbmTofDigitize::AllowPointsWithoutTrack() in your macro!!";
2702 if (iSmType < 0. || iNbSmTypes < iSmType || iSM < 0. || iNbSm < iSM || iRpc < 0. || iNbRpc < iRpc || iChannel < 0.
2703 || iNbCh < iChannel) {
2704 LOG(error) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId) <<
" SMType: " << iSmType;
2705 LOG(error) <<
" SModule: " << iSM <<
" of " << iNbSm + 1;
2706 LOG(error) <<
" Module: " << iRpc <<
" of " << iNbRpc + 1;
2707 LOG(error) <<
" Gap: " << iGap;
2708 LOG(error) <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
2716 Bool_t bFoundIt = kFALSE;
2723 for (UInt_t uTrkMainCh = 0; uTrkMainCh <
fvlTrckChAddr[iTrkId].size(); uTrkMainCh++)
2729 if (kTRUE == bFoundIt)
continue;
2745 if (
fDigiBdfPar->GetGapEfficiency(iSmType, iRpc) < gRandom->Uniform(1))
continue;
2752 pPoint->Position(vPntPos);
2756 LOG(debug1) << Form(
" TofDigitizerBDF:: (%3d,%3d,%3d,%3d) - node at "
2757 "(%6.1f,%6.1f,%6.1f) : 0x%p Pos(%6.1f,%6.1f,%6.1f)",
2759 fNode, vPntPos.X(), vPntPos.Y(), vPntPos.Z());
2760 gGeoManager->GetCurrentNode();
2761 gGeoManager->GetCurrentMatrix();
2762 Double_t poipos[3] = {vPntPos.X(), vPntPos.Y(), vPntPos.Z()};
2763 Double_t poipos_local[3];
2764 gGeoManager->MasterToLocal(poipos, poipos_local);
2768 while (dClusterSize < 0.0001)
2778 TF2* f2ChargeDist =
new TF2(
"ChargeDist",
"[0]*TMath::Gaus(x,[1],[2])*TMath::Gaus(y,[3],[4])", -5.0 * dClusterSize,
2779 5.0 * dClusterSize, -5.0 * dClusterSize, 5.0 * dClusterSize);
2780 f2ChargeDist->SetParameters(dClustCharge / (TMath::Sqrt(2.0 * TMath::Pi()) * dClusterSize / 3.0), poipos_local[0],
2781 dClusterSize / 3.0, poipos_local[1], dClusterSize / 3.0);
2784 Double_t dChargeCentral = f2ChargeDist->Integral(
2789 Double_t dCentralTime;
2793 Bool_t bFoundIt = kFALSE;
2794 UInt_t uTrkRpcPair = 0;
2795 for (uTrkRpcPair = 0; uTrkRpcPair <
fvlTrckRpcAddr[iTrkId].size(); uTrkRpcPair++)
2801 if (kTRUE == bFoundIt)
2804 dCentralTime = pPoint->GetTime() + gRandom->Gaus(0.0,
fDigiBdfPar->GetResolution(iSmType))
2811 dCentralTime = pPoint->GetTime() + gRandom->Gaus(0.0,
fDigiBdfPar->GetResolution(iSmType))
2827 Double_t dTimeA = dCentralTime;
2828 Double_t dTimeB = dCentralTime;
2829 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
2832#ifdef FULL_PROPAGATION_TIME
2833 + TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() / 2.0))
2839#ifdef FULL_PROPAGATION_TIME
2840 + TMath::Abs(poipos_local[0] - (-
fChannelInfo->GetSizex() / 2.0))
2849#ifdef FULL_PROPAGATION_TIME
2850 + TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() / 2.0))
2856#ifdef FULL_PROPAGATION_TIME
2857 + TMath::Abs(poipos_local[1] - (-
fChannelInfo->GetSizey() / 2.0))
2865 iSM, iRpc, iChannel, dTimeA,
2866 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0, 1, iSmType);
2868 std::pair<CbmTofDigi*, CbmMatch*> data1(tofDigi,
nullptr);
2869 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(data1);
2870 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(iPntInd);
2871 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val1 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
2872 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].
size(), iPntInd, iTrackID);
2876 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0, 0, iSmType);
2878 std::pair<CbmTofDigi*, CbmMatch*> data2(tofDigi,
nullptr);
2879 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(data2);
2880 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(iPntInd);
2881 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val2 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
2882 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].
size(), iPntInd, iTrackID);
2906 Double_t dClustToReadout = 0.0;
2907 Double_t dPadTime = dCentralTime;
2909 if (iChannel < iNbCh / 2.0) {
2911 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc))
2913 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2914 + TMath::Power(poipos_local[0] - (
fChannelInfo->GetSizex() / 2.0), 2));
2916 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2917 + TMath::Power(poipos_local[1] - (-
fChannelInfo->GetSizey() / 2.0), 2));
2921 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc))
2923 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2924 + TMath::Power(poipos_local[0] - (-
fChannelInfo->GetSizex() / 2.0), 2));
2926 dClustToReadout = TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2927 + TMath::Power(poipos_local[1] - (+
fChannelInfo->GetSizey() / 2.0), 2));
2934 new CbmTofDigi(iSM, iRpc, iChannel, dPadTime,
2935 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChannel], 0, iSmType);
2937 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2938 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(data);
2939 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(iPntInd);
2940 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val3 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
2949 Int_t iSideChInd = iChannel - 1;
2953 Int_t iCh1 = iSideChInd;
2957 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
2962 Double_t dChargeSideCh = f2ChargeDist->Integral(
2966 while (
fDigiBdfPar->GetFeeThreshold() <= dChargeSideCh && 0 <= iSideChInd) {
2968 Double_t dTimeA = dCentralTime;
2969 Double_t dTimeB = dCentralTime;
2970 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
2973#ifdef FULL_PROPAGATION_TIME
2974 + TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() / 2.0))
2980#ifdef FULL_PROPAGATION_TIME
2981 + TMath::Abs(poipos_local[0] - (-
fChannelInfo->GetSizex() / 2.0))
2990#ifdef FULL_PROPAGATION_TIME
2991 + TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() / 2.0))
2997#ifdef FULL_PROPAGATION_TIME
2998 + TMath::Abs(poipos_local[1] - (-
fChannelInfo->GetSizey() / 2.0))
3006 iSM, iRpc, iSideChInd, dTimeA,
3007 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1] / 2.0, 1, iSmType);
3009 std::pair<CbmTofDigi*, CbmMatch*> data1(tofDigi,
nullptr);
3010 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(data1);
3011 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(iPntInd);
3012 tofDigi =
new CbmTofDigi(iSM, iRpc, iSideChInd, dTimeB,
3013 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd] / 2.0, 0,
3016 std::pair<CbmTofDigi*, CbmMatch*> data2(tofDigi,
nullptr);
3017 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(data2);
3018 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(iPntInd);
3019 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val4 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3020 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].
size(), iPntInd, iTrackID);
3029 Int_t iCh2 = iSideChInd;
3031 xDetInfo.
fCell = iCh2;
3033 iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
3045 if (iChannel < iNbCh - 1) {
3046 Int_t iSideChInd = iChannel + 1;
3050 Int_t iCh1 = iSideChInd;
3054 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
3059 Double_t dChargeSideCh = f2ChargeDist->Integral(
3063 while (
fDigiBdfPar->GetFeeThreshold() < dChargeSideCh && iSideChInd < iNbCh) {
3065 Double_t dTimeA = dCentralTime;
3066 Double_t dTimeB = dCentralTime;
3067 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc)) {
3070#ifdef FULL_PROPAGATION_TIME
3071 + TMath::Abs(poipos_local[0] - (+
fChannelInfo->GetSizex() / 2.0))
3077#ifdef FULL_PROPAGATION_TIME
3078 + TMath::Abs(poipos_local[0] - (-
fChannelInfo->GetSizex() / 2.0))
3087#ifdef FULL_PROPAGATION_TIME
3088 + TMath::Abs(poipos_local[1] - (+
fChannelInfo->GetSizey() / 2.0))
3094#ifdef FULL_PROPAGATION_TIME
3095 + TMath::Abs(poipos_local[1] - (-
fChannelInfo->GetSizey() / 2.0))
3103 iSM, iRpc, iSideChInd, dTimeA,
3104 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1] / 2.0, 1, iSmType);
3106 std::pair<CbmTofDigi*, CbmMatch*> data1(tofDigi,
nullptr);
3107 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(data1);
3108 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(iPntInd);
3109 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val5 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3113 tofDigi =
new CbmTofDigi(iSM, iRpc, iSideChInd, dTimeB,
3114 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd] / 2.0, 0,
3117 std::pair<CbmTofDigi*, CbmMatch*> data2(tofDigi,
nullptr);
3118 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(data2);
3119 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(iPntInd);
3120 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val6 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3121 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].
size(), iPntInd, iTrackID);
3128 xDetInfo.
fCell = iSideChInd + 1;
3130 iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
3164 Int_t iMinChanInd = iChannel;
3165 Int_t iMaxChanInd = iChannel;
3170 if (iChannel < iNbCh / 2.0)
3176 if (iRow * iNbCh / 2.0 < iChannel) {
3177 Int_t iSideChInd = iChannel - 1;
3181 Int_t iCh1 = iSideChInd;
3185 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
3190 Double_t dChargeSideCh = f2ChargeDist->Integral(
3194 while (
fDigiBdfPar->GetFeeThreshold() < dChargeSideCh && iRow * iNbCh / 2.0 <= iSideChInd) {
3195 iMinChanInd = iSideChInd;
3197 Double_t dClustToReadout = 0.0;
3198 Double_t dPadTime = dCentralTime;
3200 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc))
3203 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
3204 + TMath::Power(poipos_local[0] - ((1 - 2 * iRow) *
fChannelInfo->GetSizex() / 2.0), 2));
3207 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
3208 + TMath::Power(poipos_local[1] - (-(1 - 2 * iRow) *
fChannelInfo->GetSizey() / 2.0), 2));
3213 new CbmTofDigi(iSM, iRpc, iSideChInd, dPadTime,
3214 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iSideChInd], 0, iSmType);
3216 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3217 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(data);
3218 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(iPntInd);
3219 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val7 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3220 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].
size(), iPntInd, iTrackID);
3228 xDetInfo.
fCell = iSideChInd + 1;
3230 iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
3242 if (iChannel < (1 + iRow) * iNbCh / 2.0 - 1) {
3243 Int_t iSideChInd = iChannel + 1;
3247 Int_t iCh1 = iSideChInd;
3251 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
3256 Double_t dChargeSideCh = f2ChargeDist->Integral(
3260 while (
fDigiBdfPar->GetFeeThreshold() < dChargeSideCh && iSideChInd < (1 + iRow) * iNbCh / 2.0) {
3261 iMaxChanInd = iSideChInd;
3263 Double_t dClustToReadout = 0.0;
3264 Double_t dPadTime = dCentralTime;
3266 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc))
3269 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
3270 + TMath::Power(poipos_local[0] - (+(1 - 2 * iRow) *
fChannelInfo->GetSizex() / 2.0), 2));
3273 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
3274 + TMath::Power(poipos_local[1] - (-(1 - 2 * iRow) *
fChannelInfo->GetSizey() / 2.0), 2));
3279 new CbmTofDigi(iSM, iRpc, iSideChInd, dPadTime,
3280 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iSideChInd], 0, iSmType);
3282 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3283 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(data);
3284 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(iPntInd);
3285 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val8 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3293 xDetInfo.
fCell = iSideChInd + 1;
3295 iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
3312 Int_t iCh1 = iChannel;
3315 Int_t iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
3319 Double_t dChargeSideCh = f2ChargeDist->Integral(
3323 if (
fDigiBdfPar->GetFeeThreshold() < dChargeSideCh) {
3326 for (
Int_t iChanInd = iMinChanInd + (1 - 2 * iRow) * iNbCh / 2.0;
3327 iChanInd <= iMaxChanInd + (1 - 2 * iRow) * iNbCh / 2.0; iChanInd++) {
3330 xDetInfo.
fCell = iChanInd + 1;
3331 iSideChId =
fTofId->SetDetectorInfo(xDetInfo);
3340 if (
fDigiBdfPar->GetFeeThreshold() < dChargeSideCh) {
3341 Double_t dClustToReadout = 0.0;
3342 Double_t dPadTime = dCentralTime;
3344 if (1 ==
fDigiBdfPar->GetChanOrient(iSmType, iRpc))
3347 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
3348 + TMath::Power(poipos_local[0] - (+(1 - 2 * iRow) *
fChannelInfo->GetSizex() / 2.0), 2));
3351 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
3352 + TMath::Power(poipos_local[1] - (-(1 - 2 * iRow) *
fChannelInfo->GetSizey() / 2.0), 2));
3357 new CbmTofDigi(iSM, iRpc, iChanInd, dPadTime,
3358 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChanInd], 0, iSmType);
3360 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3361 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(data);
3362 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(iPntInd);
3363 LOG(debug1) << Form(
"Digimatch (%d,%d,%d,%d): size %zu, val9 %d, MCt %d", iSmType, iSM, iRpc, iChannel,
3371 delete f2ChargeDist;
3376 for (UInt_t uTrkInd = 0; uTrkInd <
fvlTrckChAddr.size(); uTrkInd++) {
3391 Double_t dClustCentY)
3393 Double_t dCornersX[4];
3394 Double_t dCornersY[4];
3395 Double_t dCornersR[4];
3398 Double_t dChanCentPosX = 0.;
3399 Double_t dChanCentPosY = 0.;
3400 Double_t dEdgeCentDistX =
fChannelInfo->GetSizex() / 2.0;
3401 Double_t dEdgeCentDistY =
fChannelInfo->GetSizey() / 2.0;
3404 dCornersX[0] = dChanCentPosX - dEdgeCentDistX;
3405 dCornersY[0] = dChanCentPosY + dEdgeCentDistY;
3406 dCornersR[0] = TMath::Sqrt(TMath::Power(dCornersX[0] - dClustCentX, 2) + TMath::Power(dCornersY[0] - dClustCentY, 2));
3408 dCornersX[1] = dChanCentPosX + dEdgeCentDistX;
3409 dCornersY[1] = dChanCentPosY + dEdgeCentDistY;
3410 dCornersR[1] = TMath::Sqrt(TMath::Power(dCornersX[1] - dClustCentX, 2) + TMath::Power(dCornersY[1] - dClustCentY, 2));
3412 dCornersX[2] = dChanCentPosX + dEdgeCentDistX;
3413 dCornersY[2] = dChanCentPosY - dEdgeCentDistY;
3414 dCornersR[2] = TMath::Sqrt(TMath::Power(dCornersX[2] - dClustCentX, 2) + TMath::Power(dCornersY[2] - dClustCentY, 2));
3416 dCornersX[3] = dChanCentPosX - dEdgeCentDistX;
3417 dCornersY[3] = dChanCentPosY - dEdgeCentDistY;
3418 dCornersR[3] = TMath::Sqrt(TMath::Power(dCornersX[3] - dClustCentX, 2) + TMath::Power(dCornersY[3] - dClustCentY, 2));
3420 Int_t iNbCornersIn = (dCornersR[0] < dClustRadius ? 1 : 0) + (dCornersR[1] < dClustRadius ? 1 : 0)
3421 + (dCornersR[2] < dClustRadius ? 1 : 0) + (dCornersR[3] < dClustRadius ? 1 : 0);
3423 LOG(debug3) <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => Check " << iNbCornersIn <<
" Radius " << dClustRadius
3424 <<
" " << dCornersR[0] <<
" " << dCornersR[1] <<
" " << dCornersR[2] <<
" " << dCornersR[3];
3426 switch (iNbCornersIn) {
3432 dEdgeR[0] = dChanCentPosX - dEdgeCentDistX - dClustCentX;
3433 dEdgeR[1] = dChanCentPosX + dEdgeCentDistX - dClustCentX;
3434 dEdgeR[2] = dChanCentPosY - dEdgeCentDistY - dClustCentY;
3435 dEdgeR[3] = dChanCentPosY + dEdgeCentDistY - dClustCentY;
3436 if ((0.0 >= dEdgeR[0]) && (0.0 <= dEdgeR[1]) && (0.0 >= dEdgeR[2]) && (0.0 <= dEdgeR[3])) {
3440 Double_t dArea = dClustRadius * dClustRadius * TMath::Pi();
3442 LOG(debug3) <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => CC in Ch " << dArea;
3447 if (TMath::Abs(dEdgeR[0]) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR[0]));
3448 if (TMath::Abs(dEdgeR[1]) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR[1]));
3449 if (TMath::Abs(dEdgeR[2]) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR[2]));
3450 if (TMath::Abs(dEdgeR[3]) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR[3]));
3452 LOG(error) <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => Neg. area! " << dArea <<
" Radius "
3453 << dClustRadius <<
" " << dEdgeR[0] <<
" " << dEdgeR[1] <<
" " << dEdgeR[2] <<
" " << dEdgeR[3];
3462 LOG(debug3) <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => CC out Ch " << dClustRadius <<
" " << dEdgeR[0]
3463 <<
" " << dEdgeR[1] <<
" " << dEdgeR[2] <<
" " << dEdgeR[3];
3465 if (TMath::Abs(dEdgeR[0]) < dClustRadius)
3467 else if (TMath::Abs(dEdgeR[1]) < dClustRadius)
3469 else if (TMath::Abs(dEdgeR[2]) < dClustRadius)
3471 else if (TMath::Abs(dEdgeR[3]) < dClustRadius)
3485 Double_t dIntPtX[2] = {0., 0.};
3486 Double_t dIntPtY[2] = {0., 0.};
3487 Double_t dArea = 0.;
3489 if (dCornersR[0] < dClustRadius) {
3492 dIntPtX[0] = dCornersX[0];
3493 dIntPtY[0] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3496 dIntPtY[1] = dCornersY[0];
3499 dArea =
TriangleArea(dCornersX[0], dCornersY[0], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3501 else if (dCornersR[1] < dClustRadius) {
3504 dIntPtX[0] = dCornersX[1];
3508 dIntPtY[1] = dCornersY[1];
3511 dArea =
TriangleArea(dCornersX[1], dCornersY[1], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3513 else if (dCornersR[2] < dClustRadius) {
3516 dIntPtX[0] = dCornersX[2];
3519 dIntPtX[1] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3520 dIntPtY[1] = dCornersY[2];
3523 dArea =
TriangleArea(dCornersX[2], dCornersY[2], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3525 else if (dCornersR[3] < dClustRadius) {
3528 dIntPtX[0] = dCornersX[3];
3529 dIntPtY[0] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3531 dIntPtX[1] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3532 dIntPtY[1] = dCornersY[3];
3535 dArea =
TriangleArea(dCornersX[3], dCornersY[3], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3540 Double_t dSecBaseD =
DistanceCircleToBase(dClustRadius, dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3559 Bool_t bFirstCorner = kTRUE;
3564 if (dCornersR[0] < dClustRadius) {
3567 bFirstCorner = kFALSE;
3569 if (dCornersR[1] < dClustRadius) {
3571 if (kTRUE == bFirstCorner) {
3573 bFirstCorner = kFALSE;
3578 if (dCornersR[2] < dClustRadius) {
3580 if (kTRUE == bFirstCorner) {
3582 bFirstCorner = kFALSE;
3587 if (dCornersR[3] < dClustRadius) {
3593 LOG(debug3) <<
"Corners In check " << (iCorners[0]) <<
" " << (iCorners[1]);
3595 Double_t dIntPtX[2] = {0., 0.};
3596 Double_t dIntPtY[2] = {0., 0.};
3597 Double_t dEdgeR = 0.;
3598 Int_t iOppCorner = 0;
3599 if (0 == iCorners[0] && 1 == iCorners[1]) {
3600 LOG(debug3) <<
"Test upper edge";
3603 dIntPtX[0] = dCornersX[0];
3604 dIntPtY[0] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3606 dIntPtX[1] = dCornersX[1];
3611 dEdgeR = dChanCentPosY - dEdgeCentDistY - dClustCentY;
3613 else if (1 == iCorners[0] && 2 == iCorners[1]) {
3614 LOG(debug3) <<
"Test right edge";
3618 dIntPtY[0] = dCornersY[1];
3620 dIntPtX[1] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3621 dIntPtY[1] = dCornersY[2];
3625 dEdgeR = dChanCentPosX - dEdgeCentDistX - dClustCentX;
3627 else if (2 == iCorners[0] && 3 == iCorners[1]) {
3628 LOG(debug3) <<
"Test lower edge";
3631 dIntPtX[0] = dCornersX[2];
3634 dIntPtX[1] = dCornersX[3];
3635 dIntPtY[1] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3639 dEdgeR = dChanCentPosY + dEdgeCentDistY - dClustCentY;
3641 else if (0 == iCorners[0] && 3 == iCorners[1]) {
3642 LOG(debug3) <<
"Test left edge";
3645 dIntPtX[0] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3646 dIntPtY[0] = dCornersY[3];
3649 dIntPtY[1] = dCornersY[0];
3653 dEdgeR = dChanCentPosX + dEdgeCentDistX - dClustCentX;
3657 Double_t dArea =
TriangleArea(dCornersX[iCorners[0]], dCornersY[iCorners[0]], dCornersX[iCorners[1]],
3658 dCornersY[iCorners[1]], dIntPtX[0], dIntPtY[0]);
3661 TriangleArea(dCornersX[iOppCorner], dCornersY[iOppCorner], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3665 Double_t dSecBaseD =
DistanceCircleToBase(dClustRadius, dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3674 if (TMath::Abs(dEdgeR) < dClustRadius) dArea -=
DiscSectionArea(dClustRadius, TMath::Abs(dEdgeR));
3686 Int_t iOutCorner = 0;
3687 Double_t dIntPtX[2] = {0., 0.};
3688 Double_t dIntPtY[2] = {0., 0.};
3690 if (dCornersR[0] > dClustRadius) {
3695 dIntPtY[0] = dCornersY[0];
3697 dIntPtX[1] = dCornersX[0];
3698 dIntPtY[1] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3700 else if (dCornersR[1] > dClustRadius) {
3705 dIntPtY[0] = dCornersY[1];
3707 dIntPtX[1] = dCornersX[1];
3710 else if (dCornersR[2] > dClustRadius) {
3714 dIntPtX[0] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3715 dIntPtY[0] = dCornersY[2];
3717 dIntPtX[1] = dCornersX[2];
3720 else if (dCornersR[3] > dClustRadius) {
3724 dIntPtX[0] =
CircleIntersectPosX(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3725 dIntPtY[0] = dCornersY[3];
3727 dIntPtX[1] = dCornersX[3];
3728 dIntPtY[1] =
CircleIntersectPosY(iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
3736 TriangleArea(dCornersX[iOutCorner], dCornersY[iOutCorner], dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
3740 Double_t dSecBaseD =
DistanceCircleToBase(dClustRadius, dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);