38 double TS4TS5ChargeThreshold,
39 unsigned int TrianglePeakTS,
40 const std::vector<double>& LinearThreshold,
41 const std::vector<double>& LinearCut,
42 const std::vector<double>& RMS8MaxThreshold,
43 const std::vector<double>& RMS8MaxCut,
44 const std::vector<double>& LeftSlopeThreshold,
45 const std::vector<double>& LeftSlopeCut,
46 const std::vector<double>& RightSlopeThreshold,
47 const std::vector<double>& RightSlopeCut,
48 const std::vector<double>& RightSlopeSmallThreshold,
49 const std::vector<double>& RightSlopeSmallCut,
50 const std::vector<double>& TS4TS5LowerThreshold,
51 const std::vector<double>& TS4TS5LowerCut,
52 const std::vector<double>& TS4TS5UpperThreshold,
53 const 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 std::vector<double> F1(DigiSize);
503 std::vector<double> F2(DigiSize);
513 for(
int j = 0;
j < DigiSize;
j++)
521 int OffsetTemp = Offset +
j * 25 + Distance;
526 if(OffsetTemp + 25 < (
int)CumulativeIdealPulse.size() && OffsetTemp + 25 >= 0)
527 C1 = CumulativeIdealPulse[OffsetTemp+25];
528 if(OffsetTemp + 25 >= (
int)CumulativeIdealPulse.size())
529 C1 = CumulativeIdealPulse[CumulativeIdealPulse.size()-1];
530 if(OffsetTemp < (
int)CumulativeIdealPulse.size() && OffsetTemp >= 0)
531 C2 = CumulativeIdealPulse[OffsetTemp];
532 if(OffsetTemp >= (
int)CumulativeIdealPulse.size())
533 C2 = CumulativeIdealPulse[CumulativeIdealPulse.size()-1];
540 SumF1F1 += F1[
j] * F1[
j] / Error;
541 SumF1F2 += F1[
j] * F2[
j] / Error;
542 SumF2F2 += F2[
j] * F2[
j] / Error;
543 SumTF1 += F1[
j] * Charge[
j] / Error;
544 SumTF2 += F2[
j] * Charge[
j] / Error;
549 if (fabs(SumF1F2*SumF1F2-SumF1F1*SumF2F2)>1
e-5)
551 Height = (SumF1F2 * SumTF2 - SumF2F2 * SumTF1) / (SumF1F2 * SumF1F2 - SumF1F1 * SumF2F2);
552 Height2 = (SumF1F2 * SumTF1 - SumF1F1 * SumTF2) / (SumF1F2 * SumF1F2 - SumF1F1 * SumF2F2);
556 for(
int j = 0;
j < DigiSize;
j++)
558 double Error = Charge[
j];
562 double Residual = Height * F1[
j] + Height2 * F2[
j] - Charge[
j];
563 Chi2 += Residual * Residual / Error;
584 int DigiSize = Charge.size();
586 if (DigiSize<=2)
return 1
e-5;
588 std::vector<double> TempCharge = Charge;
591 sort(TempCharge.begin(), TempCharge.end());
595 for(
int i = 0;
i < DigiSize - 2;
i++)
597 Total = Total + TempCharge[
i];
598 Total2 = Total2 + TempCharge[
i] * TempCharge[
i];
607 double RMS =
sqrt(Total2 - Total * Total / (DigiSize - 2));
609 double RMS8Max = RMS / TempCharge[DigiSize-1];
613 return RMS / TempCharge[DigiSize-1];
626 int DigiSize = Charge.size();
628 double SumTS2OverTi = 0;
629 double SumTSOverTi = 0;
630 double SumOverTi = 0;
635 for(
int i = 0;
i < DigiSize;
i++)
641 SumTS2OverTi += 1.*
i *
i / Error2;
642 SumTSOverTi += 1.*
i / Error2;
643 SumOverTi += 1. / Error2;
644 SumTiTS += Charge[
i] *
i / Error2;
645 SumTi += Charge[
i] / Error2;
648 double CM1 = SumTS2OverTi;
649 double CM2 = SumTSOverTi;
650 double CD1 = SumTSOverTi;
651 double CD2 = SumOverTi;
656 double Slope = (C1 * CD2 - C2 * CD1) / (CM1 * CD2 - CM2 * CD1);
657 double Intercept = (C1 * CM2 - C2 * CM1) / (CD1 * CM2 - CD2 * CM1);
661 for(
int i = 0;
i < DigiSize;
i++)
663 double Deviation = Slope *
i + Intercept - Charge[
i];
664 double Error2 = Charge[
i];
667 Chi2 += Deviation * Deviation / Error2;
679 std::vector<std::pair<double, double> > &Cuts,
694 if(Charge <= Cuts[0].
first)
697 int IndexLargerThanCharge = -1;
698 for(
int i = 1;
i < (int)Cuts.size();
i++)
700 if(Cuts[
i].first > Charge)
702 IndexLargerThanCharge =
i;
707 double limit = 1000000;
709 if(IndexLargerThanCharge == -1)
710 limit = Cuts[Cuts.size()-1].second;
713 double C1 = Cuts[IndexLargerThanCharge].first;
714 double C2 = Cuts[IndexLargerThanCharge-1].first;
715 double L1 = Cuts[IndexLargerThanCharge].second;
716 double L2 = Cuts[IndexLargerThanCharge-1].second;
718 limit = (Charge - C1) / (C2 - C1) * (L2 - L1) + L1;
721 if(Side > 0 && Discriminant > limit)
723 if(Side < 0 && Discriminant < limit)
static std::vector< std::string > checklist log
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