218 int transformSize = fFFT->
FFTSize();
225 art::TFileDirectory dirc = tfs->mkdir(
"DeconvolutionKernels",
"DeconvolutionKernels");
233 TH1::AddDirectory(kFALSE);
239 TF1 *
hit =
new TF1(
"hit",
"gaus",0,3200);
260 double threshold = 0.;
261 double fitWidth = 0.;
262 double minWidth = 0.;
266 std::vector<int> startTimes;
267 std::vector<int> maxTimes;
268 std::vector<int> endTimes;
270 int minTimeHolder = 0;
276 bool maxFound =
false;
277 std::stringstream numConv;
283 if (
fSpillName.size()>0) digitVecHandle = evt.
getHandle< std::vector<raw::RawDigit> >(itag1);
286 if (!digitVecHandle->size())
return;
287 mf::LogInfo(
"DeconvGausHFDUNE35t") <<
"DeconvGausHFDUNE35t:: digitVecHandle size is " << digitVecHandle->size();
292 unsigned int dataSize = digitVec0->Samples();
296 <<
"CalGausHFDUNE only supports zero-suppressed raw digit input!";
306 std::vector<float> holder;
307 std::vector<short> rawadc(transformSize);
308 std::vector<TComplex> freqHolder(transformSize+1);
313 for(
size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){
318 channel = digitVec->Channel();
322 holder.resize(transformSize);
329 holder[
bin]=(rawadc[
bin]-digitVec->GetPedestal());
336 holder.resize(dataSize,1
e-5);
344 for(
bin = 0;
bin < holder.size(); ++
bin) holder[
bin]-=average;
374 view = geom->
View(channel);
383 std::vector<float> signal(holder);
405 for(timeIter = signal.begin();timeIter+2<signal.end();timeIter++){
412 if(*timeIter > *(timeIter+1) && *(timeIter+1) < *(timeIter+2)){
416 endTimes.push_back(time+1);
419 minTimeHolder = time+2;
421 else minTimeHolder = time+1;
433 else if(*timeIter < *(timeIter+1) && *(timeIter+1) > *(timeIter+2) && *(timeIter+1) > threshold){
435 maxTimes.push_back(time+1);
436 startTimes.push_back(minTimeHolder);
447 while( maxTimes.size() > endTimes.size() ){
448 endTimes.push_back(signal.size()-1);
455 if( startTimes.size() == 0 ){
477 double minPeakHeight(0);
499 std::vector<double> hitSig;
504 while( hitIndex < (
signed)startTimes.size() ) {
511 minPeakHeight = signal[maxTimes[hitIndex]];
518 while(numHits <
fMaxMultiHit && numHits+hitIndex < (
signed)endTimes.size() &&
519 signal[endTimes[hitIndex+numHits-1]] >threshold/2.0 &&
520 startTimes[hitIndex+numHits] - endTimes[hitIndex+numHits-1] < 2){
521 if(signal[maxTimes[hitIndex+numHits]] < minPeakHeight){
522 minPeakHeight=signal[maxTimes[hitIndex+numHits]];
536 startT=startTimes[hitIndex];
537 while(signal[(
int)startT] < minPeakHeight/2.0) {startT++;}
543 endT=endTimes[hitIndex+numHits-1];
544 while(signal[(
int)endT] <minPeakHeight/2.0) {endT--;}
562 TH1D hitSignal(
"hitSignal",
"",
size,startT,endT);
564 for(
int i = (
int)startT; i < (
int)endT; i++){
568 hitSignal.Fill(i,signal[i]);
582 for(
int i = 3; i < numHits*3; i+=3){
583 eqn.append(
"+gaus(");
586 eqn.append(numConv.str());
593 TF1 Gaus(
"Gaus",eqn.c_str(),0,
size);
600 for(
int i = 0; i < numHits; ++i){
607 amplitude = signal[maxTimes[hitIndex+i]];
608 Gaus.SetParameter(3*i,amplitude);
609 Gaus.SetParameter(1+3*i, maxTimes[hitIndex+i]);
610 Gaus.SetParameter(2+3*i, fitWidth);
611 Gaus.SetParLimits(3*i, 0.0, 3.0*amplitude);
612 Gaus.SetParLimits(1+3*i, startT , endT);
613 Gaus.SetParLimits(2+3*i, 0.0, 10.0*fitWidth);
622 Gaus.SetParameters(signal[maxTimes[hitIndex]],maxTimes[hitIndex],fitWidth);
623 Gaus.SetParLimits(0,0.0,1.5*signal[maxTimes[hitIndex]]);
624 Gaus.SetParLimits(1, startT , endT);
625 Gaus.SetParLimits(2,0.0,10.0*fitWidth);
633 hitSignal.Fit(&Gaus,
"QNRW",
"", startT, endT);
636 for(
int hitNumber = 0; hitNumber < numHits; ++hitNumber){
644 if(Gaus.GetParameter(3*hitNumber) > threshold/2.0 &&
645 Gaus.GetParameter(3*hitNumber+2) > minWidth){
646 StartIime = Gaus.GetParameter(3*hitNumber+1) - Gaus.GetParameter(3*hitNumber+2);
648 EndTime = Gaus.GetParameter(3*hitNumber+1) + Gaus.GetParameter(3*hitNumber+2);
651 RMS = Gaus.GetParameter(3*hitNumber+2);
666 for(
int sigPos = 0; sigPos<
size; sigPos++){
668 hitSig[sigPos] = Gaus.GetParameter(3*hitNumber)*TMath::Gaus(sigPos+startT,Gaus.GetParameter(3*hitNumber+1), Gaus.GetParameter(3*hitNumber+2));
669 totSig+=hitSig[(
int)sigPos];
675 totSig = std::sqrt(2*TMath::Pi())*Gaus.GetParameter(3*hitNumber)*Gaus.GetParameter(3*hitNumber+2)/
fAreaNorms[(size_t)sigType];
682 ChargeError = TMath::Sqrt(TMath::Pi())*(Gaus.GetParError(3*hitNumber+0)*Gaus.GetParameter(3*hitNumber+2)+
683 Gaus.GetParError(3*hitNumber+2)*Gaus.GetParameter(3*hitNumber+0));
684 Amp = Gaus.GetParameter(3*hitNumber);
685 AmpError = Gaus.GetParError(3*hitNumber);
695 hit->SetParameters(
Amp,
MeanPosition, Gaus.GetParameter(3*hitNumber+2));
696 hit->FixParameter(0,
Amp);
711 char outputfilename[100];
714 sprintf(outputfilename,
"/dune/data/users/jti3/fits/induction_deconvgaus_fit_%d.eps",
inductioncount);
715 TCanvas *
c1 =
new TCanvas(
"c1",
"plot");
717 gStyle->SetOptFit(1);
719 hitSignal.Fit(hit,
"QRLLi",
"", TempStartTime, TempEndTime);
721 c1->Print(outputfilename);
727 sprintf(outputfilename,
"/dune/data/users/jti3/fits/collection_deconvgaus_fit_%d.eps",
collectioncount);
728 TCanvas *c1 =
new TCanvas(
"c1",
"plot");
730 gStyle->SetOptFit(1);
732 hitSignal.Fit(hit,
"QRLLi",
"", TempStartTime, TempEndTime);
734 c1->Print(outputfilename);
740 hitSignal.Fit(hit,
"QNRLLi",
"", TempStartTime, TempEndTime);
742 else hitSignal.Fit(hit,
"QNRLLi",
"", TempStartTime, TempEndTime);
745 FitGoodnes = hit->GetChisquare() / hit->GetNDF();
748 StartTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
749 (hit->GetParError(2)*hit->GetParError(2)));
751 EndTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
752 (hit->GetParError(2)*hit->GetParError(2)));
763 std::vector<geo::WireID> wids = geom->
ChannelToWire(channel);
778 (signal.begin() + TempStartTime, signal.begin() + TempEndTime, 0.),
789 hcol.emplace_back(
std::move(hit), digitVec);
void Deconvolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
double StartIime
maximum Chisquared / NDF allowed for a hit to be saved
Handle< PROD > getHandle(SelectorBase const &) const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
bool BadChannel(uint32_t channel) const
int fMaxMultiHit
maximum hits for multi fit
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
int TDCtick_t
Type representing a TDC tick.
Zero Suppression algorithm.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
double fColWidth
Initial width for collection fit.
double fColMinWidth
Minimum collection hit width.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
A class handling a collection of hits and its associations.
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
double fIndMinWidth
Minimum induction hit width.
int fPostsample
number of postsample bins
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Detector simulation of raw signals on wires.
double fMinSigInd
Induction signal height threshold.
double fIndWidth
Initial width for induction fit.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
QTextStream & bin(QTextStream &s)
std::string fDigitModuleLabel
constants
2D representation of charge deposited in the TDC/wire plane
unsigned int ChannelID_t
Type representing the ID of a readout channel.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
int fAreaMethod
Type of area calculation.
std::vector< double > fAreaNorms
factors for converting area to same units as peak height
double fMinSigCol
Collection signal height threshold.
Signal from collection planes.