Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions CRVReco/fcl/prolog_v11.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ BEGIN_PROLOG
//e.g. 0.985 for a leading edge at 50% pulse height
//e.g. 1.385 for a leading edge at 20% pulse height
//e.g. 1.587 for a leading edge at 10% pulse height
pulseThreshold : 0.5 //50% of ADC peak value above pedestal
//threshold used to determine the pulse time interval for the no-fit option
pulseAreaThreshold : 5 //5 ADC above pedestal
//threshold used to determine the pulse area for the no-fit option
doublePulseSeparation : 0.25 //25% of both ADC peaks of the double pulse
//threshold at which double pulses can be separated in the no-fit option
samplesBefore : 4 //samples before the peak included in fit
samplesAfter : 3 //samples after the peak included in fit (less to avoid hidden pulses from reflections)
useTimeOffsetDB : true //applies time offsets from the DB
timeOffsetScale : 1.0 //scale factor for the time offsets from the database
//examples:
Expand Down
8 changes: 2 additions & 6 deletions CRVReco/fcl/prolog_v12.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ BEGIN_PROLOG
//e.g. 0.985 for a leading edge at 50% pulse height
//e.g. 1.385 for a leading edge at 20% pulse height
//e.g. 1.587 for a leading edge at 10% pulse height
pulseThreshold : 0.5 //50% of ADC peak value above pedestal
//threshold used to determine the pulse time interval for the no-fit option
pulseAreaThreshold : 5 //5 ADC above pedestal
//threshold used to determine the pulse area for the no-fit option
doublePulseSeparation : 0.25 //25% of both ADC peaks of the double pulse
//threshold at which double pulses can be separated in the no-fit option
samplesBefore : 4 //samples before the peak included in fit
samplesAfter : 3 //samples after the peak included in fit (less to avoid hidden pulses from reflections)
useTimeOffsetDB : true //applies time offsets from the DB
timeOffsetScale : 1.0 //scale factor for the time offsets from the database
//examples:
Expand Down
30 changes: 5 additions & 25 deletions CRVReco/inc/MakeCrvRecoPulses.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MakeCrvRecoPulses
public:
MakeCrvRecoPulses(float minADCdifference, float defaultBeta, float minBeta, float maxBeta,
float maxTimeDifference, float minPulseHeightRatio, float maxPulseHeightRatio,
float LEtimeFactor, float pulseThreshold, float pulseAreaThreshold, float doublePulseSeparation);
float LEtimeFactor, int samplesBefore, int samplesAfter);
void SetWaveform(const std::vector<int16_t> &waveform, uint16_t startTDC,
float digitizationPeriod, float pedestal, float calibrationFactor,
float calibrationFactorPulseHeight);
Expand All @@ -30,10 +30,8 @@ class MakeCrvRecoPulses

private:
MakeCrvRecoPulses();
void FillGraphAndFindPeaks(const std::vector<int16_t> &waveform, uint16_t startTDC,
float digitizationPeriod, float pedestal,
TGraph &g, std::vector<std::pair<size_t,size_t> > &peaks);
void RangeFinder(const std::vector<int16_t> &waveform, const size_t peakStart, const size_t peakEnd, size_t &start, size_t &end);
bool FindNextPeak(const TGraph &g, int start, int &peakStart, int &peakEnd, int &fitStart, int &fitEnd);
void SubtractPulse(TGraph &g, uint16_t startTDC, float digitizationPeriod);
bool FailedFit(TFitResultPtr fr);

TF1 _f1;
Expand All @@ -43,30 +41,12 @@ class MakeCrvRecoPulses
float _maxTimeDifference;
float _minPulseHeightRatio, _maxPulseHeightRatio;
float _LEtimeFactor;
float _pulseThreshold;
float _pulseAreaThreshold;
float _doublePulseSeparation;
int _samplesBefore, _samplesAfter;

std::vector<float> _PEs, _PEsPulseHeight;
std::vector<double> _pulseTimes, _LEtimes;
std::vector<float> _pulseHeights, _pulseBetas, _pulseFitChi2s;
std::vector<bool> _zeroNdf, _failedFits, _duplicateNoFitPulses, _separatedDoublePulses;

public:
const std::vector<float> &GetPEsNoFit() const {return _PEsNoFit;}
const std::vector<double> &GetPulseTimesNoFit() const {return _pulseTimesNoFit;}
const std::vector<double> &GetPulseStarts() const {return _pulseStart;}
const std::vector<double> &GetPulseEnds() const {return _pulseEnd;}
const std::vector<bool> &GetDuplicateNoFitPulses() const {return _duplicateNoFitPulses;}
const std::vector<bool> &GetSeparatedDoublePulses() const {return _separatedDoublePulses;}

private:
void NoFitOption(const std::vector<int16_t> &waveform, const std::vector<std::pair<size_t,size_t> > &peaks,
uint16_t startTDC, float digitizationPeriod, float pedestal, float calibrationFactor);
std::vector<float> _PEsNoFit;
std::vector<double> _pulseTimesNoFit;
std::vector<double> _pulseStart;
std::vector<double> _pulseEnd;
std::vector<bool> _zeroNdf, _failedFits;
};

}
Expand Down
26 changes: 5 additions & 21 deletions CRVReco/src/CrvRecoPulsesFinder_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ namespace mu2e
fhicl::Atom<float> minPulseHeightRatio{Name("minPulseHeightRatio"), Comment("smallest accepted ratio between largest ADC value and fitted peak")}; //0.7
fhicl::Atom<float> maxPulseHeightRatio{Name("maxPulseHeightRatio"), Comment("largest accepted ratio between largest ADC value and fitted peak")}; //1.5
fhicl::Atom<float> LEtimeFactor{Name("LEtimeFactor"), Comment("time of leading edge is peakTime-LEtimeFactor*beta (0.985,1.385,1.587 for a leading edge of 0.5,0.2,0.1 pulse height")};
fhicl::Atom<float> pulseThreshold{Name("pulseThreshold"), Comment("fraction of ADC peak used as threshold to determine the pulse time interval for the no-fit option")}; //0.5
fhicl::Atom<float> pulseAreaThreshold{Name("pulseAreaThreshold"), Comment("threshold to determine the pulse area for the the no-fit option")}; //5
fhicl::Atom<float> doublePulseSeparation{Name("doublePulseSeparation"), Comment("fraction of both peaks at which double pulses can be separated in the no-fit option")}; //0.25
fhicl::Atom<int> samplesBefore{Name("samplesBefore"), Comment("number of samples before the peak to be included in fit")};
fhicl::Atom<int> samplesAfter{Name("samplesAfter"), Comment("number of samples after the peak to be included in fit")};
fhicl::Atom<art::InputTag> eventWindowMarkerTag{Name("eventWindowMarkerTag"), Comment("EventWindowMarker producer"),"EWMProducer"};
fhicl::Atom<art::InputTag> protonBunchTimeTag{Name("protonBunchTimeTag"), Comment("ProtonBunchTime producer"),"EWMProducer"};
fhicl::Atom<bool> useTimeOffsetDB{Name("useTimeOffsetDB"), Comment("apply time offsets from the DB")}; //true
Expand Down Expand Up @@ -109,10 +108,6 @@ namespace mu2e
_timeOffsetScale(conf().timeOffsetScale()),
_ignoreChannels(conf().ignoreChannels())
{
if(conf().pulseAreaThreshold()>conf().minADCdifference())
throw cet::exception("CRVRECO_BAD_CONFIG")
<< "CrvRecoPulseFinder pulseAreaThreshold " << conf().pulseAreaThreshold()
<< " larger than minADCdifference " << conf().minADCdifference();
produces<CrvRecoPulseCollection>(_NZSdata?"NZS":"");
_makeCrvRecoPulses=boost::shared_ptr<mu2eCrv::MakeCrvRecoPulses>(new mu2eCrv::MakeCrvRecoPulses(conf().minADCdifference(),
conf().defaultBeta(),
Expand All @@ -122,9 +117,8 @@ namespace mu2e
conf().minPulseHeightRatio(),
conf().maxPulseHeightRatio(),
conf().LEtimeFactor(),
conf().pulseThreshold(),
conf().pulseAreaThreshold(),
conf().doublePulseSeparation()));
conf().samplesBefore(),
conf().samplesAfter()));
}

void CrvRecoPulsesFinder::beginJob()
Expand Down Expand Up @@ -233,25 +227,15 @@ namespace mu2e
float pulseFitChi2= _makeCrvRecoPulses->GetPulseFitChi2s().at(j);

bool failedFit = _makeCrvRecoPulses->GetFailedFits().at(j);
bool duplicateNoFitPulse = _makeCrvRecoPulses->GetDuplicateNoFitPulses().at(j);
bool separatedDoublePulse = _makeCrvRecoPulses->GetSeparatedDoublePulses().at(j);
bool zeroNdf = _makeCrvRecoPulses->GetZeroNdfs().at(j);
CrvRecoPulseFlags flags;
if(failedFit) flags.set(CrvRecoPulseFlagEnums::failedFit);
if(duplicateNoFitPulse) flags.set(CrvRecoPulseFlagEnums::duplicateNoFitPulse);
if(separatedDoublePulse) flags.set(CrvRecoPulseFlagEnums::separatedDoublePulse);
if(zeroNdf) flags.set(CrvRecoPulseFlagEnums::zeroNdf);

float PEsNoFit = _makeCrvRecoPulses->GetPEsNoFit().at(j);
double pulseTimeNoFit = _makeCrvRecoPulses->GetPulseTimesNoFit().at(j) + TDC0time + timeOffset;
double pulseStart = _makeCrvRecoPulses->GetPulseStarts().at(j) + TDC0time + timeOffset;
double pulseEnd = _makeCrvRecoPulses->GetPulseEnds().at(j) + TDC0time + timeOffset;

if(calibPulseArea<=0) {PEs=0; PEsNoFit=0; flags.set(CrvRecoPulseFlagEnums::noCalibConstPulseArea);}
if(calibPulseArea<=0) {PEs=0; flags.set(CrvRecoPulseFlagEnums::noCalibConstPulseArea);}
if(calibPulseHeight<=0) {PEsPulseHeight=0; flags.set(CrvRecoPulseFlagEnums::noCalibConstPulseHeight);}

crvRecoPulseCollection->emplace_back(PEs, PEsPulseHeight, pulseTime, pulseHeight, pulseBeta, pulseFitChi2, LEtime, flags,
PEsNoFit, pulseTimeNoFit, pulseStart, pulseEnd,
waveformIndices, barIndex, SiPM, ROC, FEB, FEBchannel, pedestal, pedestalFromDB);
}

Expand Down
Loading