1 #ifndef DPRAWHITFINDER_H 2 #define DPRAWHITFINDER_H 70 #include "TGraphErrors.h" 72 #include "TDecompSVD.h" 76 #include "TStopwatch.h" 95 using PeakDevVec = std::vector<std::tuple<double,int,int,int>>;
102 int firstTick)
const;
134 void AddPeak(std::tuple<double,int,int,int> fPeakDevCand,
137 void SplitPeak(std::tuple<double,int,int,int> fPeakDevCand,
146 double fPeakMeanTrue);
152 double fChargeNormFactor,
153 double fPeakMeanTrue);
156 std::vector<double>& output);
159 std::vector<float>& outputVec,
160 size_t binsToAverage)
const;
162 void reBin(
const std::vector<float>& inputVec,
163 std::vector<float>& outputVec,
164 size_t nBinsToCombine)
const;
172 {
return std::get<0>(p) < s; }
174 {
return s < std::get<0>(p); }
228 pset.get<
std::string>(
"module_label"),
"",
229 art::ServiceHandle<
art::TriggerNamesService>()->getProcessName()),
249 std::vector<double>& output)
252 throw std::runtime_error(
"DPRawHitFinder::FillOutHitParameterVector ERROR! Input config vector has zero size.");
255 const unsigned int N_PLANES = geom->
Nplanes();
258 output.resize(N_PLANES,input[0]);
259 else if(input.size()==N_PLANES)
262 throw std::runtime_error(
"DPRawHitFinder::FillOutHitParameterVector ERROR! Input config vector size !=1 and !=N_PLANES.");
315 fFirstChi2 = tfs->
make<TH1F>(
"fFirstChi2",
"#chi^{2}", 10000, 0, 5000);
316 fChi2 = tfs->
make<TH1F>(
"fChi2",
"#chi^{2}", 10000, 0, 5000);
330 TH1::AddDirectory(kFALSE);
367 for(
size_t wireIter = 0; wireIter < wireVecHandle->size(); wireIter++)
377 std::vector<geo::WireID> wids = geom->
ChannelToWire(channel);
383 std::cout << std::endl;
384 std::cout << std::endl;
385 std::cout << std::endl;
386 std::cout <<
"-----------------------------------------------------------------------------------------------------------" << std::endl;
387 std::cout <<
"Channel: " << channel << std::endl;
388 std::cout <<
"Cryostat: " << wid.
Cryostat << std::endl;
389 std::cout <<
"TPC: " << wid.
TPC << std::endl;
390 std::cout <<
"Plane: " << wid.
Plane << std::endl;
391 std::cout <<
"Wire: " << wid.
Wire << std::endl;
401 for(
const auto& range : signalROI.
get_ranges())
406 const std::vector<float>& signal = range.data();
423 std::vector<float> timeAve;
435 if (timeValsVec.empty())
continue;
456 std::cout << std::endl;
457 std::cout << std::endl;
458 std::cout <<
"-------------------- ROI #" << CountROI <<
" -------------------- " << std::endl;
459 if(timeValsVec.size() == 1) std::cout <<
"ROI #" << CountROI <<
" (" << timeValsVec.size() <<
" peak): ROIStartTick: " << range.offset <<
" ROIEndTick:" << range.offset+range.size() << std::endl;
460 else std::cout <<
"ROI #" << CountROI <<
" (" << timeValsVec.size() <<
" peaks): ROIStartTick: " << range.offset <<
" ROIEndTick:" << range.offset+range.size() << std::endl;
467 for(
auto const& timeValsTmp : timeValsVec )
469 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;
476 if (timeValsVec.empty())
continue;
491 int NumberOfPeaksBeforeFit=0;
492 unsigned int nExponentialsForFit=0;
493 double chi2PerNDF=0.;
496 unsigned int NumberOfMergedVecs = mergedVec.size();
502 for(
unsigned int j=0; j < NumberOfMergedVecs; j++)
504 int startT = std::get<0>(mergedVec.at(j));
505 int endT = std::get<1>(mergedVec.at(j));
506 int width = endT + 1 - startT;
509 int NFluctuations = std::get<3>(mergedVec.at(j));
513 std::cout << std::endl;
514 if(peakVals.size() == 1) std::cout <<
"- Group #" << j <<
" (" << peakVals.size() <<
" peak): GroupStartTick: " << range.offset + startT <<
" GroupEndTick: " << range.offset + endT << std::endl;
515 else std::cout <<
"- Group #" << j <<
" (" << peakVals.size() <<
" peaks): GroupStartTick: " << range.offset + startT <<
" GroupEndTick: " << range.offset + endT << std::endl;
516 std::cout <<
"Fluctuations in this group: " << NFluctuations << std::endl;
517 int CountPeakInGroup=0;
518 for(
auto const& peakValsTmp : peakVals )
520 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;
526 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)
530 std::cout <<
"Delete this group of peaks because width, integral or width/intergral is too small." << std::endl;
539 NumberOfPeaksBeforeFit = peakVals.size();
540 nExponentialsForFit = peakVals.size();
553 std::cout << std::endl;
554 std::cout <<
"--- First fit ---" << std::endl;
555 if (nExponentialsForFit == 1) std::cout <<
"- Fitted " << nExponentialsForFit <<
" peak in group #" << j <<
":" << std::endl;
556 else std::cout <<
"- Fitted " << nExponentialsForFit <<
" peaks in group #" << j <<
":" << std::endl;
557 std::cout <<
"chi2/ndf = " << chi2PerNDF << std::endl;
561 std::cout <<
"tau1 [mus] = " << paramVec[0].first << std::endl;
562 std::cout <<
"tau2 [mus] = " << paramVec[1].first << std::endl;
564 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
566 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[2*(i+1)].first << std::endl;
567 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << range.offset + paramVec[2*(i+1)+1].first << std::endl;
572 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
574 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[4*i+2].first << std::endl;
575 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << range.offset + paramVec[4*i+3].first << std::endl;
576 std::cout <<
"Peak #" << i <<
": tau1 [mus] = " << paramVec[4*i].first << std::endl;
577 std::cout <<
"Peak #" << i <<
": tau2 [mus] = " << paramVec[4*i+1].first << std::endl;
583 if (!(chi2PerNDF < std::numeric_limits<double>::infinity()))
continue;
594 unsigned int nExponentialsBeforeRefit=nExponentialsForFit;
595 unsigned int nExponentialsAfterRefit=nExponentialsForFit;
596 double oldChi2PerNDF = chi2PerNDF;
601 while( (nExponentialsForFit == 1 && nExponentialsAfterRefit < 3*nExponentialsBeforeRefit && chi2PerNDF > fChi2NDFRetry) ||
602 (nExponentialsForFit > 1 && nExponentialsAfterRefit < 3*nExponentialsBeforeRefit && chi2PerNDF >
fChi2NDFRetryFactorMultiHits*fChi2NDFRetry) )
604 RefitSuccess =
false;
609 for(
auto& PeakDevCand : PeakDev)
614 peakValsTemp = peakVals;
616 AddPeak(PeakDevCand, peakValsTemp);
619 if (chi2PerNDF2 < chi2PerNDF)
621 paramVec = paramVecRefit;
622 peakVals = peakValsTemp;
623 nExponentialsForFit = peakVals.size();
624 chi2PerNDF = chi2PerNDF2;
626 nExponentialsAfterRefit++;
633 if(RefitSuccess ==
false)
635 for(
auto& PeakDevCand : PeakDev)
640 peakValsTemp=peakVals;
645 if (chi2PerNDF2 < chi2PerNDF)
647 paramVec = paramVecRefit;
648 peakVals = peakValsTemp;
649 nExponentialsForFit = peakVals.size();
650 chi2PerNDF = chi2PerNDF2;
652 nExponentialsAfterRefit++;
659 if(RefitSuccess ==
false)
667 std::cout << std::endl;
668 std::cout <<
"--- Refit ---" << std::endl;
669 if( chi2PerNDF == oldChi2PerNDF) std::cout <<
"chi2/ndf didn't improve. Keep first fit." << std::endl;
672 std::cout <<
"- Added peaks to group #" << j <<
". This group now has " << nExponentialsForFit <<
" peaks:" << std::endl;
673 std::cout <<
"- Group #" << j <<
" (" << peakVals.size() <<
" peaks): GroupStartTick: " << range.offset + startT <<
" GroupEndTick: " << range.offset + endT << std::endl;
675 int CountPeakInGroup=0;
676 for(
auto const& peakValsTmp : peakVals )
678 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;
682 std::cout <<
"chi2/ndf = " << chi2PerNDF << std::endl;
686 std::cout <<
"tau1 [mus] = " << paramVec[0].first << std::endl;
687 std::cout <<
"tau2 [mus] = " << paramVec[1].first << std::endl;
689 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
691 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[2*(i+1)].first << std::endl;
692 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << range.offset + paramVec[2*(i+1)+1].first << std::endl;
697 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
699 std::cout <<
"Peak #" << i <<
": A [ADC] = " << paramVec[4*i+2].first << std::endl;
700 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << range.offset + paramVec[4*i+3].first << std::endl;
701 std::cout <<
"Peak #" << i <<
": tau1 [mus] = " << paramVec[4*i].first << std::endl;
702 std::cout <<
"Peak #" << i <<
": tau2 [mus] = " << paramVec[4*i+1].first << std::endl;
714 for(
unsigned int i = 0; i < nExponentialsForFit; i++)
724 peakTau1 = paramVec[0].first;
725 peakTau2 = paramVec[1].first;
726 peakAmp = paramVec[2*(i+1)].first;
727 peakMean = paramVec[2*(i+1)+1].first;
731 peakTau1 = paramVec[4*i].first;
732 peakTau2 = paramVec[4*i+1].first;
733 peakAmp = paramVec[4*i+2].first;
734 peakMean = paramVec[4*i+3].first;
738 double peakAmpTrue = signal[std::get<0>(peakVals.at(i))];
739 double peakAmpErr = 1.;
742 TF1 Exponentials(
"Exponentials",
"( [0] * exp(0.4*(x-[1])/[2]) / ( 1 + exp(0.4*(x-[1])/[3]) ) )",startT,endT);
743 Exponentials.SetParameter(0, peakAmp);
744 Exponentials.SetParameter(1, peakMean);
745 Exponentials.SetParameter(2, peakTau1);
746 Exponentials.SetParameter(3, peakTau2);
747 double peakMeanTrue = Exponentials.GetMaximumX(startT,endT);
748 Exponentials.Delete();
751 double peakWidth =
WidthFunc(peakMean, peakAmp, peakTau1, peakTau2, startT, endT, peakMeanTrue);
760 peakMeanErr = paramVec[2*(i+1)+1].second;
764 peakMeanErr = paramVec[4*i+3].second;
766 double peakWidthErr = 0.1*peakWidth;
770 double chargeErr = std::sqrt(TMath::Pi()) * (peakAmpErr*peakWidthErr + peakWidthErr*peakAmpErr);
773 int startTthisHit = std::get<2>(peakVals.at(i));
774 int endTthisHit = std::get<3>(peakVals.at(i));
779 double sumADC = std::accumulate(sumStartItr, sumEndItr + 1, 0.);
787 std::cout << std::endl;
788 std::cout <<
"WARNING: For peak #" << i <<
" in this group:" << std::endl;
789 if( peakWidth <= 0 || charge <= 0. || charge != charge) std::cout <<
"Fit function returned width < 0 or charge < 0 or charge = nan." << std::endl;
790 if( ( nExponentialsForFit == 1 && chi2PerNDF > fChi2NDFMax ) || ( nExponentialsForFit >= 2 && chi2PerNDF >
fChi2NDFMaxFactorMultiHits*fChi2NDFMax ) )
792 std::cout << std::endl;
793 std::cout <<
"WARNING: For fit of this group (" << NumberOfPeaksBeforeFit <<
" peaks before refit, " << nExponentialsForFit <<
" peaks after refit): " << std::endl;
794 if ( nExponentialsForFit == 1 && chi2PerNDF > fChi2NDFMax ) std::cout <<
"chi2/ndf of this fit (" << chi2PerNDF <<
") is higher than threshold (" << fChi2NDFMax <<
")." << std::endl;
797 std::cout <<
"---> DO NOT create hit object from fit parameters but use peak values instead." << std::endl;
798 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;
801 peakMeanErr=peakWidth/2;
803 peakMeanTrue = std::get<0>(peakVals.at(i));
806 peakMean = peakMeanTrue;
815 startTthisHit+roiFirstBinTick,
816 endTthisHit+roiFirstBinTick,
818 peakMeanTrue+roiFirstBinTick,
833 std::cout << std::endl;
834 std::cout <<
"- Created hit object for peak #" << i <<
" in this group with the following parameters (obtained from fit):" << std::endl;
835 std::cout <<
"HitStartTick: " << startTthisHit+roiFirstBinTick << std::endl;
836 std::cout <<
"HitEndTick: " << endTthisHit+roiFirstBinTick << std::endl;
837 std::cout <<
"HitWidthTicks: " << peakWidth << std::endl;
838 std::cout <<
"HitMeanTick: " << peakMeanTrue+roiFirstBinTick <<
" +- " << peakMeanErr << std::endl;
839 std::cout <<
"HitAmplitude [ADC]: " << peakAmpTrue <<
" +- " << peakAmpErr << std::endl;
840 std::cout <<
"HitIntegral [ADC*ticks]: " << charge <<
" +- " << chargeErr << std::endl;
841 std::cout <<
"HitADCSum [ADC*ticks]: " << sumADC << std::endl;
842 std::cout <<
"HitMultiplicity: " << nExponentialsForFit << std::endl;
843 std::cout <<
"HitIndex in group: " << numHits << std::endl;
844 std::cout <<
"Hitchi2/ndf: " << chi2PerNDF << std::endl;
845 std::cout <<
"HitNDF: " << NDF << std::endl;
852 std::array<float, 4> fitParams;
853 fitParams[0] = peakMean+roiFirstBinTick;
854 fitParams[1] = peakTau1;
855 fitParams[2] = peakTau2;
856 fitParams[3] = peakAmp;
880 if (nHitsInThisGroup *
fLongPulseWidth < (endT - startT + 1) ) nHitsInThisGroup++;
882 int firstTick = startT;
889 std::cout << std::endl;
890 std::cout <<
"WARNING: Number of peaks in this group (" << NumberOfPeaksBeforeFit <<
") is higher than threshold (" <<
fMaxMultiHit <<
")." << std::endl;
891 std::cout <<
"---> DO NOT fit. Split group of peaks into hits with equal length instead." << std::endl;
895 std::cout << std::endl;
896 std::cout <<
"WARNING: group of peak is longer (" << width <<
" ticks) than threshold (" <<
fMaxGroupLength <<
" ticks)." << std::endl;
897 std::cout <<
"---> DO NOT fit. Split group of peaks into hits with equal length instead." << std::endl;
901 std::cout << std::endl;
902 std::cout <<
"WARNING: fluctuations (" << NFluctuations <<
") higher than threshold (" <<
fMaxFluctuations <<
")." << std::endl;
903 std::cout <<
"---> DO NOT fit. Split group of peaks into hits with equal length instead." << std::endl;
914 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;
918 for(
int hitIdx = 0; hitIdx < nHitsInThisGroup; hitIdx++)
922 double peakMeanTrue = (firstTick + lastTick) / 2.;
923 if( NumberOfPeaksBeforeFit == 1 && nHitsInThisGroup == 1) peakMeanTrue = std::get<0>(peakVals.at(0));
924 double peakMeanErr = (lastTick - firstTick) / 2.;
925 double sumADC = std::accumulate(signal.begin() + firstTick, signal.begin() + lastTick + 1, 0.);
926 double charge = sumADC;
927 double chargeErr = 0.1*sumADC;
928 double peakAmpTrue = 0;
930 for(
int tick = firstTick; tick <= lastTick; tick++)
932 if(signal[tick] > peakAmpTrue) peakAmpTrue = signal[tick];
935 double peakAmpErr = 1.;
936 nExponentialsForFit = nHitsInThisGroup;
940 double peakMean = peakMeanTrue-2;
941 double peakTau1 = 0.008;
942 double peakTau2 = 0.0065;
943 double peakAmp = 20.;
947 firstTick+roiFirstBinTick,
948 lastTick+roiFirstBinTick,
950 peakMeanTrue+roiFirstBinTick,
966 std::cout << std::endl;
967 std::cout <<
"- Created hit object for peak #" << hitIdx <<
" in this group with the following parameters (obtained from waveform):" << std::endl;
968 std::cout <<
"HitStartTick: " << firstTick+roiFirstBinTick << std::endl;
969 std::cout <<
"HitEndTick: " << lastTick+roiFirstBinTick << std::endl;
970 std::cout <<
"HitWidthTicks: " << peakWidth << std::endl;
971 std::cout <<
"HitMeanTick: " << peakMeanTrue+roiFirstBinTick <<
" +- " << peakMeanErr << std::endl;
972 std::cout <<
"HitAmplitude [ADC]: " << peakAmpTrue <<
" +- " << peakAmpErr << std::endl;
973 std::cout <<
"HitIntegral [ADC*ticks]: " << charge <<
" +- " << chargeErr << std::endl;
974 std::cout <<
"HitADCSum [ADC*ticks]: " << sumADC << std::endl;
975 std::cout <<
"HitMultiplicity: " << nExponentialsForFit << std::endl;
976 std::cout <<
"HitIndex in group: " << hitIdx << std::endl;
977 std::cout <<
"Hitchi2/ndf: " << chi2PerNDF << std::endl;
978 std::cout <<
"HitNDF: " << NDF << std::endl;
983 std::array<float, 4> fitParams;
984 fitParams[0] = peakMean+roiFirstBinTick;
985 fitParams[1] = peakTau1;
986 fitParams[2] = peakTau2;
987 fitParams[3] = peakAmp;
991 firstTick = lastTick+1;
996 fChi2->Fill(chi2PerNDF);
1017 std::vector<std::tuple<int,int,int>>& timeValsVec,
1019 int firstTick)
const 1022 if (std::distance(startItr,stopItr) > 4)
1025 auto maxItr = std::max_element(startItr, stopItr);
1027 float maxValue = *maxItr;
1028 int maxTime = std::distance(startItr,maxItr);
1030 if (maxValue >= PeakMin)
1033 auto firstItr = std::distance(startItr,maxItr) > 2 ? maxItr - 1 : startItr;
1034 bool PeakStartIsHere =
true;
1036 while(firstItr != startItr)
1039 PeakStartIsHere =
true;
1042 if( *firstItr >= *(firstItr-i) )
1044 PeakStartIsHere =
false;
1049 if (*firstItr <= 0 || PeakStartIsHere)
break;
1053 int firstTime = std::distance(startItr,firstItr);
1059 auto lastItr = std::distance(maxItr,stopItr) > 2 ? maxItr + 1 : stopItr - 1;
1060 bool PeakEndIsHere =
true;
1062 while(lastItr != stopItr)
1065 PeakEndIsHere =
true;
1068 if( *lastItr >= *(lastItr+i) )
1070 PeakEndIsHere =
false;
1074 if (*lastItr <= 0 || PeakEndIsHere)
break;
1078 int lastTime = std::distance(startItr,lastItr);
1081 timeValsVec.push_back(std::make_tuple(firstTick+firstTime,firstTick+maxTime,firstTick+lastTime));
1084 findCandidatePeaks(lastItr + 1, stopItr, timeValsVec, PeakMin, firstTick + std::distance(startItr,lastItr + 1));
1100 auto timeValsVecItr = timeValsVec.begin();
1101 unsigned int PeaksInThisMergedPeak = 0;
1103 while(timeValsVecItr != timeValsVec.end())
1108 auto& timeVal = *timeValsVecItr++;
1109 int startT = std::get<0>(timeVal);
1110 int maxT = std::get<1>(timeVal);
1111 int endT = std::get<2>(timeVal);
1112 int widT = endT - startT;
1113 int FinalStartT=startT;
1118 peakVals.emplace_back(maxT,widT,startT,endT);
1122 bool checkNextHit = timeValsVecItr != timeValsVec.end();
1128 int NextStartT = std::get<0>(*timeValsVecItr);
1130 double MinADC = signalVec[endT];
1131 for(
int i = endT; i <= NextStartT; i++)
1133 if(signalVec[i]<MinADC)
1135 MinADC = signalVec[i];
1142 int CurrentStartT=startT;
1143 int CurrentMaxT=maxT;
1144 int CurrentEndT=endT;
1147 timeVal = *timeValsVecItr++;
1148 int NextMaxT = std::get<1>(timeVal);
1149 int NextEndT = std::get<2>(timeVal);
1150 int NextWidT = NextEndT - NextStartT;
1155 int CurrentSumADC = 0;
1156 for(
int i = CurrentStartT; i<= CurrentEndT; i++)
1158 CurrentSumADC+=signalVec[i];
1162 for (
int i = NextStartT; i<= NextEndT; i++)
1164 NextSumADC+=signalVec[i];
1173 startT=CurrentStartT;
1176 peakVals.pop_back();
1177 peakVals.emplace_back(maxT,widT,startT,endT);
1182 startT=CurrentStartT;
1185 peakVals.pop_back();
1186 peakVals.emplace_back(maxT,widT,startT,endT);
1194 peakVals.emplace_back(maxT,widT,startT,endT);
1195 PeaksInThisMergedPeak++;
1204 peakVals.emplace_back(maxT,widT,startT,endT);
1205 PeaksInThisMergedPeak++;
1207 checkNextHit = timeValsVecItr != timeValsVec.end();
1211 checkNextHit =
false;
1212 PeaksInThisMergedPeak = 0;
1217 mergedVec.emplace_back(FinalStartT, FinalEndT, peakVals, NFluctuations);
1230 int NFluctuations=0;
1232 for(
int j = peakMean-1; j >= peakStart; j--)
1234 if(fsignalVec[j] < 5)
break;
1236 if(fsignalVec[j] > fsignalVec[j+1])
1242 for(
int j = peakMean+1; j <= peakEnd; j++)
1244 if(fsignalVec[j] < 5)
break;
1246 if(fsignalVec[j] > fsignalVec[j-1])
1252 return NFluctuations;
1263 double& fchi2PerNDF,
1267 int size = fEndTime - fStartTime + 1;
1268 int NPeaks = fPeakVals.size();
1273 if(fEndTime - fStartTime < 0){size = 0;}
1276 TH1F hitSignal(
"hitSignal",
"",
std::max(size,1),fStartTime,fEndTime+1);
1282 for(
int i = fStartTime; i < fEndTime+1; i++)
1284 hitSignal.Fill(i,fSignalVector[i]);
1285 hitSignal.SetBinError(i,0.288675);
1297 TF1 Exponentials(
"Exponentials",eqn.c_str(),fStartTime,fEndTime+1);
1301 std::cout << std::endl;
1302 std::cout <<
"--- Preparing fit ---" << std::endl;
1303 std::cout <<
"--- Lower limits, seed, upper limit:" << std::endl;
1308 Exponentials.SetParameter(0, 0.5);
1309 Exponentials.SetParameter(1, 0.5);
1315 double peakMeanShift=2;
1316 double peakMeanSeed=0;
1317 double peakMeanRangeLow=0;
1318 double peakMeanRangeHi=0;
1322 for(
int i = 0; i < NPeaks; i++)
1324 peakMean = std::get<0>(fPeakVals.at(i));
1325 peakStart = std::get<2>(fPeakVals.at(i));
1326 peakEnd = std::get<3>(fPeakVals.at(i));
1327 peakMeanSeed=peakMean-peakMeanShift;
1330 amplitude = fSignalVector[peakMean];
1332 Exponentials.SetParameter(2*(i+1), 1.65*amplitude);
1333 Exponentials.SetParLimits(2*(i+1), 0.3*1.65*amplitude, 2*1.65*amplitude);
1334 Exponentials.SetParameter(2*(i+1)+1, peakMeanSeed);
1338 Exponentials.SetParLimits(2*(i+1)+1, peakMeanRangeLow, peakMeanRangeHi);
1340 else if(NPeaks >= 2 && i == 0)
1342 double HalfDistanceToNextMean = 0.5*(std::get<0>(fPeakVals.at(i+1)) - peakMean);
1343 Exponentials.SetParLimits( 2*(i+1)+1, peakMeanRangeLow,
std::min(peakMeanRangeHi, peakMeanSeed+HalfDistanceToNextMean) );
1345 else if(NPeaks >= 2 && i == NPeaks-1)
1347 double HalfDistanceToPrevMean = 0.5*(peakMean - std::get<0>(fPeakVals.at(i-1)));
1348 Exponentials.SetParLimits(2*(i+1)+1,
std::max(peakMeanRangeLow, peakMeanSeed-HalfDistanceToPrevMean), peakMeanRangeHi );
1352 double HalfDistanceToNextMean = 0.5*(std::get<0>(fPeakVals.at(i+1)) - peakMean);
1353 double HalfDistanceToPrevMean = 0.5*(peakMean - std::get<0>(fPeakVals.at(i-1)));
1354 Exponentials.SetParLimits(2*(i+1)+1,
std::max(peakMeanRangeLow, peakMeanSeed-HalfDistanceToPrevMean),
std::min(peakMeanRangeHi, peakMeanSeed+HalfDistanceToNextMean) );
1359 double t0low, t0high;
1360 Exponentials.GetParLimits(2*(i+1)+1, t0low, t0high);
1361 std::cout <<
"Peak #" << i <<
": A [ADC] = " << 0.3*1.65*amplitude <<
" , " << 1.65*amplitude <<
" , " << 2*1.65*amplitude << std::endl;
1362 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << t0low <<
" , " << peakMeanSeed <<
" , " << t0high << std::endl;
1371 double peakMeanShift=2;
1372 double peakMeanSeed=0;
1373 double peakMeanRangeLow=0;
1374 double peakMeanRangeHi=0;
1379 for(
int i = 0; i < NPeaks; i++)
1381 Exponentials.SetParameter(4*i, 0.5);
1382 Exponentials.SetParameter(4*i+1, 0.5);
1386 peakMean = std::get<0>(fPeakVals.at(i));
1387 peakStart = std::get<2>(fPeakVals.at(i));
1388 peakEnd = std::get<3>(fPeakVals.at(i));
1389 peakMeanSeed=peakMean-peakMeanShift;
1392 amplitude = fSignalVector[peakMean];
1394 Exponentials.SetParameter(4*i+2, 1.65*amplitude);
1395 Exponentials.SetParLimits(4*i+2, 0.3*1.65*amplitude, 2*1.65*amplitude);
1396 Exponentials.SetParameter(4*i+3, peakMeanSeed);
1400 Exponentials.SetParLimits(4*i+3, peakMeanRangeLow, peakMeanRangeHi);
1402 else if(NPeaks >= 2 && i == 0)
1404 double HalfDistanceToNextMean = 0.5*(std::get<0>(fPeakVals.at(i+1)) - peakMean);
1405 Exponentials.SetParLimits( 4*i+3, peakMeanRangeLow,
std::min(peakMeanRangeHi, peakMeanSeed+HalfDistanceToNextMean) );
1407 else if(NPeaks >= 2 && i == NPeaks-1)
1409 double HalfDistanceToPrevMean = 0.5*(peakMean - std::get<0>(fPeakVals.at(i-1)));
1410 Exponentials.SetParLimits(4*i+3,
std::max(peakMeanRangeLow, peakMeanSeed-HalfDistanceToPrevMean), peakMeanRangeHi );
1414 double HalfDistanceToNextMean = 0.5*(std::get<0>(fPeakVals.at(i+1)) - peakMean);
1415 double HalfDistanceToPrevMean = 0.5*(peakMean - std::get<0>(fPeakVals.at(i-1)));
1416 Exponentials.SetParLimits(4*i+3,
std::max(peakMeanRangeLow, peakMeanSeed-HalfDistanceToPrevMean),
std::min(peakMeanRangeHi, peakMeanSeed+HalfDistanceToNextMean) );
1421 double t0low, t0high;
1422 Exponentials.GetParLimits(4*i+3, t0low, t0high);
1423 std::cout <<
"Peak #" << i <<
": A [ADC] = " << 0.3*1.65*amplitude <<
" , " << 1.65*amplitude <<
" , " << 2*1.65*amplitude << std::endl;
1424 std::cout <<
"Peak #" << i <<
": t0 [ticks] = " << t0low <<
" , " << peakMeanSeed <<
" , " << t0high << std::endl;
1434 { hitSignal.Fit(&Exponentials,
"QNRWM",
"", fStartTime, fEndTime+1);}
1436 {
mf::LogWarning(
"DPRawHitFinder") <<
"Fitter failed finding a hit";}
1441 fchi2PerNDF = (Exponentials.GetChisquare() / Exponentials.GetNDF());
1442 fNDF = Exponentials.GetNDF();
1446 fparamVec.emplace_back(Exponentials.GetParameter(0),Exponentials.GetParError(0));
1447 fparamVec.emplace_back(Exponentials.GetParameter(1),Exponentials.GetParError(1));
1449 for(
int i = 0; i < NPeaks; i++)
1451 fparamVec.emplace_back(Exponentials.GetParameter(2*(i+1)),Exponentials.GetParError(2*(i+1)));
1452 fparamVec.emplace_back(Exponentials.GetParameter(2*(i+1)+1),Exponentials.GetParError(2*(i+1)+1));
1457 for(
int i = 0; i < NPeaks; i++)
1459 fparamVec.emplace_back(Exponentials.GetParameter(4*i),Exponentials.GetParError(4*i));
1460 fparamVec.emplace_back(Exponentials.GetParameter(4*i+1),Exponentials.GetParError(4*i+1));
1461 fparamVec.emplace_back(Exponentials.GetParameter(4*i+2),Exponentials.GetParError(4*i+2));
1462 fparamVec.emplace_back(Exponentials.GetParameter(4*i+3),Exponentials.GetParError(4*i+3));
1465 Exponentials.Delete();
1485 TF1 Exponentials(
"Exponentials",eqn.c_str(),fStartTime,fEndTime+1);
1487 for(
size_t i=0; i < fparamVec.size(); i++)
1489 Exponentials.SetParameter(i, fparamVec[i].first);
1495 double Chi2PerNDFPeak;
1496 double MaxPosDeviation;
1497 double MaxNegDeviation;
1498 int BinMaxPosDeviation;
1499 int BinMaxNegDeviation;
1500 for(
int i = 0; i < fNPeaks; i++)
1502 Chi2PerNDFPeak = 0.;
1505 BinMaxPosDeviation=0;
1506 BinMaxNegDeviation=0;
1508 for(
int j = std::get<2>(fpeakVals.at(i)); j < std::get<3>(fpeakVals.at(i))+1; j++)
1510 if( (Exponentials(j+0.5)-fSignalVector[j]) > MaxPosDeviation && j != std::get<0>(fpeakVals.at(i)) )
1512 MaxPosDeviation = Exponentials(j+0.5)-fSignalVector[j];
1513 BinMaxPosDeviation = j;
1515 if( (Exponentials(j+0.5)-fSignalVector[j]) < MaxNegDeviation && j != std::get<0>(fpeakVals.at(i)) )
1517 MaxNegDeviation = Exponentials(j+0.5)-fSignalVector[j];
1518 BinMaxNegDeviation = j;
1520 Chi2PerNDFPeak += pow((Exponentials(j+0.5)-fSignalVector[j])/sqrt(fSignalVector[j]),2);
1523 if(BinMaxNegDeviation != 0)
1525 Chi2PerNDFPeak /=
static_cast<double>((std::get<3>(fpeakVals.at(i))-std::get<2>(fpeakVals.at(i))));
1526 fPeakDev.emplace_back(Chi2PerNDFPeak,i,BinMaxNegDeviation,BinMaxPosDeviation);
1530 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);} );
1531 Exponentials.Delete();
1537 std::string feqn =
"";
1538 std::stringstream numConv;
1542 for(
int i = 0; i < fNPeaks; i++)
1544 feqn.append(
"+( [");
1547 feqn.append(numConv.str());
1548 feqn.append(
"] * exp(0.4*(x-[");
1550 numConv << 2*(i+1)+1;
1551 feqn.append(numConv.str());
1552 feqn.append(
"])/[");
1555 feqn.append(numConv.str());
1556 feqn.append(
"]) / ( 1 + exp(0.4*(x-[");
1558 numConv << 2*(i+1)+1;
1559 feqn.append(numConv.str());
1560 feqn.append(
"])/[");
1563 feqn.append(numConv.str());
1564 feqn.append(
"]) ) )");
1569 for(
int i = 0; i < fNPeaks; i++)
1571 feqn.append(
"+( [");
1574 feqn.append(numConv.str());
1575 feqn.append(
"] * exp(0.4*(x-[");
1578 feqn.append(numConv.str());
1579 feqn.append(
"])/[");
1582 feqn.append(numConv.str());
1583 feqn.append(
"]) / ( 1 + exp(0.4*(x-[");
1585 numConv << 2*(i+1)+1;
1586 feqn.append(numConv.str());
1587 feqn.append(
"])/[");
1590 feqn.append(numConv.str());
1591 feqn.append(
"]) ) )");
1602 int PeakNumberWithNewPeak = std::get<1>(fPeakDevCand);
1603 int NewPeakMax = std::get<2>(fPeakDevCand);
1604 int OldPeakMax = std::get<0>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1605 int OldPeakOldStart = std::get<2>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1606 int OldPeakOldEnd = std::get<3>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1610 int OldPeakNewStart=0;
1611 int OldPeakNewEnd=0;
1612 int DistanceBwOldAndNewPeak=0;
1614 if(NewPeakMax<OldPeakMax)
1616 NewPeakStart = OldPeakOldStart;
1617 OldPeakNewEnd = OldPeakOldEnd;
1618 DistanceBwOldAndNewPeak = OldPeakMax - NewPeakMax;
1619 NewPeakEnd = NewPeakMax+0.5*(DistanceBwOldAndNewPeak-(DistanceBwOldAndNewPeak%2));
1620 if(DistanceBwOldAndNewPeak%2 == 0) NewPeakEnd -= 1;
1621 OldPeakNewStart = NewPeakEnd+1;
1623 else if(OldPeakMax<NewPeakMax)
1625 NewPeakEnd = OldPeakOldEnd;
1626 OldPeakNewStart = OldPeakOldStart;
1627 DistanceBwOldAndNewPeak = NewPeakMax - OldPeakMax;
1628 OldPeakNewEnd = OldPeakMax+0.5*(DistanceBwOldAndNewPeak-(DistanceBwOldAndNewPeak%2));
1629 if(DistanceBwOldAndNewPeak%2 == 0) OldPeakNewEnd -= 1;
1630 NewPeakStart = OldPeakNewEnd+1;
1632 else if(OldPeakMax==NewPeakMax){
return;}
1634 fpeakValsTemp.at(PeakNumberWithNewPeak) = std::make_tuple(OldPeakMax,0,OldPeakNewStart,OldPeakNewEnd);
1635 fpeakValsTemp.emplace_back(NewPeakMax,0,NewPeakStart,NewPeakEnd);
1636 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);} );
1646 int PeakNumberWithNewPeak = std::get<1>(fPeakDevCand);
1647 int OldPeakOldStart = std::get<2>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1648 int OldPeakOldEnd = std::get<3>(fpeakValsTemp.at(PeakNumberWithNewPeak));
1649 int WidthOldPeakOld = OldPeakOldEnd - OldPeakOldStart;
1651 if(WidthOldPeakOld<3) {
return;}
1654 int NewPeakStart = 0;
1656 int OldPeakNewMax = 0;
1657 int OldPeakNewStart = 0;
1658 int OldPeakNewEnd = 0;
1661 OldPeakNewStart = OldPeakOldStart;
1662 NewPeakEnd = OldPeakOldEnd;
1664 OldPeakNewEnd = OldPeakNewStart + 0.5*(WidthOldPeakOld + (WidthOldPeakOld%2));
1665 NewPeakStart = OldPeakNewEnd+1;
1667 int WidthOldPeakNew = OldPeakNewEnd-OldPeakNewStart;
1668 int WidthNewPeak = NewPeakEnd-NewPeakStart;
1670 OldPeakNewMax = OldPeakNewStart + 0.5*(WidthOldPeakNew - (WidthOldPeakNew%2));
1671 NewPeakMax = NewPeakStart + 0.5*(WidthNewPeak - (WidthNewPeak%2));
1673 fpeakValsTemp.at(PeakNumberWithNewPeak) = std::make_tuple(OldPeakNewMax,0,OldPeakNewStart,OldPeakNewEnd);
1674 fpeakValsTemp.emplace_back(NewPeakMax,0,NewPeakStart,NewPeakEnd);
1675 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);} );
1687 double fPeakMeanTrue)
1689 double MaxValue = ( fPeakAmp * exp(0.4*(fPeakMeanTrue-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(fPeakMeanTrue-fPeakMean)/fPeakTau2) );
1690 double FuncValue = 0.;
1691 double HalfMaxLeftTime = 0.;
1692 double HalfMaxRightTime = 0.;
1696 for(
double x = fPeakMeanTrue;
x > fStartTime-1000.;
x--)
1698 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1699 if( FuncValue < 0.5*MaxValue )
1701 HalfMaxLeftTime =
x;
1706 for(
double x = fPeakMeanTrue;
x < fEndTime+1000.;
x++)
1708 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1709 if( FuncValue < 0.5*MaxValue )
1711 HalfMaxRightTime =
x;
1717 for(
double x = HalfMaxLeftTime+1;
x > HalfMaxLeftTime;
x-=(1/ReBin))
1719 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1720 if( FuncValue < 0.5*MaxValue )
1722 HalfMaxLeftTime =
x;
1727 for(
double x = HalfMaxRightTime-1;
x < HalfMaxRightTime;
x+=(1/ReBin))
1729 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1730 if( FuncValue < 0.5*MaxValue )
1732 HalfMaxRightTime =
x;
1738 for(
double x = HalfMaxLeftTime+1/ReBin;
x > HalfMaxLeftTime;
x-=1/(ReBin*ReBin))
1740 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1741 if( FuncValue < 0.5*MaxValue )
1743 HalfMaxLeftTime =
x;
1748 for(
double x = HalfMaxRightTime-1/ReBin;
x < HalfMaxRightTime;
x+=1/(ReBin*ReBin))
1750 FuncValue = ( fPeakAmp * exp(0.4*(
x-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x-fPeakMean)/fPeakTau2) );
1751 if( FuncValue < 0.5*MaxValue )
1753 HalfMaxRightTime =
x;
1758 return HalfMaxRightTime-HalfMaxLeftTime;
1766 double fChargeNormFactor,
1767 double fPeakMeanTrue)
1770 double ChargeSum = 0.;
1774 bool ChargeBigEnough=
true;
1775 for(
double x = fPeakMeanTrue - 1/ReBin; ChargeBigEnough &&
x > fPeakMeanTrue-1000.;
x-=1.)
1777 for(
double i=0.; i > -1.; i-=(1/ReBin))
1779 Charge = ( fPeakAmp * exp(0.4*(
x+i-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x+i-fPeakMean)/fPeakTau2) );
1780 ChargeSum += Charge;
1782 if(Charge < 0.01) ChargeBigEnough =
false;
1785 ChargeBigEnough=
true;
1786 for(
double x = fPeakMeanTrue; ChargeBigEnough &&
x < fPeakMeanTrue+1000.;
x+=1.)
1788 for(
double i=0.; i < 1.; i+=(1/ReBin))
1790 Charge = ( fPeakAmp * exp(0.4*(
x+i-fPeakMean)/fPeakTau1)) / ( 1 + exp(0.4*(
x+i-fPeakMean)/fPeakTau2) );
1791 ChargeSum += Charge;
1793 if(Charge < 0.01) ChargeBigEnough =
false;
1797 return ChargeSum*fChargeNormFactor/ReBin;
1802 std::vector<float>& outputVec,
1803 size_t binsToAverage)
const 1805 size_t halfBinsToAverage(binsToAverage/2);
1807 float runningSum(0.);
1809 for(
size_t idx = 0; idx < halfBinsToAverage; idx++) runningSum += inputVec[idx];
1811 outputVec.resize(inputVec.size());
1817 size_t startOffset = std::distance(inputVec.begin(),inputItr);
1818 size_t stopOffset = std::distance(inputItr,inputVec.end());
1819 size_t count =
std::min(2 * halfBinsToAverage,
std::min(startOffset + halfBinsToAverage + 1, halfBinsToAverage + stopOffset - 1));
1821 if (startOffset >= halfBinsToAverage) runningSum -= *(inputItr - halfBinsToAverage);
1822 if (stopOffset > halfBinsToAverage) runningSum += *(inputItr + halfBinsToAverage);
1824 *outputVecItr++ = runningSum / float(count);
1832 std::vector<float>& outputVec,
1833 size_t nBinsToCombine)
const 1835 size_t nNewBins = inputVec.size() / nBinsToCombine;
1837 if (inputVec.size() % nBinsToCombine > 0) nNewBins++;
1839 outputVec.resize(nNewBins, 0.);
1841 size_t outputBin = 0;
1843 for(
size_t inputIdx = 0; inputIdx < inputVec.size();)
1845 outputVec[outputBin] += inputVec[inputIdx++];
1847 if (inputIdx % nBinsToCombine == 0) outputBin++;
1849 if (outputBin > outputVec.size())
1851 std::cout <<
"***** DISASTER!!! ****** outputBin: " << outputBin <<
", inputIdx = " << inputIdx << std::endl;
1863 #endif // DPRawHitFinder_H
void findCandidatePeaks(std::vector< float >::const_iterator startItr, std::vector< float >::const_iterator stopItr, TimeValsVec &timeValsVec, float &PeakMin, int firstTick) const
int fTicksToStopPeakFinder
Encapsulate the construction of a single cyostat.
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.
std::vector< std::tuple< int, int, PeakTimeWidVec, int >> MergedTimeWidVec
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)
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.
static void declare_products(ModuleType &producer, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
void SplitPeak(std::tuple< double, int, int, int > fPeakDevCand, PeakTimeWidVec &fpeakValsTemp)
double fChi2NDFMaxFactorMultiHits
DPRawHitFinder(fhicl::ParameterSet const &pset)
void addVector(FVector_ID id, std::array< float, N > const &values)
int TDCtick_t
Type representing a TDC tick.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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.
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
void reconfigure(fhicl::ParameterSet const &p)
T get(std::string const &key) const
std::string CreateFitFunction(int fNPeaks, bool fSameShape)
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.
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
T * make(ARGS...args) const
std::vector< std::tuple< int, int, int >> TimeValsVec
Encapsulate the construction of a single detector plane.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
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.
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
Encapsulate the construction of a single detector plane.
bool operator()(int s, std::tuple< int, int, int, int > p) const