48 #include "art_root_io/TFileService.h" 79 std::tuple<int, int, int, int>>;
85 using PeakDevVec = std::vector<std::tuple<double, int, int, int>>;
105 const PeakTimeWidVec fPeakVals,
119 PeakTimeWidVec fpeakVals,
124 void AddPeak(std::tuple<double, int, int, int> fPeakDevCand, PeakTimeWidVec& fpeakValsTemp);
126 void SplitPeak(std::tuple<double, int, int, int> fPeakDevCand, PeakTimeWidVec& fpeakValsTemp);
134 double fPeakMeanTrue);
140 double fChargeNormFactor,
141 double fPeakMeanTrue);
146 std::vector<float>& outputVec,
147 size_t binsToAverage)
const;
149 void reBin(
const std::vector<float>& inputVec,
150 std::vector<float>& outputVec,
151 size_t nBinsToCombine)
const;
157 bool operator()(std::tuple<int, int, int, int> p,
int s)
const {
return std::get<0>(p) < s; }
158 bool operator()(
int s, std::tuple<int, int, int, int> p)
const {
return s < std::get<0>(p); }
209 ,
fNewHitsTag(pset.get<std::string>(
"module_label"),
224 fMinSig = pset.get<
float>(
"MinSig");
230 fMinTau = pset.get<
double>(
"MinTau");
231 fMaxTau = pset.get<
double>(
"MaxTau");
261 std::vector<double>& output)
263 if (input.size() == 0)
264 throw std::runtime_error(
265 "DPRawHitFinder::FillOutHitParameterVector ERROR! Input config vector has zero size.");
268 const unsigned int N_PLANES = geom->
Nplanes();
270 if (input.size() == 1)
271 output.resize(N_PLANES, input[0]);
272 else if (input.size() == N_PLANES)
275 throw std::runtime_error(
"DPRawHitFinder::FillOutHitParameterVector ERROR! Input config " 276 "vector size !=1 and !=N_PLANES.");
288 fFirstChi2 = tfs->make<TH1F>(
"fFirstChi2",
"#chi^{2}", 10000, 0, 5000);
289 fChi2 = tfs->make<TH1F>(
"fChi2",
"#chi^{2}", 10000, 0, 5000);
296 TH1::AddDirectory(kFALSE);
334 for (
size_t wireIter = 0; wireIter < wireVecHandle->size(); wireIter++) {
343 std::vector<geo::WireID> wids = geom->
ChannelToWire(channel);
348 std::cout << std::endl;
349 std::cout << std::endl;
350 std::cout << std::endl;
351 std::cout <<
"-----------------------------------------------------------------------------" 352 "------------------------------" 354 std::cout <<
"Channel: " << channel << std::endl;
355 std::cout <<
"Cryostat: " << wid.
Cryostat << std::endl;
356 std::cout <<
"TPC: " << wid.
TPC << std::endl;
357 std::cout <<
"Plane: " << wid.
Plane << std::endl;
358 std::cout <<
"Wire: " << wid.
Wire << std::endl;
368 for (
const auto& range : signalROI.
get_ranges()) {
372 const std::vector<float>& signal = range.data();
383 std::vector<float> timeAve;
395 if (timeValsVec.empty())
continue;
414 std::cout << std::endl;
415 std::cout << std::endl;
416 std::cout <<
"-------------------- ROI #" << CountROI <<
" -------------------- " 418 if (timeValsVec.size() == 1)
419 std::cout <<
"ROI #" << CountROI <<
" (" << timeValsVec.size()
420 <<
" peak): ROIStartTick: " << range.offset
421 <<
" ROIEndTick:" << range.offset + range.size() << std::endl;
423 std::cout <<
"ROI #" << CountROI <<
" (" << timeValsVec.size()
424 <<
" peaks): ROIStartTick: " << range.offset
425 <<
" ROIEndTick:" << range.offset + range.size() << std::endl;
431 for (
auto const& timeValsTmp : timeValsVec) {
432 std::cout <<
"Peak #" << CountPeak
433 <<
": PeakStartTick: " << range.offset + std::get<0>(timeValsTmp)
434 <<
" PeakMaxTick: " << range.offset + std::get<1>(timeValsTmp)
435 <<
" PeakEndTick: " << range.offset + std::get<2>(timeValsTmp)
443 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++) {
469 int startT = std::get<0>(mergedVec.at(j));
470 int endT = std::get<1>(mergedVec.at(j));
471 int width = endT + 1 - startT;
474 int NFluctuations = std::get<3>(mergedVec.at(j));
477 std::cout << std::endl;
478 if (peakVals.size() == 1)
479 std::cout <<
"- Group #" << j <<
" (" << peakVals.size()
480 <<
" peak): GroupStartTick: " << range.offset + startT
481 <<
" GroupEndTick: " << range.offset + endT << std::endl;
483 std::cout <<
"- Group #" << j <<
" (" << peakVals.size()
484 <<
" peaks): GroupStartTick: " << range.offset + startT
485 <<
" GroupEndTick: " << range.offset + endT << std::endl;
486 std::cout <<
"Fluctuations in this group: " << NFluctuations << std::endl;
487 int CountPeakInGroup = 0;
488 for (
auto const& peakValsTmp : peakVals) {
489 std::cout <<
"Peak #" << CountPeakInGroup <<
" in group #" << j
490 <<
": PeakInGroupStartTick: " << range.offset + std::get<2>(peakValsTmp)
491 <<
" PeakInGroupMaxTick: " << range.offset + std::get<0>(peakValsTmp)
492 <<
" PeakInGroupEndTick: " << range.offset + std::get<3>(peakValsTmp)
500 (
double)std::accumulate(signal.begin() + startT, signal.begin() + endT + 1, 0) <
502 (
double)std::accumulate(signal.begin() + startT, signal.begin() + endT + 1, 0) /
506 std::cout <<
"Delete this group of peaks because width, integral or width/intergral " 516 NumberOfPeaksBeforeFit = peakVals.size();
517 nExponentialsForFit = peakVals.size();
529 std::cout << std::endl;
530 std::cout <<
"--- First fit ---" << std::endl;
531 if (nExponentialsForFit == 1)
532 std::cout <<
"- Fitted " << nExponentialsForFit <<
" peak in group #" << j <<
":" 535 std::cout <<
"- Fitted " << nExponentialsForFit <<
" peaks in group #" << j <<
":" 537 std::cout <<
"chi2/ndf = " << chi2PerNDF << std::endl;
540 std::cout <<
"tau1 [mus] = " << paramVec[0].first << std::endl;
541 std::cout <<
"tau2 [mus] = " << paramVec[1].first << std::endl;
543 for (
unsigned int i = 0; i < nExponentialsForFit; i++) {
544 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[2 * (i + 1)].first
546 std::cout <<
"Peak #" << i
547 <<
": t0 [ticks] = " << range.offset + paramVec[2 * (i + 1) + 1].first
552 for (
unsigned int i = 0; i < nExponentialsForFit; i++) {
553 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[4 * i + 2].first
555 std::cout <<
"Peak #" << i
556 <<
": t0 [ticks] = " << range.offset + paramVec[4 * i + 3].first
558 std::cout <<
"Peak #" << i <<
": tau1 [mus] = " << paramVec[4 * i].first
560 std::cout <<
"Peak #" << i <<
": tau2 [mus] = " << paramVec[4 * i + 1].first
567 if (!(chi2PerNDF < std::numeric_limits<double>::infinity()))
continue;
578 unsigned int nExponentialsBeforeRefit = nExponentialsForFit;
579 unsigned int nExponentialsAfterRefit = nExponentialsForFit;
580 double oldChi2PerNDF = chi2PerNDF;
585 while ((nExponentialsForFit == 1 &&
586 nExponentialsAfterRefit < 3 * nExponentialsBeforeRefit &&
587 chi2PerNDF > fChi2NDFRetry) ||
588 (nExponentialsForFit > 1 &&
589 nExponentialsAfterRefit < 3 * nExponentialsBeforeRefit &&
591 RefitSuccess =
false;
603 for (
auto& PeakDevCand : PeakDev) {
607 peakValsTemp = peakVals;
609 AddPeak(PeakDevCand, peakValsTemp);
619 if (chi2PerNDF2 < chi2PerNDF) {
620 paramVec = paramVecRefit;
621 peakVals = peakValsTemp;
622 nExponentialsForFit = peakVals.size();
623 chi2PerNDF = chi2PerNDF2;
625 nExponentialsAfterRefit++;
632 if (RefitSuccess ==
false) {
633 for (
auto& PeakDevCand : PeakDev) {
637 peakValsTemp = peakVals;
649 if (chi2PerNDF2 < chi2PerNDF) {
650 paramVec = paramVecRefit;
651 peakVals = peakValsTemp;
652 nExponentialsForFit = peakVals.size();
653 chi2PerNDF = chi2PerNDF2;
655 nExponentialsAfterRefit++;
662 if (RefitSuccess ==
false) {
break; }
666 std::cout << std::endl;
667 std::cout <<
"--- Refit ---" << std::endl;
668 if (chi2PerNDF == oldChi2PerNDF)
669 std::cout <<
"chi2/ndf didn't improve. Keep first fit." << std::endl;
671 std::cout <<
"- Added peaks to group #" << j <<
". This group now has " 672 << nExponentialsForFit <<
" peaks:" << std::endl;
673 std::cout <<
"- Group #" << j <<
" (" << peakVals.size()
674 <<
" peaks): GroupStartTick: " << range.offset + startT
675 <<
" GroupEndTick: " << range.offset + endT << std::endl;
677 int CountPeakInGroup = 0;
678 for (
auto const& peakValsTmp : peakVals) {
679 std::cout <<
"Peak #" << CountPeakInGroup <<
" in group #" << j
680 <<
": PeakInGroupStartTick: " 681 << range.offset + std::get<2>(peakValsTmp)
682 <<
" PeakInGroupMaxTick: " 683 << range.offset + std::get<0>(peakValsTmp)
684 <<
" PeakInGroupEndTick: " 685 << range.offset + std::get<3>(peakValsTmp) << std::endl;
689 std::cout <<
"chi2/ndf = " << chi2PerNDF << std::endl;
692 std::cout <<
"tau1 [mus] = " << paramVec[0].first << std::endl;
693 std::cout <<
"tau2 [mus] = " << paramVec[1].first << std::endl;
695 for (
unsigned int i = 0; i < nExponentialsForFit; i++) {
696 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[2 * (i + 1)].first
698 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " 699 << range.offset + paramVec[2 * (i + 1) + 1].first << std::endl;
703 for (
unsigned int i = 0; i < nExponentialsForFit; i++) {
704 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[4 * i + 2].first
706 std::cout <<
"Peak #" << i
707 <<
": t0 [ticks] = " << range.offset + paramVec[4 * i + 3].first
709 std::cout <<
"Peak #" << i <<
": tau1 [mus] = " << paramVec[4 * i].first
711 std::cout <<
"Peak #" << i <<
": tau2 [mus] = " << paramVec[4 * i + 1].first
724 for (
unsigned int i = 0; i < nExponentialsForFit; i++) {
732 peakTau1 = paramVec[0].first;
733 peakTau2 = paramVec[1].first;
734 peakAmp = paramVec[2 * (i + 1)].first;
735 peakMean = paramVec[2 * (i + 1) + 1].first;
738 peakTau1 = paramVec[4 * i].first;
739 peakTau2 = paramVec[4 * i + 1].first;
740 peakAmp = paramVec[4 * i + 2].first;
741 peakMean = paramVec[4 * i + 3].first;
745 double peakAmpTrue = signal[std::get<0>(peakVals.at(i))];
746 double peakAmpErr = 1.;
749 TF1 Exponentials(
"Exponentials",
750 "( [0] * exp(0.4*(x-[1])/[2]) / ( 1 + exp(0.4*(x-[1])/[3]) ) )",
753 Exponentials.SetParameter(0, peakAmp);
754 Exponentials.SetParameter(1, peakMean);
755 Exponentials.SetParameter(2, peakTau1);
756 Exponentials.SetParameter(3, peakTau2);
757 double peakMeanTrue = Exponentials.GetMaximumX(startT, endT);
758 Exponentials.Delete();
762 WidthFunc(peakMean, peakAmp, peakTau1, peakTau2, startT, endT, peakMeanTrue);
771 peakMeanErr = paramVec[4 * i + 3].second;
773 double peakWidthErr = 0.1 * peakWidth;
779 std::sqrt(TMath::Pi()) * (peakAmpErr * peakWidthErr + peakWidthErr * peakAmpErr);
782 int startTthisHit = std::get<2>(peakVals.at(i));
783 int endTthisHit = std::get<3>(peakVals.at(i));
788 double sumADC = std::accumulate(sumStartItr, sumEndItr + 1, 0.);
791 if (peakWidth <= 0 || charge <= 0. || charge != charge ||
792 (nExponentialsForFit == 1 && chi2PerNDF >
fChi2NDFMax) ||
793 (nExponentialsForFit >= 2 &&
796 std::cout << std::endl;
797 std::cout <<
"WARNING: For peak #" << i <<
" in this group:" << std::endl;
798 if (peakWidth <= 0 || charge <= 0. || charge != charge)
799 std::cout <<
"Fit function returned width < 0 or charge < 0 or charge = nan." 801 if ((nExponentialsForFit == 1 && chi2PerNDF > fChi2NDFMax) ||
802 (nExponentialsForFit >= 2 &&
804 std::cout << std::endl;
805 std::cout <<
"WARNING: For fit of this group (" << NumberOfPeaksBeforeFit
806 <<
" peaks before refit, " << nExponentialsForFit
807 <<
" peaks after refit): " << std::endl;
808 if (nExponentialsForFit == 1 && chi2PerNDF > fChi2NDFMax)
809 std::cout <<
"chi2/ndf of this fit (" << chi2PerNDF
810 <<
") is higher than threshold (" << fChi2NDFMax <<
")." 812 if (nExponentialsForFit >= 2 &&
814 std::cout <<
"chi2/ndf of this fit (" << chi2PerNDF
815 <<
") is higher than threshold (" 818 std::cout <<
"---> DO NOT create hit object from fit parameters but use peak " 821 std::cout <<
"---> Set fit parameter so that a sharp peak with a width of 1 tick " 822 "is shown in the event display. This indicates that the fit failed." 826 (((double)endTthisHit - (
double)startTthisHit) / 4.) /
828 peakMeanErr = peakWidth / 2;
830 peakMeanTrue = std::get<0>(peakVals.at(i));
833 peakMean = peakMeanTrue;
843 startTthisHit + roiFirstBinTick,
844 endTthisHit + roiFirstBinTick,
846 peakMeanTrue + roiFirstBinTick,
860 std::cout << std::endl;
861 std::cout <<
"- Created hit object for peak #" << i
862 <<
" in this group with the following parameters (obtained from fit):" 864 std::cout <<
"HitStartTick: " << startTthisHit + roiFirstBinTick << std::endl;
865 std::cout <<
"HitEndTick: " << endTthisHit + roiFirstBinTick << std::endl;
866 std::cout <<
"HitWidthTicks: " << peakWidth << std::endl;
867 std::cout <<
"HitMeanTick: " << peakMeanTrue + roiFirstBinTick <<
" +- " 868 << peakMeanErr << std::endl;
869 std::cout <<
"HitAmplitude [ADC]: " << peakAmpTrue <<
" +- " << peakAmpErr
871 std::cout <<
"HitIntegral [ADC*ticks]: " << charge <<
" +- " << chargeErr
873 std::cout <<
"HitADCSum [ADC*ticks]: " << sumADC << std::endl;
874 std::cout <<
"HitMultiplicity: " << nExponentialsForFit << std::endl;
875 std::cout <<
"HitIndex in group: " << numHits << std::endl;
876 std::cout <<
"Hitchi2/ndf: " << chi2PerNDF << std::endl;
877 std::cout <<
"HitNDF: " << NDF << std::endl;
884 std::array<float, 4> fitParams;
885 fitParams[0] = peakMean + roiFirstBinTick;
886 fitParams[1] = peakTau1;
887 fitParams[2] = peakTau2;
888 fitParams[3] = peakAmp;
911 if (nHitsInThisGroup *
fLongPulseWidth < (endT - startT + 1)) nHitsInThisGroup++;
913 int firstTick = startT;
918 std::cout << std::endl;
919 std::cout <<
"WARNING: Number of peaks in this group (" << NumberOfPeaksBeforeFit
920 <<
") is higher than threshold (" <<
fMaxMultiHit <<
")." << std::endl;
922 <<
"---> DO NOT fit. Split group of peaks into hits with equal length instead." 926 std::cout << std::endl;
927 std::cout <<
"WARNING: group of peak is longer (" << width
931 <<
"---> DO NOT fit. Split group of peaks into hits with equal length instead." 935 std::cout << std::endl;
936 std::cout <<
"WARNING: fluctuations (" << NFluctuations
939 <<
"---> DO NOT fit. Split group of peaks into hits with equal length instead." 951 std::cout <<
"---> Group goes from tick " << roiFirstBinTick + startT <<
" to " 952 << roiFirstBinTick + endT <<
". Split group into (" 953 << roiFirstBinTick + endT <<
" - " << roiFirstBinTick + startT <<
")/" 956 <<
" = LongPulseWidth), or maximum LongMaxHits = " <<
fLongMaxHits 957 <<
" peaks." << std::endl;
960 for (
int hitIdx = 0; hitIdx < nHitsInThisGroup; hitIdx++) {
963 ((lastTick - firstTick) / 4.) /
965 double peakMeanTrue = (firstTick + lastTick) / 2.;
966 if (NumberOfPeaksBeforeFit == 1 && nHitsInThisGroup == 1)
967 peakMeanTrue = std::get<0>(peakVals.at(
969 double peakMeanErr = (lastTick - firstTick) / 2.;
971 std::accumulate(signal.begin() + firstTick, signal.begin() + lastTick + 1, 0.);
972 double charge = sumADC;
973 double chargeErr = 0.1 * sumADC;
974 double peakAmpTrue = 0;
977 if (signal[
tick] > peakAmpTrue) peakAmpTrue = signal[
tick];
980 double peakAmpErr = 1.;
981 nExponentialsForFit = nHitsInThisGroup;
985 double peakMean = peakMeanTrue - 2;
986 double peakTau1 = 0.008;
987 double peakTau2 = 0.0065;
988 double peakAmp = 20.;
993 firstTick + roiFirstBinTick,
994 lastTick + roiFirstBinTick,
996 peakMeanTrue + roiFirstBinTick,
1003 nExponentialsForFit,
1010 std::cout << std::endl;
1012 <<
"- Created hit object for peak #" << hitIdx
1013 <<
" in this group with the following parameters (obtained from waveform):" 1015 std::cout <<
"HitStartTick: " << firstTick + roiFirstBinTick << std::endl;
1016 std::cout <<
"HitEndTick: " << lastTick + roiFirstBinTick << std::endl;
1017 std::cout <<
"HitWidthTicks: " << peakWidth << std::endl;
1018 std::cout <<
"HitMeanTick: " << peakMeanTrue + roiFirstBinTick <<
" +- " 1019 << peakMeanErr << std::endl;
1020 std::cout <<
"HitAmplitude [ADC]: " << peakAmpTrue <<
" +- " << peakAmpErr
1022 std::cout <<
"HitIntegral [ADC*ticks]: " << charge <<
" +- " << chargeErr
1024 std::cout <<
"HitADCSum [ADC*ticks]: " << sumADC << std::endl;
1025 std::cout <<
"HitMultiplicity: " << nExponentialsForFit << std::endl;
1026 std::cout <<
"HitIndex in group: " << hitIdx << std::endl;
1027 std::cout <<
"Hitchi2/ndf: " << chi2PerNDF << std::endl;
1028 std::cout <<
"HitNDF: " << NDF << std::endl;
1033 std::array<float, 4> fitParams;
1034 fitParams[0] = peakMean + roiFirstBinTick;
1035 fitParams[1] = peakTau1;
1036 fitParams[2] = peakTau2;
1037 fitParams[3] = peakAmp;
1041 firstTick = lastTick + 1;
1046 fChi2->Fill(chi2PerNDF);
1067 std::vector<std::tuple<int, int, int>>& timeValsVec,
1069 int firstTick)
const 1072 if (std::distance(startItr, stopItr) > 4) {
1074 auto maxItr = std::max_element(startItr, stopItr);
1076 float maxValue = *maxItr;
1077 int maxTime = std::distance(startItr, maxItr);
1079 if (maxValue >= PeakMin) {
1081 auto firstItr = std::distance(startItr, maxItr) > 2 ? maxItr - 1 : startItr;
1082 bool PeakStartIsHere =
true;
1084 while (firstItr != startItr) {
1086 PeakStartIsHere =
true;
1088 if (*firstItr >= *(firstItr - i)) {
1089 PeakStartIsHere =
false;
1093 if (*firstItr <= 0 || PeakStartIsHere)
break;
1097 int firstTime = std::distance(startItr, firstItr);
1103 auto lastItr = std::distance(maxItr, stopItr) > 2 ? maxItr + 1 : stopItr - 1;
1104 bool PeakEndIsHere =
true;
1106 while (lastItr != stopItr) {
1108 PeakEndIsHere =
true;
1110 if (*lastItr >= *(lastItr + i)) {
1111 PeakEndIsHere =
false;
1115 if (*lastItr <= 0 || PeakEndIsHere)
break;
1119 int lastTime = std::distance(startItr, lastItr);
1122 timeValsVec.push_back(
1123 std::make_tuple(firstTick + firstTime, firstTick + maxTime, firstTick + lastTime));
1130 firstTick + std::distance(startItr, lastItr + 1));
1148 auto timeValsVecItr = timeValsVec.begin();
1149 unsigned int PeaksInThisMergedPeak = 0;
1151 while (timeValsVecItr != timeValsVec.end()) {
1155 auto& timeVal = *timeValsVecItr++;
1156 int startT = std::get<0>(timeVal);
1157 int maxT = std::get<1>(timeVal);
1158 int endT = std::get<2>(timeVal);
1159 int widT = endT - startT;
1160 int FinalStartT = startT;
1161 int FinalEndT = endT;
1165 peakVals.emplace_back(maxT, widT, startT, endT);
1169 bool checkNextHit = timeValsVecItr != timeValsVec.end();
1172 while (checkNextHit) {
1174 int NextStartT = std::get<0>(*timeValsVecItr);
1176 double MinADC = signalVec[endT];
1177 for (
int i = endT; i <= NextStartT; i++) {
1178 if (signalVec[i] < MinADC) { MinADC = signalVec[i]; }
1183 int CurrentStartT = startT;
1184 int CurrentMaxT = maxT;
1185 int CurrentEndT = endT;
1188 timeVal = *timeValsVecItr++;
1189 int NextMaxT = std::get<1>(timeVal);
1190 int NextEndT = std::get<2>(timeVal);
1191 int NextWidT = NextEndT - NextStartT;
1192 FinalEndT = NextEndT;
1196 int CurrentSumADC = 0;
1197 for (
int i = CurrentStartT; i <= CurrentEndT; i++) {
1198 CurrentSumADC += signalVec[i];
1202 for (
int i = NextStartT; i <= NextEndT; i++) {
1203 NextSumADC += signalVec[i];
1208 if (signalVec[NextMaxT] <= signalVec[CurrentMaxT] &&
1211 (signalVec[NextMaxT] - signalVec[NextStartT]) <
1215 startT = CurrentStartT;
1217 widT = endT - startT;
1218 peakVals.pop_back();
1219 peakVals.emplace_back(maxT, widT, startT, endT);
1221 else if (signalVec[NextMaxT] > signalVec[CurrentMaxT] &&
1224 (signalVec[CurrentMaxT] - signalVec[CurrentEndT]) <
1228 startT = CurrentStartT;
1230 widT = endT - startT;
1231 peakVals.pop_back();
1232 peakVals.emplace_back(maxT, widT, startT, endT);
1236 startT = NextStartT;
1239 peakVals.emplace_back(maxT, widT, startT, endT);
1240 PeaksInThisMergedPeak++;
1245 startT = NextStartT;
1248 peakVals.emplace_back(maxT, widT, startT, endT);
1249 PeaksInThisMergedPeak++;
1251 checkNextHit = timeValsVecItr != timeValsVec.end();
1254 checkNextHit =
false;
1255 PeaksInThisMergedPeak = 0;
1260 mergedVec.emplace_back(FinalStartT, FinalEndT, peakVals, NFluctuations);
1273 int NFluctuations = 0;
1275 for (
int j = peakMean - 1; j >= peakStart; j--) {
1276 if (fsignalVec[j] < 5)
1279 if (fsignalVec[j] > fsignalVec[j + 1]) { NFluctuations++; }
1282 for (
int j = peakMean + 1; j <= peakEnd; j++) {
1283 if (fsignalVec[j] < 5)
1286 if (fsignalVec[j] > fsignalVec[j - 1]) { NFluctuations++; }
1289 return NFluctuations;
1300 double& fchi2PerNDF,
1304 int size = fEndTime - fStartTime + 1;
1305 int NPeaks = fPeakVals.size();
1310 if (fEndTime - fStartTime < 0) { size = 0; }
1313 TH1F hitSignal(
"hitSignal",
"", std::max(size, 1), fStartTime, fEndTime + 1);
1319 for (
int i = fStartTime; i < fEndTime + 1; i++) {
1320 hitSignal.Fill(i, fSignalVector[i]);
1321 hitSignal.SetBinError(i, 0.288675);
1333 TF1 Exponentials(
"Exponentials", eqn.c_str(), fStartTime, fEndTime + 1);
1336 std::cout << std::endl;
1337 std::cout <<
"--- Preparing fit ---" << std::endl;
1338 std::cout <<
"--- Lower limits, seed, upper limit:" << std::endl;
1342 Exponentials.SetParameter(0, 0.5);
1343 Exponentials.SetParameter(1, 0.5);
1346 double amplitude = 0;
1347 double peakMean = 0;
1349 double peakMeanShift = 2;
1350 double peakMeanSeed = 0;
1351 double peakMeanRangeLow = 0;
1352 double peakMeanRangeHi = 0;
1353 double peakStart = 0;
1356 for (
int i = 0; i < NPeaks; i++) {
1357 peakMean = std::get<0>(fPeakVals.at(i));
1358 peakStart = std::get<2>(fPeakVals.at(i));
1359 peakEnd = std::get<3>(fPeakVals.at(i));
1360 peakMeanSeed = peakMean - peakMeanShift;
1361 peakMeanRangeLow = std::max(peakStart - peakMeanShift, peakMeanSeed -
fFitPeakMeanRange);
1363 amplitude = fSignalVector[peakMean];
1365 Exponentials.SetParameter(2 * (i + 1), 1.65 * amplitude);
1366 Exponentials.SetParLimits(2 * (i + 1), 0.3 * 1.65 * amplitude, 2 * 1.65 * amplitude);
1367 Exponentials.SetParameter(2 * (i + 1) + 1, peakMeanSeed);
1370 Exponentials.SetParLimits(2 * (i + 1) + 1, peakMeanRangeLow, peakMeanRangeHi);
1372 else if (NPeaks >= 2 && i == 0) {
1373 double HalfDistanceToNextMean = 0.5 * (std::get<0>(fPeakVals.at(i + 1)) - peakMean);
1374 Exponentials.SetParLimits(
1377 std::min(peakMeanRangeHi, peakMeanSeed + HalfDistanceToNextMean));
1379 else if (NPeaks >= 2 && i == NPeaks - 1) {
1380 double HalfDistanceToPrevMean = 0.5 * (peakMean - std::get<0>(fPeakVals.at(i - 1)));
1381 Exponentials.SetParLimits(
1383 std::max(peakMeanRangeLow, peakMeanSeed - HalfDistanceToPrevMean),
1387 double HalfDistanceToNextMean = 0.5 * (std::get<0>(fPeakVals.at(i + 1)) - peakMean);
1388 double HalfDistanceToPrevMean = 0.5 * (peakMean - std::get<0>(fPeakVals.at(i - 1)));
1389 Exponentials.SetParLimits(
1391 std::max(peakMeanRangeLow, peakMeanSeed - HalfDistanceToPrevMean),
1392 std::min(peakMeanRangeHi, peakMeanSeed + HalfDistanceToNextMean));
1396 double t0low, t0high;
1397 Exponentials.GetParLimits(2 * (i + 1) + 1, t0low, t0high);
1398 std::cout <<
"Peak #" << i <<
": A [ADC] = " << 0.3 * 1.65 * amplitude <<
" , " 1399 << 1.65 * amplitude <<
" , " << 2 * 1.65 * amplitude << std::endl;
1400 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << t0low <<
" , " << peakMeanSeed
1401 <<
" , " << t0high << std::endl;
1406 double amplitude = 0;
1407 double peakMean = 0;
1409 double peakMeanShift = 2;
1410 double peakMeanSeed = 0;
1411 double peakMeanRangeLow = 0;
1412 double peakMeanRangeHi = 0;
1413 double peakStart = 0;
1416 for (
int i = 0; i < NPeaks; i++) {
1417 Exponentials.SetParameter(4 * i, 0.5);
1418 Exponentials.SetParameter(4 * i + 1, 0.5);
1422 peakMean = std::get<0>(fPeakVals.at(i));
1423 peakStart = std::get<2>(fPeakVals.at(i));
1424 peakEnd = std::get<3>(fPeakVals.at(i));
1425 peakMeanSeed = peakMean - peakMeanShift;
1426 peakMeanRangeLow = std::max(peakStart - peakMeanShift, peakMeanSeed -
fFitPeakMeanRange);
1428 amplitude = fSignalVector[peakMean];
1430 Exponentials.SetParameter(4 * i + 2, 1.65 * amplitude);
1431 Exponentials.SetParLimits(4 * i + 2, 0.3 * 1.65 * amplitude, 2 * 1.65 * amplitude);
1432 Exponentials.SetParameter(4 * i + 3, peakMeanSeed);
1435 Exponentials.SetParLimits(4 * i + 3, peakMeanRangeLow, peakMeanRangeHi);
1437 else if (NPeaks >= 2 && i == 0) {
1438 double HalfDistanceToNextMean = 0.5 * (std::get<0>(fPeakVals.at(i + 1)) - peakMean);
1439 Exponentials.SetParLimits(
1442 std::min(peakMeanRangeHi, peakMeanSeed + HalfDistanceToNextMean));
1444 else if (NPeaks >= 2 && i == NPeaks - 1) {
1445 double HalfDistanceToPrevMean = 0.5 * (peakMean - std::get<0>(fPeakVals.at(i - 1)));
1446 Exponentials.SetParLimits(
1448 std::max(peakMeanRangeLow, peakMeanSeed - HalfDistanceToPrevMean),
1452 double HalfDistanceToNextMean = 0.5 * (std::get<0>(fPeakVals.at(i + 1)) - peakMean);
1453 double HalfDistanceToPrevMean = 0.5 * (peakMean - std::get<0>(fPeakVals.at(i - 1)));
1454 Exponentials.SetParLimits(
1456 std::max(peakMeanRangeLow, peakMeanSeed - HalfDistanceToPrevMean),
1457 std::min(peakMeanRangeHi, peakMeanSeed + HalfDistanceToNextMean));
1461 double t0low, t0high;
1462 Exponentials.GetParLimits(4 * i + 3, t0low, t0high);
1463 std::cout <<
"Peak #" << i <<
": A [ADC] = " << 0.3 * 1.65 * amplitude <<
" , " 1464 << 1.65 * amplitude <<
" , " << 2 * 1.65 * amplitude << std::endl;
1465 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << t0low <<
" , " << peakMeanSeed
1466 <<
" , " << t0high << std::endl;
1475 hitSignal.Fit(&Exponentials,
"QNRWM",
"", fStartTime, fEndTime + 1);
1478 mf::LogWarning(
"DPRawHitFinder") <<
"Fitter failed finding a hit";
1484 fchi2PerNDF = (Exponentials.GetChisquare() / Exponentials.GetNDF());
1485 fNDF = Exponentials.GetNDF();
1488 fparamVec.emplace_back(Exponentials.GetParameter(0), Exponentials.GetParError(0));
1489 fparamVec.emplace_back(Exponentials.GetParameter(1), Exponentials.GetParError(1));
1491 for (
int i = 0; i < NPeaks; i++) {
1492 fparamVec.emplace_back(Exponentials.GetParameter(2 * (i + 1)),
1493 Exponentials.GetParError(2 * (i + 1)));
1494 fparamVec.emplace_back(Exponentials.GetParameter(2 * (i + 1) + 1),
1495 Exponentials.GetParError(2 * (i + 1) + 1));
1499 for (
int i = 0; i < NPeaks; i++) {
1500 fparamVec.emplace_back(Exponentials.GetParameter(4 * i), Exponentials.GetParError(4 * i));
1501 fparamVec.emplace_back(Exponentials.GetParameter(4 * i + 1),
1502 Exponentials.GetParError(4 * i + 1));
1503 fparamVec.emplace_back(Exponentials.GetParameter(4 * i + 2),
1504 Exponentials.GetParError(4 * i + 2));
1505 fparamVec.emplace_back(Exponentials.GetParameter(4 * i + 3),
1506 Exponentials.GetParError(4 * i + 3));
1509 Exponentials.Delete();
1529 TF1 Exponentials(
"Exponentials", eqn.c_str(), fStartTime, fEndTime + 1);
1531 for (
size_t i = 0; i < fparamVec.size(); i++) {
1532 Exponentials.SetParameter(i, fparamVec[i].first);
1538 double Chi2PerNDFPeak;
1539 double MaxPosDeviation;
1540 double MaxNegDeviation;
1541 int BinMaxPosDeviation;
1542 int BinMaxNegDeviation;
1543 for (
int i = 0; i < fNPeaks; i++) {
1544 Chi2PerNDFPeak = 0.;
1545 MaxPosDeviation = 0.;
1546 MaxNegDeviation = 0.;
1547 BinMaxPosDeviation = 0;
1548 BinMaxNegDeviation = 0;
1550 for (
int j = std::get<2>(fpeakVals.at(i)); j < std::get<3>(fpeakVals.at(i)) + 1; j++) {
1551 if ((Exponentials(j + 0.5) - fSignalVector[j]) > MaxPosDeviation &&
1552 j != std::get<0>(fpeakVals.at(i))) {
1553 MaxPosDeviation = Exponentials(j + 0.5) - fSignalVector[j];
1554 BinMaxPosDeviation = j;
1556 if ((Exponentials(j + 0.5) - fSignalVector[j]) < MaxNegDeviation &&
1557 j != std::get<0>(fpeakVals.at(i))) {
1558 MaxNegDeviation = Exponentials(j + 0.5) - fSignalVector[j];
1559 BinMaxNegDeviation = j;
1562 pow((Exponentials(j + 0.5) - fSignalVector[j]) / sqrt(fSignalVector[j]), 2);
1565 if (BinMaxNegDeviation != 0) {
1567 static_cast<double>((std::get<3>(fpeakVals.at(i)) - std::get<2>(fpeakVals.at(i))));
1568 fPeakDev.emplace_back(Chi2PerNDFPeak, i, BinMaxNegDeviation, BinMaxPosDeviation);
1575 [](std::tuple<double, int, int, int>
const&
t1, std::tuple<double, int, int, int>
const&
t2) {
1576 return std::get<0>(
t1) > std::get<0>(
t2);
1578 Exponentials.Delete();
1584 std::string feqn =
"";
1585 std::stringstream numConv;
1588 for (
int i = 0; i < fNPeaks; i++) {
1589 feqn.append(
"+( [");
1591 numConv << 2 * (i + 1);
1592 feqn.append(numConv.str());
1593 feqn.append(
"] * exp(0.4*(x-[");
1595 numConv << 2 * (i + 1) + 1;
1596 feqn.append(numConv.str());
1597 feqn.append(
"])/[");
1600 feqn.append(numConv.str());
1601 feqn.append(
"]) / ( 1 + exp(0.4*(x-[");
1603 numConv << 2 * (i + 1) + 1;
1604 feqn.append(numConv.str());
1605 feqn.append(
"])/[");
1608 feqn.append(numConv.str());
1609 feqn.append(
"]) ) )");
1613 for (
int i = 0; i < fNPeaks; i++) {
1614 feqn.append(
"+( [");
1616 numConv << 4 * i + 2;
1617 feqn.append(numConv.str());
1618 feqn.append(
"] * exp(0.4*(x-[");
1620 numConv << 4 * i + 3;
1621 feqn.append(numConv.str());
1622 feqn.append(
"])/[");
1625 feqn.append(numConv.str());
1626 feqn.append(
"]) / ( 1 + exp(0.4*(x-[");
1628 numConv << 2 * (i + 1) + 1;
1629 feqn.append(numConv.str());
1630 feqn.append(
"])/[");
1632 numConv << 4 * i + 1;
1633 feqn.append(numConv.str());
1634 feqn.append(
"]) ) )");
1644 int PeakNumberWithNewPeak = std::get<1>(fPeakDevCand);
1645 int NewPeakMax = std::get<2>(fPeakDevCand);
1646 int OldPeakMax = std::get<0>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1647 int OldPeakOldStart = std::get<2>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1648 int OldPeakOldEnd = std::get<3>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1650 int NewPeakStart = 0;
1652 int OldPeakNewStart = 0;
1653 int OldPeakNewEnd = 0;
1654 int DistanceBwOldAndNewPeak = 0;
1656 if (NewPeakMax < OldPeakMax) {
1657 NewPeakStart = OldPeakOldStart;
1658 OldPeakNewEnd = OldPeakOldEnd;
1659 DistanceBwOldAndNewPeak = OldPeakMax - NewPeakMax;
1660 NewPeakEnd = NewPeakMax + 0.5 * (DistanceBwOldAndNewPeak - (DistanceBwOldAndNewPeak % 2));
1661 if (DistanceBwOldAndNewPeak % 2 == 0) NewPeakEnd -= 1;
1662 OldPeakNewStart = NewPeakEnd + 1;
1664 else if (OldPeakMax < NewPeakMax) {
1665 NewPeakEnd = OldPeakOldEnd;
1666 OldPeakNewStart = OldPeakOldStart;
1667 DistanceBwOldAndNewPeak = NewPeakMax - OldPeakMax;
1668 OldPeakNewEnd = OldPeakMax + 0.5 * (DistanceBwOldAndNewPeak - (DistanceBwOldAndNewPeak % 2));
1669 if (DistanceBwOldAndNewPeak % 2 == 0) OldPeakNewEnd -= 1;
1670 NewPeakStart = OldPeakNewEnd + 1;
1672 else if (OldPeakMax == NewPeakMax) {
1676 fpeakValsTemp.at(PeakNumberWithNewPeak) =
1677 std::make_tuple(OldPeakMax, 0, OldPeakNewStart, OldPeakNewEnd);
1678 fpeakValsTemp.emplace_back(NewPeakMax, 0, NewPeakStart, NewPeakEnd);
1680 fpeakValsTemp.begin(),
1681 fpeakValsTemp.end(),
1682 [](std::tuple<int, int, int, int>
const&
t1, std::tuple<int, int, int, int>
const&
t2) {
1683 return std::get<0>(
t1) < std::get<0>(
t2);
1693 int PeakNumberWithNewPeak = std::get<1>(fPeakDevCand);
1694 int OldPeakOldStart = std::get<2>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1695 int OldPeakOldEnd = std::get<3>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1696 int WidthOldPeakOld = OldPeakOldEnd - OldPeakOldStart;
1698 if (WidthOldPeakOld < 3) {
return; }
1701 int NewPeakStart = 0;
1703 int OldPeakNewMax = 0;
1704 int OldPeakNewStart = 0;
1705 int OldPeakNewEnd = 0;
1707 OldPeakNewStart = OldPeakOldStart;
1708 NewPeakEnd = OldPeakOldEnd;
1710 OldPeakNewEnd = OldPeakNewStart + 0.5 * (WidthOldPeakOld + (WidthOldPeakOld % 2));
1711 NewPeakStart = OldPeakNewEnd + 1;
1713 int WidthOldPeakNew = OldPeakNewEnd - OldPeakNewStart;
1714 int WidthNewPeak = NewPeakEnd - NewPeakStart;
1716 OldPeakNewMax = OldPeakNewStart + 0.5 * (WidthOldPeakNew - (WidthOldPeakNew % 2));
1717 NewPeakMax = NewPeakStart + 0.5 * (WidthNewPeak - (WidthNewPeak % 2));
1719 fpeakValsTemp.at(PeakNumberWithNewPeak) =
1720 std::make_tuple(OldPeakNewMax, 0, OldPeakNewStart, OldPeakNewEnd);
1721 fpeakValsTemp.emplace_back(NewPeakMax, 0, NewPeakStart, NewPeakEnd);
1723 fpeakValsTemp.begin(),
1724 fpeakValsTemp.end(),
1725 [](std::tuple<int, int, int, int>
const&
t1, std::tuple<int, int, int, int>
const&
t2) {
1726 return std::get<0>(
t1) < std::get<0>(
t2);
1739 double fPeakMeanTrue)
1741 double MaxValue = (fPeakAmp * exp(0.4 * (fPeakMeanTrue - fPeakMean) / fPeakTau1)) /
1742 (1 + exp(0.4 * (fPeakMeanTrue - fPeakMean) / fPeakTau2));
1743 double FuncValue = 0.;
1744 double HalfMaxLeftTime = 0.;
1745 double HalfMaxRightTime = 0.;
1749 for (
double x = fPeakMeanTrue;
x > fStartTime - 1000.;
x--) {
1750 FuncValue = (fPeakAmp * exp(0.4 * (
x - fPeakMean) / fPeakTau1)) /
1751 (1 + exp(0.4 * (
x - fPeakMean) / fPeakTau2));
1752 if (FuncValue < 0.5 * MaxValue) {
1753 HalfMaxLeftTime =
x;
1758 for (
double x = fPeakMeanTrue;
x < fEndTime + 1000.;
x++) {
1759 FuncValue = (fPeakAmp * exp(0.4 * (
x - fPeakMean) / fPeakTau1)) /
1760 (1 + exp(0.4 * (
x - fPeakMean) / fPeakTau2));
1761 if (FuncValue < 0.5 * MaxValue) {
1762 HalfMaxRightTime =
x;
1768 for (
double x = HalfMaxLeftTime + 1;
x > HalfMaxLeftTime;
x -= (1 / ReBin)) {
1769 FuncValue = (fPeakAmp * exp(0.4 * (
x - fPeakMean) / fPeakTau1)) /
1770 (1 + exp(0.4 * (
x - fPeakMean) / fPeakTau2));
1771 if (FuncValue < 0.5 * MaxValue) {
1772 HalfMaxLeftTime =
x;
1777 for (
double x = HalfMaxRightTime - 1;
x < HalfMaxRightTime;
x += (1 / ReBin)) {
1778 FuncValue = (fPeakAmp * exp(0.4 * (
x - fPeakMean) / fPeakTau1)) /
1779 (1 + exp(0.4 * (
x - fPeakMean) / fPeakTau2));
1780 if (FuncValue < 0.5 * MaxValue) {
1781 HalfMaxRightTime =
x;
1787 for (
double x = HalfMaxLeftTime + 1 / ReBin;
x > HalfMaxLeftTime;
x -= 1 / (ReBin * ReBin)) {
1788 FuncValue = (fPeakAmp * exp(0.4 * (
x - fPeakMean) / fPeakTau1)) /
1789 (1 + exp(0.4 * (
x - fPeakMean) / fPeakTau2));
1790 if (FuncValue < 0.5 * MaxValue) {
1791 HalfMaxLeftTime =
x;
1796 for (
double x = HalfMaxRightTime - 1 / ReBin;
x < HalfMaxRightTime;
x += 1 / (ReBin * ReBin)) {
1797 FuncValue = (fPeakAmp * exp(0.4 * (
x - fPeakMean) / fPeakTau1)) /
1798 (1 + exp(0.4 * (
x - fPeakMean) / fPeakTau2));
1799 if (FuncValue < 0.5 * MaxValue) {
1800 HalfMaxRightTime =
x;
1805 return HalfMaxRightTime - HalfMaxLeftTime;
1813 double fChargeNormFactor,
1814 double fPeakMeanTrue)
1817 double ChargeSum = 0.;
1821 bool ChargeBigEnough =
true;
1822 for (
double x = fPeakMeanTrue - 1 / ReBin; ChargeBigEnough &&
x > fPeakMeanTrue - 1000.;
1824 for (
double i = 0.; i > -1.; i -= (1 / ReBin)) {
1825 Charge = (fPeakAmp * exp(0.4 * (
x + i - fPeakMean) / fPeakTau1)) /
1826 (1 + exp(0.4 * (
x + i - fPeakMean) / fPeakTau2));
1827 ChargeSum += Charge;
1829 if (Charge < 0.01) ChargeBigEnough =
false;
1832 ChargeBigEnough =
true;
1833 for (
double x = fPeakMeanTrue; ChargeBigEnough &&
x < fPeakMeanTrue + 1000.;
x += 1.) {
1834 for (
double i = 0.; i < 1.; i += (1 / ReBin)) {
1835 Charge = (fPeakAmp * exp(0.4 * (
x + i - fPeakMean) / fPeakTau1)) /
1836 (1 + exp(0.4 * (
x + i - fPeakMean) / fPeakTau2));
1837 ChargeSum += Charge;
1839 if (Charge < 0.01) ChargeBigEnough =
false;
1842 return ChargeSum * fChargeNormFactor / ReBin;
1847 std::vector<float>& outputVec,
1848 size_t binsToAverage)
const 1850 size_t halfBinsToAverage(binsToAverage / 2);
1852 float runningSum(0.);
1854 for (
size_t idx = 0; idx < halfBinsToAverage; idx++)
1855 runningSum += inputVec[idx];
1857 outputVec.resize(inputVec.size());
1863 size_t startOffset = std::distance(inputVec.begin(), inputItr);
1864 size_t stopOffset = std::distance(inputItr, inputVec.end());
1866 std::min(2 * halfBinsToAverage,
1867 std::min(startOffset + halfBinsToAverage + 1, halfBinsToAverage + stopOffset - 1));
1869 if (startOffset >= halfBinsToAverage) runningSum -= *(inputItr - halfBinsToAverage);
1870 if (stopOffset > halfBinsToAverage) runningSum += *(inputItr + halfBinsToAverage);
1872 *outputVecItr++ = runningSum / float(count);
1880 std::vector<float>& outputVec,
1881 size_t nBinsToCombine)
const 1883 size_t nNewBins = inputVec.size() / nBinsToCombine;
1885 if (inputVec.size() % nBinsToCombine > 0) nNewBins++;
1887 outputVec.resize(nNewBins, 0.);
1889 size_t outputBin = 0;
1891 for (
size_t inputIdx = 0; inputIdx < inputVec.size();) {
1892 outputVec[outputBin] += inputVec[inputIdx++];
1894 if (inputIdx % nBinsToCombine == 0) outputBin++;
1896 if (outputBin > outputVec.size()) {
1897 std::cout <<
"***** DISASTER!!! ****** outputBin: " << outputBin
1898 <<
", 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
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
double fMergeADCSumThreshold
void mergeCandidatePeaks(const std::vector< float > signalVec, TimeValsVec, MergedTimeWidVec &)
bool operator()(std::tuple< int, int, int, int > p, int s) const
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
void produce(art::Event &evt) override
void FindPeakWithMaxDeviation(const std::vector< float > fSignalVector, int fNPeaks, int fStartTime, int fEndTime, bool fSameShape, ParameterVec fparamVec, PeakTimeWidVec fpeakVals, PeakDevVec &fPeakDev)
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.
DPRawHitFinder(fhicl::ParameterSet const &pset)
void addVector(FVector_ID id, std::array< float, N > const &values)
std::vector< std::tuple< int, int, int >> TimeValsVec
int TDCtick_t
Type representing a TDC tick.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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.
FVector_ID initOutputs(std::string const &dataTag, size_t dataSize, std::vector< std::string > const &names=std::vector< std::string >(N,""))
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)
double fMergeMaxADCThreshold
double fWidthNormalization
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
anab::FVectorWriter< 4 > fHitParamWriter
std::vector< std::pair< double, double >> ParameterVec
std::string CreateFitFunction(int fNPeaks, bool fSameShape)
std::vector< std::tuple< int, int, int, int >> PeakTimeWidVec
std::vector< std::tuple< double, int, int, int >> PeakDevVec
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 fMinRelativePeakHeightLeft
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
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
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.
std::vector< std::tuple< int, int, PeakTimeWidVec, int >> MergedTimeWidVec
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
art framework interface to geometry description
double fMinRelativePeakHeightRight
bool operator()(int s, std::tuple< int, int, int, int > p) const