22 #include "FairTrackParP.h"
31 #include "TSpectrum2.h"
34 #include "FairRunAna.h"
35 #include "FairRootManager.h"
36 #include "FairRuntimeDb.h"
45 #include "FairEventHeader.h"
59 Int_t lastIdx = outVector.size()-1;
65 for (Int_t iVec = 0; iVec < lastIdx; ++iVec){
66 os << outVector[iVec] <<
", ";
68 os << outVector[lastIdx] <<
"]";
75 if(outMap.begin() == outMap.end()){
79 for (HitIdxPathMap::const_iterator itMap = outMap.begin(); itMap != outMap.end(); ++itMap){
80 os <<
"{ "<< itMap->first <<
", ";
91 const Int_t tubeIdToAdd = hitToAdd->
GetTubeID();
103 const Int_t tubeIdToAdd = hitToAdd->
GetTubeID();
114 for (
size_t iTestHit = 0; iTestHit <
GetNHits(); ++iTestHit)
118 const Int_t tubeIdTestHit = myTestHit->
GetTubeID();
120 if ( tubeIdToAdd == tubeIdTestHit )
return kTRUE;
143 binning.getNBinsTheta(), binning.getThetaRadLow(), binning.getThetaRadHigh(),
144 binning.getNBinsY(),binning.getYLow(),binning.getYHigh()),
145 fTrackerTask(trackerTask),
149 fAssociatedTrackCand(associatedTrackCand),
151 fInterceptZx(interceptZx),
156 std::cerr <<
"PndFtsHoughSpace FATAL ERROR Tracker task pointer not set.\n";
159 if(3<
fVerbose) std::cout <<
"PndFtsHoughSpace called with tracker ptr " <<
fTrackerTask <<
'\n';
161 fField = fTrackerTask->getMagneticFieldPtr();
177 const TString option = GetName();
182 if (
"lineBeforeDipole" == option)
186 std::cout <<
"PndFtsHoughSpace: " <<
"fInterceptZx was set to " <<
fInterceptZx <<
" That is not correct for line HT of stations before dipole field!\n";
187 std::cout <<
"Will set interceptZx to 0 for " << option <<
'\n';
198 GetXaxis()->SetTitle(
"#theta [rad]");
201 else if (
"parabola" == option)
210 GetXaxis()->SetTitle(
"#theta [rad]");
211 GetYaxis()->SetTitle(
"x_{LP} [cm]");
213 else if (
"parabolapz" == option)
222 GetXaxis()->SetTitle(
"#theta [rad]");
223 GetYaxis()->SetTitle(
"x_{LP} [cm]");
225 else if (
"lineBehindDipole" == option)
229 std::cout <<
"PndFtsHoughSpace: " <<
"fInterceptZx was set to " <<
fInterceptZx <<
" That is not correct for line HT of stations after dipole field!\n";
230 std::cout <<
"Will set interceptZx to 0 for " << option <<
'\n';
241 GetXaxis()->SetTitle(
"#theta [rad]");
244 else if (
"lineZy" == option)
248 std::cout <<
"PndFtsHoughSpace: " <<
"fInterceptZx was set to " <<
fInterceptZx <<
" That is not correct for line HT of all stations in zy plane!\n";
249 std::cout <<
"Will set interceptZx to 0 for " << option <<
'\n';
260 GetXaxis()->SetTitle(
"#theta [rad]");
265 throwError(
"in PndFtsHoughSpace! option " + option +
" is not implemented!");
270 std::cout <<
"HoughSpace parameters successfully set for option " << option <<
'\n';
302 if (3<
fVerbose) {std::cout <<
"Skipping hit with index " << iHit <<
", because it comes from a skewed straw! LayerID = " << myHit->
GetLayerID() <<
'\n';}
310 if (3<
fVerbose) {std::cout <<
"Skipping hit with index " << iHit <<
", because it comes from a non-skewed straw! LayerID = " << myHit->
GetLayerID() <<
'\n';}
319 const Double_t hitZLabSys = myHit->GetZ();
326 if (2<
fVerbose) { std::cout <<
"Adding hit with index " << iHit <<
" to the Hough space hit vector.\n"; }
339 const Int_t lastBinX,
340 const Int_t lastBinY,
341 const Int_t currentBinY,
346 const Int_t nHolesToFill = abs(currentBinY-lastBinY)-1;
347 for (Int_t iCorrect = 1; iCorrect <= nHolesToFill; ++iCorrect)
349 const Int_t xCorrect = round(
float(iCorrect)/
float(nHolesToFill));
351 if (currentBinY > lastBinY)
358 yCorrect = -iCorrect;
362 const Int_t interpolateBinX = lastBinX+xCorrect;
363 const Int_t interpolateBinY = lastBinY+yCorrect;
365 const Int_t interpolatedGlobalBin = GetBin(interpolateBinX,interpolateBinY);
366 AddBinContent(interpolatedGlobalBin);
369 ptrThetaYIdxPathVec->push_back(interpolatedGlobalBin);
373 std::cout <<
"I am filling hole " << iCorrect <<
" of " << nHolesToFill <<
'\n';
374 std::cout <<
"interpolatedGlobalBin = " << interpolatedGlobalBin <<
'\n';
375 std::cout <<
"(lastBinX, lastBinY) = (" << lastBinX <<
", " << lastBinY <<
")" <<
'\n';
376 std::cout <<
"(lastBinX+1, currentBinY) = (" << lastBinX+1 <<
", " << currentBinY <<
")" <<
'\n';
377 std::cout <<
"xCorrect = " << xCorrect <<
" yCorrect = " << yCorrect <<
'\n';
378 std::cout <<
"(interpolateBinX, interpolateBinY) = (" << interpolateBinX <<
", " << interpolateBinY <<
")" <<
'\n';
390 if(1<
fVerbose) Info(
"FillHoughSpace",
"No hits in Hough space.");
396 const TString option = GetName();
404 Int_t currentBinX = 0, currentBinY = 0, currentBinZ = 0;
405 Int_t lastBinX = 0, lastBinY = 0;
407 Bool_t firstEntry = kTRUE;
412 for (
size_t iHit = 0; iHit <
GetNHits(); iHit++)
429 std::cout <<
"Doing " << option <<
" Hough transform for hit (hitZLabSys, hitXLabSys) = (" << hitZLabSys <<
", " << hitXLabSys <<
") cm";
430 if (kTRUE ==
fKeepBConstant) { std::cout <<
" ignoring B field maps\n"; }
else { std::cout <<
" reading B field maps\n"; }
442 Int_t iThetaFirst = fXaxis.GetFirst();
443 Int_t iThetaLast = fXaxis.GetLast();
450 for (Int_t iTheta = iThetaFirst; iTheta < iThetaLast; ++iTheta)
453 Double_t thetaRad = fXaxis.GetBinCenter(iTheta);
454 if (9<
fVerbose) { std::cout <<
" for thetaRad = " << thetaRad <<
'\n'; }
457 if (
"parabola" == option)
461 if (9<
fVerbose) { std::cout <<
"Q/pzx = " << yVal; }
463 else if (
"parabolapz" == option)
467 if (9<
fVerbose) { std::cout <<
"pz/Q = " << yVal; }
469 else if ( (
"lineBeforeDipole" == option) || (
"lineBehindDipole" == option) )
473 if (9<
fVerbose) { std::cout <<
"xLP/PL = " << yVal; }
475 else if (
"lineZy" == option)
479 if (9<
fVerbose) { std::cout <<
"yLine = " << yVal; }
484 throwError(
"in FillHoughSpace! option " + option +
" is not implemented!");
492 globalBin =
Fill(thetaRad,yVal);
493 if (5<
fVerbose) { std::cout <<
"Hough point was filled into Hough space. globalbin = " << globalBin <<
" for option" << option <<
'\n'; }
495 GetBinXYZ(globalBin, currentBinX, currentBinY, currentBinZ);
503 if (5<
fVerbose) { std::cout <<
"OK! Hough point was NOT written to over- or underflow of histogram. Setting firstEntry to kFALSE now. "<< option <<
'\n'; }
506 if (currentBinX != iTheta){
507 std::cerr <<
"\n\nError in FillHoughSpace! Hough point was filled into xBin " << currentBinX <<
" and not in " << iTheta <<
"\n";
508 std::cerr <<
"iThetaFirst = " << iThetaLast <<
" iThetaLast = " << iThetaLast <<
"\n";
509 std::cerr <<
"Over- or underflow on y-axis or FATAL error!\n\n\n";
513 if (kFALSE == firstEntry)
517 std::cout <<
"This is not the first point of the hit in the histogram. I will fix all holes which might be between this entry and the last one in the histogram"<<
'\n';
520 FillHoles(lastBinX, lastBinY, currentBinY, &globalBinPathVec);
526 if (5<
fVerbose) { std::cout <<
"This is the first point of the hit in the histogram. I will not try to fix any holes in the " << option <<
" histogram"<<
'\n';}
533 globalBinPathVec.push_back(globalBin);
538 if (9<
fVerbose) { std::cout <<
"Watch out! Point was written to over- or underflow of histogram. firstEntry is set to kTRUE. "<< option <<
'\n'; }
542 if (9<
fVerbose) { std::cout <<
"currentBinY = " << currentBinY <<
" lastBinY = " << lastBinY <<
'\n'; }
543 lastBinX = currentBinX;
544 lastBinY = currentBinY;
550 if ( 0 < globalBinPathVec.size() ){
565 static Int_t histoCounter = 0;
567 newname += histoCounter;
574 newTitle += specifier;
580 TH2S peaks(newname, newTitle, fXaxis.GetNbins(), fXaxis.GetXmin(),
581 fXaxis.GetXmax(), fYaxis.GetNbins(), fYaxis.GetXmin(),
590 if ( (kTRUE == saveEachSeparately) && (kTRUE == saveAllTogether) )
return;
595 for (UInt_t iPeak = 0; iPeak < peaksToPlot.size(); ++iPeak) {
597 const Double_t currHeight = peaksToPlot[iPeak].getHeight();
598 const std::set<Int_t>& binsInPeak = peaksToPlot[iPeak].getBins();
599 for (std::set<Int_t>::iterator itBin = binsInPeak.begin(); itBin != binsInPeak.end(); ++itBin) {
600 onePeak.SetBinContent(*itBin, currHeight);
601 allPeaks.SetBinContent(*itBin, currHeight);
604 if ( kTRUE == saveEachSeparately ) onePeak.SaveAs(outNameOne,
"LEGO2");
607 if ( kTRUE == saveAllTogether ) allPeaks.SaveAs(outNameAll,
"LEGO2");
614 if ( (kTRUE == saveExclusively) && (kTRUE == saveProjected) )
return;
618 const Int_t currHit = itPath->first;
621 const IdxPath& currPath = itPath->second;
623 Int_t lastBinNumber = -1;
624 for (
size_t iGlobalBin = 0; iGlobalBin < currPath.size(); ++iGlobalBin) {
625 const Int_t currBinNumber = currPath[iGlobalBin];
627 if ( currBinNumber == lastBinNumber ) std::cerr <<
"FATAL! Bin " << currBinNumber <<
" twice in a row! in hit " << currHit <<
'\n';
628 lastBinNumber = currBinNumber;
630 if ( kTRUE == saveProjected){
631 const Double_t currHeight = GetBinContent(currBinNumber);
632 onePathProjected.SetBinContent(currBinNumber, currHeight);
635 if ( kTRUE == saveExclusively){
636 Int_t currBinX = 0, currBinY = 0, notUsedBinZ = 0;
637 GetBinXYZ(currBinNumber, currBinX, currBinY, notUsedBinZ);
640 onePathExclusively.Fill(currXVal,currYVal);
644 if ( kTRUE == saveProjected ) onePathProjected.SaveAs(outNameProj,
"LEGO2");
646 if ( kTRUE == saveExclusively ) onePathExclusively.SaveAs(outNameExcl,
"LEGO2");
658 if ( (kTRUE == saveExclusively) && (kTRUE == saveProjected) )
return;
662 std::map<Int_t, std::pair < TH2S, TH2S > > mcTruthIdHistos;
667 const Int_t currHit = itPath->first;
672 std::map<Int_t, std::pair < TH2S, TH2S > >::iterator itFind;
673 itFind = mcTruthIdHistos.find(mcTruthId);
674 if ( mcTruthIdHistos.end() == itFind ){
677 std::pair<TH2S, TH2S > histoPair( newHisto, newHisto2 );
678 std::pair<Int_t, std::pair<TH2S, TH2S > > mcTruthIdHistosPair( mcTruthId, histoPair );
679 mcTruthIdHistos.insert( mcTruthIdHistosPair );
680 itFind = mcTruthIdHistos.find(mcTruthId);
684 const IdxPath& currPath = itPath->second;
685 for (
size_t iGlobalBin = 0; iGlobalBin < currPath.size(); ++iGlobalBin) {
686 Int_t currBinNumber = currPath[iGlobalBin];
687 std::pair<TH2S, TH2S >& histoPair = itFind->second;
689 if ( kTRUE == saveProjected ){
690 const Double_t currHeight = GetBinContent(currBinNumber);
691 histoPair.first.SetBinContent(currBinNumber, currHeight);
694 if ( kTRUE == saveExclusively ){
695 Int_t currBinX = 0, currBinY = 0, notUsedBinZ = 0;
696 GetBinXYZ(currBinNumber, currBinX, currBinY, notUsedBinZ);
699 histoPair.second.Fill(currXVal,currYVal);
704 for (
std::map<Int_t, std::pair<TH2S, TH2S > >::const_iterator itHisto = mcTruthIdHistos.begin(); itHisto != mcTruthIdHistos.end(); ++itHisto) {
705 const std::pair<TH2S, TH2S >& histoPair = itHisto->second;
708 if ( kTRUE == saveProjected ) histoPair.first.SaveAs(outNameProjection,
"LEGO2");
709 if ( kTRUE == saveExclusively ) histoPair.second.SaveAs(outNameExclusive,
"LEGO2");
723 SaveAs(outName,
"LEGO2");
772 const Int_t xfirst = fXaxis.GetFirst();
773 const Int_t xlast = fXaxis.GetLast();
778 UInt_t thetaBinLo = locmax-1;
779 UInt_t thetaBinHi = locmax+1;
781 if ((
int)thetaBinLo>xfirst) {
784 if ((
int)thetaBinHi>xlast) {
789 const Double_t thetaRadLo = fXaxis.GetBinCenter(thetaBinLo);
790 const Double_t thetaRadHi = fXaxis.GetBinCenter(thetaBinHi);
797 for (
size_t iHit = 0; iHit <
GetNHits(); iHit++)
813 const TString option = GetName();
814 if (
"parabola" == option)
820 std::cout <<
"Q/pzx = " << yValLo <<
'\n';
821 std::cout <<
"Q/pzx = " << yValHi <<
'\n';
824 else if (
"parabolapz" == option)
830 std::cout <<
"pz/Q = " << yValLo <<
'\n';
831 std::cout <<
"pz/Q = " << yValHi <<
'\n';
834 else if ( (
"lineBeforeDipole" == option) || (
"lineBehindDipole" == option) )
842 std::cout <<
"xLP/PL = " << yValLo <<
'\n';
843 std::cout <<
"xLP/PL = " << yValHi <<
'\n';
846 else if (
"lineZy" == option)
854 std::cout <<
"xLP = " << yValLo <<
'\n';
855 std::cout <<
"xLP = " << yValHi <<
'\n';
860 throwError(
"Error in FillHoughSpace! option " + option +
" is not implemented!");
867 const Double_t yMinHw = fYaxis.GetBinWidth(yMin)/2.;
868 const Double_t yMaxHw = fYaxis.GetBinWidth(yMax)/2.;
872 if ( (yMin-yMinHw <= peakSecondVal) && (yMax+yMaxHw >= peakSecondVal) ){
884 std::vector<PndFtsHoughTracklet> tracklets;
889 if(1<
fVerbose) std::cout <<
"Hough Space is empty. No peak can be found. Return empty tracklet vector." <<
'\n';
907 Int_t locmax, locmay, locmaz;
911 Int_t binNumber, binx, biny;
914 const Int_t xfirst = fXaxis.GetFirst()+vicinityLength;
915 const Int_t xlast = fXaxis.GetLast()-vicinityLength;
916 const Int_t yfirst = fYaxis.GetFirst()+vicinityLength;
917 const Int_t ylast = fYaxis.GetLast()-vicinityLength;
923 locmax = locmay = locmaz = 0;
925 for (biny=yfirst;biny<=ylast;biny++) {
926 for (binx=xfirst;binx<=xlast;binx++) {
929 for (Int_t xVicinityBin = -vicinityLength; xVicinityBin <= vicinityLength; ++xVicinityBin)
931 for (Int_t yVicinityBin = -vicinityLength; yVicinityBin <= vicinityLength; ++yVicinityBin)
933 binNumber = GetBin(binx+xVicinityBin,biny+yVicinityBin);
934 currentHeight += 1./(1.+
std::max(abs(xVicinityBin),abs(yVicinityBin)))*GetBinContent(binNumber);
939 if (currentHeight >= minHeight) {
944 Double_t peakThetaVal = fXaxis.GetBinCenter(locmax);
945 Double_t peakSecondVal = fYaxis.GetBinCenter(locmay);
948 Double_t peakThetaHw = fXaxis.GetBinWidth(peakThetaVal)/2.;
949 Double_t peakSecondHw = fYaxis.GetBinWidth(peakSecondVal)/2.;
958 tracklets.push_back(currentTracklet);
975 std::vector<PndFtsHoughTracklet> tracklets;
980 if(1<
fVerbose) std::cout <<
"Hough Space is empty. No peak can be found. Return empty tracklet vector." <<
'\n';
993 std::vector< PndFtsHoughSpacePeak > peaksForOneHit;
994 std::vector< PndFtsHoughSpacePeak > mergedPeaksForAllHits;
995 mergedPeaksForAllHits.clear();
999 const Int_t hitIdx = itMap->first;
1001 peaksForOneHit.clear();
1004 for (
int iGlobalBin = 0; iGlobalBin < (int)path.size(); ++iGlobalBin){
1006 const Int_t currBinNumber = path[iGlobalBin];
1007 const Int_t currHeight = GetBinContent(currBinNumber);
1010 const Int_t nPeaksSoFar = peaksForOneHit.size();
1011 if ( 0 < nPeaksSoFar ){
1015 if ( currHeight == currPeak.
getHeight() ) currPeak.
addBin(currBinNumber, hitIdx);
1016 if ( currHeight > currPeak.
getHeight() ) currPeak.
replaceBins(currHeight, currBinNumber, hitIdx);
1021 if ( (
int)minHeight <= currHeight ) {
1026 const Int_t prevIdx =
std::max(0, iGlobalBin-1);
1027 const Int_t prevBinNumber = path[prevIdx];
1028 const Int_t prevHeight = GetBinContent(prevBinNumber);
1030 Bool_t rising = prevHeight < currHeight;
1031 if ( 0 == iGlobalBin ) rising = kTRUE;
1033 if ( kTRUE == rising ){
1037 peaksForOneHit.push_back(newPeak);
1046 for (UInt_t iPeaksForOneHit = 0; iPeaksForOneHit < peaksForOneHit.size(); ++iPeaksForOneHit){
1048 for (UInt_t iPeaksForAllHits = 0; iPeaksForAllHits < mergedPeaksForAllHits.size(); ++iPeaksForAllHits){
1049 if ( mergedPeaksForAllHits[iPeaksForAllHits].binsOverlapWith(peaksForOneHit[iPeaksForOneHit]) ) {
1050 mergedPeaksForAllHits[iPeaksForAllHits].mergeWith(peaksForOneHit[iPeaksForOneHit]);
1055 if ( kFALSE==merged ) mergedPeaksForAllHits.push_back(peaksForOneHit[iPeaksForOneHit]);
1063 for (UInt_t iPeaks = 0; iPeaks < mergedPeaksForAllHits.size(); ++iPeaks){
1064 const Double_t currentHeight = mergedPeaksForAllHits[iPeaks].getHeight();
1065 const std::set<Int_t>& binsInPeak = mergedPeaksForAllHits[iPeaks].getBins();
1068 Double_t minThetaVal = 0., maxThetaVal = 0., minSecondVal = 0., maxSecondVal = 0.;
1069 for (std::set< Int_t >::iterator itBin = binsInPeak.begin(); itBin != binsInPeak.end(); ++itBin){
1070 Int_t currentBinX = 0, currentBinY = 0, currentBinZ = 0;
1071 GetBinXYZ(*itBin, currentBinX, currentBinY, currentBinZ);
1073 const Double_t currThetaVal = fXaxis.GetBinCenter(currentBinX);
1074 const Double_t currSecondVal = fYaxis.GetBinCenter(currentBinY);
1076 if ( binsInPeak.begin() == itBin ){
1077 minThetaVal = currThetaVal;
1078 maxThetaVal = currThetaVal;
1079 minSecondVal = currSecondVal;
1080 maxSecondVal = currSecondVal;
1082 minThetaVal =
std::min(minThetaVal,currThetaVal);
1083 maxThetaVal =
std::max(maxThetaVal,currThetaVal);
1084 minSecondVal =
std::min(minSecondVal,currSecondVal);
1085 maxSecondVal =
std::max(maxSecondVal,currSecondVal);
1089 const Double_t peakThetaVal = (maxThetaVal + minThetaVal)/2.;
1090 const Double_t peakSecondVal = (maxSecondVal + minSecondVal)/2.;
1091 const Double_t peakThetaHw = (maxThetaVal - minThetaVal)/2. + fXaxis.GetBinWidth(peakThetaVal)/2.;
1092 const Double_t peakSecondHw = (maxSecondVal - minSecondVal)/2. + fYaxis.GetBinWidth(peakSecondVal)/2.;
1100 const std::set<Int_t>& hitIdsInPeak = mergedPeaksForAllHits[iPeaks].getHitIds();
1101 for (std::set< Int_t >::iterator itHitId= hitIdsInPeak.begin(); itHitId != hitIdsInPeak.end(); ++itHitId){
1109 tracklets.push_back(currentTracklet);
1122 std::vector<PndFtsHoughTracklet> tracklets;
1127 if(1<
fVerbose) std::cout <<
"Hough Space is empty. No peak can be found. Return empty tracklet vector." <<
'\n';
1133 throwError(
"This peak finder is not fully implemented!");
1141 Int_t xFirstBin = fXaxis.GetFirst();
1142 Int_t xLastBin = fXaxis.GetLast();
1143 Int_t yFirstBin = fYaxis.GetFirst();
1144 Int_t yLastBin = fYaxis.GetLast();
1150 Int_t currBinNumber;
1156 for (Int_t currBinX=xFirstBin; currBinX<=xLastBin; ++currBinX) {
1157 for (Int_t currBinY=yFirstBin; currBinY<=yLastBin; ++currBinY) {
1160 currBinNumber = GetBin(currBinX,currBinY);
1161 currHeight = GetBinContent(currBinNumber);
1162 if (minHeight > currHeight) {
1164 SetBinContent(currBinNumber,0);
1178 Int_t combinedPeakBinXLow=currBinX;
1179 Int_t combinedPeakBinXHigh=currBinX;
1180 Double_t combinedPeakHeight=currHeight;
1185 Double_t lastVisitedHeight = currHeight;
1188 Int_t currNeighborBinX = currBinX;
1189 Int_t currNeighborBinNumber = currBinNumber;
1190 Double_t currNeighborHeight = currHeight;
1195 currNeighborBinX = currBinX+iBinX;
1196 if (currNeighborBinX>xLastBin){
1199 currNeighborBinNumber = GetBin(currNeighborBinX,currBinY);
1200 currNeighborHeight = GetBinContent(currNeighborBinNumber);
1202 if (minHeight > currNeighborHeight){
1204 SetBinContent(currNeighborBinNumber,0);
1208 if (currNeighborHeight > combinedPeakHeight){
1210 for (Int_t xBinToDel=combinedPeakBinXLow; xBinToDel<= combinedPeakBinXHigh; ++xBinToDel){
1211 Int_t BinNumberToDel = GetBin(xBinToDel,currBinY);
1212 SetBinContent(BinNumberToDel,0);
1214 combinedPeakBinXLow = currNeighborBinX;
1215 combinedPeakBinXHigh = currNeighborBinX;
1216 combinedPeakHeight = currNeighborHeight;
1217 }
else if (currNeighborHeight < combinedPeakHeight){
1218 if (currNeighborHeight <= lastVisitedHeight){
1220 SetBinContent(currNeighborBinNumber,0);
1225 }
else if (currNeighborHeight == combinedPeakHeight){
1227 combinedPeakBinXHigh = currNeighborBinX;
1231 lastVisitedHeight = currNeighborHeight;
1238 for (Int_t xBinToDel=combinedPeakBinXLow; xBinToDel<= combinedPeakBinXHigh; ++xBinToDel){
1239 Int_t BinNumberToDel = GetBin(xBinToDel,currBinY);
1240 SetBinContent(BinNumberToDel,0);
1247 peakBinX = (combinedPeakBinXHigh+combinedPeakBinXLow)/2;
1248 peakBinY = currBinY;
1251 Double_t peakThetaVal = fXaxis.GetBinCenter(peakBinX);
1252 Double_t peakSecondVal = fYaxis.GetBinCenter(peakBinY);
1255 if (0!=(combinedPeakBinXHigh+combinedPeakBinXLow)%2){
1256 peakThetaVal+=fXaxis.GetBinWidth(peakThetaVal)/2.;
1260 Double_t combinedPeakThetaLowEdge = fXaxis.GetBinCenter(combinedPeakBinXLow) - fXaxis.GetBinWidth(combinedPeakBinXLow)/2.;
1261 Double_t combinedPeakThetaHighEdge = fXaxis.GetBinCenter(combinedPeakBinXHigh) + fXaxis.GetBinWidth(combinedPeakBinXHigh)/2.;
1263 Double_t peakThetaHw = (combinedPeakThetaHighEdge-combinedPeakThetaLowEdge)/2.;
1264 Double_t peakSecondHw = fYaxis.GetBinWidth(peakSecondVal)/2.;
1285 UInt_t thetaBinLo = combinedPeakBinXLow-1;
1286 UInt_t thetaBinHi = combinedPeakBinXHigh+1;
1288 if ((
int)thetaBinLo>xFirstBin) {
1289 thetaBinLo=xFirstBin;
1291 if ((
int)thetaBinHi>xLastBin) {
1292 thetaBinHi=xLastBin;
1296 const Double_t thetaRadLo = fXaxis.GetBinCenter(thetaBinLo);
1297 const Double_t thetaRadHi = fXaxis.GetBinCenter(thetaBinHi);
1303 for (
size_t iHit = 0; iHit <
GetNHits(); iHit++)
1320 const TString option = GetName();
1321 if (
"parabola" == option)
1327 std::cout <<
"Q/pzx = " << yValLo <<
'\n';
1328 std::cout <<
"Q/pzx = " << yValHi <<
'\n';
1331 else if (
"parabolapz" == option)
1337 std::cout <<
"pz/Q = " << yValLo <<
'\n';
1338 std::cout <<
"pz/Q = " << yValHi <<
'\n';
1341 else if ( (
"lineBeforeDipole" == option) || (
"lineBehindDipole" == option) )
1349 std::cout <<
"xLP/PL = " << yValLo <<
'\n';
1350 std::cout <<
"xLP/PL = " << yValHi <<
'\n';
1353 else if (
"lineZy" == option)
1361 std::cout <<
"xLP = " << yValLo <<
'\n';
1362 std::cout <<
"xLP = " << yValHi <<
'\n';
1367 throwError(
"Error in FillHoughSpace! option " + option +
" is not implemented!");
1374 const Double_t yMinHw = fYaxis.GetBinWidth(yMin)/2.;
1375 const Double_t yMaxHw = fYaxis.GetBinWidth(yMax)/2.;
1379 if ( (yMin-yMinHw <= peakSecondVal) && (yMax+yMaxHw >= peakSecondVal) ){
1380 Int_t hitIndex =
fHitId.at(iHit).GetHitId();
1386 tracklets.push_back(currentTracklet);
1400 std::vector<PndFtsHoughTracklet> tracklets;
1405 if(1<
fVerbose) std::cout <<
"Hough Space is empty. No peak can be found. Return empty tracklet vector." <<
'\n';
1411 throwError(
"This peak finder is not fully implemented!");
1415 Int_t maxpeaks = 20;
1417 TSpectrum2
s(maxpeaks,3);
1418 s.SetAverageWindow(3);
1419 s.SetDeconIterations(100);
1423 Int_t nfound = s.Search(
this, 2,
"",0.5);
1429 for (Int_t iPeak = 0; iPeak < nfound; ++iPeak){
1430 Double_t peakThetaVal = xpeaks[iPeak];
1431 Double_t peakSecondVal = ypeaks[iPeak];
1433 Int_t binmaxglobal =
Fill(peakThetaVal, peakSecondVal, 0);
1434 Double_t peakThetaHw = fXaxis.GetBinWidth(peakThetaVal)/2.;
1435 Double_t peakSecondHw = fYaxis.GetBinWidth(peakSecondVal)/2.;
1438 Double_t currentHeight = GetBinContent(binmaxglobal);
1443 tracklets.push_back(currentTracklet);
1457 std::vector<PndFtsHoughTracklet> tracklets;
1462 if(1<
fVerbose) std::cout <<
"Hough Space is empty. No peak can be found. Return empty tracklet vector." <<
'\n';
1468 throwError(
"This peak finder is not implemented!");
Bool_t isFinished() const
void AddHitsToTrackletByCalculating(PndFtsHoughTracklet *currentTracklet, Int_t locmax)
Bool_t IsHitFromTubeIdAlreadyAdded(const Int_t tubeIdToAdd)
std::vector< PndFtsHoughTracklet > FindAllPeaksBinsWoMergingWithSearchWindow(const UInt_t minHeight, const Int_t vicinityLength=0)
Finds all peaks that satisfy the minimum height requirement minHeight.
std::vector< Int_t > IdxPath
Int_t getMcTruthIdForHitId(UInt_t hitId) const
TH2S MakeEmptyHistoOfSameDimensions(TString specifier="", Int_t index=-1) const
Makes a new empty histogram with the same binning and limits as this.
Double_t equationParabola(Double_t thetaRad, Double_t hitZShifted, Double_t hitXShifted, Double_t By)
void setFinished(Bool_t newVal)
Interface between PandaRoot (data input and output) and PndFtsHoughTrackFinder (implementation of PR ...
Double_t fOnlyUseHitsFromZ
Double_t equationParabolaPz(Double_t thetaRad, Double_t hitZShifted, Double_t hitXShifted, Double_t By)
Class for saving peaks of a Hough space.
const TVector3 GetRawOrCalculatedHitPos(const PndFtsHit *const myHit) const
std::ostream & operator<<(std::ostream &o, const PndEventInfo &a)
void WriteHistoOfAllPeaks(const std::vector< PndFtsHoughSpacePeak > &peaksToPlot) const
For writing out peaks in Hough spaces as histograms (for debugging purposes).
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
hz_h GetYaxis() -> SetTitle("Counts")
std::vector< PndTrackCandHit > fHitId
Bool_t fUseNonSkewedStraws
hz_h GetXaxis() -> SetTitle("Z position")
std::vector< PndFtsHoughTracklet > FindAllPeaksScanPathsMergeBins(const UInt_t minHeight)
Finds all peaks that satisfy the minimum height requirement minHeight.
Int_t GetNFtsHits() const
Returns the event number.
Bool_t FillHoles(const Int_t lastBinX, const Int_t lastBinY, const Int_t currentBinY, IdxPath *ptrThetaYIdxPathVec)
Makes sure there are no holes in the Hough space by filling them with a line.
std::vector< PndFtsHoughTracklet > FindAllPeaksBlanko(const UInt_t minHeight)
Finds all peaks that satisfy the minimum height requirement minHeight.
Double_t getByFromBField(Double_t hitXLabSys, Double_t hitYLabSys, Double_t hitZLabSys)
void throwError(const TString s) const
For error reporting.
Class for saving the result of one Hough transform for FTS PR.
PndFtsHoughSpace(const char *name=0, const Int_t refIndex=-1, PndFtsHoughSpaceBinning binning=PndFtsHoughSpaceBinning(), Double_t zRefPos=0., Double_t interceptZx=0., PndFtsHoughTrackCand *associatedTrackCand=0, PndFtsHoughTrackerTask *trackerTask=0)
void AddHit(UInt_t detId, UInt_t hitId, Double_t rho)
void replaceBins(Int_t height, Int_t firstBin, Int_t firstHitIdx)
void SetHoughTransformResults(const Double_t thetaVal, const Double_t secondVal, const Double_t peakHeight, const Double_t thetaHw, const Double_t secondHw)
Int_t GetSaveDebugInfo() const
Returns the verbosity level.
Bool_t setParametersForHsOption()
void WriteHistoOfAllPathsForEachMcTruthTrack() const
For writing out paths from hits which stem from the same MC truth tracks (how the Hough space would b...
void WriteHistoOfAllPaths() const
For writing out paths (how the Hough space was filled seen from one hit) as histograms (for debugging...
Double_t getSecondVal() const
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
std::vector< PndFtsHoughTracklet > FindAllPeaksWithTSpectrum2(const UInt_t minHeight)
Finds all peaks that satisfy the minimum height requirement minHeight.
Class for Hough space based on TH2S (for the moment). Saves the hits which enter this Hough space and...
Int_t fFtsBranchId
@ brief FTS Hits
void WriteHistoOfHoughSpace() const
For writing out Hough spaces as histograms (for debugging purposes).
const PndFtsHit * GetFtsHit(UInt_t hitId) const
Returns pointer to the hit with index hitId in the FTS hit array.
Double_t equationLineZxOrZy(Double_t thetaRad, Double_t hitZShifted, Double_t hitXLabSys)
Int_t getHitIdFromHS(UInt_t index) const
cout<<"will loop over "<< t-> GetEntries()
Double_t fOnlyUseHitsUpToZ
std::vector< PndFtsHoughTracklet > FindAllPeaksScanPathsMergeBinsCalculatingPaths(const UInt_t minHeight)
Finds all peaks that satisfy the minimum height requirement minHeight.
Helper class for Hough space containing binning. Created: 09.02.2015.
HitIdxPathMap fHitThetaYIdxPath
Class for saving a FTS track cand. for Hough transform based FTS PR.
h1 Fill(hit_theta-point_theta)
void AddHitToHS(UInt_t hitId, Double_t rho)
void addBin(Int_t binNumber, Int_t hitIdx)
void PrintFoundTracklets(const std::vector< PndFtsHoughTracklet > &tracklets) const
const PndFtsHit * getHitFromHS(UInt_t index) const
std::map< Int_t, IdxPath > HitIdxPathMap
PndFtsHoughTrackerTask * fTrackerTask
std::pair< Int_t, IdxPath > HitIdxPathPair
TString GetDebugOutName(TString title="", Int_t param=-1) const
For writing out debugging histograms.
void FillHoughSpace()
Fills the Hough space using the equation which corresponds to the name of the Hough space...