1 #ifndef DECONVGAUSHFDUNE10KT_H 2 #define DECONVGAUSHFDUNE10KT_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" 172 if( pos!=std::string::npos ) {
211 int transformSize = fFFT->
FFTSize();
218 art::TFileDirectory dirc = tfs->mkdir(
"DeconvolutionKernels",
"DeconvolutionKernels");
226 TH1::AddDirectory(kFALSE);
232 TF1 *
hit =
new TF1(
"hit",
"gaus",0,3200);
253 double threshold = 0.;
254 double fitWidth = 0.;
255 double minWidth = 0.;
259 std::vector<int> startTimes;
260 std::vector<int> maxTimes;
261 std::vector<int> endTimes;
263 int minTimeHolder = 0;
269 bool maxFound =
false;
270 std::stringstream numConv;
276 if (
fSpillName.size()>0) digitVecHandle = evt.
getHandle< std::vector<raw::RawDigit> >(itag1);
279 if (!digitVecHandle->size())
return;
280 mf::LogInfo(
"DeconvGausHFDUNE10kt") <<
"DeconvGausHFDUNE10kt:: digitVecHandle size is " << digitVecHandle->size();
287 <<
"CalGausHFDUNE only supports zero-suppressed raw digit input!";
292 unsigned int dataSize = digitVec0->
Samples();
299 std::vector<float> holder;
300 std::vector<short> rawadc(transformSize);
301 std::vector<TComplex> freqHolder(transformSize+1);
306 for(
size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){
315 holder.resize(transformSize);
321 for(bin = 0; bin < dataSize; ++
bin)
329 holder.resize(dataSize,1
e-5);
337 for(bin = 0; bin < holder.size(); ++
bin) holder[bin]-=average;
367 view = geom->
View(channel);
376 std::vector<float> signal(holder);
398 for(timeIter = signal.begin();timeIter+2<signal.end();timeIter++){
405 if(*timeIter > *(timeIter+1) && *(timeIter+1) < *(timeIter+2)){
409 endTimes.push_back(time+1);
412 minTimeHolder = time+2;
414 else minTimeHolder = time+1;
426 else if(*timeIter < *(timeIter+1) && *(timeIter+1) > *(timeIter+2) && *(timeIter+1) > threshold){
428 maxTimes.push_back(time+1);
429 startTimes.push_back(minTimeHolder);
440 while( maxTimes.size() > endTimes.size() ){
441 endTimes.push_back(signal.size()-1);
448 if( startTimes.size() == 0 ){
470 double minPeakHeight(0);
492 std::vector<double> hitSig;
497 while( hitIndex < (
signed)startTimes.size() ) {
504 minPeakHeight = signal[maxTimes[hitIndex]];
511 while(numHits <
fMaxMultiHit && numHits+hitIndex < (
signed)endTimes.size() &&
512 signal[endTimes[hitIndex+numHits-1]] >threshold/2.0 &&
513 startTimes[hitIndex+numHits] - endTimes[hitIndex+numHits-1] < 2){
514 if(signal[maxTimes[hitIndex+numHits]] < minPeakHeight){
515 minPeakHeight=signal[maxTimes[hitIndex+numHits]];
529 startT=startTimes[hitIndex];
530 while(signal[(
int)startT] < minPeakHeight/2.0) {startT++;}
536 endT=endTimes[hitIndex+numHits-1];
537 while(signal[(
int)endT] <minPeakHeight/2.0) {endT--;}
544 size = (
int)(endT-startT);
551 if(size < 0){size = 0;}
555 TH1D hitSignal(
"hitSignal",
"",size,startT,endT);
557 for(
int i = (
int)startT; i < (
int)endT; i++){
561 hitSignal.Fill(i,signal[i]);
575 for(
int i = 3; i < numHits*3; i+=3){
576 eqn.append(
"+gaus(");
579 eqn.append(numConv.str());
586 TF1 Gaus(
"Gaus",eqn.c_str(),0,
size);
593 for(
int i = 0; i < numHits; ++i){
600 amplitude = signal[maxTimes[hitIndex+i]];
601 Gaus.SetParameter(3*i,amplitude);
602 Gaus.SetParameter(1+3*i, maxTimes[hitIndex+i]);
603 Gaus.SetParameter(2+3*i, fitWidth);
604 Gaus.SetParLimits(3*i, 0.0, 3.0*amplitude);
605 Gaus.SetParLimits(1+3*i, startT , endT);
606 Gaus.SetParLimits(2+3*i, 0.0, 10.0*fitWidth);
615 Gaus.SetParameters(signal[maxTimes[hitIndex]],maxTimes[hitIndex],fitWidth);
616 Gaus.SetParLimits(0,0.0,1.5*signal[maxTimes[hitIndex]]);
617 Gaus.SetParLimits(1, startT , endT);
618 Gaus.SetParLimits(2,0.0,10.0*fitWidth);
626 hitSignal.Fit(&Gaus,
"QNRW",
"", startT, endT);
629 for(
int hitNumber = 0; hitNumber < numHits; ++hitNumber){
637 if(Gaus.GetParameter(3*hitNumber) > threshold/2.0 &&
638 Gaus.GetParameter(3*hitNumber+2) > minWidth){
639 StartIime = Gaus.GetParameter(3*hitNumber+1) - Gaus.GetParameter(3*hitNumber+2);
641 EndTime = Gaus.GetParameter(3*hitNumber+1) + Gaus.GetParameter(3*hitNumber+2);
644 RMS = Gaus.GetParameter(3*hitNumber+2);
659 for(
int sigPos = 0; sigPos<
size; sigPos++){
661 hitSig[sigPos] = Gaus.GetParameter(3*hitNumber)*TMath::Gaus(sigPos+startT,Gaus.GetParameter(3*hitNumber+1), Gaus.GetParameter(3*hitNumber+2));
662 totSig+=hitSig[(
int)sigPos];
668 totSig = std::sqrt(2*TMath::Pi())*Gaus.GetParameter(3*hitNumber)*Gaus.GetParameter(3*hitNumber+2)/
fAreaNorms[(size_t)sigType];
675 ChargeError = TMath::Sqrt(TMath::Pi())*(Gaus.GetParError(3*hitNumber+0)*Gaus.GetParameter(3*hitNumber+2)+
676 Gaus.GetParError(3*hitNumber+2)*Gaus.GetParameter(3*hitNumber+0));
677 Amp = Gaus.GetParameter(3*hitNumber);
678 AmpError = Gaus.GetParError(3*hitNumber);
688 hit->SetParameters(
Amp,
MeanPosition, Gaus.GetParameter(3*hitNumber+2));
689 hit->FixParameter(0,
Amp);
702 hitSignal.Fit(hit,
"QNRLLi",
"", TempStartTime, TempEndTime);
705 FitGoodnes = hit->GetChisquare() / hit->GetNDF();
708 StartTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
709 (hit->GetParError(2)*hit->GetParError(2)));
711 EndTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
712 (hit->GetParError(2)*hit->GetParError(2)));
723 std::vector<geo::WireID> wids = geom->
ChannelToWire(channel);
738 (signal.begin() + TempStartTime, signal.begin() + TempEndTime, 0.),
783 #endif // DECONVGAUSHFDUNE10KT_H float GetPedestal() const
void Deconvolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
double StartIime
maximum Chisquared / NDF allowed for a hit to be saved
std::vector< double > fAreaNorms
factors for converting area to same units as peak height
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
int fMaxMultiHit
maximum hits for multi fit
double fColMinWidth
Minimum collection hit width.
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)
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.
DeconvGausHFDUNE10kt(fhicl::ParameterSet const &pset)
std::string fCalDataModuleLabel
double fColWidth
Initial width for collection fit.
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.
Zero Suppression algorithm.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
double fMinSigInd
Induction signal height threshold.
int fAreaMethod
Type of area calculation.
Helper functions to create a hit.
A class handling a collection of hits and its associations.
#define DEFINE_ART_MODULE(klass)
double fMinSigCol
Collection signal height threshold.
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
T get(std::string const &key) const
double fIndMinWidth
Minimum induction hit width.
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.
std::string fDigitModuleLabel
constants
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.
virtual ~DeconvGausHFDUNE10kt()
void reconfigure(fhicl::ParameterSet const &p)
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
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.
QTextStream & bin(QTextStream &s)
void produce(art::Event &evt)
2D representation of charge deposited in the TDC/wire plane
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Signal from collection planes.
int fPostsample
number of postsample bins