21#include <fairlogger/Logger.h>
75 return "SampleUninitalized";
77 return "NoConvergence";
81 return "BunchRejected";
94 return "sample uninitalized";
96 return "No convergence";
100 return "Bunch rejected";
113 return "Sample for fit not initialzied or bunch length is 0";
115 return "Fit of the raw bunch was not successful";
117 return "Chi2 of the fit could not be determined";
119 return "Calo bunch could not be selected";
121 return "No ADC value above threshold found";
125 return "Unknown error code";
133 mIsZerosupressed(
true),
135 mNameShort(nameshort),
145 if ((
min >
max) ||
min > constants::EMCAL_MAXTIMEBINS ||
max > constants::EMCAL_MAXTIMEBINS) {
146 LOG(warn) <<
"Attempt to set Invalid time bin range (Min , Max) = (" <<
min <<
", " <<
max <<
"), Ingored";
155 return *std::max_element(
data.begin(),
data.end());
161 int first(0), last(0);
162 int tmpfirst = indexMaxADC;
163 int tmplast = indexMaxADC;
164 double prevFirst =
adcValues[indexMaxADC];
165 double prevLast =
adcValues[indexMaxADC];
166 bool firstJump =
false;
167 bool lastJump =
false;
169 while ((tmpfirst >= 0) && (
adcValues[tmpfirst] >= threshold) && (!firstJump)) {
171 if (tmpfirst != indexMaxADC) {
180 while ((tmplast <
adcValues.size()) && (
adcValues[tmplast] >= threshold) && (!lastJump)) {
182 if (tmplast != indexMaxADC) {
193 if (firstJump || tmpfirst < 0) {
196 if (lastJump || tmplast >=
adcValues.size()) {
203 return std::make_tuple(
first, last);
208 std::array<double, constants::EMCAL_MAXTIMEBINS> outarray;
210 const gsl::span<const uint16_t> sig(bunch.
getADC());
215 outarray[
i] = sig[
length -
i - 1] - ped;
218 return std::make_tuple(ped, outarray);
236 const std::vector<uint16_t>& sig = bunch.
getADC();
239 if (sig[
i] > maxADC) {
252 const std::vector<uint16_t>& sig = bunch.
getADC();
255 if (sig[
i] > maxADC) {
261 bool isBunchEdge =
false;
271 short bunchindex = -1;
272 short indexMaxInBunch(0), maxADCallBunches(-1);
274 for (
unsigned int i = 0;
i < bunchvector.size();
i++) {
277 if (maxADC > maxADCallBunches) {
279 indexMaxInBunch = maxIndex;
280 maxADCallBunches = maxADC;
285 if (bunchindex >= 0) {
292 return std::make_tuple(bunchindex, indexMaxInBunch, maxADCallBunches);
297 if ((mintime < 0 && maxtime < 0) || maxtime < 0) {
301 return (indexMaxADC < maxtime) && (indexMaxADC > mintime) ?
true :
false;
306 double adcErr,
double tau)
const
319 double xx = (
x -
time + tau) / tau;
323 f = amp * xx * xx * TMath::Exp(2 * (1 - xx));
331 chi2 /= (adcErr * adcErr);
339 int nsamples(0),
first(0), last(0), indexMaxADCRReveresed(0);
340 double peakADC(0.), pedestal(0.);
346 for (
unsigned int i = 0;
i < bunchvector.size();
i++) {
347 if (bunchvector[
i].getBunchLength() > bunchvector[
i].getADC().
size()) {
354 if (bunchindex >= 0) {
355 if (adcMAX >= adcThreshold) {
358 int bunchlength = bunchvector[bunchindex].getBunchLength();
359 const std::vector<uint16_t>& sig = bunchvector[bunchindex].getADC();
365 int testindexReverse = -1;
366 for (
int i = 0;
i < bunchlength;
i++) {
367 mReversed[
i] = sig[bunchlength -
i - 1] - pedestal;
370 testindexReverse =
i;
374 if (peakADC >= adcThreshold)
377 indexMaxADCRReveresed = indexMaxADC - bunchvector[bunchindex].getStartTime();
378 std::tie(
first, last) =
findPeakRegion(gsl::span<double>(&
mReversed[0], bunchvector[bunchindex].getBunchLength()), indexMaxADCRReveresed, adcThreshold);
382 if (
first != indexMaxADCRReveresed && last != indexMaxADCRReveresed) {
394 return std::make_tuple(
nsamples, bunchindex, peakADC, adcMAX, indexMaxADCRReveresed, pedestal,
first, last);
std::vector< uint16_t > adcValues
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc true
char error[CURL_ERROR_SIZE]
std::vector< uint16_t > nsamples
uint8_t getStartTime() const
Get the start time bin.
const std::vector< uint16_t > & getADC() const
Get range of ADC values in the bunch.
uint8_t getBunchLength() const
Get the length of the bunch (number of time bins)
static constexpr int getNumberOfErrorTypes() noexcept
Get the number of raw fit error types supported.
CaloRawFitter(const char *name, const char *nameshort)
Constructor.
bool isMaxADCBunchEdge(const Bunch &bunch) const
Check if the max. ADC value is at the edge of a bunch.
std::tuple< short, short, short > selectMaximumBunch(const gsl::span< const Bunch > &bunchvector)
We select the bunch with the highest amplitude unless any time constraints is set.
static const char * getErrorTypeTitle(RawFitterError_t fiterror)
Get the title connected to the fit error type.
std::tuple< int, int, float, short, short, float, int, int > preFitEvaluateSamples(const gsl::span< const Bunch > bunchvector, int adcThreshold)
Method to do the selection of what should possibly be fitted.
int mMaxTimeIndex
The timebin of the max signal value must be between fMinTimeIndex and fMaxTimeIndex.
std::array< double, constants::EMCAL_MAXTIMEBINS > mReversed
Reversed sequence of samples (pedestalsubtracted)
std::tuple< short, int > getMaxAmplitudeBunch(const Bunch &bunchx) const
Get the maximum amplitude and its index of a bunch array.
bool isInTimeRange(int indexMaxADC, int maxtime, int mintime) const
Check if the index of the max ADC vaue is within accepted time range.
double evaluatePedestal(const gsl::span< const uint16_t > data, std::optional< int > length) const
Calculate the pedestal from the ADC values in a bunch.
static const char * getErrorTypeDescription(RawFitterError_t fiterror)
Get the description connected to the fit error type.
std::tuple< int, int > findPeakRegion(const gsl::span< double > adcValues, short indexMaxADC, int threshold) const
Find region constrainded by its closest minima around the main peak.
std::tuple< float, std::array< double, constants::EMCAL_MAXTIMEBINS > > reverseAndSubtractPed(const Bunch &bunch) const
Time sample comes in reversed order, revers them back Subtract the baseline based on content of altro...
double calculateChi2(double amp, double time, int first, int last, double adcErr=1, double tau=2.35) const
Calculates the chi2 of the fit.
RawFitterError_t
Error codes for failures in raw fitter procedure.
@ LOW_SIGNAL
No ADC value above threshold found.
@ FIT_ERROR
Fit procedure failed.
@ BUNCH_NOT_OK
Bunch selection failed.
@ SAMPLE_UNINITIALIZED
Samples not initialized or length is 0.
@ CHI2_ERROR
Chi2 cannot be determined (usually due to insufficient amount of samples)
static const char * getErrorTypeName(RawFitterError_t fiterror)
Get the name connected to the fit error type.
static RawFitterError_t intToErrorType(unsigned int fiterror)
Convert numeric representation of error type to RawFitterError_t.
void setTimeConstraint(int min, int max)
The require time range if the maximum ADC value is between min and max (timebin)
bool mIsZerosupressed
Wether or not the data is zeros supressed, by default its assumed that the baseline is also subtracte...
int mMinTimeIndex
The timebin of the max signal value must be between fMinTimeIndex and fMaxTimeIndex.
int mNsamplePed
Number of samples used for pedestal calculation (first in bunch)
GLuint const GLchar * name
GLuint GLsizei GLsizei * length
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"