14 #include "TClonesArray.h"
15 #include "TDirectory.h"
17 #include "TGeoManager.h"
26 #include "FairEventHeader.h"
27 #include "FairLogger.h"
28 #include "FairMCEventHeader.h"
29 #include "FairRootManager.h"
30 #include "FairRunAna.h"
31 #include "FairRunSim.h"
32 #include "FairRuntimeDb.h"
55 using std::setprecision;
64 typedef std::pair<CbmTofDigi*, CbmMatch*>
data;
66 Bool_t bOK = (pair1.first->GetTime() < pair2.first->GetTime());
90 , fdSignalPropSpeed(0.)
91 , fh1ClusterSizeProb()
93 , fvdSignalVelocityRpc()
102 , fTofPointsColl(NULL)
103 , fMcTracksColl(NULL)
110 , fsHistoOutFilename(
"")
111 , fhTofPointsPerTrack(NULL)
112 , fhTofPtsInTrkVsGapInd(NULL)
113 , fhTofPtsInTrkVsGapIndPrm(NULL)
114 , fhTofPtsInTrkVsGapIndSec(NULL)
116 , fhEvtProcTime(NULL)
117 , fhDigiMergeTime(NULL)
118 , fhDigiNbElecCh(NULL)
119 , fhProcTimeEvtSize(NULL)
120 , fhMeanDigiPerTrack(NULL)
121 , fhMeanFiredPerTrack(NULL)
124 , fhDigiTimeRes(NULL)
125 , fhDigiTimeResB(NULL)
127 , fhElecChOccup(NULL)
128 , fhMultiDigiEvtElCh(NULL)
129 , fhNbDigiEvtElCh(NULL)
130 , fhNbTracksEvtElCh(NULL)
131 , fhFiredEvtElCh(NULL)
132 , fhMultiProbElCh(NULL)
139 , fdNofTofMcTrkTot(0.)
143 , fsBeamInputFile(
"")
144 , fbMonitorHistos(kTRUE)
145 , fbMcTrkMonitor(kFALSE)
146 , fbTimeBasedOutput(kFALSE)
147 , fbAllowPointsWithoutTrack(kFALSE)
152 fdDigiTimeConvFactor(1.) {}
159 , fdSignalPropSpeed(0.)
160 , fh1ClusterSizeProb()
161 , fh1ClusterTotProb()
162 , fvdSignalVelocityRpc()
171 , fTofPointsColl(NULL)
172 , fMcTracksColl(NULL)
179 , fsHistoOutFilename(
"")
180 , fhTofPointsPerTrack(NULL)
181 , fhTofPtsInTrkVsGapInd(NULL)
182 , fhTofPtsInTrkVsGapIndPrm(NULL)
183 , fhTofPtsInTrkVsGapIndSec(NULL)
185 , fhEvtProcTime(NULL)
186 , fhDigiMergeTime(NULL)
187 , fhDigiNbElecCh(NULL)
188 , fhProcTimeEvtSize(NULL)
189 , fhMeanDigiPerTrack(NULL)
190 , fhMeanFiredPerTrack(NULL)
193 , fhDigiTimeRes(NULL)
194 , fhDigiTimeResB(NULL)
196 , fhElecChOccup(NULL)
197 , fhMultiDigiEvtElCh(NULL)
198 , fhNbDigiEvtElCh(NULL)
199 , fhNbTracksEvtElCh(NULL)
200 , fhFiredEvtElCh(NULL)
201 , fhMultiProbElCh(NULL)
208 , fdNofTofMcTrkTot(0.)
212 , fsBeamInputFile(
"")
213 , fbMonitorHistos(kTRUE)
214 , fbMcTrkMonitor(kFALSE)
215 , fbTimeBasedOutput(kFALSE)
216 , fbAllowPointsWithoutTrack(kFALSE)
221 fdDigiTimeConvFactor(1.) {}
231 std::cout << std::endl;
232 LOG(info) <<
"==========================================================";
233 LOG(info) << GetName() <<
": Initialisation";
234 if (
fEventMode) LOG(info) << GetName() <<
": Using event mode.";
238 TString fileName = gSystem->Getenv(
"VMCWORKDIR");
239 fileName +=
"/parameters/tof/test_bdf_input.root";
241 LOG(info) << GetName() <<
": Using default parameter file " << fileName;
254 LOG(info) << GetName() <<
": Initialisation successful";
255 LOG(info) <<
"==========================================================";
260 LOG(info) <<
" CbmTofDigitize => Get the digi parameters for tof";
263 FairRun* ana = FairRun::Instance();
264 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
277 LOG(debug) << fName <<
": Processing event " <<
fCurrentEvent <<
" at "
285 LOG(debug) << fName <<
": Using cluster model "
296 + (
fStop.GetNanoSec() -
fStart.GetNanoSec()) / 1e9;
298 LOG(debug) << fName <<
": Merge digis ";
302 + (
fStart.GetNanoSec() -
fStop.GetNanoSec()) / 1e9;
312 LOG(info) <<
"+ " << setw(15) << GetName() <<
": Event " << setw(6) << right
315 <<
", digis: " <<
fiNbDigis <<
". Exec time " << setprecision(6)
316 <<
fTimer.RealTime() <<
" s.";
320 std::cout << std::endl;
321 LOG(info) <<
"=====================================";
324 LOG(info) << GetName() <<
": Run summary (Time includes Hist filling)";
329 LOG(info) <<
"TofPoint / event : "
331 LOG(info) <<
"TofDigi / event : "
337 LOG(info) <<
"Real time per event : "
346 LOG(info) <<
"=====================================";
352 FairRootManager* fManager = FairRootManager::Instance();
356 LOG(error) <<
"CbmTofDigitize::RegisterInputs => Could not get the "
357 "TofPoint TClonesArray!!!";
361 fMcTracksColl = (TClonesArray*) fManager->GetObject(
"MCTrack");
363 LOG(error) <<
"CbmTofDigitize::RegisterInputs => Could not get the MCTrack "
372 Bool_t isSimulation = kFALSE;
374 if (
k12b > iGeoVersion) {
375 LOG(error) <<
"CbmTofDigitize::InitParameters => Only compatible with "
376 "geometries after v12b !!!";
380 LOG(info) << fName <<
": GeoVersion " << iGeoVersion;
382 switch (iGeoVersion) {
386 LOG(error) <<
"CbmTofDigitize::InitParameters: Invalid Detector ID "
393 LOG(info) <<
"Create DigiPar";
397 LOG(debug) <<
" CbmTofDigitize::LoadBeamtimeValues Digi Par contains "
402 LOG(info) << fName <<
": Load beamtime values from " <<
fsBeamInputFile;
410 LOG(fatal) <<
"CbmTofDigitize::LoadBeamtimeValues: Cluster properties from "
411 "testbeam could not be loaded! ";
428 <<
"CbmTofDigitize::LoadBeamtimeValues: ini gain values for SmTypes "
433 TRandom3 randFeeGain;
442 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
443 LOG(debug2) <<
"CbmTofDigitize::LoadBeamtimeValues => Gain for SM type "
452 if (iSmType == 5 && iNbSm > 0) {
454 LOG(info) <<
"Generate Fake Beam Counter digis";
457 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
459 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++)
467 for (Int_t iSm = 0; iSm < iNbSm; iSm++) {
470 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
471 LOG(debug2) <<
"CbmTofDigitize::LoadBeamtimeValues => Gain for SM/Rpc "
472 << iSm <<
"/" << iRpc;
481 fdChannelGain[iSmType][iSm * iNbRpc + iRpc].resize(iNbCh * iNbSides);
483 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
484 for (Int_t iSide = 0; iSide < iNbSides; iSide++) {
487 [iCh * iNbSides + iSide] =
490 [iCh * iNbSides + iSide]
492 LOG(error) <<
"CbmTofDigitize::LoadBeamtimeValues => Neg. Gain "
494 << iSm <<
"/" << iRpc <<
" "
496 [iCh * iNbSides + iSide];
500 [iCh * iNbSides + iSide] = 1;
507 TDirectory* oldir = gDirectory;
513 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
514 LOG(debug2) <<
"CbmTofDigitize::LoadBeamtimeValues => SM type " << iSmType;
519 new TH1D(Form(
"ClusterSizeProb%03d", iSmType),
520 "Random throw to Cluster size mapping",
525 Int_t iNbBinsSize = hClusterSize->GetNbinsX();
528 Double_t dIntegral = 0.;
539 Double_t dIntSize = hClusterSize->Integral();
540 Double_t dSizeVal = 0.;
542 for (Int_t iBin = 1; iBin <= iNbBinsSize; iBin++) {
543 dIntegral += hClusterSize->GetBinContent(iBin);
544 if ((Double_t) iProbBin / dNbBinsProb < dIntegral / dIntSize)
545 dSizeVal = hClusterSize->GetBinCenter(iBin);
546 while ((Double_t) iProbBin / dNbBinsProb < dIntegral / dIntSize) {
559 LOG(debug) <<
"CbmTofDigitize::LoadBeamtimeValues => SM type "
560 << iSmType <<
" Mean Cluster Size "
568 LOG(debug) <<
"CbmTofDigitize::LoadBeamtimeValues => SM type "
569 << iSmType <<
" Mean Cluster Size "
582 "Random throw to Cluster Tot mapping",
587 Int_t iNbBinsTot = hClusterTot->GetNbinsX();
590 Double_t dIntegral = 0.;
601 Double_t dIntTot = hClusterTot->Integral();
602 Double_t dTotVal = 0.;
606 for (Int_t iBin = 1; iBin <= iNbBinsTot; iBin++) {
607 dIntegral += hClusterTot->GetBinContent(iBin);
608 if ((Double_t) iProbBin / dNbBinsProb < dIntegral / dIntTot)
609 dTotVal = hClusterTot->GetBinLowEdge(iBin) / dPsToNs;
610 while ((Double_t) iProbBin / dNbBinsProb < dIntegral / dIntTot) {
617 gDirectory->cd(oldir->GetPath());
622 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
625 fStorDigi[iSmType].resize(iNbSm * iNbRpc);
627 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
628 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
631 fStorDigi[iSmType][iSm * iNbRpc + iRpc].resize(iNbCh * iNbSides);
632 fStorDigiMatch[iSmType][iSm * iNbRpc + iRpc].resize(iNbCh * iNbSides);
636 LOG(debug) <<
"CbmTofDigitize::LoadBeamtimeValues: GeoVersion "
641 Int_t iMinSmType = 17;
642 Int_t iMaxSmType = -1;
649 Int_t iMinCell = 257;
651 for (Int_t iCellInd = 0; iCellInd < iNbGeantChannels; iCellInd++) {
656 if (iMaxSmType < fTofId->GetSMType(iCellId))
661 if (iMaxSm < fTofId->GetSModule(iCellId))
666 if (iMaxRpc < fTofId->GetCounter(iCellId))
670 if (iMaxGap < fTofId->GetGap(iCellId)) iMaxGap =
fTofId->
GetGap(iCellId);
674 if (iMaxCell < fTofId->GetCell(iCellId))
677 LOG(debug) <<
"SM type min " << iMinSmType <<
" max " << iMaxSmType;
678 LOG(debug) <<
"SM min " << iMinSm <<
" max " << iMaxSm;
679 LOG(debug) <<
"Rpc min " << iMinRpc <<
" max " << iMaxRpc;
680 LOG(debug) <<
"Gap min " << iMinGap <<
" max " << iMaxGap;
681 LOG(debug) <<
"Chan min " << iMinCell <<
" max " << iMaxCell;
696 "Number of Tof Points per MC track reaching "
697 "the TOF; Nb Tof Points in Tracks []",
702 new TH2I(
"TofDigiBdf_TofPtInTrkGap",
703 "Gap index vs Number of Tof Points in corresponding MC Track; Nb "
704 "Tof Pts in Track []; Gap Index []",
712 new TH2I(
"TofDigiBdf_TofPtInTrkGapPrm",
713 "Gap index vs Number of Tof Points in corresponding MC Track, "
714 "primaries; Nb Tof Pts in Track []; Gap Index []",
722 new TH2I(
"TofDigiBdf_TofPtInTrkGapSec",
723 "Gap index vs Number of Tof Points in corresponding MC Track, "
724 "secondaries; Nb Tof Pts in Track []; Gap Index []",
731 for (Int_t iGap = 0; iGap < 10; iGap++)
733 new TH2I(Form(
"TofDigiBdf_fhTofPtsPosVsGap%d", iGap),
734 Form(
"Tof Point positions in gap %d; X [cm]; Y [cm]", iGap),
756 "Time needed to process each event; Time [s]",
761 new TH1I(
"TofDigiBdf_DigiMergeTime",
762 "Time needed to merge the digis for each event; Time [s]",
767 "TofDigiBdf_DigiNbElecCh",
768 "Nb of digis per channel before merging; Nb Digis in same elec. ch []",
773 "Time needed to process each event vs Event "
774 "Size; Event Size [TofPoints]; Time [s]",
782 "TofDigiBdf_DigiPerTrk",
783 "Mean Number of ToF Digi per MC track in each event; Nb Digi/Nb Tracks []",
788 "Mean Number of fired channel per MC track in "
789 "each event; Nb Fired/Nb Tracks []",
795 "TofPoints Time distribution, summed for all Pts/channels; Time [ns]",
800 new TH1I(
"TofDigiBdf_DigiTime",
801 "Time distribution, summed for all digis/channels; Time [ns]",
806 "Time to True time distribution, summed for all "
807 "digis/channels; Time Digi - Time Pt [ns]",
812 "Time to True time distribution, summed for all "
813 "digis/channels; Time Digi - Time Pt [ns]",
821 new TH1I(
"TofDigiBdf_ToTDist",
822 "ToT distribution, summed for all digis/channels; Tot [ns]",
828 "Percentage of ToF electronic channels fired per "
829 "event; Elect. chan occupancy [%]",
834 new TH1D(
"TofDigiBdf_MultiDigiEvtElCh",
835 "Number of events with multiple digi (~MC track) per electronic "
836 "channel; Elect. chan index []",
841 new TH2D(
"TofDigiBdf_NbDigiEvtElCh",
842 "Number of digis per event before merging for each electronic "
843 "channel; Elect. chan index []; Nb Digis in Event []",
851 new TH2D(
"TofDigiBdf_NbTracksEvtElCh",
852 "Number of tracks per event before merging for each electronic "
853 "channel; Elect. chan index []; Nb tracks in Event []",
861 "Number of events with at least 1 digi per "
862 "electronic channel; Elect. chan index []",
867 "TofDigiBdf_MultiProbElCh",
868 "Probability of having multiple digi (~MC track) event per electronic "
869 "channel; Elect. chan index []; Multiple signal prob. [%]",
1035 LOG(info) <<
"CbmTofDigitize::WriteHistos => Control histograms will not "
1036 "be written to disk!";
1037 LOG(info) <<
"CbmTofDigitize::WriteHistos => To change this behavior "
1038 "please provide a full path "
1039 <<
"with the SetHistoFileName method";
1043 TDirectory* oldir = gDirectory;
1052 for (Int_t iGap = 0; iGap < 10; iGap++)
1084 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
1090 gDirectory->cd(oldir->GetPath());
1103 for (Int_t iGap = 0; iGap < 10; iGap++)
1132 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
1146 UInt_t uChanUId = 0x00005006;
1148 const Double_t dHitTot = 2.;
1154 "Add fake diamond digis 0x%08x mode with t = %7.3f", uChanUId, dHitTime);
1162 for (Int_t iSmType = 0; iSmType < iNbSmTypes; iSmType++) {
1166 for (Int_t iSm = 0; iSm < iNbSm; iSm++)
1167 for (Int_t iRpc = 0; iRpc < iNbRpc; iRpc++) {
1171 for (Int_t iCh = 0; iCh < iNbCh; iCh++)
1172 for (Int_t iSide = 0; iSide < iNbSides; iSide++) {
1174 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide]
1178 Int_t iNbTracks = 0;
1179 std::vector<Int_t> vPrevTrackIdList;
1182 for (Int_t iDigi = 0; iDigi < iNbDigis;
1185 " Create match for Digi %d(%d), addr 0x%08x; %d",
1189 [iNbSides * iCh + iSide][iDigi]
1190 .
first->GetAddress(),
1192 [iNbSides * iCh + iSide][iDigi]);
1198 [iNbSides * iCh + iSide][iDigi],
1202 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide]
1204 .second = digiMatch;
1207 std::sort(
fStorDigi[iSmType][iSm * iNbRpc + iRpc]
1208 [iNbSides * iCh + iSide]
1211 [iNbSides * iCh + iSide]
1218 + iNbSides * iCh + iSide,
1224 + iNbSides * iCh + iSide);
1227 + iNbSides * iCh + iSide);
1232 [iNbSides * iCh + iSide]
1235 " cannot add digiMatch for (%d,%d,%d,%d,%d) at pos %d",
1246 digiMatch =
fStorDigi[iSmType][iSm * iNbRpc + iRpc]
1247 [iNbSides * iCh + iSide][iDigi0]
1250 LOG(debug) << Form(
"Now apply deadtime %f for %d digis, "
1251 "digi0=%d for adress 0x%08x ",
1256 [iNbSides * iCh + iSide][iDigi0]
1257 .first->GetAddress());
1259 for (Int_t iDigi = 1; iDigi < iNbDigis; iDigi++) {
1262 (
fStorDigi[iSmType][iSm * iNbRpc + iRpc]
1263 [iNbSides * iCh + iSide][iDigi]
1265 -
fStorDigi[iSmType][iSm * iNbRpc + iRpc]
1266 [iNbSides * iCh + iSide][iDigi0]
1270 digiMatch =
fStorDigi[iSmType][iSm * iNbRpc + iRpc]
1271 [iNbSides * iCh + iSide][iDigi0]
1273 Int_t nL =
fStorDigi[iSmType][iSm * iNbRpc + iRpc]
1274 [iNbSides * iCh + iSide][iDigi]
1275 .second->GetNofLinks();
1276 if (nL != 1) LOG(fatal) <<
"Invalid number of Links " << nL;
1279 [iNbSides * iCh + iSide][iDigi]
1280 .second->GetLink(0);
1290 [iNbSides * iCh + iSide][iDigi0]
1294 [iNbSides * iCh + iSide][iDigi0]
1305 for (Int_t iL = 0; iL < nL; iL++) {
1308 Bool_t bTrackFound = kFALSE;
1309 for (UInt_t uTrkId = 0;
1310 uTrkId < vPrevTrackIdList.size();
1312 if (vPrevTrackIdList[uTrkId]
1316 bTrackFound = kTRUE;
1319 if (kFALSE == bTrackFound) {
1322 vPrevTrackIdList.push_back(
1327 vPrevTrackIdList.clear();
1330 + iNbSides * iCh + iSide,
1343 [iNbSides * iCh + iSide][iDigi0]
1347 [iNbSides * iCh + iSide][iDigi0]
1356 for (Int_t iL = 0; iL < nL; iL++) {
1359 Bool_t bTrackFound = kFALSE;
1360 for (UInt_t uTrkId = 0; uTrkId < vPrevTrackIdList.size();
1362 if (vPrevTrackIdList[uTrkId]
1365 bTrackFound = kTRUE;
1368 if (kFALSE == bTrackFound) {
1371 vPrevTrackIdList.push_back(
1376 vPrevTrackIdList.clear();
1379 + iNbSides * iCh + iSide,
1383 for (Int_t iDigi = 0; iDigi < iNbDigis; iDigi++) {
1385 [iNbSides * iCh + iSide][iDigi]
1388 [iNbSides * iCh + iSide][iDigi]
1390 if (tmpDigi)
delete tmpDigi;
1391 if (tmpMatch)
delete tmpMatch;
1395 fStorDigi[iSmType][iSm * iNbRpc + iRpc][iNbSides * iCh + iSide]
1398 [iNbSides * iCh + iSide]
1410 Double_t dClusterRadius = 0;
1416 dClusterRadius = 0.0002;
1437 <<
"CbmTofDigitize::GenerateClusterRadius => Cluster Radius "
1438 <<
"obtention from cluster size not implemented for pads, Sm type "
1439 << iSmType <<
" Rpc " << iRpc;
1440 LOG(error) <<
"CbmTofDigitize::GenerateClusterRadius => Test "
1441 <<
" Sm type " << iSmType <<
" Rpc " << iRpc <<
" Type "
1442 << iChType <<
" Type " << (Int_t) iChType;
1451 Double_t dStripSize = 0;
1466 Double_t dSigmScal =
1470 dClusterRadius = dStripSize * gRandom->Landau(dPeakPos, dSigmScal);
1471 if (dClusterRadius < 0) dClusterRadius = 0;
1475 <<
"CbmTofDigitize::GenerateClusterRadius => Cluster Radius "
1476 <<
"obtention from cluster size not implemented for pads, Sm type "
1477 << iSmType <<
" Rpc " << iRpc;
1478 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Test 2"
1479 <<
" Sm type " << iSmType <<
" Rpc " << iRpc <<
" Type "
1486 LOG(error) <<
"CbmTofDigitize::GenerateClusterRadius => Wrong Cluster "
1487 "Radius method , Sm type "
1488 << iSmType <<
" Rpc " << iRpc;
1493 return dClusterRadius;
1515 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1525 Int_t iNbTofTracks = 0;
1526 Int_t iNbTofTracksPrim = 0;
1528 LOG(debug1) <<
"CbmTofDigitize::DigitizeDirectClusterSize: " << nTofPoint
1529 <<
" points in Tof for this event with " << nMcTracks
1531 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
1540 LOG(debug1) <<
"CbmTofDigitize::DigitizeDirectClusterSize: " << iNbTofTracks
1541 <<
" tracks in Tof ";
1542 LOG(debug1) <<
"CbmTofDigitize::DigitizeDirectClusterSize: "
1543 << iNbTofTracksPrim <<
" tracks in Tof from vertex";
1547 Int_t iDetId, iSmType, iSM, iRpc, iChannel, iGap;
1548 Int_t iTrackID, iChanId;
1552 Double_t dClustCharge;
1558 Int_t iNbSm, iNbRpc, iNbCh;
1572 Double_t dStartJitter = 0.;
1577 for (Int_t iPntInd = 0; iPntInd < nTofPoint; iPntInd++) {
1580 if (NULL == pPoint) {
1581 LOG(WARNING) <<
"CbmTofDigitize::DigitizeDirectClusterSize => Be "
1582 "careful: hole in the CbmTofPoint TClonesArray!";
1587 iDetId = pPoint->GetDetectorID();
1597 iTrackID = pPoint->GetTrackID();
1603 Int_t iTrkId = pPoint->GetTrackID();
1611 <<
"CbmTofDigitize::DigitizeDirectClusterSize => TofPoint without "
1612 "valid MC track Index, "
1613 <<
" track was probably cut at the transport level! "
1614 <<
" Pnt Idx: " << iPntInd <<
" Trk Idx: " << iTrkId <<
"\n"
1615 <<
"=============> To allow this kind of points and simply jump "
1617 <<
"call CbmTofDigitize::AllowPointsWithoutTrack() in your macro!!";
1629 if (iSmType < 0. || iNbSmTypes <= iSmType || iSM < 0. || iNbSm <= iSM
1630 || iRpc < 0. || iNbRpc <= iRpc || iChannel < 0. || iNbCh <= iChannel) {
1631 LOG(error) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId)
1632 <<
" SMType: " << iSmType;
1633 LOG(error) <<
" SModule: " << iSM <<
" of " << iNbSm + 1;
1634 LOG(error) <<
" Module: " << iRpc <<
" of " << iNbRpc + 1;
1635 LOG(error) <<
" Gap: " << iGap;
1636 LOG(fatal) <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
1645 Bool_t bFoundIt = kFALSE;
1653 for (UInt_t uTrkMainCh = 0; uTrkMainCh <
fvlTrckChAddr[iTrkId].size();
1660 if (kTRUE == bFoundIt)
continue;
1685 pPoint->Position(vPntPos);
1688 gGeoManager->FindNode(
1690 LOG(debug1) << Form(
" TofDigitizerBDF:: (%3d,%3d,%3d,%3d) - node at "
1691 "(%6.1f,%6.1f,%6.1f) : 0x%p Pos(%6.1f,%6.1f,%6.1f)",
1703 gGeoManager->GetCurrentNode();
1704 gGeoManager->GetCurrentMatrix();
1706 Double_t poipos[3] = {vPntPos.X(), vPntPos.Y(), vPntPos.Z()};
1707 Double_t poipos_local[3];
1708 Double_t poipos_local_man[3];
1709 gGeoManager->MasterToLocal(poipos, poipos_local_man);
1711 for (Int_t
i = 0;
i < 3;
i++)
1712 if (poipos_local[
i] != poipos_local_man[
i])
1713 LOG(fatal) <<
"Inconsistent M2L result " <<
i <<
": " << poipos_local[
i]
1714 <<
" != " << poipos_local_man[
i];
1717 LOG(error) <<
"CbmTofDigitize::DigitizeDirectClusterSize => This method "
1718 <<
"is not available for pads!!";
1726 Int_t iNbStripsSideA;
1727 Int_t iNbStripsSideB;
1728 if (1 == iClusterSize % 2) {
1730 iNbStripsSideA = (iClusterSize - 1) / 2;
1731 iNbStripsSideB = (iClusterSize - 1) / 2;
1736 iNbStripsSideA = iClusterSize / 2;
1737 iNbStripsSideB = iClusterSize / 2;
1759 Double_t dCentralTime;
1762 ULong64_t uRpcAddr =
1764 Bool_t bFoundIt = kFALSE;
1765 UInt_t uTrkRpcPair = 0;
1766 for (uTrkRpcPair = 0; uTrkRpcPair <
fvlTrckRpcAddr[iTrkId].size();
1773 if (kTRUE == bFoundIt)
1795 TF1* f1ChargeGauss =
new TF1(
"f1ChargeDist",
1796 "[0]*TMath::Gaus(x,[1],[2])",
1797 poipos_local[1] - 2 * iClusterSize,
1798 poipos_local[1] + 2 * iClusterSize);
1809 f1ChargeGauss->SetParameters(
1810 dClustCharge / (TMath::Sqrt(2.0 *
TMath::Pi() * iClusterSize / 6.0)),
1812 0.5 * iClusterSize / 3.0);
1816 f1ChargeGauss->CalcGaussLegendreSamplingPoints(
kiNbIntPts,
x, w, 1e-12);
1819 for (Int_t iStripInd = iChannel - iNbStripsSideA;
1820 iStripInd <= iChannel + iNbStripsSideB;
1822 if (0 <= iStripInd && iStripInd < iNbCh) {
1823 Int_t iCh1 = iStripInd;
1831 Double_t dStripCharge = f1ChargeGauss->IntegralFast(
1844 Double_t dTimeA = dCentralTime;
1847 #ifdef FULL_PROPAGATION_TIME
1859 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1]
1864 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1865 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(
1868 .push_back(iPntInd);
1871 "Digimatch (%d,%d,%d,%d): size %zu, valA %d, MCt %d",
1883 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd]
1885 Double_t dTimeB = dCentralTime;
1888 #ifdef FULL_PROPAGATION_TIME
1905 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
1906 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(
1909 .push_back(iPntInd);
1910 LOG(debug1) << Form(
1911 "Digimatch (%d,%d,%d,%d): size %zu, valB %d, MCt %d",
1923 delete f1ChargeGauss;
1932 TF1* f1ChargeGauss =
new TF1(
"f1ChargeDist",
1933 "[0]*TMath::Gaus(x,[1],[2])",
1934 poipos_local[0] - 2 * iClusterSize,
1935 poipos_local[0] + 2 * iClusterSize);
1944 f1ChargeGauss->SetParameters(
1945 dClustCharge / (TMath::Sqrt(2.0 *
TMath::Pi()) * iClusterSize / 6.0),
1947 0.5 * iClusterSize / 3.0);
1951 f1ChargeGauss->CalcGaussLegendreSamplingPoints(
kiNbIntPts,
x, w, 1e-12);
1954 for (Int_t iStripInd = iChannel - iNbStripsSideA;
1955 iStripInd <= iChannel + iNbStripsSideB;
1957 if (0 <= iStripInd && iStripInd < iNbCh) {
1958 Int_t iCh1 = iStripInd;
1966 Double_t dStripCharge = f1ChargeGauss->IntegralFast(
1979 Double_t dTimeA = dCentralTime;
1982 #ifdef FULL_PROPAGATION_TIME
1988 LOG(debug) <<
"Create DigiA TSRC " << iSmType << iSM << iRpc
1990 << Form(
"at %f, ypos %f", dTimeA, poipos_local[1]);
1997 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1]
2002 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2003 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd + 1]
2006 .push_back(iPntInd);
2007 LOG(debug1) << Form(
2008 "Digimatch (%d,%d,%d,%d): size %zu, valC %d, MCt %d",
2020 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd]
2022 Double_t dTimeB = dCentralTime;
2025 #ifdef FULL_PROPAGATION_TIME
2031 LOG(debug) <<
"Create DigiB TSRC " << iSmType << iSM << iRpc
2033 << Form(
"at %f, ypos %f", dTimeB, poipos_local[1]);
2040 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd]
2045 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2046 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iStripInd].push_back(
2049 .push_back(iPntInd);
2050 LOG(debug1) << Form(
2051 "Digimatch (%d,%d,%d,%d): size %zu, valE %d, MCt %d",
2062 delete f1ChargeGauss;
2070 for (UInt_t uTrkInd = 0; uTrkInd <
fvlTrckChAddr.size(); uTrkInd++) {
2102 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
2112 Int_t iNbTofTracks = 0;
2113 Int_t iNbTofTracksPrim = 0;
2115 LOG(debug1) <<
"CbmTofDigitize::DigitizeFlatDisc: " << nTofPoint
2116 <<
" points in Tof for this event with " << nMcTracks
2118 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
2127 LOG(debug1) <<
"CbmTofDigitize::DigitizeFlatDisc: " << iNbTofTracks
2128 <<
" tracks in Tof ";
2129 LOG(debug1) <<
"CbmTofDigitize::DigitizeFlatDisc: " << iNbTofTracksPrim
2130 <<
" tracks in Tof from vertex";
2134 Int_t iDetId, iSmType, iSM, iRpc, iChannel, iGap;
2135 Int_t iTrackID, iChanId;
2138 Double_t dClusterSize;
2139 Double_t dClustCharge;
2145 Int_t iNbSm, iNbRpc, iNbCh;
2159 Double_t dStartJitter = 0.;
2164 for (Int_t iPntInd = 0; iPntInd < nTofPoint; iPntInd++) {
2167 if (NULL == pPoint) {
2168 LOG(WARNING) <<
"CbmTofDigitize::DigitizeFlatDisc => Be careful: hole in "
2169 "the CbmTofPoint TClonesArray!"
2175 iDetId = pPoint->GetDetectorID();
2184 iTrackID = pPoint->GetTrackID();
2190 Int_t iTrkId = pPoint->GetTrackID();
2198 <<
"CbmTofDigitize::DigitizeDirectClusterSize => TofPoint without "
2199 "valid MC track Index, "
2200 <<
" track was probably cut at the transport level! "
2201 <<
" Pnt Idx: " << iPntInd <<
" Trk Idx: " << iTrkId <<
"\n"
2202 <<
"=============> To allow this kind of points and simply jump "
2204 <<
"call CbmTofDigitize::AllowPointsWithoutTrack() in your macro!!";
2211 LOG(debug1) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId)
2213 <<
", SMType: " << iSmType <<
" SModule: " << iSM <<
" of "
2214 << iNbSm + 1 <<
" Module: " << iRpc <<
" of " << iNbRpc + 1
2215 <<
" Gap: " << iGap <<
" Cell: " << iChannel <<
" of "
2227 if (iSmType < 0. || iNbSmTypes <= iSmType || iSM < 0. || iNbSm <= iSM
2228 || iRpc < 0. || iNbRpc <= iRpc || iChannel < 0. || iNbCh <= iChannel) {
2229 LOG(error) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId)
2231 <<
", SMType: " << iSmType;
2232 LOG(error) <<
" SModule: " << iSM <<
" of " << iNbSm + 1;
2233 LOG(error) <<
" Module: " << iRpc <<
" of " << iNbRpc + 1;
2234 LOG(error) <<
" Gap: " << iGap;
2235 LOG(fatal) <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
2238 LOG(debug2) <<
"CbmTofDigitize::DigitizeFlatDisc => Check Point " << iPntInd
2239 <<
" Sm type " << iSmType <<
" SM " << iSM <<
" Rpc " << iRpc
2240 <<
" Channel " << iChannel <<
" Type " << iChType <<
" Orient. "
2248 Bool_t bFoundIt = kFALSE;
2256 for (UInt_t uTrkMainCh = 0; uTrkMainCh <
fvlTrckChAddr[iTrkId].size();
2263 if (kTRUE == bFoundIt)
continue;
2279 LOG(debug2) <<
"CbmTofDigitize::DigitizeFlatDisc => Eff = "
2291 pPoint->Position(vPntPos);
2295 <<
"CbmTofDigitize::DigitizeFlatDisc: No DigPar for iChanId = "
2296 << Form(
"0x%08x, addr 0x%08x", iChanId, (
unsigned int) iDetId);
2301 gGeoManager->FindNode(
2303 LOG(debug1) << Form(
" TofDigitizerBDF:: (%3d,%3d,%3d,%3d) - node at "
2304 "(%6.1f,%6.1f,%6.1f) : %p Pos(%6.1f,%6.1f,%6.1f)",
2316 gGeoManager->GetCurrentNode();
2317 gGeoManager->GetCurrentMatrix();
2319 Double_t refpos[3] = {
2321 Double_t refpos_local[3];
2322 gGeoManager->MasterToLocal(refpos, refpos_local);
2323 Double_t poipos[3] = {vPntPos.X(), vPntPos.Y(), vPntPos.Z()};
2324 Double_t poipos_local[3];
2325 gGeoManager->MasterToLocal(poipos, poipos_local);
2326 LOG(debug1) << Form(
" TofDigitizerBDF:: DetId 0x%08x, ChanId 0x%08x, local "
2327 "pos (%5.1f,%5.1f,%5.1f) refpos (%5.1f,%5.1f,%5.1f) ",
2336 for (Int_t
i = 0;
i < 3;
i++)
2345 while (dClusterSize < 0.0001 || 3.0 < dClusterSize)
2355 Double_t dClustArea = dClusterSize * dClusterSize *
TMath::Pi();
2358 Double_t dChargeCentral =
2361 iChanId, dClusterSize, poipos_local[0], poipos_local[1]);
2362 LOG(debug2) <<
"CbmTofDigitize::DigitizeFlatDisc: ChargeCentral "
2363 << dChargeCentral <<
", " << dClustCharge
2364 << Form(
", 0x%08x", iChanId) <<
", " << dClusterSize <<
", "
2365 << poipos_local[0] <<
", " << poipos_local[1] <<
", "
2368 dChargeCentral /= dClustArea;
2369 if (dClustCharge + 0.0000001 < dChargeCentral) {
2370 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Central Charge "
2371 << dChargeCentral <<
" " << dClustCharge <<
" "
2372 << dClustCharge - dChargeCentral <<
" "
2374 iChanId, dClusterSize, poipos_local[0], poipos_local[1]))
2375 <<
" " << dClustArea;
2376 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Check Point "
2377 << iPntInd <<
" Sm type " << iSmType <<
" SM " << iSM
2378 <<
" Rpc " << iRpc <<
" Channel " << iChannel <<
" Type "
2379 << iChType <<
" Orient. "
2384 Double_t dCentralTime;
2387 ULong64_t uRpcAddr =
2389 Bool_t bFoundIt = kFALSE;
2390 UInt_t uTrkRpcPair = 0;
2391 for (uTrkRpcPair = 0; uTrkRpcPair <
fvlTrckRpcAddr[iTrkId].size();
2398 if (kTRUE == bFoundIt)
2432 Double_t dTimeA = dCentralTime;
2433 Double_t dTimeB = dCentralTime;
2438 #ifdef FULL_PROPAGATION_TIME
2446 #ifdef FULL_PROPAGATION_TIME
2457 #ifdef FULL_PROPAGATION_TIME
2466 #ifdef FULL_PROPAGATION_TIME
2476 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1]
2484 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1]
2490 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2491 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(
2494 .push_back(iPntInd);
2495 LOG(debug1) << Form(
2496 "Digimatch (%d,%d,%d,%d): size %zu, MCp %d, MCt %d, TA %6.2f, TotA "
2497 "%6.1f, Ypos %6.1f, Vsig %6.1f ",
2502 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].size(),
2507 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1]
2523 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0,
2527 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2528 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(data);
2529 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(
2531 LOG(debug1) << Form(
2532 "Digimatch (%d,%d,%d,%d): size %zu, MCp %d, MCt %d, TB %6.2f, TotB "
2538 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].size(),
2543 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1]
2569 Double_t dClustToReadout = 0.0;
2570 Double_t dPadTime = dCentralTime;
2572 if (iChannel < iNbCh / 2.0) {
2576 dClustToReadout = TMath::Sqrt(
2577 TMath::Power(poipos_local[1], 2)
2581 dClustToReadout = TMath::Sqrt(
2582 TMath::Power(poipos_local[0], 2)
2590 dClustToReadout = TMath::Sqrt(
2591 TMath::Power(poipos_local[1], 2)
2595 dClustToReadout = TMath::Sqrt(
2596 TMath::Power(poipos_local[0], 2)
2617 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2618 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(data);
2619 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(
2621 LOG(debug1) << Form(
2622 "Digimatch (%d,%d,%d,%d): MCpi %zu, valE %d, MCti %d",
2627 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].size(),
2644 Int_t iMinChanInd = iChannel - 1;
2645 Int_t iMaxChanInd = iChannel + 1;
2647 Double_t dClusterDist = 0.0;
2650 while (0 <= iMinChanInd) {
2651 dClusterDist = TMath::Abs(
2654 if (dClusterDist < dClusterSize)
2659 while (iMaxChanInd < iNbCh) {
2660 dClusterDist = TMath::Abs(
2663 if (dClusterDist < dClusterSize)
2671 while (0 <= iMinChanInd) {
2672 dClusterDist = TMath::Abs(
2675 if (dClusterDist < dClusterSize)
2680 while (iMaxChanInd < iNbCh) {
2681 dClusterDist = TMath::Abs(
2684 if (dClusterDist < dClusterSize)
2693 for (Int_t iChanInd = iMinChanInd + 1; iChanInd < iMaxChanInd;
2695 if (iChanInd == iChannel)
continue;
2700 Int_t iCh1 = iChanInd;
2710 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc: Invalid channel "
2711 << iSideChId <<
" " << iSmType <<
" " << iSM <<
" " << iRpc
2712 <<
" " << iChanInd + 1;
2717 Double_t dChargeSideCh =
2720 iSideChId, dClusterSize, poipos_local[0], poipos_local[1]);
2721 dChargeSideCh /= dClustArea;
2722 if (dClustCharge + 0.0000001 < dChargeSideCh) {
2723 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Side Charge "
2724 << dChargeSideCh <<
" " << dClustCharge <<
" "
2726 LOG(error) <<
"CbmTofDigitize::DigitizeFlatDisc => Check Point "
2727 << iPntInd <<
" Sm type " << iSmType <<
" SM " << iSM
2728 <<
" Rpc " << iRpc <<
" Channel " << iChanInd <<
" Type "
2729 << iChType <<
" Orient. "
2734 Double_t dTimeA = dCentralTime;
2735 Double_t dTimeB = dCentralTime;
2737 LOG(debug1) << Form(
" TofDigitizerBDF:: chrg %7.1f, times %5.1f,%5.1f, "
2738 "pos %5.1f,%5.1f,%5.1f ",
2750 #ifdef FULL_PROPAGATION_TIME
2758 #ifdef FULL_PROPAGATION_TIME
2770 #ifdef FULL_PROPAGATION_TIME
2779 #ifdef FULL_PROPAGATION_TIME
2787 LOG(debug1) << Form(
2788 " TofDigitizerBDF:: chrg %7.1f, gain %7.1f, thr %7.1f times "
2791 fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1],
2798 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1]
2806 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1]
2811 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2812 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd + 1].push_back(
2815 .push_back(iPntInd);
2816 LOG(debug1) << Form(
2817 "Digimatch (%d,%d,%d,%d): size %zu, MCpA %d, MCtt %d",
2838 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd] / 2.0,
2842 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
2843 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd].push_back(data);
2844 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChanInd].push_back(
2846 LOG(debug1) << Form(
2847 "Digimatch (%d,%d,%d,%d): size %zu, MCpB %d, MCtB %d",
2883 Int_t iMinChanInd = iChannel;
2884 Int_t iMaxChanInd = iChannel;
2886 Double_t dClusterDist = 0;
2888 Bool_t bCheckOtherRow = kFALSE;
2889 if (iChannel < iNbCh / 2.0)
2896 while (dClusterDist < dClusterSize
2897 && iRow * iNbCh / 2.0 < iMinChanInd) {
2900 TMath::Abs(poipos_local[1]
2902 * (iMinChanInd - iChannel + (1 - 2 * iRow) / 2)));
2905 while (dClusterDist < dClusterSize
2906 && iMaxChanInd < (1 + iRow) * iNbCh / 2.0 - 1) {
2909 TMath::Abs(poipos_local[1]
2911 * (iMaxChanInd - iChannel - (1 - 2 * iRow) / 2)));
2916 dClusterDist = TMath::Abs(
2918 if (dClusterDist < dClusterSize) bCheckOtherRow = kTRUE;
2922 while (dClusterDist < dClusterSize
2923 && iRow * iNbCh / 2.0 < iMinChanInd) {
2926 TMath::Abs(poipos_local[0]
2928 * (iMinChanInd - iChannel + (1 - 2 * iRow) / 2)));
2931 while (dClusterDist < dClusterSize
2932 && iMaxChanInd < (1 + iRow) * iNbCh / 2.0 - 1) {
2935 TMath::Abs(poipos_local[0]
2937 * (iMaxChanInd - iChannel - (1 - 2 * iRow) / 2)));
2942 dClusterDist = TMath::Abs(
2944 if (dClusterDist < dClusterSize) bCheckOtherRow = kTRUE;
2949 for (Int_t iChanInd = iMinChanInd + 1; iChanInd < iMaxChanInd;
2951 if (iChanInd == iChannel)
continue;
2955 Int_t iCh1 = iChanInd;
2966 Double_t dChargeSideCh =
2969 iSideChId, dClusterSize, poipos_local[0], poipos_local[1]);
2970 dChargeSideCh /= dClustArea;
2978 Double_t dClustToReadout = 0.0;
2979 Double_t dPadTime = dCentralTime;
2984 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
2985 + TMath::Power(poipos_local[0]
2991 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
2992 + TMath::Power(poipos_local[1]
3006 dChargeSideCh *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChanInd],
3010 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3011 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(data);
3012 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(
3014 LOG(debug1) << Form(
3015 "Digimatch (%d,%d,%d,%d): size %zu, MCpP %d, MCtP %d",
3020 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].size(),
3026 if (kTRUE == bCheckOtherRow)
3027 for (Int_t iChanInd = iMinChanInd + 1 + (1 - 2 * iRow) * iNbCh / 2.0;
3028 iChanInd < iMaxChanInd + (1 - 2 * iRow) * iNbCh / 2.0;
3032 Int_t iCh1 = iChanInd;
3043 Double_t dChargeSideCh =
3046 iSideChId, dClusterSize, poipos_local[0], poipos_local[1]);
3054 Double_t dClustToReadout = 0.0;
3055 Double_t dPadTime = dCentralTime;
3060 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
3061 + TMath::Power(poipos_local[0]
3067 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
3068 + TMath::Power(poipos_local[1]
3087 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3088 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(data);
3089 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(
3091 LOG(debug1) << Form(
3092 "Digimatch (%d,%d,%d,%d): size %zu, MCpX %d, MCtX %d",
3109 for (UInt_t uTrkInd = 0; uTrkInd <
fvlTrckChAddr.size(); uTrkInd++) {
3141 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
3151 Int_t iNbTofTracks = 0;
3152 Int_t iNbTofTracksPrim = 0;
3154 LOG(debug1) <<
"CbmTofDigitize::DigitizeGaussCharge: " << nTofPoint
3155 <<
" points in Tof for this event with " << nMcTracks
3157 for (Int_t iTrkInd = 0; iTrkInd < nMcTracks; iTrkInd++) {
3166 LOG(debug1) <<
"CbmTofDigitize::DigitizeGaussCharge: " << iNbTofTracks
3167 <<
" tracks in Tof ";
3168 LOG(debug1) <<
"CbmTofDigitize::DigitizeGaussCharge: " << iNbTofTracksPrim
3169 <<
" tracks in Tof from vertex";
3173 Int_t iDetId, iSmType, iSM, iRpc, iChannel, iGap;
3174 Int_t iTrackID, iChanId;
3177 Double_t dClusterSize;
3178 Double_t dClustCharge;
3184 Int_t iNbSm, iNbRpc, iNbCh;
3198 Double_t dStartJitter = 0.;
3203 for (Int_t iPntInd = 0; iPntInd < nTofPoint; iPntInd++) {
3206 if (NULL == pPoint) {
3207 LOG(WARNING) <<
"CbmTofDigitize::DigitizeGaussCharge => Be careful: hole "
3208 "in the CbmTofPoint TClonesArray!"
3214 iDetId = pPoint->GetDetectorID();
3222 iTrackID = pPoint->GetTrackID();
3228 Int_t iTrkId = pPoint->GetTrackID();
3236 <<
"CbmTofDigitize::DigitizeDirectClusterSize => TofPoint without "
3237 "valid MC track Index, "
3238 <<
" track was probably cut at the transport level! "
3239 <<
" Pnt Idx: " << iPntInd <<
" Trk Idx: " << iTrkId <<
"\n"
3240 <<
"=============> To allow this kind of points and simply jump "
3242 <<
"call CbmTofDigitize::AllowPointsWithoutTrack() in your macro!!";
3254 if (iSmType < 0. || iNbSmTypes < iSmType || iSM < 0. || iNbSm < iSM
3255 || iRpc < 0. || iNbRpc < iRpc || iChannel < 0. || iNbCh < iChannel) {
3256 LOG(error) << Form(
"CbmTofDigitize => det ID 0x%08x", iDetId)
3257 <<
" SMType: " << iSmType;
3258 LOG(error) <<
" SModule: " << iSM <<
" of " << iNbSm + 1;
3259 LOG(error) <<
" Module: " << iRpc <<
" of " << iNbRpc + 1;
3260 LOG(error) <<
" Gap: " << iGap;
3261 LOG(error) <<
" Cell: " << iChannel <<
" of " << iNbCh + 1;
3270 Bool_t bFoundIt = kFALSE;
3278 for (UInt_t uTrkMainCh = 0; uTrkMainCh <
fvlTrckChAddr[iTrkId].size();
3285 if (kTRUE == bFoundIt)
continue;
3310 pPoint->Position(vPntPos);
3313 gGeoManager->FindNode(
3315 LOG(debug1) << Form(
" TofDigitizerBDF:: (%3d,%3d,%3d,%3d) - node at "
3316 "(%6.1f,%6.1f,%6.1f) : 0x%p Pos(%6.1f,%6.1f,%6.1f)",
3328 gGeoManager->GetCurrentNode();
3329 gGeoManager->GetCurrentMatrix();
3330 Double_t poipos[3] = {vPntPos.X(), vPntPos.Y(), vPntPos.Z()};
3331 Double_t poipos_local[3];
3332 gGeoManager->MasterToLocal(poipos, poipos_local);
3336 while (dClusterSize < 0.0001)
3348 new TF2(
"ChargeDist",
3349 "[0]*TMath::Gaus(x,[1],[2])*TMath::Gaus(y,[3],[4])",
3350 -5.0 * dClusterSize,
3352 -5.0 * dClusterSize,
3353 5.0 * dClusterSize);
3354 f2ChargeDist->SetParameters(
3355 dClustCharge / (TMath::Sqrt(2.0 *
TMath::Pi()) * dClusterSize / 3.0),
3359 dClusterSize / 3.0);
3362 Double_t dChargeCentral = f2ChargeDist->Integral(
3369 Double_t dCentralTime;
3372 ULong64_t uRpcAddr =
3374 Bool_t bFoundIt = kFALSE;
3375 UInt_t uTrkRpcPair = 0;
3376 for (uTrkRpcPair = 0; uTrkRpcPair <
fvlTrckRpcAddr[iTrkId].size();
3383 if (kTRUE == bFoundIt)
3413 Double_t dTimeA = dCentralTime;
3414 Double_t dTimeB = dCentralTime;
3419 #ifdef FULL_PROPAGATION_TIME
3427 #ifdef FULL_PROPAGATION_TIME
3438 #ifdef FULL_PROPAGATION_TIME
3446 #ifdef FULL_PROPAGATION_TIME
3460 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1] / 2.0,
3464 std::pair<CbmTofDigi*, CbmMatch*> data1(tofDigi,
nullptr);
3465 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(
3467 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].push_back(
3469 LOG(debug1) << Form(
3470 "Digimatch (%d,%d,%d,%d): size %zu, val1 %d, MCt %d",
3475 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel + 1].size(),
3485 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iChannel] / 2.0,
3489 std::pair<CbmTofDigi*, CbmMatch*> data2(tofDigi,
nullptr);
3490 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(data2);
3491 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].push_back(
3493 LOG(debug1) << Form(
3494 "Digimatch (%d,%d,%d,%d): size %zu, val2 %d, MCt %d",
3499 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iChannel].size(),
3525 Double_t dClustToReadout = 0.0;
3526 Double_t dPadTime = dCentralTime;
3528 if (iChannel < iNbCh / 2.0) {
3532 dClustToReadout = TMath::Sqrt(
3533 TMath::Power(poipos_local[1], 2)
3537 dClustToReadout = TMath::Sqrt(
3538 TMath::Power(poipos_local[0], 2)
3546 dClustToReadout = TMath::Sqrt(
3547 TMath::Power(poipos_local[1], 2)
3551 dClustToReadout = TMath::Sqrt(
3552 TMath::Power(poipos_local[0], 2)
3566 dChargeCentral *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][iChannel],
3570 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3571 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(data);
3572 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChannel].push_back(iPntInd);
3573 LOG(debug1) << Form(
3574 "Digimatch (%d,%d,%d,%d): size %zu, val3 %d, MCt %d",
3589 Int_t iSideChInd = iChannel - 1;
3593 Int_t iCh1 = iSideChInd;
3604 Double_t dChargeSideCh = f2ChargeDist->Integral(
3611 && 0 <= iSideChInd) {
3613 Double_t dTimeA = dCentralTime;
3614 Double_t dTimeB = dCentralTime;
3619 #ifdef FULL_PROPAGATION_TIME
3627 #ifdef FULL_PROPAGATION_TIME
3638 #ifdef FULL_PROPAGATION_TIME
3646 #ifdef FULL_PROPAGATION_TIME
3660 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1]
3665 std::pair<CbmTofDigi*, CbmMatch*> data1(tofDigi,
nullptr);
3666 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(
3669 .push_back(iPntInd);
3676 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd]
3681 std::pair<CbmTofDigi*, CbmMatch*> data2(tofDigi,
nullptr);
3682 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(
3685 .push_back(iPntInd);
3686 LOG(debug1) << Form(
3687 "Digimatch (%d,%d,%d,%d): size %zu, val4 %d, MCt %d",
3692 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].size(),
3703 Int_t iCh2 = iSideChInd;
3706 xDetInfo.
fCell = iCh2;
3713 dChargeSideCh = f2ChargeDist->Integral(
3721 if (iChannel < iNbCh - 1) {
3722 Int_t iSideChInd = iChannel + 1;
3726 Int_t iCh1 = iSideChInd;
3737 Double_t dChargeSideCh = f2ChargeDist->Integral(
3744 && iSideChInd < iNbCh) {
3746 Double_t dTimeA = dCentralTime;
3747 Double_t dTimeB = dCentralTime;
3752 #ifdef FULL_PROPAGATION_TIME
3760 #ifdef FULL_PROPAGATION_TIME
3771 #ifdef FULL_PROPAGATION_TIME
3779 #ifdef FULL_PROPAGATION_TIME
3793 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1]
3798 std::pair<CbmTofDigi*, CbmMatch*> data1(tofDigi,
nullptr);
3799 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd + 1].push_back(
3802 .push_back(iPntInd);
3803 LOG(debug1) << Form(
3804 "Digimatch (%d,%d,%d,%d): size %zu, val5 %d, MCt %d",
3820 *
fdChannelGain[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd]
3825 std::pair<CbmTofDigi*, CbmMatch*> data2(tofDigi,
nullptr);
3826 fStorDigi[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].push_back(
3829 .push_back(iPntInd);
3830 LOG(debug1) << Form(
3831 "Digimatch (%d,%d,%d,%d): size %zu, val6 %d, MCt %d",
3836 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].size(),
3845 xDetInfo.
fCell = iSideChInd + 1;
3852 dChargeSideCh = f2ChargeDist->Integral(
3882 Int_t iMinChanInd = iChannel;
3883 Int_t iMaxChanInd = iChannel;
3888 if (iChannel < iNbCh / 2.0)
3894 if (iRow * iNbCh / 2.0 < iChannel) {
3895 Int_t iSideChInd = iChannel - 1;
3899 Int_t iCh1 = iSideChInd;
3910 Double_t dChargeSideCh = f2ChargeDist->Integral(
3917 && iRow * iNbCh / 2.0 <= iSideChInd) {
3918 iMinChanInd = iSideChInd;
3920 Double_t dClustToReadout = 0.0;
3921 Double_t dPadTime = dCentralTime;
3926 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
3927 + TMath::Power(poipos_local[0]
3933 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
3934 + TMath::Power(poipos_local[1]
3953 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
3954 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(data);
3955 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(
3957 LOG(debug1) << Form(
3958 "Digimatch (%d,%d,%d,%d): size %zu, val7 %d, MCt %d",
3963 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][2 * iSideChInd].size(),
3973 xDetInfo.
fCell = iSideChInd + 1;
3980 dChargeSideCh = f2ChargeDist->Integral(
3988 if (iChannel < (1 + iRow) * iNbCh / 2.0 - 1) {
3989 Int_t iSideChInd = iChannel + 1;
3993 Int_t iCh1 = iSideChInd;
4004 Double_t dChargeSideCh = f2ChargeDist->Integral(
4011 && iSideChInd < (1 + iRow) * iNbCh / 2.0) {
4012 iMaxChanInd = iSideChInd;
4014 Double_t dClustToReadout = 0.0;
4015 Double_t dPadTime = dCentralTime;
4020 TMath::Sqrt(TMath::Power(poipos_local[1], 2)
4021 + TMath::Power(poipos_local[0]
4027 TMath::Sqrt(TMath::Power(poipos_local[0], 2)
4028 + TMath::Power(poipos_local[1]
4047 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
4048 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(data);
4049 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iSideChInd].push_back(
4051 LOG(debug1) << Form(
4052 "Digimatch (%d,%d,%d,%d): size %zu, val8 %d, MCt %d",
4066 xDetInfo.
fCell = iSideChInd + 1;
4073 dChargeSideCh = f2ChargeDist->Integral(
4086 Int_t iCh1 = iChannel;
4094 iCh1 + (1 - 2 * iRow) * iNbCh / 2.0);
4099 Double_t dChargeSideCh = f2ChargeDist->Integral(
4108 for (Int_t iChanInd = iMinChanInd + (1 - 2 * iRow) * iNbCh / 2.0;
4109 iChanInd <= iMaxChanInd + (1 - 2 * iRow) * iNbCh / 2.0;
4113 xDetInfo.
fCell = iChanInd + 1;
4118 dChargeSideCh = f2ChargeDist->Integral(
4125 Double_t dClustToReadout = 0.0;
4126 Double_t dPadTime = dCentralTime;
4130 dClustToReadout = TMath::Sqrt(
4131 TMath::Power(poipos_local[1], 2)
4137 dClustToReadout = TMath::Sqrt(
4138 TMath::Power(poipos_local[0], 2)
4158 std::pair<CbmTofDigi*, CbmMatch*> data(tofDigi,
nullptr);
4159 fStorDigi[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(data);
4160 fStorDigiMatch[iSmType][iSM * iNbRpc + iRpc][iChanInd].push_back(
4162 LOG(debug1) << Form(
4163 "Digimatch (%d,%d,%d,%d): size %zu, val9 %d, MCt %d",
4177 delete f2ChargeDist;
4182 for (UInt_t uTrkInd = 0; uTrkInd <
fvlTrckChAddr.size(); uTrkInd++) {
4197 Double_t dClustRadius,
4198 Double_t dClustCentX,
4199 Double_t dClustCentY) {
4200 Double_t dCornersX[4];
4201 Double_t dCornersY[4];
4202 Double_t dCornersR[4];
4205 Double_t dChanCentPosX = 0.;
4206 Double_t dChanCentPosY = 0.;
4211 dCornersX[0] = dChanCentPosX - dEdgeCentDistX;
4212 dCornersY[0] = dChanCentPosY + dEdgeCentDistY;
4213 dCornersR[0] = TMath::Sqrt(TMath::Power(dCornersX[0] - dClustCentX, 2)
4214 + TMath::Power(dCornersY[0] - dClustCentY, 2));
4216 dCornersX[1] = dChanCentPosX + dEdgeCentDistX;
4217 dCornersY[1] = dChanCentPosY + dEdgeCentDistY;
4218 dCornersR[1] = TMath::Sqrt(TMath::Power(dCornersX[1] - dClustCentX, 2)
4219 + TMath::Power(dCornersY[1] - dClustCentY, 2));
4221 dCornersX[2] = dChanCentPosX + dEdgeCentDistX;
4222 dCornersY[2] = dChanCentPosY - dEdgeCentDistY;
4223 dCornersR[2] = TMath::Sqrt(TMath::Power(dCornersX[2] - dClustCentX, 2)
4224 + TMath::Power(dCornersY[2] - dClustCentY, 2));
4226 dCornersX[3] = dChanCentPosX - dEdgeCentDistX;
4227 dCornersY[3] = dChanCentPosY - dEdgeCentDistY;
4228 dCornersR[3] = TMath::Sqrt(TMath::Power(dCornersX[3] - dClustCentX, 2)
4229 + TMath::Power(dCornersY[3] - dClustCentY, 2));
4231 Int_t iNbCornersIn = (dCornersR[0] < dClustRadius ? 1 : 0)
4232 + (dCornersR[1] < dClustRadius ? 1 : 0)
4233 + (dCornersR[2] < dClustRadius ? 1 : 0)
4234 + (dCornersR[3] < dClustRadius ? 1 : 0);
4236 LOG(debug3) <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => Check "
4237 << iNbCornersIn <<
" Radius " << dClustRadius <<
" "
4238 << dCornersR[0] <<
" " << dCornersR[1] <<
" " << dCornersR[2]
4239 <<
" " << dCornersR[3];
4241 switch (iNbCornersIn) {
4248 dChanCentPosX - dEdgeCentDistX - dClustCentX;
4250 dChanCentPosX + dEdgeCentDistX - dClustCentX;
4252 dChanCentPosY - dEdgeCentDistY - dClustCentY;
4254 dChanCentPosY + dEdgeCentDistY - dClustCentY;
4255 if ((0.0 >= dEdgeR[0]) && (0.0 <= dEdgeR[1]) && (0.0 >= dEdgeR[2])
4256 && (0.0 <= dEdgeR[3])) {
4260 Double_t dArea = dClustRadius * dClustRadius *
TMath::Pi();
4263 <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => CC in Ch "
4269 if (TMath::Abs(dEdgeR[0]) < dClustRadius)
4271 if (TMath::Abs(dEdgeR[1]) < dClustRadius)
4273 if (TMath::Abs(dEdgeR[2]) < dClustRadius)
4275 if (TMath::Abs(dEdgeR[3]) < dClustRadius)
4279 <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => Neg. area! "
4280 << dArea <<
" Radius " << dClustRadius <<
" " << dEdgeR[0] <<
" "
4281 << dEdgeR[1] <<
" " << dEdgeR[2] <<
" " << dEdgeR[3];
4291 <<
"CbmTofDigitize::ComputeClusterAreaOnChannel => CC out Ch "
4292 << dClustRadius <<
" " << dEdgeR[0] <<
" " << dEdgeR[1] <<
" "
4293 << dEdgeR[2] <<
" " << dEdgeR[3];
4295 if (TMath::Abs(dEdgeR[0]) < dClustRadius)
4297 else if (TMath::Abs(dEdgeR[1]) < dClustRadius)
4299 else if (TMath::Abs(dEdgeR[2]) < dClustRadius)
4301 else if (TMath::Abs(dEdgeR[3]) < dClustRadius)
4315 Double_t dIntPtX[2] = {0., 0.};
4316 Double_t dIntPtY[2] = {0., 0.};
4317 Double_t dArea = 0.;
4319 if (dCornersR[0] < dClustRadius) {
4322 dIntPtX[0] = dCornersX[0];
4324 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4327 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4328 dIntPtY[1] = dCornersY[0];
4337 }
else if (dCornersR[1] < dClustRadius) {
4340 dIntPtX[0] = dCornersX[1];
4342 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4345 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4346 dIntPtY[1] = dCornersY[1];
4355 }
else if (dCornersR[2] < dClustRadius) {
4358 dIntPtX[0] = dCornersX[2];
4360 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4363 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4364 dIntPtY[1] = dCornersY[2];
4373 }
else if (dCornersR[3] < dClustRadius) {
4376 dIntPtX[0] = dCornersX[3];
4378 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4381 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4382 dIntPtY[1] = dCornersY[3];
4396 dClustRadius, dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
4415 Bool_t bFirstCorner = kTRUE;
4420 if (dCornersR[0] < dClustRadius) {
4423 bFirstCorner = kFALSE;
4425 if (dCornersR[1] < dClustRadius) {
4427 if (kTRUE == bFirstCorner) {
4429 bFirstCorner = kFALSE;
4434 if (dCornersR[2] < dClustRadius) {
4436 if (kTRUE == bFirstCorner) {
4438 bFirstCorner = kFALSE;
4443 if (dCornersR[3] < dClustRadius) {
4449 LOG(debug3) <<
"Corners In check " << (iCorners[0]) <<
" "
4452 Double_t dIntPtX[2] = {0., 0.};
4453 Double_t dIntPtY[2] = {0., 0.};
4454 Double_t dEdgeR = 0.;
4455 Int_t iOppCorner = 0;
4456 if (0 == iCorners[0] && 1 == iCorners[1]) {
4457 LOG(debug3) <<
"Test upper edge";
4460 dIntPtX[0] = dCornersX[0];
4462 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4464 dIntPtX[1] = dCornersX[1];
4466 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4470 dEdgeR = dChanCentPosY - dEdgeCentDistY
4472 }
else if (1 == iCorners[0] && 2 == iCorners[1]) {
4473 LOG(debug3) <<
"Test right edge";
4477 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4478 dIntPtY[0] = dCornersY[1];
4481 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4482 dIntPtY[1] = dCornersY[2];
4487 dChanCentPosX - dEdgeCentDistX - dClustCentX;
4488 }
else if (2 == iCorners[0] && 3 == iCorners[1]) {
4489 LOG(debug3) <<
"Test lower edge";
4492 dIntPtX[0] = dCornersX[2];
4494 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4496 dIntPtX[1] = dCornersX[3];
4498 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4502 dEdgeR = dChanCentPosY + dEdgeCentDistY
4504 }
else if (0 == iCorners[0] && 3 == iCorners[1]) {
4505 LOG(debug3) <<
"Test left edge";
4509 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4510 dIntPtY[0] = dCornersY[3];
4513 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4514 dIntPtY[1] = dCornersY[0];
4518 dEdgeR = dChanCentPosX + dEdgeCentDistX
4524 dCornersY[iCorners[0]],
4525 dCornersX[iCorners[1]],
4526 dCornersY[iCorners[1]],
4531 dCornersY[iOppCorner],
4540 dClustRadius, dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
4549 if (TMath::Abs(dEdgeR) < dClustRadius)
4562 Int_t iOutCorner = 0;
4563 Double_t dIntPtX[2] = {0., 0.};
4564 Double_t dIntPtY[2] = {0., 0.};
4566 if (dCornersR[0] > dClustRadius) {
4571 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4572 dIntPtY[0] = dCornersY[0];
4574 dIntPtX[1] = dCornersX[0];
4576 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4578 else if (dCornersR[1] > dClustRadius) {
4583 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4584 dIntPtY[0] = dCornersY[1];
4586 dIntPtX[1] = dCornersX[1];
4588 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4590 else if (dCornersR[2] > dClustRadius) {
4595 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4596 dIntPtY[0] = dCornersY[2];
4598 dIntPtX[1] = dCornersX[2];
4600 iChanId, dClustRadius, dClustCentX, dClustCentY, kTRUE);
4602 else if (dCornersR[3] > dClustRadius) {
4607 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4608 dIntPtY[0] = dCornersY[3];
4610 dIntPtX[1] = dCornersX[3];
4612 iChanId, dClustRadius, dClustCentX, dClustCentY, kFALSE);
4620 dCornersY[iOutCorner],
4629 dClustRadius, dIntPtX[0], dIntPtY[0], dIntPtX[1], dIntPtY[1]);
4658 0.5 * ((dXa - dXc) * (dYb - dYa) - (dXa - dXb) * (dYc - dYa));
4659 return TMath::Abs(dArea);
4662 Double_t dDistBaseToCenter) {
4663 if (dDiscRadius < dDistBaseToCenter || dDiscRadius <= 0
4664 || dDistBaseToCenter < 0) {
4665 LOG(error) <<
"CbmTofDigitize::DiscSectionArea => Invalid Input values!! "
4667 << dDiscRadius <<
" and Base distance " << dDistBaseToCenter;
4671 Double_t dArea = dDiscRadius * dDiscRadius *
TMath::Pi() / 2.0;
4674 dArea -= dDistBaseToCenter
4675 * TMath::Sqrt(dDiscRadius * dDiscRadius
4676 - dDistBaseToCenter * dDistBaseToCenter);
4679 dDiscRadius * dDiscRadius * TMath::ASin(dDistBaseToCenter / dDiscRadius);
4686 Double_t dClustRadius,
4687 Double_t dClustCentX,
4688 Double_t dClustCentY,
4689 Bool_t bUpperSide) {
4691 Double_t dChanCentPosX = 0.;
4692 Double_t dChanCentPosY = 0.;
4696 Double_t dEdgePosY =
4697 dChanCentPosY + (kTRUE == bUpperSide ? 1 : -1) * dEdgeCentDistY;
4699 if (dChanCentPosX == dClustCentX) {
4703 if (TMath::Abs(dEdgePosY - dClustCentY) == dClustRadius)
4705 return dChanCentPosX;
4709 LOG(error) <<
"CbmTofDigitize::CircleIntersectPosX => Invalid values: "
4710 <<
" 0 or 2 intersections with cluster aligned on channel ";
4716 dClustRadius * dClustRadius - TMath::Power(dClustCentY - dEdgePosY, 2);
4727 Double_t dDistX = TMath::Sqrt(dRoot);
4729 ((dClustCentX - dDistX > dChanCentPosX - dEdgeCentDistX)
4730 && (dClustCentX - dDistX < dChanCentPosX + dEdgeCentDistX)
4733 return dClustCentX + dSign * dDistX;
4739 LOG(error) <<
"CbmTofDigitize::CircleIntersectPosX => Invalid values: "
4740 <<
" 0 intersection at all (negative root = " << dRoot <<
") ";
4742 Form(
" Radius = %5.4f ClustX = %6.3f ClustY = %6.3f Side = %1d EdgeY = "
4743 "%6.3f ChanX = %6.3f ChanY = %6.3f Channel = %6d",
4752 LOG(error) <<
"CbmTofDigitize::CircleIntersectPosX => Input values: "
4759 Double_t dClustRadius,
4760 Double_t dClustCentX,
4761 Double_t dClustCentY,
4762 Bool_t bRightSide) {
4764 Double_t dChanCentPosX = 0.;
4765 Double_t dChanCentPosY = 0.;
4769 Double_t dEdgePosX =
4770 dChanCentPosX + (kTRUE == bRightSide ? 1 : -1) * dEdgeCentDistX;
4772 if (dChanCentPosY == dClustCentY) {
4776 if (TMath::Abs(dEdgePosX - dClustCentX) == dClustRadius)
4778 return dChanCentPosY;
4782 LOG(error) <<
"CbmTofDigitize::CircleIntersectPosY => Invalid values: "
4783 <<
" 0 or 2 intersections with cluster aligned on channel ";
4789 dClustRadius * dClustRadius - TMath::Power(dClustCentX - dEdgePosX, 2);
4803 Double_t dDistY = TMath::Sqrt(dRoot);
4805 ((dClustCentY - dDistY > dChanCentPosY - dEdgeCentDistY)
4806 && (dClustCentY - dDistY < dChanCentPosY + dEdgeCentDistY)
4809 return dClustCentY + dSign * dDistY;
4815 LOG(error) <<
"CbmTofDigitize::CircleIntersectPosY => Invalid values: "
4816 <<
" 0 intersection at all (negative root = " << dRoot <<
") ";
4818 Form(
" Radius = %5.4f ClustX = %6.3f ClustY = %6.3f Side = %1d EdgeX = "
4819 "%6.3f ChanX = %6.3f ChanY = %6.3f Channel = %6d",
4828 LOG(error) <<
"CbmTofDigitize::CircleIntersectPosY => Input values: "
4842 Double_t dBaseLength = TMath::Sqrt(TMath::Power(dBaseXb - dBaseXa, 2)
4843 + TMath::Power(dBaseYb - dBaseYa, 2));
4844 Double_t dRoot = dClustRadius * dClustRadius - dBaseLength * dBaseLength / 4;
4846 return TMath::Sqrt(dRoot);
4848 LOG(error) <<
"CbmTofDigitize::DistanceCircleToBase => Invalid values: "
4849 <<
" base end-points not on circle (negative root" << dRoot
4852 Form(
" Radius = %5.4f Xa = %6.3f Ya = %6.3f Xb = %6.3f Yb = %6.3f ",
4858 LOG(error) <<
"CbmTofDigitize::DistanceCircleToBase => Input values: "