9 : _computeErrors(
true),
12 _dynamicPedestals(
false),
13 _mitigateBadSamples(
false),
14 _selectiveBadSampleCriteria(
false),
15 _addPedestalUncertainty(0.),
16 _simplifiedNoiseModelForGainSwitch(
true),
17 _gainSwitchUseMaxSample(
false) {
39 const unsigned int iSampleMax = 5;
40 const unsigned int iFullPulseMax = 9;
54 for (
unsigned int iSample = 0; iSample < nsample; iSample++) {
61 double gainratio = 1.;
63 if (gainId == 0 || gainId == 3) {
66 gainsNoise[iSample] = 2;
67 gainsPedestal[iSample] = dynamicPedestal ? 2 : -1;
68 }
else if (gainId == 1) {
71 gainsNoise[iSample] = 0;
72 gainsPedestal[iSample] = dynamicPedestal ? 0 : -1;
73 }
else if (gainId == 2) {
76 gainsNoise[iSample] = 1;
77 gainsPedestal[iSample] = dynamicPedestal ? 1 : -1;
80 if (dynamicPedestal) {
81 amplitude = (double)(sample.
adc()) * gainratio;
83 amplitude = ((double)(sample.
adc()) - pedestal) * gainratio;
88 <<
"Saturation encountered. Multifit is not intended to be used for saturated channels.";
90 if (dynamicPedestal) {
91 amplitude = 4095. * gainratio;
93 amplitude = (4095. -
pedestal) * gainratio;
99 if (iSample == iSampleMax) {
112 double maxpulseamplitude = maxamplitude / fullpulse[iFullPulseMax];
115 for (
unsigned int ipulse = 0; ipulse <
_pulsefunc.
BXs().rows(); ++ipulse) {
118 rh.setOutOfTimeAmplitude(bx + 5, 0.0);
129 if (mitigateBadSample) {
130 badSamples[iSampleMax - 1] = 1;
139 int gainidxmax = gainsNoise[iSampleMax];
140 noisecov = gainratios[gainidxmax] * gainratios[gainidxmax] * pedrmss[gainidxmax] * pedrmss[gainidxmax] *
141 noisecors[gainidxmax];
147 noisecov = SampleMatrix::Zero();
148 for (
unsigned int gainidx = 0; gainidx < noisecors.size(); ++gainidx) {
151 if (pedestal.maxCoeff() > 0.) {
154 noisecov += gainratios[gainidx] * gainratios[gainidx] * pedrmss[gainidx] * pedrmss[gainidx] *
155 pedestal.asDiagonal() * noisecors[gainidx] * pedestal.asDiagonal();
159 pedestal.asDiagonal() * SampleMatrix::Ones() * pedestal.asDiagonal();
173 bool usePrefit =
false;
189 status =
_pulsefunc.
DoFit(amplitudes, noisecov, activeBX, fullpulse, fullpulsecov, gainsPedestal, badSamples);
193 edm::LogWarning(
"EcalUncalibRecHitMultiFitAlgo::makeRecHit") <<
"Failed Fit" << std::endl;
196 unsigned int ipulseintime = 0;
197 for (
unsigned int ipulse = 0; ipulse <
_pulsefunc.
BXs().rows(); ++ipulse) {
199 ipulseintime = ipulse;
204 amplitude = status ?
_pulsefunc.
X()[ipulseintime] : 0.;
214 for (
unsigned int ipulse = 0; ipulse <
_pulsefunc.
BXs().rows(); ++ipulse) {
216 if (bx != 0 &&
std::abs(bx) < 100) {
217 rh.setOutOfTimeAmplitude(bx + 5, status ?
_pulsefunc.
X().coeff(ipulse) : 0.);
218 }
else if (bx == (100 + gainsPedestal[iSampleMax])) {
219 rh.setPedestal(status ?
_pulsefunc.
X().coeff(ipulse) : 0.);
void setMaxIterWarnings(bool b)
bool hasSwitchToGain1() const
std::array< SampleMatrix, NGains > SampleMatrixGainArray
bool hasSwitchToGain6() const
Eigen::Matrix< double, FullSampleVectorSize, FullSampleVectorSize > FullSampleMatrix
void disableErrorCalculation()
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
const PulseVector & Errors() const
bool _simplifiedNoiseModelForGainSwitch
EcalMGPASample sample(int i) const
bool DoFit(const SampleVector &samples, const SampleMatrix &samplecov, const BXVector &bxs, const FullSampleVector &fullpulse, const FullSampleMatrix &fullpulsecov, const SampleGainVector &gains=-1 *SampleGainVector::Ones(), const SampleGainVector &badSamples=SampleGainVector::Zero())
int gainId() const
get the gainId (2 bits)
EcalUncalibRecHitMultiFitAlgo()
const PulseVector & X() const
bool _gainSwitchUseMaxSample
double _addPedestalUncertainty
Abs< T >::type abs(const T &t)
void setAmplitudeError(float amplitudeerror)
bool _selectiveBadSampleCriteria
EcalUncalibratedRecHit makeRecHit(const EcalDataFrame &dataFrame, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const SampleMatrixGainArray &noisecors, const FullSampleVector &fullpulse, const FullSampleMatrix &fullpulsecov, const BXVector &activeBX)
compute rechits
void resize(int bx, unsigned size)
float gain12Over6() const
Eigen::Matrix< double, SampleVectorSize, 1 > SampleVector
Eigen::Matrix< double, SampleVectorSize, SampleVectorSize > SampleMatrix
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
Eigen::Matrix< char, SampleVectorSize, 1 > SampleGainVector
const BXVector & BXs() const
PulseChiSqSNNLS _pulsefuncSingle
PulseChiSqSNNLS _pulsefunc
static constexpr int MAXSAMPLES
int adc() const
get the ADC sample (12 bits)