1 #ifndef DECONVGAUSHFDUNE35T_H 2 #define DECONVGAUSHFDUNE35T_H 29 #include "art_root_io/TFileService.h" 30 #include "art_root_io/TFileDirectory.h" 33 #include "cetlib_except/exception.h" 48 #include "TDecompSVD.h" 176 if( pos!=std::string::npos ) {
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){
322 holder.resize(transformSize);
328 for(bin = 0; bin < dataSize; ++
bin)
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--;}
551 size = (
int)(endT-startT);
558 if(size < 0){size = 0;}
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.),
823 #endif // DECONVGAUSHFDUNE35T_H
float GetPedestal() const
void Deconvolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
void produce(art::Event &evt)
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
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
EDProducer(fhicl::ParameterSet const &pset)
int fMaxMultiHit
maximum hits for multi fit
ChannelID_t Channel() const
DAQ channel this raw data was read from.
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.
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
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
int TDCtick_t
Type representing a TDC tick.
void reconfigure(fhicl::ParameterSet const &p)
Zero Suppression algorithm.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Helper functions to create a hit.
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.
#define DEFINE_ART_MODULE(klass)
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
T get(std::string const &key) const
double fIndMinWidth
Minimum induction hit width.
int fPostsample
number of postsample bins
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.
creation of calibrated signals on wires
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
void put_into(art::Event &)
Moves the data into an event.
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
double fMinSigInd
Induction signal height threshold.
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
double fIndWidth
Initial width for induction fit.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Declaration of signal hit object.
DeconvGausHFDUNE35t(fhicl::ParameterSet const &pset)
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
virtual ~DeconvGausHFDUNE35t()
std::string fCalDataModuleLabel
double fMinSigCol
Collection signal height threshold.
Signal from collection planes.