38 double TS4TS5ChargeThreshold,
39 unsigned int TrianglePeakTS,
40 std::vector<double> LinearThreshold,
41 std::vector<double> LinearCut,
42 std::vector<double> RMS8MaxThreshold,
43 std::vector<double> RMS8MaxCut,
44 std::vector<double> LeftSlopeThreshold,
45 std::vector<double> LeftSlopeCut,
46 std::vector<double> RightSlopeThreshold,
47 std::vector<double> RightSlopeCut,
48 std::vector<double> RightSlopeSmallThreshold,
49 std::vector<double> RightSlopeSmallCut,
50 std::vector<double> TS4TS5LowerThreshold,
51 std::vector<double> TS4TS5LowerCut,
52 std::vector<double> TS4TS5UpperThreshold,
53 std::vector<double> TS4TS5UpperCut,
55 bool TriangleIgnoreSlow)
70 mLambdaLinearCut.push_back(std::pair<double, double>(LinearThreshold[
i], LinearCut[i]));
74 mLambdaRMS8MaxCut.push_back(std::pair<double, double>(RMS8MaxThreshold[i], RMS8MaxCut[i]));
78 mLeftSlopeCut.push_back(std::pair<double, double>(LeftSlopeThreshold[i], LeftSlopeCut[i]));
82 mRightSlopeCut.push_back(std::pair<double, double>(RightSlopeThreshold[i], RightSlopeCut[i]));
86 mRightSlopeSmallCut.push_back(std::pair<double, double>(RightSlopeSmallThreshold[i], RightSlopeSmallCut[i]));
90 mTS4TS5UpperCut.push_back(std::pair<double, double>(TS4TS5UpperThreshold[i], TS4TS5UpperCut[i]));
94 mTS4TS5LowerCut.push_back(std::pair<double, double>(TS4TS5LowerThreshold[i], TS4TS5LowerCut[i]));
128 if(abseta == 28 || abseta == 29)
return;
136 double TotalCharge = 0;
138 for(
int i = 0;
i < digi.
size(); ++
i)
148 double NominalChi2 = 0;
169 double TS4Left = 1000;
170 double TS4Right = 1000;
178 if(TS4Left > 1000 || TS4Left < -1000)
180 if(TS4Right > 1000 || TS4Right < -1000)
222 std::vector<double> PulseShape;
227 PulseShape.reserve(350);
228 for(
int i = 0;
i < 200;
i++)
229 PulseShape.push_back(HPDShape.
at(
i));
230 PulseShape.insert(PulseShape.begin(), 150, 0);
235 for(
unsigned int i = 1;
i < PulseShape.size();
i++)
255 int DigiSize = Charge.size();
258 double MinimumRightChi2 = 1000000;
259 double Numerator = 0;
260 double Denominator = 0;
274 double BestSlope = 0;
275 if (Denominator!=0) BestSlope = Numerator / Denominator;
304 for(
int i = iTS;
i < DigiSize;
i++)
305 Chi2 += Charge[
i] * Charge[
i];
307 if(Chi2 < MinimumRightChi2)
309 MinimumRightChi2 = Chi2;
315 double MinimumLeftChi2 = 1000000;
328 double BestSlope = 0;
329 if (Denominator!=0) BestSlope = Numerator / Denominator;
350 for(
int i = 0;
i < iTS;
i++)
351 Chi2 += Charge[
i] * Charge[
i];
356 if(MinimumLeftChi2 > Chi2)
358 MinimumLeftChi2 = Chi2;
363 result.
Chi2 = MinimumLeftChi2 + MinimumRightChi2;
377 int DigiSize = Charge.size();
379 double MinimumChi2 = 100000;
397 for(
int j = 0;
j < DigiSize;
j++)
406 SumF2 += F * F / ErrorTemp;
407 SumTF += F * Charge[
j] / ErrorTemp;
408 SumT2 += fabs(Charge[
j]);
422 double Chi2 = SumT2 - SumTF * SumTF / SumF2;
424 if(Chi2 < MinimumChi2)
429 if(MinimumChi2 < 1
e-5)
445 double OverallMinimumChi2 = 1000000;
447 int AvailableDistance[] = {-100, -75, -50, 50, 75, 100};
450 for(
int k = 0;
k < 6;
k++)
452 double SingleMinimumChi2 = 1000000;
460 if(Chi2 < SingleMinimumChi2)
462 SingleMinimumChi2 = Chi2;
471 if(Chi2 < SingleMinimumChi2)
472 SingleMinimumChi2 = Chi2;
476 if(SingleMinimumChi2 < OverallMinimumChi2)
477 OverallMinimumChi2 = SingleMinimumChi2;
480 return OverallMinimumChi2;
495 int DigiSize = Charge.size();
502 static std::vector<double> F1;
503 static std::vector<double> F2;
516 for(
int j = 0;
j < DigiSize;
j++)
524 int OffsetTemp = Offset +
j * 25 + Distance;
529 if(OffsetTemp + 25 < (
int)CumulativeIdealPulse.size() && OffsetTemp + 25 >= 0)
530 C1 = CumulativeIdealPulse[OffsetTemp+25];
531 if(OffsetTemp + 25 >= (
int)CumulativeIdealPulse.size())
532 C1 = CumulativeIdealPulse[CumulativeIdealPulse.size()-1];
533 if(OffsetTemp < (
int)CumulativeIdealPulse.size() && OffsetTemp >= 0)
534 C2 = CumulativeIdealPulse[OffsetTemp];
535 if(OffsetTemp >= (
int)CumulativeIdealPulse.size())
536 C2 = CumulativeIdealPulse[CumulativeIdealPulse.size()-1];
543 SumF1F1 += F1[
j] * F1[
j] / Error;
544 SumF1F2 += F1[
j] * F2[
j] / Error;
545 SumF2F2 += F2[
j] * F2[
j] / Error;
546 SumTF1 += F1[
j] * Charge[
j] / Error;
547 SumTF2 += F2[
j] * Charge[
j] / Error;
552 if (fabs(SumF1F2*SumF1F2-SumF1F1*SumF2F2)>1
e-5)
554 Height = (SumF1F2 * SumTF2 - SumF2F2 * SumTF1) / (SumF1F2 * SumF1F2 - SumF1F1 * SumF2F2);
555 Height2 = (SumF1F2 * SumTF1 - SumF1F1 * SumTF2) / (SumF1F2 * SumF1F2 - SumF1F1 * SumF2F2);
559 for(
int j = 0;
j < DigiSize;
j++)
561 double Error = Charge[
j];
565 double Residual = Height * F1[
j] + Height2 * F2[
j] - Charge[
j];
566 Chi2 += Residual * Residual / Error;
587 int DigiSize = Charge.size();
589 if (DigiSize<=2)
return 1
e-5;
591 std::vector<double> TempCharge = Charge;
594 sort(TempCharge.begin(), TempCharge.end());
598 for(
int i = 0;
i < DigiSize - 2;
i++)
600 Total = Total + TempCharge[
i];
601 Total2 = Total2 + TempCharge[
i] * TempCharge[
i];
610 double RMS =
sqrt(Total2 - Total * Total / (DigiSize - 2));
612 double RMS8Max = RMS / TempCharge[DigiSize-1];
616 return RMS / TempCharge[DigiSize-1];
629 int DigiSize = Charge.size();
631 double SumTS2OverTi = 0;
632 double SumTSOverTi = 0;
633 double SumOverTi = 0;
638 for(
int i = 0;
i < DigiSize;
i++)
644 SumTS2OverTi += 1.*
i *
i / Error2;
645 SumTSOverTi += 1.*
i / Error2;
646 SumOverTi += 1. / Error2;
647 SumTiTS += Charge[
i] *
i / Error2;
648 SumTi += Charge[
i] / Error2;
651 double CM1 = SumTS2OverTi;
652 double CM2 = SumTSOverTi;
653 double CD1 = SumTSOverTi;
654 double CD2 = SumOverTi;
659 double Slope = (C1 * CD2 - C2 * CD1) / (CM1 * CD2 - CM2 * CD1);
660 double Intercept = (C1 * CM2 - C2 * CM1) / (CD1 * CM2 - CD2 * CM1);
664 for(
int i = 0;
i < DigiSize;
i++)
666 double Deviation = Slope *
i + Intercept - Charge[
i];
667 double Error2 = Charge[
i];
670 Chi2 += Deviation * Deviation / Error2;
682 std::vector<std::pair<double, double> > &Cuts,
697 if(Charge <= Cuts[0].
first)
700 int IndexLargerThanCharge = -1;
701 for(
int i = 1;
i < (int)Cuts.size();
i++)
703 if(Cuts[
i].first > Charge)
705 IndexLargerThanCharge =
i;
710 double limit = 1000000;
712 if(IndexLargerThanCharge == -1)
713 limit = Cuts[Cuts.size()-1].second;
716 double C1 = Cuts[IndexLargerThanCharge].first;
717 double C2 = Cuts[IndexLargerThanCharge-1].first;
718 double L1 = Cuts[IndexLargerThanCharge].second;
719 double L2 = Cuts[IndexLargerThanCharge-1].second;
721 limit = (Charge - C1) / (C2 - C1) * (L2 - L1) + L1;
724 if(Side > 0 && Discriminant > limit)
726 if(Side < 0 && Discriminant < limit)
double mMinimumChargeThreshold
std::vector< std::pair< double, double > > mLambdaLinearCut
float at(double time) const
int size() const
total number of samples in the digi
HcalDetId id() const
get the id
void setFlagField(uint32_t value, int base, int width=1)
double pedestal(int fCapId) const
get pedestal for capid=0..3
double CalculateRMS8Max(const std::vector< double > &Charge)
std::vector< std::pair< double, double > > mTS4TS5LowerCut
double PerformNominalFit(const std::vector< double > &Charge)
double PerformDualNominalFit(const std::vector< double > &Charge)
~HBHEPulseShapeFlagSetter()
double PerformLinearFit(const std::vector< double > &Charge)
std::vector< std::pair< double, double > > mLeftSlopeCut
TriangleFitResult PerformTriangleFit(const std::vector< double > &Charge)
MVATrainerComputer * calib
double mTS4TS5ChargeThreshold
HBHEPulseShapeFlagSetter()
std::vector< std::pair< double, double > > mRightSlopeCut
bool CheckPassFilter(double Charge, double Discriminant, std::vector< std::pair< double, double > > &Cuts, int Side)
int ietaAbs() const
get the absolute value of the cell ieta
std::vector< double > mCharge
std::vector< std::pair< double, double > > mRightSlopeSmallCut
int capid() const
get the Capacitor id
const HcalQIESample & sample(int i) const
access a sample
double DualNominalFitSingleTry(const std::vector< double > &Charge, int Offset, int Distance)
const Shape & hbShape() const
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
void SetPulseShapeFlags(HBHERecHit &hbhe, const HBHEDataFrame &digi, const HcalCoder &coder, const HcalCalibrations &calib)
std::vector< double > CumulativeIdealPulse
std::vector< std::pair< double, double > > mLambdaRMS8MaxCut
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
std::vector< std::pair< double, double > > mTS4TS5UpperCut