46 #include "canvas/Persistency/Common/FindOneP.h" 49 #include "art_root_io/TFileService.h" 83 using PeakDevVec = std::vector<std::tuple<double,int,int,int>>;
122 void AddPeak(std::tuple<double,int,int,int> fPeakDevCand,
125 void SplitPeak(std::tuple<double,int,int,int> fPeakDevCand,
134 double fPeakMeanTrue);
140 double fChargeNormFactor,
141 double fPeakMeanTrue);
144 std::vector<double>&
output);
147 std::vector<float>& outputVec,
148 size_t binsToAverage)
const;
150 void reBin(
const std::vector<float>& inputVec,
151 std::vector<float>& outputVec,
152 size_t nBinsToCombine)
const;
160 {
return std::get<0>(
p) < s; }
162 {
return s < std::get<0>(
p); }
228 fMinSig = pset.get<
float >(
"MinSig");
234 fMinTau = pset.get<
double >(
"MinTau");
235 fMaxTau = pset.get<
double >(
"MaxTau");
266 std::vector<double>&
output)
269 throw std::runtime_error(
"DPRawHitFinder::FillOutHitParameterVector ERROR! Input config vector has zero size.");
272 const unsigned int N_PLANES = geom->
Nplanes();
275 output.resize(N_PLANES,input[0]);
276 else if(input.size()==N_PLANES)
279 throw std::runtime_error(
"DPRawHitFinder::FillOutHitParameterVector ERROR! Input config vector size !=1 and !=N_PLANES.");
293 fFirstChi2 = tfs->make<TH1F>(
"fFirstChi2",
"#chi^{2}", 10000, 0, 5000);
294 fChi2 = tfs->make<TH1F>(
"fChi2",
"#chi^{2}", 10000, 0, 5000);
301 TH1::AddDirectory(kFALSE);
338 for(
size_t wireIter = 0; wireIter < wireVecHandle->size(); wireIter++)
348 std::vector<geo::WireID> wids = geom->
ChannelToWire(channel);
357 std::cout <<
"-----------------------------------------------------------------------------------------------------------" <<
std::endl;
358 std::cout <<
"Channel: " << channel <<
std::endl;
372 for(
const auto& range : signalROI.
get_ranges())
377 const std::vector<float>& signal = range.data();
389 std::vector<float> timeAve;
401 if (timeValsVec.empty())
continue;
424 std::cout <<
"-------------------- ROI #" << CountROI <<
" -------------------- " <<
std::endl;
425 if(timeValsVec.size() == 1) std::cout <<
"ROI #" << CountROI <<
" (" << timeValsVec.size() <<
" peak): ROIStartTick: " << range.offset <<
" ROIEndTick:" << range.offset+range.size() <<
std::endl;
426 else std::cout <<
"ROI #" << CountROI <<
" (" << timeValsVec.size() <<
" peaks): ROIStartTick: " << range.offset <<
" ROIEndTick:" << range.offset+range.size() <<
std::endl;
433 for(
auto const& timeValsTmp : timeValsVec )
435 std::cout <<
"Peak #" << CountPeak <<
": PeakStartTick: " << range.offset + std::get<0>(timeValsTmp) <<
" PeakMaxTick: " << range.offset + std::get<1>(timeValsTmp) <<
" PeakEndTick: " << range.offset + std::get<2>(timeValsTmp) <<
std::endl;
442 if (timeValsVec.empty())
continue;
457 int NumberOfPeaksBeforeFit=0;
458 unsigned int nExponentialsForFit=0;
459 double chi2PerNDF=0.;
462 unsigned int NumberOfMergedVecs = mergedVec.size();
468 for(
unsigned int j=0; j < NumberOfMergedVecs; j++)
470 int startT = std::get<0>(mergedVec.at(j));
471 int endT = std::get<1>(mergedVec.at(j));
472 int width = endT + 1 - startT;
475 int NFluctuations = std::get<3>(mergedVec.at(j));
480 if(peakVals.size() == 1) std::cout <<
"- Group #" << j <<
" (" << peakVals.size() <<
" peak): GroupStartTick: " << range.offset + startT <<
" GroupEndTick: " << range.offset + endT <<
std::endl;
481 else std::cout <<
"- Group #" << j <<
" (" << peakVals.size() <<
" peaks): GroupStartTick: " << range.offset + startT <<
" GroupEndTick: " << range.offset + endT <<
std::endl;
482 std::cout <<
"Fluctuations in this group: " << NFluctuations <<
std::endl;
483 int CountPeakInGroup=0;
484 for(
auto const& peakValsTmp : peakVals )
486 std::cout <<
"Peak #" << CountPeakInGroup <<
" in group #" << j <<
": PeakInGroupStartTick: " << range.offset + std::get<2>(peakValsTmp) <<
" PeakInGroupMaxTick: " << range.offset + std::get<0>(peakValsTmp) <<
" PeakInGroupEndTick: " << range.offset + std::get<3>(peakValsTmp) << std::endl;
492 if (width <
fMinWidth || (
double)std::accumulate(signal.begin()+startT, signal.begin()+endT+1, 0) <
fMinADCSum || (
double)std::accumulate(signal.begin()+startT, signal.begin()+endT+1, 0)/width <
fMinADCSumOverWidth)
496 std::cout <<
"Delete this group of peaks because width, integral or width/intergral is too small." <<
std::endl;
505 NumberOfPeaksBeforeFit = peakVals.size();
506 nExponentialsForFit = peakVals.size();
520 std::cout <<
"--- First fit ---" <<
std::endl;
521 if (nExponentialsForFit == 1) std::cout <<
"- Fitted " << nExponentialsForFit <<
" peak in group #" << j <<
":" <<
std::endl;
522 else std::cout <<
"- Fitted " << nExponentialsForFit <<
" peaks in group #" << j <<
":" <<
std::endl;
523 std::cout <<
"chi2/ndf = " << chi2PerNDF <<
std::endl;
527 std::cout <<
"tau1 [mus] = " << paramVec[0].first <<
std::endl;
528 std::cout <<
"tau2 [mus] = " << paramVec[1].first <<
std::endl;
530 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
532 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[2*(i+1)].first << std::endl;
533 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << range.offset + paramVec[2*(i+1)+1].first << std::endl;
538 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
540 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[4*i+2].first <<
std::endl;
541 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << range.offset + paramVec[4*i+3].first <<
std::endl;
542 std::cout <<
"Peak #" << i <<
": tau1 [mus] = " << paramVec[4*i].first <<
std::endl;
543 std::cout <<
"Peak #" << i <<
": tau2 [mus] = " << paramVec[4*i+1].first <<
std::endl;
549 if (!(chi2PerNDF < std::numeric_limits<double>::infinity()))
continue;
560 unsigned int nExponentialsBeforeRefit=nExponentialsForFit;
561 unsigned int nExponentialsAfterRefit=nExponentialsForFit;
562 double oldChi2PerNDF = chi2PerNDF;
567 while( (nExponentialsForFit == 1 && nExponentialsAfterRefit < 3*nExponentialsBeforeRefit && chi2PerNDF > fChi2NDFRetry) ||
568 (nExponentialsForFit > 1 && nExponentialsAfterRefit < 3*nExponentialsBeforeRefit && chi2PerNDF >
fChi2NDFRetryFactorMultiHits*fChi2NDFRetry) )
570 RefitSuccess =
false;
575 for(
auto& PeakDevCand : PeakDev)
580 peakValsTemp = peakVals;
582 AddPeak(PeakDevCand, peakValsTemp);
585 if (chi2PerNDF2 < chi2PerNDF)
587 paramVec = paramVecRefit;
588 peakVals = peakValsTemp;
589 nExponentialsForFit = peakVals.size();
590 chi2PerNDF = chi2PerNDF2;
592 nExponentialsAfterRefit++;
599 if(RefitSuccess ==
false)
601 for(
auto& PeakDevCand : PeakDev)
606 peakValsTemp=peakVals;
611 if (chi2PerNDF2 < chi2PerNDF)
613 paramVec = paramVecRefit;
614 peakVals = peakValsTemp;
615 nExponentialsForFit = peakVals.size();
616 chi2PerNDF = chi2PerNDF2;
618 nExponentialsAfterRefit++;
625 if(RefitSuccess ==
false)
634 std::cout <<
"--- Refit ---" <<
std::endl;
635 if( chi2PerNDF == oldChi2PerNDF) std::cout <<
"chi2/ndf didn't improve. Keep first fit." <<
std::endl;
638 std::cout <<
"- Added peaks to group #" << j <<
". This group now has " << nExponentialsForFit <<
" peaks:" <<
std::endl;
639 std::cout <<
"- Group #" << j <<
" (" << peakVals.size() <<
" peaks): GroupStartTick: " << range.offset + startT <<
" GroupEndTick: " << range.offset + endT <<
std::endl;
641 int CountPeakInGroup=0;
642 for(
auto const& peakValsTmp : peakVals )
644 std::cout <<
"Peak #" << CountPeakInGroup <<
" in group #" << j <<
": PeakInGroupStartTick: " << range.offset + std::get<2>(peakValsTmp) <<
" PeakInGroupMaxTick: " << range.offset + std::get<0>(peakValsTmp) <<
" PeakInGroupEndTick: " << range.offset + std::get<3>(peakValsTmp) << std::endl;
648 std::cout <<
"chi2/ndf = " << chi2PerNDF <<
std::endl;
652 std::cout <<
"tau1 [mus] = " << paramVec[0].first <<
std::endl;
653 std::cout <<
"tau2 [mus] = " << paramVec[1].first <<
std::endl;
655 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
657 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[2*(i+1)].first << std::endl;
658 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << range.offset + paramVec[2*(i+1)+1].first << std::endl;
663 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
665 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[4*i+2].first <<
std::endl;
666 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << range.offset + paramVec[4*i+3].first <<
std::endl;
667 std::cout <<
"Peak #" << i <<
": tau1 [mus] = " << paramVec[4*i].first <<
std::endl;
668 std::cout <<
"Peak #" << i <<
": tau2 [mus] = " << paramVec[4*i+1].first <<
std::endl;
680 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
690 peakTau1 = paramVec[0].first;
691 peakTau2 = paramVec[1].first;
692 peakAmp = paramVec[2*(i+1)].first;
693 peakMean = paramVec[2*(i+1)+1].first;
697 peakTau1 = paramVec[4*i].first;
698 peakTau2 = paramVec[4*i+1].first;
699 peakAmp = paramVec[4*i+2].first;
700 peakMean = paramVec[4*i+3].first;
704 double peakAmpTrue = signal[std::get<0>(peakVals.at(i))];
705 double peakAmpErr = 1.;
708 TF1 Exponentials(
"Exponentials",
"( [0] * exp(0.4*(x-[1])/[2]) / ( 1 + exp(0.4*(x-[1])/[3]) ) )",startT,endT);
709 Exponentials.SetParameter(0, peakAmp);
710 Exponentials.SetParameter(1, peakMean);
711 Exponentials.SetParameter(2, peakTau1);
712 Exponentials.SetParameter(3, peakTau2);
713 double peakMeanTrue = Exponentials.GetMaximumX(startT,endT);
714 Exponentials.Delete();
717 double peakWidth =
WidthFunc(peakMean, peakAmp, peakTau1, peakTau2, startT, endT, peakMeanTrue);
726 peakMeanErr = paramVec[2*(i+1)+1].
second;
730 peakMeanErr = paramVec[4*i+3].second;
732 double peakWidthErr = 0.1*peakWidth;
736 double chargeErr = std::sqrt(TMath::Pi()) * (peakAmpErr*peakWidthErr + peakWidthErr*peakAmpErr);
739 int startTthisHit = std::get<2>(peakVals.at(i));
740 int endTthisHit = std::get<3>(peakVals.at(i));
745 double sumADC = std::accumulate(sumStartItr, sumEndItr + 1, 0.);
754 std::cout <<
"WARNING: For peak #" << i <<
" in this group:" <<
std::endl;
755 if( peakWidth <= 0 || charge <= 0. || charge != charge) std::cout <<
"Fit function returned width < 0 or charge < 0 or charge = nan." <<
std::endl;
756 if( ( nExponentialsForFit == 1 && chi2PerNDF > fChi2NDFMax ) || ( nExponentialsForFit >= 2 && chi2PerNDF >
fChi2NDFMaxFactorMultiHits*fChi2NDFMax ) )
759 std::cout <<
"WARNING: For fit of this group (" << NumberOfPeaksBeforeFit <<
" peaks before refit, " << nExponentialsForFit <<
" peaks after refit): " <<
std::endl;
760 if ( nExponentialsForFit == 1 && chi2PerNDF > fChi2NDFMax ) std::cout <<
"chi2/ndf of this fit (" << chi2PerNDF <<
") is higher than threshold (" << fChi2NDFMax <<
")." <<
std::endl;
763 std::cout <<
"---> DO NOT create hit object from fit parameters but use peak values instead." <<
std::endl;
764 std::cout <<
"---> Set fit parameter so that a sharp peak with a width of 1 tick is shown in the event display. This indicates that the fit failed." <<
std::endl;
767 peakMeanErr=peakWidth/2;
769 peakMeanTrue = std::get<0>(peakVals.at(i));
772 peakMean = peakMeanTrue;
781 startTthisHit+roiFirstBinTick,
782 endTthisHit+roiFirstBinTick,
784 peakMeanTrue+roiFirstBinTick,
800 std::cout <<
"- Created hit object for peak #" << i <<
" in this group with the following parameters (obtained from fit):" <<
std::endl;
801 std::cout <<
"HitStartTick: " << startTthisHit+roiFirstBinTick <<
std::endl;
802 std::cout <<
"HitEndTick: " << endTthisHit+roiFirstBinTick <<
std::endl;
803 std::cout <<
"HitWidthTicks: " << peakWidth <<
std::endl;
804 std::cout <<
"HitMeanTick: " << peakMeanTrue+roiFirstBinTick <<
" +- " << peakMeanErr <<
std::endl;
805 std::cout <<
"HitAmplitude [ADC]: " << peakAmpTrue <<
" +- " << peakAmpErr <<
std::endl;
806 std::cout <<
"HitIntegral [ADC*ticks]: " << charge <<
" +- " << chargeErr <<
std::endl;
807 std::cout <<
"HitADCSum [ADC*ticks]: " << sumADC <<
std::endl;
808 std::cout <<
"HitMultiplicity: " << nExponentialsForFit <<
std::endl;
809 std::cout <<
"HitIndex in group: " << numHits <<
std::endl;
810 std::cout <<
"Hitchi2/ndf: " << chi2PerNDF <<
std::endl;
811 std::cout <<
"HitNDF: " << NDF <<
std::endl;
818 std::array<float, 4> fitParams;
819 fitParams[0] = peakMean+roiFirstBinTick;
820 fitParams[1] = peakTau1;
821 fitParams[2] = peakTau2;
822 fitParams[3] = peakAmp;
846 if (nHitsInThisGroup *
fLongPulseWidth < (endT - startT + 1) ) nHitsInThisGroup++;
848 int firstTick = startT;
856 std::cout <<
"WARNING: Number of peaks in this group (" << NumberOfPeaksBeforeFit <<
") is higher than threshold (" <<
fMaxMultiHit <<
")." <<
std::endl;
857 std::cout <<
"---> DO NOT fit. Split group of peaks into hits with equal length instead." <<
std::endl;
862 std::cout <<
"WARNING: group of peak is longer (" << width <<
" ticks) than threshold (" <<
fMaxGroupLength <<
" ticks)." <<
std::endl;
863 std::cout <<
"---> DO NOT fit. Split group of peaks into hits with equal length instead." <<
std::endl;
868 std::cout <<
"WARNING: fluctuations (" << NFluctuations <<
") higher than threshold (" <<
fMaxFluctuations <<
")." <<
std::endl;
869 std::cout <<
"---> DO NOT fit. Split group of peaks into hits with equal length instead." <<
std::endl;
880 std::cout <<
"---> Group goes from tick " << roiFirstBinTick+startT <<
" to " << roiFirstBinTick+endT <<
". Split group into (" << roiFirstBinTick+endT <<
" - " << roiFirstBinTick+startT <<
")/" <<
fLongPulseWidth <<
" = " << (endT - startT) <<
"/" <<
fLongPulseWidth <<
" = " << nHitsInThisGroup <<
" peaks (" <<
fLongPulseWidth <<
" = LongPulseWidth), or maximum LongMaxHits = " <<
fLongMaxHits <<
" peaks." <<
std::endl;
884 for(
int hitIdx = 0; hitIdx < nHitsInThisGroup; hitIdx++)
888 double peakMeanTrue = (firstTick + lastTick) / 2.;
889 if( NumberOfPeaksBeforeFit == 1 && nHitsInThisGroup == 1) peakMeanTrue = std::get<0>(peakVals.at(0));
890 double peakMeanErr = (lastTick - firstTick) / 2.;
891 double sumADC = std::accumulate(signal.begin() + firstTick, signal.begin() + lastTick + 1, 0.);
892 double charge = sumADC;
893 double chargeErr = 0.1*sumADC;
894 double peakAmpTrue = 0;
898 if(signal[
tick] > peakAmpTrue) peakAmpTrue = signal[
tick];
901 double peakAmpErr = 1.;
902 nExponentialsForFit = nHitsInThisGroup;
906 double peakMean = peakMeanTrue-2;
907 double peakTau1 = 0.008;
908 double peakTau2 = 0.0065;
909 double peakAmp = 20.;
913 firstTick+roiFirstBinTick,
914 lastTick+roiFirstBinTick,
916 peakMeanTrue+roiFirstBinTick,
933 std::cout <<
"- Created hit object for peak #" << hitIdx <<
" in this group with the following parameters (obtained from waveform):" <<
std::endl;
934 std::cout <<
"HitStartTick: " << firstTick+roiFirstBinTick <<
std::endl;
935 std::cout <<
"HitEndTick: " << lastTick+roiFirstBinTick <<
std::endl;
936 std::cout <<
"HitWidthTicks: " << peakWidth <<
std::endl;
937 std::cout <<
"HitMeanTick: " << peakMeanTrue+roiFirstBinTick <<
" +- " << peakMeanErr <<
std::endl;
938 std::cout <<
"HitAmplitude [ADC]: " << peakAmpTrue <<
" +- " << peakAmpErr <<
std::endl;
939 std::cout <<
"HitIntegral [ADC*ticks]: " << charge <<
" +- " << chargeErr <<
std::endl;
940 std::cout <<
"HitADCSum [ADC*ticks]: " << sumADC <<
std::endl;
941 std::cout <<
"HitMultiplicity: " << nExponentialsForFit <<
std::endl;
942 std::cout <<
"HitIndex in group: " << hitIdx <<
std::endl;
943 std::cout <<
"Hitchi2/ndf: " << chi2PerNDF <<
std::endl;
944 std::cout <<
"HitNDF: " << NDF <<
std::endl;
949 std::array<float, 4> fitParams;
950 fitParams[0] = peakMean+roiFirstBinTick;
951 fitParams[1] = peakTau1;
952 fitParams[2] = peakTau2;
953 fitParams[3] = peakAmp;
957 firstTick = lastTick+1;
962 fChi2->Fill(chi2PerNDF);
991 auto maxItr = std::max_element(startItr, stopItr);
993 float maxValue = *maxItr;
996 if (maxValue >= PeakMin)
999 auto firstItr =
std::distance(startItr,maxItr) > 2 ? maxItr - 1 : startItr;
1000 bool PeakStartIsHere =
true;
1002 while(firstItr != startItr)
1005 PeakStartIsHere =
true;
1008 if( *firstItr >= *(firstItr-i) )
1010 PeakStartIsHere =
false;
1015 if (*firstItr <= 0 || PeakStartIsHere)
break;
1025 auto lastItr =
std::distance(maxItr,stopItr) > 2 ? maxItr + 1 : stopItr - 1;
1026 bool PeakEndIsHere =
true;
1028 while(lastItr != stopItr)
1031 PeakEndIsHere =
true;
1034 if( *lastItr >= *(lastItr+i) )
1036 PeakEndIsHere =
false;
1040 if (*lastItr <= 0 || PeakEndIsHere)
break;
1047 timeValsVec.push_back(std::make_tuple(firstTick+firstTime,firstTick+maxTime,firstTick+lastTime));
1066 auto timeValsVecItr = timeValsVec.begin();
1067 unsigned int PeaksInThisMergedPeak = 0;
1069 while(timeValsVecItr != timeValsVec.end())
1074 auto& timeVal = *timeValsVecItr++;
1075 int startT = std::get<0>(timeVal);
1076 int maxT = std::get<1>(timeVal);
1077 int endT = std::get<2>(timeVal);
1078 int widT = endT - startT;
1079 int FinalStartT=startT;
1084 peakVals.emplace_back(maxT,widT,startT,endT);
1088 bool checkNextHit = timeValsVecItr != timeValsVec.end();
1094 int NextStartT = std::get<0>(*timeValsVecItr);
1096 double MinADC = signalVec[endT];
1097 for(
int i = endT; i <= NextStartT; i++)
1099 if(signalVec[i]<MinADC)
1101 MinADC = signalVec[i];
1108 int CurrentStartT=startT;
1109 int CurrentMaxT=maxT;
1110 int CurrentEndT=endT;
1113 timeVal = *timeValsVecItr++;
1114 int NextMaxT = std::get<1>(timeVal);
1115 int NextEndT = std::get<2>(timeVal);
1116 int NextWidT = NextEndT - NextStartT;
1121 int CurrentSumADC = 0;
1122 for(
int i = CurrentStartT; i<= CurrentEndT; i++)
1124 CurrentSumADC+=signalVec[i];
1128 for (
int i = NextStartT; i<= NextEndT; i++)
1130 NextSumADC+=signalVec[i];
1139 startT=CurrentStartT;
1142 peakVals.pop_back();
1143 peakVals.emplace_back(maxT,widT,startT,endT);
1148 startT=CurrentStartT;
1151 peakVals.pop_back();
1152 peakVals.emplace_back(maxT,widT,startT,endT);
1160 peakVals.emplace_back(maxT,widT,startT,endT);
1161 PeaksInThisMergedPeak++;
1170 peakVals.emplace_back(maxT,widT,startT,endT);
1171 PeaksInThisMergedPeak++;
1173 checkNextHit = timeValsVecItr != timeValsVec.end();
1177 checkNextHit =
false;
1178 PeaksInThisMergedPeak = 0;
1183 mergedVec.emplace_back(FinalStartT, FinalEndT, peakVals, NFluctuations);
1196 int NFluctuations=0;
1198 for(
int j = peakMean-1; j >= peakStart; j--)
1200 if(fsignalVec[j] < 5)
break;
1202 if(fsignalVec[j] > fsignalVec[j+1])
1208 for(
int j = peakMean+1; j <= peakEnd; j++)
1210 if(fsignalVec[j] < 5)
break;
1212 if(fsignalVec[j] > fsignalVec[j-1])
1218 return NFluctuations;
1229 double& fchi2PerNDF,
1233 int size = fEndTime - fStartTime + 1;
1234 int NPeaks = fPeakVals.size();
1239 if(fEndTime - fStartTime < 0){size = 0;}
1242 TH1F hitSignal(
"hitSignal",
"",
std::max(size,1),fStartTime,fEndTime+1);
1248 for(
int i = fStartTime; i < fEndTime+1; i++)
1250 hitSignal.Fill(i,fSignalVector[i]);
1251 hitSignal.SetBinError(i,0.288675);
1263 TF1 Exponentials(
"Exponentials",eqn.c_str(),fStartTime,fEndTime+1);
1268 std::cout <<
"--- Preparing fit ---" <<
std::endl;
1269 std::cout <<
"--- Lower limits, seed, upper limit:" <<
std::endl;
1274 Exponentials.SetParameter(0, 0.5);
1275 Exponentials.SetParameter(1, 0.5);
1281 double peakMeanShift=2;
1282 double peakMeanSeed=0;
1283 double peakMeanRangeLow=0;
1284 double peakMeanRangeHi=0;
1288 for(
int i = 0; i < NPeaks; i++)
1290 peakMean = std::get<0>(fPeakVals.at(i));
1291 peakStart = std::get<2>(fPeakVals.at(i));
1292 peakEnd = std::get<3>(fPeakVals.at(i));
1293 peakMeanSeed=peakMean-peakMeanShift;
1296 amplitude = fSignalVector[peakMean];
1298 Exponentials.SetParameter(2*(i+1), 1.65*amplitude);
1299 Exponentials.SetParLimits(2*(i+1), 0.3*1.65*amplitude, 2*1.65*amplitude);
1300 Exponentials.SetParameter(2*(i+1)+1, peakMeanSeed);
1304 Exponentials.SetParLimits(2*(i+1)+1, peakMeanRangeLow, peakMeanRangeHi);
1306 else if(NPeaks >= 2 && i == 0)
1308 double HalfDistanceToNextMean = 0.5*(std::get<0>(fPeakVals.at(i+1)) - peakMean);
1309 Exponentials.SetParLimits( 2*(i+1)+1, peakMeanRangeLow,
std::min(peakMeanRangeHi, peakMeanSeed+HalfDistanceToNextMean) );
1311 else if(NPeaks >= 2 && i == NPeaks-1)
1313 double HalfDistanceToPrevMean = 0.5*(peakMean - std::get<0>(fPeakVals.at(i-1)));
1314 Exponentials.SetParLimits(2*(i+1)+1,
std::max(peakMeanRangeLow, peakMeanSeed-HalfDistanceToPrevMean), peakMeanRangeHi );
1318 double HalfDistanceToNextMean = 0.5*(std::get<0>(fPeakVals.at(i+1)) - peakMean);
1319 double HalfDistanceToPrevMean = 0.5*(peakMean - std::get<0>(fPeakVals.at(i-1)));
1320 Exponentials.SetParLimits(2*(i+1)+1,
std::max(peakMeanRangeLow, peakMeanSeed-HalfDistanceToPrevMean),
std::min(peakMeanRangeHi, peakMeanSeed+HalfDistanceToNextMean) );
1325 double t0low, t0high;
1326 Exponentials.GetParLimits(2*(i+1)+1, t0low, t0high);
1327 std::cout <<
"Peak #" << i <<
": A [ADC] = " << 0.3*1.65*amplitude <<
" , " << 1.65*amplitude <<
" , " << 2*1.65*amplitude <<
std::endl;
1328 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << t0low <<
" , " << peakMeanSeed <<
" , " << t0high <<
std::endl;
1337 double peakMeanShift=2;
1338 double peakMeanSeed=0;
1339 double peakMeanRangeLow=0;
1340 double peakMeanRangeHi=0;
1345 for(
int i = 0; i < NPeaks; i++)
1347 Exponentials.SetParameter(4*i, 0.5);
1348 Exponentials.SetParameter(4*i+1, 0.5);
1352 peakMean = std::get<0>(fPeakVals.at(i));
1353 peakStart = std::get<2>(fPeakVals.at(i));
1354 peakEnd = std::get<3>(fPeakVals.at(i));
1355 peakMeanSeed=peakMean-peakMeanShift;
1358 amplitude = fSignalVector[peakMean];
1360 Exponentials.SetParameter(4*i+2, 1.65*amplitude);
1361 Exponentials.SetParLimits(4*i+2, 0.3*1.65*amplitude, 2*1.65*amplitude);
1362 Exponentials.SetParameter(4*i+3, peakMeanSeed);
1366 Exponentials.SetParLimits(4*i+3, peakMeanRangeLow, peakMeanRangeHi);
1368 else if(NPeaks >= 2 && i == 0)
1370 double HalfDistanceToNextMean = 0.5*(std::get<0>(fPeakVals.at(i+1)) - peakMean);
1371 Exponentials.SetParLimits( 4*i+3, peakMeanRangeLow,
std::min(peakMeanRangeHi, peakMeanSeed+HalfDistanceToNextMean) );
1373 else if(NPeaks >= 2 && i == NPeaks-1)
1375 double HalfDistanceToPrevMean = 0.5*(peakMean - std::get<0>(fPeakVals.at(i-1)));
1376 Exponentials.SetParLimits(4*i+3,
std::max(peakMeanRangeLow, peakMeanSeed-HalfDistanceToPrevMean), peakMeanRangeHi );
1380 double HalfDistanceToNextMean = 0.5*(std::get<0>(fPeakVals.at(i+1)) - peakMean);
1381 double HalfDistanceToPrevMean = 0.5*(peakMean - std::get<0>(fPeakVals.at(i-1)));
1382 Exponentials.SetParLimits(4*i+3,
std::max(peakMeanRangeLow, peakMeanSeed-HalfDistanceToPrevMean),
std::min(peakMeanRangeHi, peakMeanSeed+HalfDistanceToNextMean) );
1387 double t0low, t0high;
1388 Exponentials.GetParLimits(4*i+3, t0low, t0high);
1389 std::cout <<
"Peak #" << i <<
": A [ADC] = " << 0.3*1.65*amplitude <<
" , " << 1.65*amplitude <<
" , " << 2*1.65*amplitude <<
std::endl;
1390 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << t0low <<
" , " << peakMeanSeed <<
" , " << t0high <<
std::endl;
1400 { hitSignal.Fit(&Exponentials,
"QNRWM",
"", fStartTime, fEndTime+1);}
1402 {
mf::LogWarning(
"DPRawHitFinder") <<
"Fitter failed finding a hit";}
1407 fchi2PerNDF = (Exponentials.GetChisquare() / Exponentials.GetNDF());
1408 fNDF = Exponentials.GetNDF();
1412 fparamVec.emplace_back(Exponentials.GetParameter(0),Exponentials.GetParError(0));
1413 fparamVec.emplace_back(Exponentials.GetParameter(1),Exponentials.GetParError(1));
1415 for(
int i = 0; i < NPeaks; i++)
1417 fparamVec.emplace_back(Exponentials.GetParameter(2*(i+1)),Exponentials.GetParError(2*(i+1)));
1418 fparamVec.emplace_back(Exponentials.GetParameter(2*(i+1)+1),Exponentials.GetParError(2*(i+1)+1));
1423 for(
int i = 0; i < NPeaks; i++)
1425 fparamVec.emplace_back(Exponentials.GetParameter(4*i),Exponentials.GetParError(4*i));
1426 fparamVec.emplace_back(Exponentials.GetParameter(4*i+1),Exponentials.GetParError(4*i+1));
1427 fparamVec.emplace_back(Exponentials.GetParameter(4*i+2),Exponentials.GetParError(4*i+2));
1428 fparamVec.emplace_back(Exponentials.GetParameter(4*i+3),Exponentials.GetParError(4*i+3));
1431 Exponentials.Delete();
1451 TF1 Exponentials(
"Exponentials",eqn.c_str(),fStartTime,fEndTime+1);
1453 for(
size_t i=0; i < fparamVec.size(); i++)
1455 Exponentials.SetParameter(i, fparamVec[i].first);
1461 double Chi2PerNDFPeak;
1462 double MaxPosDeviation;
1463 double MaxNegDeviation;
1464 int BinMaxPosDeviation;
1465 int BinMaxNegDeviation;
1466 for(
int i = 0; i < fNPeaks; i++)
1468 Chi2PerNDFPeak = 0.;
1471 BinMaxPosDeviation=0;
1472 BinMaxNegDeviation=0;
1474 for(
int j = std::get<2>(fpeakVals.at(i)); j < std::get<3>(fpeakVals.at(i))+1; j++)
1476 if( (Exponentials(j+0.5)-fSignalVector[j]) > MaxPosDeviation && j != std::get<0>(fpeakVals.at(i)) )
1478 MaxPosDeviation = Exponentials(j+0.5)-fSignalVector[j];
1479 BinMaxPosDeviation = j;
1481 if( (Exponentials(j+0.5)-fSignalVector[j]) < MaxNegDeviation && j != std::get<0>(fpeakVals.at(i)) )
1483 MaxNegDeviation = Exponentials(j+0.5)-fSignalVector[j];
1484 BinMaxNegDeviation = j;
1486 Chi2PerNDFPeak +=
pow((Exponentials(j+0.5)-fSignalVector[j])/sqrt(fSignalVector[j]),2);
1489 if(BinMaxNegDeviation != 0)
1491 Chi2PerNDFPeak /=
static_cast<double>((std::get<3>(fpeakVals.at(i))-std::get<2>(fpeakVals.at(i))));
1492 fPeakDev.emplace_back(Chi2PerNDFPeak,i,BinMaxNegDeviation,BinMaxPosDeviation);
1496 std::sort(fPeakDev.begin(),fPeakDev.end(), [](std::tuple<double,int,int,int>
const &
t1, std::tuple<double,int,int,int>
const &t2) {
return std::get<0>(
t1) > std::get<0>(t2);} );
1497 Exponentials.Delete();
1504 std::stringstream numConv;
1508 for(
int i = 0; i < fNPeaks; i++)
1510 feqn.append(
"+( [");
1513 feqn.append(numConv.str());
1514 feqn.append(
"] * exp(0.4*(x-[");
1516 numConv << 2*(i+1)+1;
1517 feqn.append(numConv.str());
1518 feqn.append(
"])/[");
1521 feqn.append(numConv.str());
1522 feqn.append(
"]) / ( 1 + exp(0.4*(x-[");
1524 numConv << 2*(i+1)+1;
1525 feqn.append(numConv.str());
1526 feqn.append(
"])/[");
1529 feqn.append(numConv.str());
1530 feqn.append(
"]) ) )");
1535 for(
int i = 0; i < fNPeaks; i++)
1537 feqn.append(
"+( [");
1540 feqn.append(numConv.str());
1541 feqn.append(
"] * exp(0.4*(x-[");
1544 feqn.append(numConv.str());
1545 feqn.append(
"])/[");
1548 feqn.append(numConv.str());
1549 feqn.append(
"]) / ( 1 + exp(0.4*(x-[");
1551 numConv << 2*(i+1)+1;
1552 feqn.append(numConv.str());
1553 feqn.append(
"])/[");
1556 feqn.append(numConv.str());
1557 feqn.append(
"]) ) )");
1568 int PeakNumberWithNewPeak = std::get<1>(fPeakDevCand);
1569 int NewPeakMax = std::get<2>(fPeakDevCand);
1570 int OldPeakMax = std::get<0>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1571 int OldPeakOldStart = std::get<2>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1572 int OldPeakOldEnd = std::get<3>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1576 int OldPeakNewStart=0;
1577 int OldPeakNewEnd=0;
1578 int DistanceBwOldAndNewPeak=0;
1580 if(NewPeakMax<OldPeakMax)
1582 NewPeakStart = OldPeakOldStart;
1583 OldPeakNewEnd = OldPeakOldEnd;
1584 DistanceBwOldAndNewPeak = OldPeakMax - NewPeakMax;
1585 NewPeakEnd = NewPeakMax+0.5*(DistanceBwOldAndNewPeak-(DistanceBwOldAndNewPeak%2));
1586 if(DistanceBwOldAndNewPeak%2 == 0) NewPeakEnd -= 1;
1587 OldPeakNewStart = NewPeakEnd+1;
1589 else if(OldPeakMax<NewPeakMax)
1591 NewPeakEnd = OldPeakOldEnd;
1592 OldPeakNewStart = OldPeakOldStart;
1593 DistanceBwOldAndNewPeak = NewPeakMax - OldPeakMax;
1594 OldPeakNewEnd = OldPeakMax+0.5*(DistanceBwOldAndNewPeak-(DistanceBwOldAndNewPeak%2));
1595 if(DistanceBwOldAndNewPeak%2 == 0) OldPeakNewEnd -= 1;
1596 NewPeakStart = OldPeakNewEnd+1;
1598 else if(OldPeakMax==NewPeakMax){
return;}
1600 fpeakValsTemp.at(PeakNumberWithNewPeak) = std::make_tuple(OldPeakMax,0,OldPeakNewStart,OldPeakNewEnd);
1601 fpeakValsTemp.emplace_back(NewPeakMax,0,NewPeakStart,NewPeakEnd);
1602 std::sort(fpeakValsTemp.begin(),fpeakValsTemp.end(), [](std::tuple<int,int,int,int>
const &
t1, std::tuple<int,int,int,int>
const &t2) {
return std::get<0>(
t1) < std::get<0>(t2);} );
1612 int PeakNumberWithNewPeak = std::get<1>(fPeakDevCand);
1613 int OldPeakOldStart = std::get<2>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1614 int OldPeakOldEnd = std::get<3>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1615 int WidthOldPeakOld = OldPeakOldEnd - OldPeakOldStart;
1617 if(WidthOldPeakOld<3) {
return;}
1620 int NewPeakStart = 0;
1622 int OldPeakNewMax = 0;
1623 int OldPeakNewStart = 0;
1624 int OldPeakNewEnd = 0;
1627 OldPeakNewStart = OldPeakOldStart;
1628 NewPeakEnd = OldPeakOldEnd;
1630 OldPeakNewEnd = OldPeakNewStart + 0.5*(WidthOldPeakOld + (WidthOldPeakOld%2));
1631 NewPeakStart = OldPeakNewEnd+1;
1633 int WidthOldPeakNew = OldPeakNewEnd-OldPeakNewStart;
1634 int WidthNewPeak = NewPeakEnd-NewPeakStart;
1636 OldPeakNewMax = OldPeakNewStart + 0.5*(WidthOldPeakNew - (WidthOldPeakNew%2));
1637 NewPeakMax = NewPeakStart + 0.5*(WidthNewPeak - (WidthNewPeak%2));
1639 fpeakValsTemp.at(PeakNumberWithNewPeak) = std::make_tuple(OldPeakNewMax,0,OldPeakNewStart,OldPeakNewEnd);
1640 fpeakValsTemp.emplace_back(NewPeakMax,0,NewPeakStart,NewPeakEnd);
1641 std::sort(fpeakValsTemp.begin(),fpeakValsTemp.end(), [](std::tuple<int,int,int,int>
const &
t1, std::tuple<int,int,int,int>
const &t2) {
return std::get<0>(
t1) < std::get<0>(t2);} );
1653 double fPeakMeanTrue)
1655 double MaxValue = ( fPeakAmp * exp(0.4*(fPeakMeanTrue-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(fPeakMeanTrue-fPeakMean)/fPeakTau2) );
1656 double FuncValue = 0.;
1657 double HalfMaxLeftTime = 0.;
1658 double HalfMaxRightTime = 0.;
1662 for(
double x = fPeakMeanTrue;
x > fStartTime-1000.;
x--)
1664 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1665 if( FuncValue < 0.5*MaxValue )
1667 HalfMaxLeftTime =
x;
1672 for(
double x = fPeakMeanTrue;
x < fEndTime+1000.;
x++)
1674 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1675 if( FuncValue < 0.5*MaxValue )
1677 HalfMaxRightTime =
x;
1683 for(
double x = HalfMaxLeftTime+1;
x > HalfMaxLeftTime;
x-=(1/ReBin))
1685 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1686 if( FuncValue < 0.5*MaxValue )
1688 HalfMaxLeftTime =
x;
1693 for(
double x = HalfMaxRightTime-1;
x < HalfMaxRightTime;
x+=(1/ReBin))
1695 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1696 if( FuncValue < 0.5*MaxValue )
1698 HalfMaxRightTime =
x;
1704 for(
double x = HalfMaxLeftTime+1/ReBin;
x > HalfMaxLeftTime;
x-=1/(ReBin*ReBin))
1706 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1707 if( FuncValue < 0.5*MaxValue )
1709 HalfMaxLeftTime =
x;
1714 for(
double x = HalfMaxRightTime-1/ReBin;
x < HalfMaxRightTime;
x+=1/(ReBin*ReBin))
1716 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1717 if( FuncValue < 0.5*MaxValue )
1719 HalfMaxRightTime =
x;
1724 return HalfMaxRightTime-HalfMaxLeftTime;
1732 double fChargeNormFactor,
1733 double fPeakMeanTrue)
1736 double ChargeSum = 0.;
1740 bool ChargeBigEnough=
true;
1741 for(
double x = fPeakMeanTrue - 1/ReBin; ChargeBigEnough &&
x > fPeakMeanTrue-1000.;
x-=1.)
1743 for(
double i=0.; i > -1.; i-=(1/ReBin))
1745 Charge = ( fPeakAmp * exp(0.4*(
x+i-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x+i-fPeakMean)/fPeakTau2) );
1746 ChargeSum += Charge;
1748 if(Charge < 0.01) ChargeBigEnough =
false;
1751 ChargeBigEnough=
true;
1752 for(
double x = fPeakMeanTrue; ChargeBigEnough &&
x < fPeakMeanTrue+1000.;
x+=1.)
1754 for(
double i=0.; i < 1.; i+=(1/ReBin))
1756 Charge = ( fPeakAmp * exp(0.4*(
x+i-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x+i-fPeakMean)/fPeakTau2) );
1757 ChargeSum += Charge;
1759 if(Charge < 0.01) ChargeBigEnough =
false;
1763 return ChargeSum*fChargeNormFactor/ReBin;
1768 std::vector<float>& outputVec,
1769 size_t binsToAverage)
const 1771 size_t halfBinsToAverage(binsToAverage/2);
1773 float runningSum(0.);
1775 for(
size_t idx = 0; idx < halfBinsToAverage; idx++) runningSum += inputVec[idx];
1777 outputVec.resize(inputVec.size());
1783 size_t startOffset =
std::distance(inputVec.begin(),inputItr);
1785 size_t count =
std::min(2 * halfBinsToAverage,
std::min(startOffset + halfBinsToAverage + 1, halfBinsToAverage + stopOffset - 1));
1787 if (startOffset >= halfBinsToAverage) runningSum -= *(inputItr - halfBinsToAverage);
1788 if (stopOffset > halfBinsToAverage) runningSum += *(inputItr + halfBinsToAverage);
1790 *outputVecItr++ = runningSum /
float(count);
1798 std::vector<float>& outputVec,
1799 size_t nBinsToCombine)
const 1801 size_t nNewBins = inputVec.size() / nBinsToCombine;
1803 if (inputVec.size() % nBinsToCombine > 0) nNewBins++;
1805 outputVec.resize(nNewBins, 0.);
1807 size_t outputBin = 0;
1809 for(
size_t inputIdx = 0; inputIdx < inputVec.size();)
1811 outputVec[outputBin] += inputVec[inputIdx++];
1813 if (inputIdx % nBinsToCombine == 0) outputBin++;
1815 if (outputBin > outputVec.size())
1817 std::cout <<
"***** DISASTER!!! ****** outputBin: " << outputBin <<
", inputIdx = " << inputIdx <<
std::endl;
void findCandidatePeaks(std::vector< float >::const_iterator startItr, std::vector< float >::const_iterator stopItr, TimeValsVec &timeValsVec, float &PeakMin, int firstTick) const
int fTicksToStopPeakFinder
double fMergeADCSumThreshold
void mergeCandidatePeaks(const std::vector< float > signalVec, TimeValsVec, MergedTimeWidVec &)
bool operator()(std::tuple< int, int, int, int > p, int s) const
EDProducer(fhicl::ParameterSet const &pset)
std::vector< std::tuple< int, int, PeakTimeWidVec, int >> MergedTimeWidVec
void produce(art::Event &evt) override
std::vector< raw::RawDigit > RawDigits
void FindPeakWithMaxDeviation(const std::vector< float > fSignalVector, int fNPeaks, int fStartTime, int fEndTime, bool fSameShape, ParameterVec fparamVec, PeakTimeWidVec fpeakVals, PeakDevVec &fPeakDev)
std::vector< std::tuple< double, int, int, int >> PeakDevVec
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
CryostatID_t Cryostat
Index of cryostat.
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
WireID_t Wire
Index of the wire within its plane.
void SplitPeak(std::tuple< double, int, int, int > fPeakDevCand, PeakTimeWidVec &fpeakValsTemp)
double fChi2NDFMaxFactorMultiHits
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
art framework interface to geometry description
DPRawHitFinder(fhicl::ParameterSet const &pset)
void addVector(FVector_ID id, std::array< float, N > const &values)
int TDCtick_t
Type representing a TDC tick.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::vector< std::tuple< int, int, int, int >> PeakTimeWidVec
Class managing the creation of a new recob::Hit object.
void FillOutHitParameterVector(const std::vector< double > &input, std::vector< double > &output)
Helper functions to create a hit.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
FVector_ID initOutputs(std::string const &dataTag, size_t dataSize, std::vector< std::string > const &names=std::vector< std::string >(N,""))
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
void AddPeak(std::tuple< double, int, int, int > fPeakDevCand, PeakTimeWidVec &fpeakValsTemp)
double fChi2NDFRetryFactorMultiHits
A class handling a collection of hits and its associations.
#define DEFINE_ART_MODULE(klass)
std::vector< std::pair< double, double >> ParameterVec
double fMergeMaxADCThreshold
double fWidthNormalization
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
anab::FVectorWriter< 4 > fHitParamWriter
std::string CreateFitFunction(int fNPeaks, bool fSameShape)
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
double ChargeFunc(double fPeakMean, double fPeakAmp, double fPeakTau1, double fPeakTau2, double fChargeNormFactor, double fPeakMeanTrue)
void emplace_back(recob::Hit &&hit, art::Ptr< recob::Wire > const &wire=art::Ptr< recob::Wire >(), art::Ptr< raw::RawDigit > const &digits=art::Ptr< raw::RawDigit >())
Adds the specified hit to the data collection.
double fMinADCSumOverWidth
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
double fMinRelativePeakHeightLeft
static int max(int a, int b)
PlaneID_t Plane
Index of the plane within its TPC.
void put_into(art::Event &)
Moves the data into an event.
void saveOutputs(art::Event &evt)
Check consistency and save all the results in the event.
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
void FitExponentials(const std::vector< float > fSignalVector, const PeakTimeWidVec fPeakVals, int fStartTime, int fEndTime, ParameterVec &fparamVec, double &fchi2PerNDF, int &fNDF, bool fSameShape)
std::string fCalDataModuleLabel
Declaration of signal hit object.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
std::vector< std::tuple< int, int, int >> TimeValsVec
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Declaration of basic channel signal object.
int EstimateFluctuations(const std::vector< float > fsignalVec, int peakStart, int peakMean, int peakEnd)
void doBinAverage(const std::vector< float > &inputVec, std::vector< float > &outputVec, size_t binsToAverage) const
2D representation of charge deposited in the TDC/wire plane
unsigned int ChannelID_t
Type representing the ID of a readout channel.
TPCID_t TPC
Index of the TPC within its cryostat.
second_as<> second
Type of time stored in seconds, in double precision.
recob::Hit && move()
Prepares the constructed hit to be moved away.
art::InputTag fNewHitsTag
double WidthFunc(double fPeakMean, double fPeakAmp, double fPeakTau1, double fPeakTau2, double fStartTime, double fEndTime, double fPeakMeanTrue)
void reBin(const std::vector< float > &inputVec, std::vector< float > &outputVec, size_t nBinsToCombine) const
double fMinRelativePeakHeightRight
QTextStream & endl(QTextStream &s)
bool operator()(int s, std::tuple< int, int, int, int > p) const