1 #ifndef CALGAUSHFDUNE10KT_H 2 #define CALGAUSHFDUNE10KT_H 31 #include "cetlib_except/exception.h" 45 #include "TDecompSVD.h" 167 if( pos!=std::string::npos ) {
209 TH1::AddDirectory(kFALSE);
215 TF1 *
hit =
new TF1(
"hit",
"gaus",0,3200);
236 double threshold = 0.;
237 double fitWidth = 0.;
238 double minWidth = 0.;
242 std::vector<int> startTimes;
243 std::vector<int> maxTimes;
244 std::vector<int> endTimes;
246 int minTimeHolder = 0;
252 bool maxFound =
false;
253 std::stringstream numConv;
260 if (
fSpillName.size()>0) digitVecHandle = evt.
getHandle< std::vector<raw::RawDigit> >(itag1);
263 if (!digitVecHandle->size())
return;
264 mf::LogInfo(
"CalGausHFDUNE10kt") <<
"CalGausHFDUNE10kt:: digitVecHandle size is " << digitVecHandle->size();
271 <<
"CalGausHFDUNE only supports zero-suppressed raw digit input!";
280 std::vector<float> holder;
281 std::vector<float> rawadc_conv;
282 std::vector<short> rawadc;
285 for(
size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){
296 const int numberofblocks = digitVec->
ADC(1);
298 int zerosuppressedindex = numberofblocks*2 + 2;
301 for(
int i=0; i<numberofblocks; i++){
303 const int lengthofblock = digitVec->
ADC(2+numberofblocks+i);
304 rawadc.resize(lengthofblock);
305 holder.resize(lengthofblock);
306 rawadc_conv.resize(lengthofblock);
308 for (
int j=0;j<lengthofblock;j++)
310 rawadc[j] = digitVec->
ADC(zerosuppressedindex);
311 zerosuppressedindex++;
317 for(bin = 0; bin < rawadc.size(); ++
bin)
318 rawadc_conv[bin]=(rawadc[bin]-digitVec->
GetPedestal());
322 view = geom->
View(channel);
327 for(bin = 0; bin < rawadc_conv.size(); ++
bin)
328 holder[bin] = rawadc_conv[bin];
333 for(bin = 0; bin < rawadc_conv.size(); ++
bin)
334 holder[bin] = (bin>0) ? rawadc_conv[
bin] + holder[bin-1] : rawadc_conv[
bin];
363 std::vector<float> signal(holder);
385 for(timeIter = signal.begin();timeIter+2<signal.end();timeIter++){
392 if(*timeIter > *(timeIter+1) && *(timeIter+1) < *(timeIter+2)){
396 endTimes.push_back(time+1);
399 minTimeHolder = time+2;
401 else minTimeHolder = time+1;
413 else if(*timeIter < *(timeIter+1) && *(timeIter+1) > *(timeIter+2) && *(timeIter+1) > threshold){
415 maxTimes.push_back(time+1);
416 startTimes.push_back(minTimeHolder);
427 while( maxTimes.size() > endTimes.size() ){
428 endTimes.push_back(signal.size()-1);
435 if( startTimes.size() == 0 ){
457 double minPeakHeight(0);
479 std::vector<double> hitSig;
484 while( hitIndex < (
signed)startTimes.size() ) {
491 minPeakHeight = signal[maxTimes[hitIndex]];
498 while(numHits <
fMaxMultiHit && numHits+hitIndex < (
signed)endTimes.size() &&
499 signal[endTimes[hitIndex+numHits-1]] >threshold/2.0 &&
500 startTimes[hitIndex+numHits] - endTimes[hitIndex+numHits-1] < 2){
501 if(signal[maxTimes[hitIndex+numHits]] < minPeakHeight){
502 minPeakHeight=signal[maxTimes[hitIndex+numHits]];
516 startT=startTimes[hitIndex];
517 while(signal[(
int)startT] < minPeakHeight/2.0) {startT++;}
523 endT=endTimes[hitIndex+numHits-1];
524 while(signal[(
int)endT] <minPeakHeight/2.0) {endT--;}
531 size = (
int)(endT-startT);
538 if(size < 0){size = 0;}
542 TH1D hitSignal(
"hitSignal",
"",size,startT,endT);
544 for(
int i = (
int)startT; i < (
int)endT; i++){
548 hitSignal.Fill(i,signal[i]);
562 for(
int i = 3; i < numHits*3; i+=3){
563 eqn.append(
"+gaus(");
566 eqn.append(numConv.str());
573 TF1 Gaus(
"Gaus",eqn.c_str(),0,
size);
580 for(
int i = 0; i < numHits; ++i){
587 amplitude = signal[maxTimes[hitIndex+i]];
588 Gaus.SetParameter(3*i,amplitude);
589 Gaus.SetParameter(1+3*i, maxTimes[hitIndex+i]);
590 Gaus.SetParameter(2+3*i, fitWidth);
591 Gaus.SetParLimits(3*i, 0.0, 3.0*amplitude);
592 Gaus.SetParLimits(1+3*i, startT , endT);
593 Gaus.SetParLimits(2+3*i, 0.0, 10.0*fitWidth);
602 Gaus.SetParameters(signal[maxTimes[hitIndex]],maxTimes[hitIndex],fitWidth);
603 Gaus.SetParLimits(0,0.0,1.5*signal[maxTimes[hitIndex]]);
604 Gaus.SetParLimits(1, startT , endT);
605 Gaus.SetParLimits(2,0.0,10.0*fitWidth);
613 hitSignal.Fit(&Gaus,
"QNRW",
"", startT, endT);
617 for(
int hitNumber = 0; hitNumber < numHits; ++hitNumber){
625 if(Gaus.GetParameter(3*hitNumber) > threshold/2.0 &&
626 Gaus.GetParameter(3*hitNumber+2) > minWidth){
627 StartIime = Gaus.GetParameter(3*hitNumber+1) - Gaus.GetParameter(3*hitNumber+2);
629 EndTime = Gaus.GetParameter(3*hitNumber+1) + Gaus.GetParameter(3*hitNumber+2);
632 StartIime = Gaus.GetParameter(3*hitNumber+2);
647 for(
int sigPos = 0; sigPos<
size; sigPos++){
649 hitSig[sigPos] = Gaus.GetParameter(3*hitNumber)*TMath::Gaus(sigPos+startT,Gaus.GetParameter(3*hitNumber+1), Gaus.GetParameter(3*hitNumber+2));
650 totSig+=hitSig[(
int)sigPos];
656 totSig = std::sqrt(2*TMath::Pi())*Gaus.GetParameter(3*hitNumber)*Gaus.GetParameter(3*hitNumber+2)/
fAreaNorms[(size_t)sigType];
663 ChargeError = TMath::Sqrt(TMath::Pi())*(Gaus.GetParError(3*hitNumber+0)*Gaus.GetParameter(3*hitNumber+2)+
664 Gaus.GetParError(3*hitNumber+2)*Gaus.GetParameter(3*hitNumber+0));
665 Amp = Gaus.GetParameter(3*hitNumber);
666 AmpError = Gaus.GetParError(3*hitNumber);
676 hit->SetParameters(
Amp,
MeanPosition, Gaus.GetParameter(3*hitNumber+2));
677 hit->FixParameter(0,
Amp);
690 hitSignal.Fit(hit,
"QNRLLi",
"", TempStartTime, TempEndTime);
693 FitGoodnes = hit->GetChisquare() / hit->GetNDF();
696 StartTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
697 (hit->GetParError(2)*hit->GetParError(2)));
699 EndTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
700 (hit->GetParError(2)*hit->GetParError(2)));
711 std::vector<geo::WireID> wids = geom->
ChannelToWire(channel);
726 (signal.begin() + TempStartTime, signal.begin() + TempEndTime, 0.),
775 #endif // CALGAUSHFDUNE10KT_H float GetPedestal() const
double fIndWidth
Initial width for induction fit.
short ADC(int i) const
ADC vector element number i; no decompression is applied.
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
double fColMinWidth
Minimum collection hit width.
EDProducer(fhicl::ParameterSet const &pset)
double fColWidth
Initial width for collection 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.
double fIndMinWidth
Minimum induction hit width.
Zero Suppression algorithm.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Helper functions to create a hit.
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
std::string fCalDataModuleLabel
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.
CalGausHFDUNE10kt(fhicl::ParameterSet const &pset)
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.
double fMinSigCol
Collection signal height threshold.
Detector simulation of raw signals on wires.
ProducesCollector & producesCollector() noexcept
int fMaxMultiHit
maximum hits for multi fit
void reconfigure(fhicl::ParameterSet const &p)
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Declaration of signal hit object.
double fMinSigInd
Induction signal height threshold.
QTextStream & bin(QTextStream &s)
void produce(art::Event &evt)
double StartIime
maximum Chisquared / NDF allowed for a hit to be saved
2D representation of charge deposited in the TDC/wire plane
int fAreaMethod
Type of area calculation.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
std::string fDigitModuleLabel
constants
std::vector< double > fAreaNorms
factors for converting area to same units as peak height
virtual ~CalGausHFDUNE10kt()
creation of calibrated signals on wires
Signal from collection planes.