12 _dynamicPedestals(
false),
13 _mitigateBadSamples(
false),
14 _selectiveBadSampleCriteria(
false),
15 _addPedestalUncertainty(0.),
16 _simplifiedNoiseModelForGainSwitch(
true),
17 _gainSwitchUseMaxSample(
false){
36 const unsigned int iSampleMax = 5;
37 const unsigned int iFullPulseMax = 9;
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 (iSample==iSampleMax) {
114 double maxpulseamplitude = maxamplitude / fullpulse[iFullPulseMax];
117 for (
unsigned int ipulse=0; ipulse<
_pulsefunc.
BXs().rows(); ++ipulse) {
120 rh.setOutOfTimeAmplitude(bx+5, 0.0);
130 if (mitigateBadSample) {
131 badSamples[iSampleMax-1] = 1;
140 int gainidxmax = gainsNoise[iSampleMax];
141 noisecov = gainratios[gainidxmax]*gainratios[gainidxmax]*pedrmss[gainidxmax]*pedrmss[gainidxmax]*noisecors[gainidxmax];
148 noisecov = SampleMatrix::Zero();
149 for (
unsigned int gainidx=0; gainidx<noisecors.size(); ++gainidx) {
152 if (pedestal.maxCoeff()>0.) {
155 noisecov += gainratios[gainidx]*gainratios[gainidx]*pedrmss[gainidx]*pedrmss[gainidx]*pedestal.asDiagonal()*noisecors[gainidx]*pedestal.asDiagonal();
173 bool usePrefit =
false;
188 status =
_pulsefunc.
DoFit(amplitudes,noisecov,activeBX,fullpulse,fullpulsecov,gainsPedestal,badSamples);
192 edm::LogWarning(
"EcalUncalibRecHitMultiFitAlgo::makeRecHit") <<
"Failed Fit" << std::endl;
195 unsigned int ipulseintime = 0;
196 for (
unsigned int ipulse=0; ipulse<
_pulsefunc.
BXs().rows(); ++ipulse) {
198 ipulseintime = ipulse;
203 amplitude = status ?
_pulsefunc.
X()[ipulseintime] : 0.;
214 for (
unsigned int ipulse=0; ipulse<
_pulsefunc.
BXs().rows(); ++ipulse) {
217 rh.setOutOfTimeAmplitude(bx+5, status ?
_pulsefunc.
X().coeff(ipulse) : 0.);
219 else if (bx==(100+gainsPedestal[iSampleMax])) {
220 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)