12 _dynamicPedestals(
false),
13 _mitigateBadSamples(
false),
14 _selectiveBadSampleCriteria(
false),
15 _addPedestalUncertainty(0.),
16 _simplifiedNoiseModelForGainSwitch(
true),
17 _gainSwitchUseMaxSample(
false){
37 unsigned int iSampleMax = 0;
51 for(
unsigned int iSample = 0; iSample < nsample; iSample++) {
59 double gainratio = 1.;
61 if (gainId==0 || gainId==3) {
64 gainsNoise[iSample] = 2;
65 gainsPedestal[iSample] = dynamicPedestal ? 2 : -1;
70 gainsNoise[iSample] = 0;
71 gainsPedestal[iSample] = dynamicPedestal ? 0 : -1;
76 gainsNoise[iSample] = 1;
77 gainsPedestal[iSample] = dynamicPedestal ? 1 : -1;
80 if (dynamicPedestal) {
81 amplitude = (double)(sample.
adc())*gainratio;
84 amplitude = ((double)(sample.
adc()) - pedestal) * gainratio;
88 edm::LogError(
"EcalUncalibRecHitMultiFitAlgo")<<
"Saturation encountered. Multifit is not intended to be used for saturated channels.";
90 if (dynamicPedestal) {
91 amplitude = 4095.*gainratio;
94 amplitude = (4095. -
pedestal) * gainratio;
100 if (gainratio > maxgainratio || gainId==0 || amplitude>maxamplitude) {
103 maxgainratio = gainratio;
104 iSampleMax = iSample;
119 for (
unsigned int ipulse=0; ipulse<
_pulsefunc.
BXs().rows(); ++ipulse) {
122 rh.setOutOfTimeAmplitude(bx+5, 0.0);
132 if (mitigateBadSample) {
133 badSamples[iSampleMax-1] = 1;
142 int gainidxmax = gainsNoise[iSampleMax];
143 noisecov = gainratios[gainidxmax]*gainratios[gainidxmax]*pedrmss[gainidxmax]*pedrmss[gainidxmax]*noisecors[gainidxmax];
150 noisecov = SampleMatrix::Zero();
151 for (
unsigned int gainidx=0; gainidx<noisecors.size(); ++gainidx) {
154 if (pedestal.maxCoeff()>0.) {
157 noisecov += gainratios[gainidx]*gainratios[gainidx]*pedrmss[gainidx]*pedrmss[gainidx]*pedestal.asDiagonal()*noisecors[gainidx]*pedestal.asDiagonal();
175 bool usePrefit =
false;
190 status =
_pulsefunc.
DoFit(amplitudes,noisecov,activeBX,fullpulse,fullpulsecov,gainsPedestal,badSamples);
194 edm::LogWarning(
"EcalUncalibRecHitMultiFitAlgo::makeRecHit") <<
"Failed Fit" << std::endl;
197 unsigned int ipulseintime = 0;
198 for (
unsigned int ipulse=0; ipulse<
_pulsefunc.
BXs().rows(); ++ipulse) {
200 ipulseintime = ipulse;
205 amplitude = status ?
_pulsefunc.
X()[ipulseintime] : 0.;
216 for (
unsigned int ipulse=0; ipulse<
_pulsefunc.
BXs().rows(); ++ipulse) {
219 rh.setOutOfTimeAmplitude(bx+5, status ?
_pulsefunc.
X().coeff(ipulse) : 0.);
221 else if (bx==(100+gainsPedestal[iSampleMax])) {
222 rh.setPedestal(status ?
_pulsefunc.
X().coeff(ipulse) : 0.);
void setMaxIterWarnings(bool b)
bool hasSwitchToGain1() const
Eigen::Matrix< char, SampleVectorSize, 1 > SampleGainVector
int gainId(sample_type sample)
get the gainId (2 bits)
bool hasSwitchToGain6() const
void disableErrorCalculation()
Eigen::Matrix< double, SampleVectorSize, 1 > SampleVector
const PulseVector & Errors() const
bool _simplifiedNoiseModelForGainSwitch
EcalMGPASample sample(int i) const
std::vector< Variable::Flags > flags
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()
Eigen::Matrix< double, SampleVectorSize, SampleVectorSize > SampleMatrix
const PulseVector & X() const
bool _gainSwitchUseMaxSample
double _addPedestalUncertainty
std::array< SampleMatrix, NGains > SampleMatrixGainArray
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
const BXVector & BXs() const
PulseChiSqSNNLS _pulsefuncSingle
PulseChiSqSNNLS _pulsefunc
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
Eigen::Matrix< double, FullSampleVectorSize, FullSampleVectorSize > FullSampleMatrix
static const int MAXSAMPLES
int adc() const
get the ADC sample (12 bits)