236 TH1::AddDirectory(kFALSE);
242 TF1 *
hit =
new TF1(
"hit",
"gaus",0,3200);
262 double threshold = 0.;
263 double fitWidth = 0.;
264 double minWidth = 0.;
268 std::vector<int> startTimes;
269 std::vector<int> maxTimes;
270 std::vector<int> endTimes;
272 int minTimeHolder = 0;
278 bool maxFound =
false;
279 std::stringstream numConv;
285 if(
fSpillName.size()>0) digitVecHandle = evt.
getHandle< std::vector<raw::RawDigit> >(itag1);
288 if (!digitVecHandle->size())
return;
289 mf::LogInfo(
"CalGausHFDUNE35t") <<
"CalGausHFDUNE35t:: digitVecHandle size is " << digitVecHandle->size();
296 <<
"CalGausHFDUNE only supports zero-suppressed raw digit input!";
305 std::vector<float> holder;
306 std::vector<float> rawadc_conv;
307 std::vector<short> rawadc;
310 for(
size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){
324 const int numberofblocks = digitVec->ADC(1);
326 int zerosuppressedindex = numberofblocks*2 + 2;
329 for(
int i=0; i<numberofblocks; i++){
331 const int lengthofblock = digitVec->ADC(2+numberofblocks+i);
332 rawadc.resize(lengthofblock);
333 holder.resize(lengthofblock);
334 rawadc_conv.resize(lengthofblock);
337 for (
int j=0;j<lengthofblock;j++)
339 rawadc[j] = digitVec->ADC(zerosuppressedindex);
340 zerosuppressedindex++;
346 rawadc_conv[
bin]=(rawadc[
bin]-digitVec->GetPedestal());
355 for(
bin = 0;
bin < rawadc_conv.size(); ++
bin)
356 holder[
bin] = rawadc_conv[
bin];
361 for(
bin = 0;
bin < rawadc_conv.size(); ++
bin)
362 holder[
bin] = (
bin>0) ? rawadc_conv[
bin] + holder[
bin-1] : rawadc_conv[
bin];
391 std::vector<float> signal(holder);
413 for(timeIter = signal.begin();timeIter+2<signal.end();timeIter++){
420 if(*timeIter > *(timeIter+1) && *(timeIter+1) < *(timeIter+2)){
424 endTimes.push_back(time+1);
427 minTimeHolder = time+2;
429 else minTimeHolder = time+1;
441 else if(*timeIter < *(timeIter+1) && *(timeIter+1) > *(timeIter+2) && *(timeIter+1) > threshold){
443 maxTimes.push_back(time+1);
444 startTimes.push_back(minTimeHolder);
455 while( maxTimes.size() > endTimes.size() ){
456 endTimes.push_back(signal.size()-1);
463 if( startTimes.size() == 0 ){
485 double minPeakHeight(0);
507 std::vector<double> hitSig;
512 while( hitIndex < (
signed)startTimes.size() ) {
519 minPeakHeight = signal[maxTimes[hitIndex]];
526 while(numHits <
fMaxMultiHit && numHits+hitIndex < (
signed)endTimes.size() &&
527 signal[endTimes[hitIndex+numHits-1]] >threshold/2.0 &&
528 startTimes[hitIndex+numHits] - endTimes[hitIndex+numHits-1] < 2){
529 if(signal[maxTimes[hitIndex+numHits]] < minPeakHeight){
530 minPeakHeight=signal[maxTimes[hitIndex+numHits]];
544 startT=startTimes[hitIndex];
545 while(signal[(
int)startT] < minPeakHeight/2.0) {startT++;}
551 endT=endTimes[hitIndex+numHits-1];
552 while(signal[(
int)endT] <minPeakHeight/2.0) {endT--;}
570 TH1D hitSignal(
"hitSignal",
"",
size,startT,endT);
572 for(
int i = (
int)startT; i < (
int)endT; i++){
576 hitSignal.Fill(i,signal[i]);
590 for(
int i = 3; i < numHits*3; i+=3){
591 eqn.append(
"+gaus(");
594 eqn.append(numConv.str());
601 TF1 Gaus(
"Gaus",eqn.c_str(),0,
size);
608 for(
int i = 0; i < numHits; ++i){
615 amplitude = signal[maxTimes[hitIndex+i]];
616 Gaus.SetParameter(3*i,amplitude);
617 Gaus.SetParameter(1+3*i, maxTimes[hitIndex+i]);
618 Gaus.SetParameter(2+3*i, fitWidth);
619 Gaus.SetParLimits(3*i, 0.0, 3.0*amplitude);
620 Gaus.SetParLimits(1+3*i, startT , endT);
621 Gaus.SetParLimits(2+3*i, 0.0, 10.0*fitWidth);
630 Gaus.SetParameters(signal[maxTimes[hitIndex]],maxTimes[hitIndex],fitWidth);
631 Gaus.SetParLimits(0,0.0,1.5*signal[maxTimes[hitIndex]]);
632 Gaus.SetParLimits(1, startT , endT);
633 Gaus.SetParLimits(2,0.0,10.0*fitWidth);
642 hitSignal.Fit(&Gaus,
"QNRW",
"", startT, endT);
647 for(
int hitNumber = 0; hitNumber < numHits; ++hitNumber){
655 if(Gaus.GetParameter(3*hitNumber) > threshold/2.0 &&
656 Gaus.GetParameter(3*hitNumber+2) > minWidth){
657 StartIime = Gaus.GetParameter(3*hitNumber+1) - Gaus.GetParameter(3*hitNumber+2);
659 EndTime = Gaus.GetParameter(3*hitNumber+1) + Gaus.GetParameter(3*hitNumber+2);
662 RMS = Gaus.GetParameter(3*hitNumber+2);
677 for(
int sigPos = 0; sigPos<
size; sigPos++){
679 hitSig[sigPos] = Gaus.GetParameter(3*hitNumber)*TMath::Gaus(sigPos+startT,Gaus.GetParameter(3*hitNumber+1), Gaus.GetParameter(3*hitNumber+2));
680 totSig+=hitSig[(
int)sigPos];
686 totSig = std::sqrt(2*TMath::Pi())*Gaus.GetParameter(3*hitNumber)*Gaus.GetParameter(3*hitNumber+2)/
fAreaNorms[(size_t)sigType];
693 ChargeError = TMath::Sqrt(TMath::Pi())*(Gaus.GetParError(3*hitNumber+0)*Gaus.GetParameter(3*hitNumber+2)+
694 Gaus.GetParError(3*hitNumber+2)*Gaus.GetParameter(3*hitNumber+0));
695 Amp = Gaus.GetParameter(3*hitNumber);
696 AmpError = Gaus.GetParError(3*hitNumber);
706 hit->SetParameters(
Amp,
MeanPosition, Gaus.GetParameter(3*hitNumber+2));
707 hit->FixParameter(0,
Amp);
721 hitSignal.Fit(hit,
"QNRLLi",
"", TempStartTime, TempEndTime);
757 FitGoodnes = hit->GetChisquare() / hit->GetNDF();
760 StartTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
761 (hit->GetParError(2)*hit->GetParError(2)));
763 EndTimeError = TMath::Sqrt( (hit->GetParError(1)*hit->GetParError(1)) +
764 (hit->GetParError(2)*hit->GetParError(2)));
791 (signal.begin() + TempStartTime, signal.begin() + TempEndTime, 0.),
802 hcol.emplace_back(
std::move(hit), digitVec);
std::string fDigitModuleLabel
constants
double fColMinWidth
Minimum collection hit width.
int fAreaMethod
Type of area calculation.
std::vector< double > fAreaNorms
factors for converting area to same units as peak height
double fIndWidth
Initial width for induction fit.
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.
A class handling a collection of hits and its associations.
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
double fMinSigCol
Collection signal height threshold.
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.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
double fColWidth
Initial width for collection fit.
double fIndMinWidth
Minimum induction hit width.
double fChi2NDF
maximum Chisquared / NDF allowed for a hit to be saved
QTextStream & bin(QTextStream &s)
2D representation of charge deposited in the TDC/wire plane
double fMinSigInd
Induction signal height threshold.
Signal from collection planes.