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;
137 double TotalCharge = 0;
139 for(
int i = 0;
i < digi.
size(); ++
i)
149 double NominalChi2 = 0;
170 double TS4Left = 1000;
171 double TS4Right = 1000;
179 if(TS4Left > 1000 || TS4Left < -1000)
181 if(TS4Right > 1000 || TS4Right < -1000)
223 std::vector<double> PulseShape;
228 PulseShape.reserve(350);
229 for(
int i = 0;
i < 200;
i++)
230 PulseShape.push_back(HPDShape.
at(
i));
231 PulseShape.insert(PulseShape.begin(), 150, 0);
236 for(
unsigned int i = 1;
i < PulseShape.size();
i++)
256 int DigiSize = Charge.size();
259 double MinimumRightChi2 = 1000000;
260 double Numerator = 0;
261 double Denominator = 0;
275 double BestSlope = 0;
276 if (Denominator!=0) BestSlope = Numerator / Denominator;
305 for(
int i = iTS;
i < DigiSize;
i++)
306 Chi2 += Charge[
i] * Charge[
i];
308 if(Chi2 < MinimumRightChi2)
310 MinimumRightChi2 = Chi2;
316 double MinimumLeftChi2 = 1000000;
329 double BestSlope = 0;
330 if (Denominator!=0) BestSlope = Numerator / Denominator;
351 for(
int i = 0;
i < iTS;
i++)
352 Chi2 += Charge[
i] * Charge[
i];
357 if(MinimumLeftChi2 > Chi2)
359 MinimumLeftChi2 = Chi2;
364 result.
Chi2 = MinimumLeftChi2 + MinimumRightChi2;
378 int DigiSize = Charge.size();
380 double MinimumChi2 = 100000;
398 for(
int j = 0;
j < DigiSize;
j++)
407 SumF2 += F * F / ErrorTemp;
408 SumTF += F * Charge[
j] / ErrorTemp;
409 SumT2 += fabs(Charge[
j]);
423 double Chi2 = SumT2 - SumTF * SumTF / SumF2;
425 if(Chi2 < MinimumChi2)
430 if(MinimumChi2 < 1e-5)
446 double OverallMinimumChi2 = 1000000;
448 int AvailableDistance[] = {-100, -75, -50, 50, 75, 100};
451 for(
int k = 0;
k < 6;
k++)
453 double SingleMinimumChi2 = 1000000;
461 if(Chi2 < SingleMinimumChi2)
463 SingleMinimumChi2 = Chi2;
472 if(Chi2 < SingleMinimumChi2)
473 SingleMinimumChi2 = Chi2;
477 if(SingleMinimumChi2 < OverallMinimumChi2)
478 OverallMinimumChi2 = SingleMinimumChi2;
481 return OverallMinimumChi2;
496 int DigiSize = Charge.size();
503 static std::vector<double> F1;
504 static std::vector<double> F2;
517 for(
int j = 0;
j < DigiSize;
j++)
525 int OffsetTemp = Offset +
j * 25 + Distance;
530 if(OffsetTemp + 25 < (
int)CumulativeIdealPulse.size() && OffsetTemp + 25 >= 0)
531 C1 = CumulativeIdealPulse[OffsetTemp+25];
532 if(OffsetTemp + 25 >= (
int)CumulativeIdealPulse.size())
533 C1 = CumulativeIdealPulse[CumulativeIdealPulse.size()-1];
534 if(OffsetTemp < (
int)CumulativeIdealPulse.size() && OffsetTemp >= 0)
535 C2 = CumulativeIdealPulse[OffsetTemp];
536 if(OffsetTemp >= (
int)CumulativeIdealPulse.size())
537 C2 = CumulativeIdealPulse[CumulativeIdealPulse.size()-1];
544 SumF1F1 += F1[
j] * F1[
j] / Error;
545 SumF1F2 += F1[
j] * F2[
j] / Error;
546 SumF2F2 += F2[
j] * F2[
j] / Error;
547 SumTF1 += F1[
j] * Charge[
j] / Error;
548 SumTF2 += F2[
j] * Charge[
j] / Error;
553 if (fabs(SumF1F2*SumF1F2-SumF1F1*SumF2F2)>1e-5)
555 Height = (SumF1F2 * SumTF2 - SumF2F2 * SumTF1) / (SumF1F2 * SumF1F2 - SumF1F1 * SumF2F2);
556 Height2 = (SumF1F2 * SumTF1 - SumF1F1 * SumTF2) / (SumF1F2 * SumF1F2 - SumF1F1 * SumF2F2);
560 for(
int j = 0;
j < DigiSize;
j++)
562 double Error = Charge[
j];
566 double Residual = Height * F1[
j] + Height2 * F2[
j] - Charge[
j];
567 Chi2 += Residual * Residual / Error;
588 int DigiSize = Charge.size();
590 if (DigiSize<=2)
return 1e-5;
592 std::vector<double> TempCharge = Charge;
595 sort(TempCharge.begin(), TempCharge.end());
599 for(
int i = 0;
i < DigiSize - 2;
i++)
601 Total = Total + TempCharge[
i];
602 Total2 = Total2 + TempCharge[
i] * TempCharge[
i];
611 double RMS =
sqrt(Total2 - Total * Total / (DigiSize - 2));
613 double RMS8Max = RMS / TempCharge[DigiSize-1];
617 return RMS / TempCharge[DigiSize-1];
630 int DigiSize = Charge.size();
632 double SumTS2OverTi = 0;
633 double SumTSOverTi = 0;
634 double SumOverTi = 0;
639 for(
int i = 0;
i < DigiSize;
i++)
645 SumTS2OverTi += 1.*
i *
i / Error2;
646 SumTSOverTi += 1.*
i / Error2;
647 SumOverTi += 1. / Error2;
648 SumTiTS += Charge[
i] *
i / Error2;
649 SumTi += Charge[
i] / Error2;
652 double CM1 = SumTS2OverTi;
653 double CM2 = SumTSOverTi;
654 double CD1 = SumTSOverTi;
655 double CD2 = SumOverTi;
660 double Slope = (C1 * CD2 - C2 * CD1) / (CM1 * CD2 - CM2 * CD1);
661 double Intercept = (C1 * CM2 - C2 * CM1) / (CD1 * CM2 - CD2 * CM1);
665 for(
int i = 0;
i < DigiSize;
i++)
667 double Deviation = Slope *
i + Intercept - Charge[
i];
668 double Error2 = Charge[
i];
671 Chi2 += Deviation * Deviation / Error2;
683 std::vector<std::pair<double, double> > &Cuts,
698 if(Charge <= Cuts[0].
first)
701 int IndexLargerThanCharge = -1;
702 for(
int i = 1;
i < (int)Cuts.size();
i++)
704 if(Cuts[
i].first > Charge)
706 IndexLargerThanCharge =
i;
711 double limit = 1000000;
713 if(IndexLargerThanCharge == -1)
714 limit = Cuts[Cuts.size()-1].second;
717 double C1 = Cuts[IndexLargerThanCharge].first;
718 double C2 = Cuts[IndexLargerThanCharge-1].first;
719 double L1 = Cuts[IndexLargerThanCharge].second;
720 double L2 = Cuts[IndexLargerThanCharge-1].second;
722 limit = (Charge - C1) / (C2 - C1) * (L2 - L1) + L1;
725 if(Side > 0 && Discriminant > limit)
727 if(Side < 0 && Discriminant < limit)
double mMinimumChargeThreshold
std::vector< std::pair< double, double > > mLambdaLinearCut
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
Log< T >::type log(const T &t)
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)
float at(double time) const
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
std::vector< std::pair< double, double > > mTS4TS5UpperCut