CMS 3D CMS Logo

MahiFit.cc
Go to the documentation of this file.
3 
5  fullTSSize_(19),
6  fullTSofInterest_(8)
7 {}
8 
9 double MahiFit::getSiPMDarkCurrent(double darkCurrent, double fcByPE, double lambda) const {
10  double mu = darkCurrent * 25 / fcByPE;
11  return sqrt(mu/pow(1-lambda,3)) * fcByPE;
12 }
13 
14 void MahiFit::setParameters(bool iDynamicPed, double iTS4Thresh, double chiSqSwitch,
15  bool iApplyTimeSlew, HcalTimeSlew::BiasSetting slewFlavor,
16  double iMeanTime, double iTimeSigmaHPD, double iTimeSigmaSiPM,
17  const std::vector <int> &iActiveBXs, int iNMaxItersMin, int iNMaxItersNNLS,
18  double iDeltaChiSqThresh, double iNnlsThresh) {
19 
20  dynamicPed_ = iDynamicPed;
21 
22  ts4Thresh_ = iTS4Thresh;
24 
25  applyTimeSlew_ = iApplyTimeSlew;
26  slewFlavor_ = slewFlavor;
27 
28  meanTime_ = iMeanTime;
29  timeSigmaHPD_ = iTimeSigmaHPD;
30  timeSigmaSiPM_ = iTimeSigmaSiPM;
31 
32  activeBXs_ = iActiveBXs;
33 
34  nMaxItersMin_ = iNMaxItersMin;
35  nMaxItersNNLS_ = iNMaxItersNNLS;
36 
37  deltaChiSqThresh_ = iDeltaChiSqThresh;
38  nnlsThresh_ = iNnlsThresh;
39 
40  bxOffsetConf_ = -(*std::min_element(activeBXs_.begin(), activeBXs_.end()));
41  bxSizeConf_ = activeBXs_.size();
42 
43 }
44 
45 void MahiFit::phase1Apply(const HBHEChannelInfo& channelData,
46  float& reconstructedEnergy,
47  float& reconstructedTime,
48  bool& useTriple,
49  float& chi2,
50  const HcalTimeSlew* hcalTimeSlew_delay) const {
51 
52  assert(channelData.nSamples()==8||channelData.nSamples()==10);
53 
55 
56  nnlsWork_.tsSize = channelData.nSamples();
57  nnlsWork_.tsOffset = channelData.soi();
59 
60  // 1 sigma time constraint
61  if (channelData.hasTimeInfo()) nnlsWork_.dt=timeSigmaSiPM_;
63 
64  //Dark current value for this channel (SiPM only)
65  float darkCurrent = getSiPMDarkCurrent(channelData.darkCurrent(),
66  channelData.fcByPE(),
67  channelData.lambda());
68 
69  //Average pedestal width (for covariance matrix constraint)
70  float pedVal = 0.25*( channelData.tsPedestalWidth(0)*channelData.tsPedestalWidth(0)+
71  channelData.tsPedestalWidth(1)*channelData.tsPedestalWidth(1)+
72  channelData.tsPedestalWidth(2)*channelData.tsPedestalWidth(2)+
73  channelData.tsPedestalWidth(3)*channelData.tsPedestalWidth(3) );
74 
75  nnlsWork_.pedConstraint = pedVal*SampleMatrix::Ones(nnlsWork_.tsSize, nnlsWork_.tsSize);
78 
79  std::array<float,3> reconstructedVals {{ 0.0, -9999, -9999 }};
80 
81  double tsTOT = 0, tstrig = 0; // in GeV
82  for(unsigned int iTS=0; iTS<nnlsWork_.tsSize; ++iTS){
83  double charge = channelData.tsRawCharge(iTS);
84  double ped = channelData.tsPedestal(iTS);
85 
86  nnlsWork_.amplitudes.coeffRef(iTS) = charge - ped;
87 
88  //ADC granularity
89  double noiseADC = (1./sqrt(12))*channelData.tsDFcPerADC(iTS);
90 
91  //Dark current (for SiPMs)
92  double noiseDC=0;
93  if(channelData.hasTimeInfo() && !channelData.hasEffectivePedestals() && (charge-ped)>channelData.tsPedestalWidth(iTS)) {
94  noiseDC = darkCurrent;
95  }
96 
97  //Photostatistics
98  double noisePhoto = 0;
99  if ( (charge-ped)>channelData.tsPedestalWidth(iTS)) {
100  noisePhoto = sqrt((charge-ped)*channelData.fcByPE());
101  }
102 
103  //Electronic pedestal
104  double pedWidth = channelData.tsPedestalWidth(iTS);
105 
106  //Total uncertainty from all sources
107  nnlsWork_.noiseTerms.coeffRef(iTS) = noiseADC*noiseADC + noiseDC*noiseDC + noisePhoto*noisePhoto + pedWidth*pedWidth;
108 
109  tsTOT += (charge - ped)*channelData.tsGain(0);
110  if( iTS==nnlsWork_.tsOffset ){
111  tstrig += (charge - ped)*channelData.tsGain(0);
112  }
113  }
114 
115  if(tstrig >= ts4Thresh_ && tsTOT > 0) {
116 
117  useTriple=false;
118 
119  // only do pre-fit with 1 pulse if chiSq threshold is positive
120  if (chiSqSwitch_>0) {
121  doFit(reconstructedVals,1,hcalTimeSlew_delay);
122  if (reconstructedVals[2]>chiSqSwitch_) {
123  doFit(reconstructedVals,0,hcalTimeSlew_delay); //nbx=0 means use configured BXs
124  useTriple=true;
125  }
126  }
127  else {
128  doFit(reconstructedVals,0,hcalTimeSlew_delay);
129  useTriple=true;
130  }
131  }
132  else{
133  reconstructedVals.at(0) = 0.; //energy
134  reconstructedVals.at(1) = -9999.; //time
135  reconstructedVals.at(2) = -9999.; //chi2
136  }
137 
138  reconstructedEnergy = reconstructedVals[0]*channelData.tsGain(0);
139  reconstructedTime = reconstructedVals[1];
140  chi2 = reconstructedVals[2];
141 
142 }
143 
144 void MahiFit::doFit(std::array<float,3> &correctedOutput, int nbx, const HcalTimeSlew* hcalTimeSlew_delay) const {
145 
146  unsigned int bxSize=1;
147 
148  if (nbx==1) {
149  nnlsWork_.bxOffset = 0;
150  }
151  else {
152  bxSize = bxSizeConf_;
154  }
155 
156  nnlsWork_.bxs.resize(bxSize);
157 
158  if (nbx==1) {
159  nnlsWork_.bxs.coeffRef(0) = 0;
160  }
161  else {
162  for (unsigned int iBX=0; iBX<bxSize; iBX++) {
163  nnlsWork_.bxs.coeffRef(iBX) = activeBXs_[iBX];
164  }
165  }
166 
167  nnlsWork_.nPulseTot = bxSize;
168 
169  if (dynamicPed_) {
173  }
174 
176  nnlsWork_.ampVec = PulseVector::Zero(nnlsWork_.nPulseTot);
177  nnlsWork_.errVec = PulseVector::Zero(nnlsWork_.nPulseTot);
178 
179  int offset=0;
180  for (unsigned int iBX=0; iBX<nnlsWork_.nPulseTot; iBX++) {
181  offset=nnlsWork_.bxs.coeff(iBX);
182 
183  nnlsWork_.pulseShapeArray[iBX] = FullSampleVector::Zero(MaxFSVSize);
184  nnlsWork_.pulseDerivArray[iBX] = FullSampleVector::Zero(MaxFSVSize);
186 
187  if (offset==pedestalBX_) {
188  nnlsWork_.ampVec.coeffRef(iBX) = 0;
189  }
190  else {
191 
196  hcalTimeSlew_delay);
197 
198  nnlsWork_.ampVec.coeffRef(iBX)=0;
199 
201 
202  }
203  }
204 
205  nnlsWork_.pulseMat.col(nnlsWork_.nPulseTot-1) = SampleVector::Ones(nnlsWork_.tsSize);
206 
209 
210  double chiSq = minimize();
211 
213 
214  bool foundintime = false;
215  unsigned int ipulseintime = 0;
216 
217  for (unsigned int iBX=0; iBX<nnlsWork_.nPulseTot; ++iBX) {
218  if (nnlsWork_.bxs.coeff(iBX)==0) {
219  ipulseintime = iBX;
220  foundintime = true;
221  }
222  }
223 
224  if (foundintime) {
225  correctedOutput.at(0) = nnlsWork_.ampVec.coeff(ipulseintime); //charge
226  double arrivalTime = calculateArrivalTime();
227  correctedOutput.at(1) = arrivalTime; //time
228  correctedOutput.at(2) = chiSq; //chi2
229 
230  }
231 
232 }
233 
234 double MahiFit::minimize() const {
235 
236  int iter = 0;
237  double oldChiSq=9999;
238  double chiSq=oldChiSq;
239 
240  while (true) {
241  if (iter>=nMaxItersMin_) {
242  break;
243  }
244 
245  updateCov();
246 
247  if (nnlsWork_.nPulseTot>1) {
248  nnls();
249  }
250  else {
252  }
253 
254  double newChiSq=calculateChiSq();
255  double deltaChiSq = newChiSq - chiSq;
256 
257  if (newChiSq==oldChiSq && newChiSq<chiSq) {
258  break;
259  }
260  oldChiSq=chiSq;
261  chiSq = newChiSq;
262 
263  if (std::abs(deltaChiSq)<deltaChiSqThresh_) break;
264 
265  iter++;
266 
267  }
268 
269  return chiSq;
270 
271 }
272 
273 void MahiFit::updatePulseShape(double itQ, FullSampleVector &pulseShape, FullSampleVector &pulseDeriv,
274  FullSampleMatrix &pulseCov,
275  const HcalTimeSlew* hcalTimeSlew_delay) const {
276 
277  float t0=meanTime_;
278  if (applyTimeSlew_) t0+=hcalTimeSlew_delay->delay(std::max(1.0, itQ), slewFlavor_);
279 
280  nnlsWork_.pulseN.fill(0);
281  nnlsWork_.pulseM.fill(0);
282  nnlsWork_.pulseP.fill(0);
283 
284  const double xx[4]={t0, 1.0, 0.0, 3};
285  const double xxm[4]={-nnlsWork_.dt+t0, 1.0, 0.0, 3};
286  const double xxp[4]={ nnlsWork_.dt+t0, 1.0, 0.0, 3};
287 
288  (*pfunctor_)(&xx[0]);
289  psfPtr_->getPulseShape(nnlsWork_.pulseN);
290 
291  (*pfunctor_)(&xxm[0]);
292  psfPtr_->getPulseShape(nnlsWork_.pulseM);
293 
294  (*pfunctor_)(&xxp[0]);
295  psfPtr_->getPulseShape(nnlsWork_.pulseP);
296 
297  //in the 2018+ case where the sample of interest (SOI) is in TS3, add an extra offset to align
298  //with previous SOI=TS4 case assumed by psfPtr_->getPulseShape()
299  int delta =nnlsWork_. tsOffset == 3 ? 1 : 0;
300 
301  for (unsigned int iTS=nnlsWork_.fullTSOffset; iTS<nnlsWork_.fullTSOffset + nnlsWork_.tsSize; iTS++) {
302 
303  pulseShape.coeffRef(iTS) = nnlsWork_.pulseN[iTS-nnlsWork_.fullTSOffset+delta];
304  pulseDeriv.coeffRef(iTS) = 0.5*(nnlsWork_.pulseM[iTS-nnlsWork_.fullTSOffset+delta]+nnlsWork_.pulseP[iTS-nnlsWork_.fullTSOffset+delta])/(2*nnlsWork_.dt);
305 
308  }
309 
310  for (unsigned int iTS=nnlsWork_.fullTSOffset; iTS<nnlsWork_.fullTSOffset+nnlsWork_.tsSize; iTS++) {
311  for (unsigned int jTS=nnlsWork_.fullTSOffset; jTS<iTS+1; jTS++) {
312 
315 
316  pulseCov(iTS,jTS) += tmp;
317  pulseCov(jTS,iTS) += tmp;
318 
319  }
320  }
321 
322 }
323 
324 void MahiFit::updateCov() const {
325 
327 
328  nnlsWork_.invCovMat = nnlsWork_.noiseTerms.asDiagonal();
330 
331  for (unsigned int iBX=0; iBX<nnlsWork_.nPulseTot; iBX++) {
332  if (nnlsWork_.ampVec.coeff(iBX)==0) continue;
333 
334  int offset=nnlsWork_.bxs.coeff(iBX);
335 
336  if (offset==pedestalBX_) continue;
337  else {
338  nnlsWork_.invCovMat += nnlsWork_.ampVec.coeff(iBX)*nnlsWork_.ampVec.coeff(iBX)
340  }
341  }
342 
344 }
345 
347 
349 
350  int itIndex=0;
351 
352  for (unsigned int iBX=0; iBX<nnlsWork_.nPulseTot; iBX++) {
353  int offset=nnlsWork_.bxs.coeff(iBX);
354  if (offset==0) itIndex=iBX;
355 
356  if (offset==pedestalBX_) {
357  nnlsWork_.pulseDerivMat.col(iBX) = SampleVector::Zero(nnlsWork_.tsSize);
358  }
359  else {
361  }
362  }
363 
364  PulseVector solution = nnlsWork_.pulseDerivMat.colPivHouseholderQr().solve(nnlsWork_.residuals);
365  return solution.coeff(itIndex)/nnlsWork_.ampVec.coeff(itIndex);
366 
367 }
368 
369 
370 void MahiFit::nnls() const {
371  const unsigned int npulse = nnlsWork_.nPulseTot;
372 
373  for (unsigned int iBX=0; iBX<npulse; iBX++) {
374  int offset=nnlsWork_.bxs.coeff(iBX);
375  if (offset==pedestalBX_) {
376  nnlsWork_.pulseMat.col(iBX) = SampleVector::Ones(nnlsWork_.tsSize);
377  }
378  else {
380  }
381  }
382 
384  nnlsWork_.aTaMat = nnlsWork_.invcovp.transpose().lazyProduct(nnlsWork_.invcovp);
385  nnlsWork_.aTbVec = nnlsWork_.invcovp.transpose().lazyProduct(nnlsWork_.covDecomp.matrixL().solve(nnlsWork_.amplitudes));
386 
387  int iter = 0;
388  Index idxwmax = 0;
389  double wmax = 0.0;
390  double threshold = nnlsThresh_;
391 
392  nnlsWork_.nP=0;
393 
394  while (true) {
395  if (iter>0 || nnlsWork_.nP==0) {
396  if ( nnlsWork_.nP==std::min(npulse, nnlsWork_.tsSize)) break;
397 
398  const unsigned int nActive = npulse - nnlsWork_.nP;
400 
401  Index idxwmaxprev = idxwmax;
402  double wmaxprev = wmax;
403  wmax = nnlsWork_.updateWork.tail(nActive).maxCoeff(&idxwmax);
404 
405  if (wmax<threshold || (idxwmax==idxwmaxprev && wmax==wmaxprev)) {
406  break;
407  }
408 
409  if (iter>=nMaxItersNNLS_) {
410  break;
411  }
412 
413  //unconstrain parameter
414  Index idxp = nnlsWork_.nP + idxwmax;
416 
417  }
418 
419  while (true) {
420  if (nnlsWork_.nP==0) break;
421 
423 
425 
426  //check solution
427  bool positive = true;
428  for (unsigned int i = 0; i < nnlsWork_.nP; ++i)
429  positive &= (nnlsWork_.ampvecpermtest(i) > 0);
430  if (positive) {
432  break;
433  }
434 
435  //update parameter vector
436  Index minratioidx=0;
437 
438  // no realizable optimization here (because it autovectorizes!)
439  double minratio = std::numeric_limits<double>::max();
440  for (unsigned int ipulse=0; ipulse<nnlsWork_.nP; ++ipulse) {
441  if (nnlsWork_.ampvecpermtest.coeff(ipulse)<=0.) {
442  const double c_ampvec = nnlsWork_.ampVec.coeff(ipulse);
443  const double ratio = c_ampvec/(c_ampvec-nnlsWork_.ampvecpermtest.coeff(ipulse));
444  if (ratio<minratio) {
445  minratio = ratio;
446  minratioidx = ipulse;
447  }
448  }
449  }
451 
452  //avoid numerical problems with later ==0. check
453  nnlsWork_.ampVec.coeffRef(minratioidx) = 0.;
454 
455  nnlsConstrainParameter(minratioidx);
456  }
457 
458  ++iter;
459 
460  //adaptive convergence threshold to avoid infinite loops but still
461  //ensure best value is used
462  if (iter%10==0) {
463  threshold *= 10.;
464  }
465 
466  }
467 
468 }
469 
471 
473 
474  SingleMatrix aTamatval = nnlsWork_.invcovp.transpose()*nnlsWork_.invcovp;
475  SingleVector aTbvecval = nnlsWork_.invcovp.transpose()*nnlsWork_.covDecomp.matrixL().solve(nnlsWork_.amplitudes);
476 
477  nnlsWork_.ampVec.coeffRef(0) = std::max(0., aTbvecval.coeff(0)/aTamatval.coeff(0));
478 
479 
480 }
481 
482 double MahiFit::calculateChiSq() const {
483 
484  return (nnlsWork_.covDecomp.matrixL().solve(nnlsWork_.pulseMat*nnlsWork_.ampVec - nnlsWork_.amplitudes)).squaredNorm();
485 }
486 
488 
489  if (!(&ps == currentPulseShape_ ))
490  {
492  currentPulseShape_ = &ps;
493  }
494 }
495 
498 
499  // only the pulse shape itself from PulseShapeFunctor is used for Mahi
500  // the uncertainty terms calculated inside PulseShapeFunctor are used for Method 2 only
501  psfPtr_.reset(new FitterFuncs::PulseShapeFunctor(ps,false,false,false,false,
502  1,0,2.5,0,0.00065,1,10));
503  pfunctor_ = std::unique_ptr<ROOT::Math::Functor>( new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::singlePulseShapeFunc, 3) );
504 
505 }
506 
508  nnlsWork_.aTaMat.col(nnlsWork_.nP).swap(nnlsWork_.aTaMat.col(idxp));
509  nnlsWork_.aTaMat.row(nnlsWork_.nP).swap(nnlsWork_.aTaMat.row(idxp));
510  nnlsWork_.pulseMat.col(nnlsWork_.nP).swap(nnlsWork_.pulseMat.col(idxp));
511  std::swap(nnlsWork_.aTbVec.coeffRef(nnlsWork_.nP),nnlsWork_.aTbVec.coeffRef(idxp));
512  std::swap(nnlsWork_.ampVec.coeffRef(nnlsWork_.nP),nnlsWork_.ampVec.coeffRef(idxp));
513  std::swap(nnlsWork_.bxs.coeffRef(nnlsWork_.nP),nnlsWork_.bxs.coeffRef(idxp));
514  ++nnlsWork_.nP;
515 }
516 
517 void MahiFit::nnlsConstrainParameter(Index minratioidx) const {
518  nnlsWork_.aTaMat.col(nnlsWork_.nP-1).swap(nnlsWork_.aTaMat.col(minratioidx));
519  nnlsWork_.aTaMat.row(nnlsWork_.nP-1).swap(nnlsWork_.aTaMat.row(minratioidx));
520  nnlsWork_.pulseMat.col(nnlsWork_.nP-1).swap(nnlsWork_.pulseMat.col(minratioidx));
521  std::swap(nnlsWork_.aTbVec.coeffRef(nnlsWork_.nP-1),nnlsWork_.aTbVec.coeffRef(minratioidx));
522  std::swap(nnlsWork_.ampVec.coeffRef(nnlsWork_.nP-1),nnlsWork_.ampVec.coeffRef(minratioidx));
523  std::swap(nnlsWork_.bxs.coeffRef(nnlsWork_.nP-1),nnlsWork_.bxs.coeffRef(minratioidx));
524  --nnlsWork_.nP;
525 
526 }
527 
528 void MahiFit::solveSubmatrix(PulseMatrix& mat, PulseVector& invec, PulseVector& outvec, unsigned nP) const {
529  using namespace Eigen;
530  switch( nP ) { // pulse matrix is always square.
531  case 10:
532  {
533  Matrix<double,10,10> temp = mat;
534  outvec.head<10>() = temp.ldlt().solve(invec.head<10>());
535  }
536  break;
537  case 9:
538  {
539  Matrix<double,9,9> temp = mat.topLeftCorner<9,9>();
540  outvec.head<9>() = temp.ldlt().solve(invec.head<9>());
541  }
542  break;
543  case 8:
544  {
545  Matrix<double,8,8> temp = mat.topLeftCorner<8,8>();
546  outvec.head<8>() = temp.ldlt().solve(invec.head<8>());
547  }
548  break;
549  case 7:
550  {
551  Matrix<double,7,7> temp = mat.topLeftCorner<7,7>();
552  outvec.head<7>() = temp.ldlt().solve(invec.head<7>());
553  }
554  break;
555  case 6:
556  {
557  Matrix<double,6,6> temp = mat.topLeftCorner<6,6>();
558  outvec.head<6>() = temp.ldlt().solve(invec.head<6>());
559  }
560  break;
561  case 5:
562  {
563  Matrix<double,5,5> temp = mat.topLeftCorner<5,5>();
564  outvec.head<5>() = temp.ldlt().solve(invec.head<5>());
565  }
566  break;
567  case 4:
568  {
569  Matrix<double,4,4> temp = mat.topLeftCorner<4,4>();
570  outvec.head<4>() = temp.ldlt().solve(invec.head<4>());
571  }
572  break;
573  case 3:
574  {
575  Matrix<double,3,3> temp = mat.topLeftCorner<3,3>();
576  outvec.head<3>() = temp.ldlt().solve(invec.head<3>());
577  }
578  break;
579  case 2:
580  {
581  Matrix<double,2,2> temp = mat.topLeftCorner<2,2>();
582  outvec.head<2>() = temp.ldlt().solve(invec.head<2>());
583  }
584  break;
585  case 1:
586  {
587  Matrix<double,1,1> temp = mat.topLeftCorner<1,1>();
588  outvec.head<1>() = temp.ldlt().solve(invec.head<1>());
589  }
590  break;
591  default:
592  throw cms::Exception("HcalMahiWeirdState")
593  << "Weird number of pulses encountered in Mahi, module is configured incorrectly!";
594  }
595 }
596 
598 
600  nnlsWork_.tsSize=0;
604  nnlsWork_.dt=0;
605 
609 
613 
614  nnlsWork_.amplitudes.setZero();
615  nnlsWork_.bxs.setZero();
616  nnlsWork_.invCovMat.setZero();
617  nnlsWork_.noiseTerms.setZero();
618  nnlsWork_.pedConstraint.setZero();
619  nnlsWork_.pulseMat.setZero();
620  nnlsWork_.pulseDerivMat.setZero();
621  nnlsWork_.residuals.setZero();
622  nnlsWork_.ampVec.setZero();
623  nnlsWork_.errVec.setZero();
624  nnlsWork_.ampvecpermtest.setZero();
625  nnlsWork_.invcovp.setZero();
626  nnlsWork_.aTaMat.setZero();
627  nnlsWork_.aTbVec.setZero();
628  nnlsWork_.updateWork.setZero();
629  nnlsWork_.covDecompLinv.setZero();
630  nnlsWork_.topleft_work.setZero();
631 
632 
633 
634 }
unsigned int nPulseTot
Definition: MahiFit.h:19
dbl * delta
Definition: mlp_gen.cc:36
void nnls() const
Definition: MahiFit.cc:370
float chiSqSwitch_
Definition: MahiFit.h:143
double lambda() const
SamplePulseMatrix invcovp
Definition: MahiFit.h:72
HcalTimeSlew::BiasSetting slewFlavor_
Definition: MahiFit.h:146
bool hasTimeInfo() const
double tsGain(const unsigned ts) const
void nnlsConstrainParameter(Index minratioidx) const
Definition: MahiFit.cc:517
SampleVector amplitudes
Definition: MahiFit.h:30
MahiNnlsWorkspace nnlsWork_
Definition: MahiFit.h:132
BXVector::Index Index
Definition: MahiFit.h:108
void phase1Apply(const HBHEChannelInfo &channelData, float &reconstructedEnergy, float &reconstructedTime, bool &useTriple, float &chi2, const HcalTimeSlew *hcalTimeSlew_delay) const
Definition: MahiFit.cc:45
double singlePulseShapeFunc(const double *x)
void solveSubmatrix(PulseMatrix &mat, PulseVector &invec, PulseVector &outvec, unsigned nP) const
Definition: MahiFit.cc:528
double delay(double fC, BiasSetting bias=Medium) const
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
Definition: HcalTimeSlew.cc:14
static constexpr int pedestalBX_
Definition: MahiFit.h:138
bool applyTimeSlew_
Definition: MahiFit.h:145
void resetPulseShapeTemplate(const HcalPulseShapes::Shape &ps)
Definition: MahiFit.cc:496
unsigned soi() const
PulseVector ampVec
Definition: MahiFit.h:67
SampleDecompLLT covDecomp
Definition: MahiFit.h:77
PulseVector ampvecpermtest
Definition: MahiFit.h:70
constexpr int MaxFSVSize
std::array< FullSampleVector, MaxPVSize > pulseShapeArray
Definition: MahiFit.h:46
float meanTime_
Definition: MahiFit.h:148
void nnlsUnconstrainParameter(Index idxp) const
Definition: MahiFit.cc:507
std::array< double, MaxSVSize > pulseM
Definition: MahiFit.h:53
PulseMatrix topleft_work
Definition: MahiFit.h:79
bool hasEffectivePedestals() const
double tsPedestal(const unsigned ts) const
void doFit(std::array< float, 3 > &correctedOutput, int nbx, const HcalTimeSlew *hcalTimeSlew_delay) const
Definition: MahiFit.cc:144
SamplePulseMatrix pulseDerivMat
Definition: MahiFit.h:60
std::array< double, MaxSVSize > pulseN
Definition: MahiFit.h:52
int bxOffsetConf_
Definition: MahiFit.h:161
PulseVector aTbVec
Definition: MahiFit.h:74
double tsRawCharge(const unsigned ts) const
float nnlsThresh_
Definition: MahiFit.h:158
int cntsetPulseShape_
Definition: MahiFit.h:164
void onePulseMinimize() const
Definition: MahiFit.cc:470
std::unique_ptr< FitterFuncs::PulseShapeFunctor > psfPtr_
Definition: MahiFit.h:165
MahiFit()
Definition: MahiFit.cc:4
Eigen::Matrix< double, FullSampleVectorSize, 1 > FullSampleVector
double getSiPMDarkCurrent(double darkCurrent, double fcByPE, double lambda) const
Definition: MahiFit.cc:9
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:18
unsigned int bxSizeConf_
Definition: MahiFit.h:160
double fcByPE() const
int nMaxItersMin_
Definition: MahiFit.h:154
PulseVector residuals
Definition: MahiFit.h:63
Eigen::Matrix< double, 1, 1 > SingleVector
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
#define end
Definition: vmac.h:39
T min(T a, T b)
Definition: MathUtil.h:58
void setPulseShapeTemplate(const HcalPulseShapes::Shape &ps)
Definition: MahiFit.cc:487
double calculateArrivalTime() const
Definition: MahiFit.cc:346
SampleMatrix pedConstraint
Definition: MahiFit.h:39
std::vector< int > activeBXs_
Definition: MahiFit.h:152
std::array< FullSampleVector, MaxPVSize > pulseDerivArray
Definition: MahiFit.h:49
double darkCurrent() const
const unsigned int fullTSofInterest_
Definition: MahiFit.h:136
Polynomial< 0 > Constant
Definition: Constant.h:6
SampleMatrix covDecompLinv
Definition: MahiFit.h:78
SampleMatrix invCovMat
Definition: MahiFit.h:33
unsigned int tsOffset
Definition: MahiFit.h:21
void resetWorkspace() const
Definition: MahiFit.cc:597
std::unique_ptr< ROOT::Math::Functor > pfunctor_
Definition: MahiFit.h:166
Eigen::Matrix< double, FullSampleVectorSize, FullSampleVectorSize > FullSampleMatrix
void resize(int bx, unsigned size)
double tsPedestalWidth(const unsigned ts) const
double calculateChiSq() const
Definition: MahiFit.cc:482
void updatePulseShape(double itQ, FullSampleVector &pulseShape, FullSampleVector &pulseDeriv, FullSampleMatrix &pulseCov, const HcalTimeSlew *hcalTimeSlew_delay) const
Definition: MahiFit.cc:273
PulseMatrix aTaMat
Definition: MahiFit.h:73
unsigned int fullTSOffset
Definition: MahiFit.h:22
Eigen::Matrix< double, Eigen::Dynamic, 1, 0, PulseVectorSize, 1 > PulseVector
SamplePulseMatrix pulseMat
Definition: MahiFit.h:57
bool dynamicPed_
Definition: MahiFit.h:141
std::array< FullSampleMatrix, MaxPVSize > pulseCovArray
Definition: MahiFit.h:43
float timeSigmaSiPM_
Definition: MahiFit.h:150
SampleVector noiseTerms
Definition: MahiFit.h:36
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define begin
Definition: vmac.h:32
void setParameters(bool iDynamicPed, double iTS4Thresh, double chiSqSwitch, bool iApplyTimeSlew, HcalTimeSlew::BiasSetting slewFlavor, double iMeanTime, double iTimeSigmaHPD, double iTimeSigmaSiPM, const std::vector< int > &iActiveBXs, int iNMaxItersMin, int iNMaxItersNNLS, double iDeltaChiSqThresh, double iNnlsThresh)
Definition: MahiFit.cc:14
float ts4Thresh_
Definition: MahiFit.h:142
unsigned int tsSize
Definition: MahiFit.h:20
float deltaChiSqThresh_
Definition: MahiFit.h:157
void updateCov() const
Definition: MahiFit.cc:324
float timeSigmaHPD_
Definition: MahiFit.h:149
unsigned int nP
Definition: MahiFit.h:66
BXVector bxs
Definition: MahiFit.h:27
const HcalPulseShapes::Shape * currentPulseShape_
Definition: MahiFit.h:109
unsigned nSamples() const
PulseVector errVec
Definition: MahiFit.h:69
int nMaxItersNNLS_
Definition: MahiFit.h:155
std::array< double, MaxSVSize > pulseP
Definition: MahiFit.h:54
Eigen::Matrix< double, 1, 1 > SingleMatrix
PulseVector updateWork
Definition: MahiFit.h:75
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, PulseVectorSize, PulseVectorSize > PulseMatrix
double minimize() const
Definition: MahiFit.cc:234
float tsDFcPerADC(const unsigned ts) const