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){
290 channel = digitVec->Channel();
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++;
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--;}
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.),
737 hcol.emplace_back(
std::move(hit), digitVec);
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
double fColMinWidth
Minimum collection hit width.
double fColWidth
Initial width for collection 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.
double fIndMinWidth
Minimum induction hit width.
Zero Suppression algorithm.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
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
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
double fMinSigCol
Collection signal height threshold.
Detector simulation of raw signals on wires.
int fMaxMultiHit
maximum hits for multi fit
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
double fMinSigInd
Induction signal height threshold.
QTextStream & bin(QTextStream &s)
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
Signal from collection planes.