test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PulseShapeFitOOTPileupCorrection Class Reference

#include <PulseShapeFitOOTPileupCorrection.h>

Public Member Functions

void apply (const CaloSamples &cs, const std::vector< int > &capidvec, const HcalCalibrations &calibs, double &reconstructedEnergy, float &reconstructedTime, bool &useTriple, float &chi2) const
 
void phase1Apply (const HBHEChannelInfo &channelData, float &reconstructedEnergy, float &reconstructedTime, bool &useTriple, float &chi2) const
 
 PulseShapeFitOOTPileupCorrection ()
 
void resetPulseShapeTemplate (const HcalPulseShapes::Shape &ps)
 
void setChi2Term (bool isHPD)
 
void setPulseShapeTemplate (const HcalPulseShapes::Shape &ps, bool isHPD)
 
void setPUParams (bool iPedestalConstraint, bool iTimeConstraint, bool iAddPulseJitter, bool iApplyTimeSlew, double iTS4Min, const std::vector< double > &iTS4Max, double iPulseJitter, double iTimeMean, double iTimeSigHPD, double iTimeSigSiPM, double iPedMean, double iPedSigHPD, double iPedSigSiPM, double iNoiseHPD, double iNoiseSiPM, double iTMin, double iTMax, const std::vector< double > &its4Chi2, HcalTimeSlew::BiasSetting slewFlavor, int iFitTimes)
 
 ~PulseShapeFitOOTPileupCorrection ()
 

Private Member Functions

void fit (int iFit, float &timevalfit, float &chargevalfit, float &pedvalfit, float &chi2, bool &fitStatus, double &iTSMax, const double &iTSTOTen, double *iEnArr, int(&iBX)[3]) const
 
int pulseShapeFit (const double *energyArr, const double *pedenArr, const double *chargeArr, const double *pedArr, const double *gainArr, const double tsTOTen, std::vector< float > &fitParsVec, const double *ADCnoise) const
 

Private Attributes

bool addPulseJitter_
 
bool applyTimeSlew_
 
double chargeThreshold_
 
int cntsetPulseShape
 
ROOT::Math::Functor * dpfunctor_
 
int fitTimes_
 
PSFitter::HybridMinimizerhybridfitter
 
std::array< double,
HcalConst::maxSamples
iniTimesArr
 
double noise_
 
double noiseHPD_
 
double noiseSiPM_
 
bool pedestalConstraint_
 
double pedMean_
 
double pedSig_
 
double pedSigHPD_
 
double pedSigSiPM_
 
std::unique_ptr
< FitterFuncs::PulseShapeFunctor
psfPtr_
 
double pulseJitter_
 
HcalTimeSlew::BiasSetting slewFlavor_
 
ROOT::Math::Functor * spfunctor_
 
bool timeConstraint_
 
double timeMean_
 
double timeSig_
 
double timeSigHPD_
 
double timeSigSiPM_
 
ROOT::Math::Functor * tpfunctor_
 
double ts4Chi2_
 
double ts4Max_
 
double ts4Min_
 
int TSMax_
 
int TSMin_
 
bool unConstrainedFit_
 
std::vector< double > vts4Chi2_
 
std::vector< double > vts4Max_
 

Detailed Description

Definition at line 90 of file PulseShapeFitOOTPileupCorrection.h.

Constructor & Destructor Documentation

PulseShapeFitOOTPileupCorrection::PulseShapeFitOOTPileupCorrection ( )

Definition at line 210 of file PulseShapeFitOOTPileupCorrection.cc.

References hybridfitter, iniTimesArr, and PSFitter::HybridMinimizer::kMigrad.

210  : cntsetPulseShape(0),
211  psfPtr_(nullptr), spfunctor_(nullptr), dpfunctor_(nullptr), tpfunctor_(nullptr),
214  ts4Min_(0), vts4Max_(0), pulseJitter_(0), timeMean_(0), timeSig_(0), pedMean_(0), pedSig_(0),
215  noise_(0) {
217  iniTimesArr = { {-100,-75,-50,-25,0,25,50,75,100,125} };
218 }
std::array< double, HcalConst::maxSamples > iniTimesArr
std::unique_ptr< FitterFuncs::PulseShapeFunctor > psfPtr_
PulseShapeFitOOTPileupCorrection::~PulseShapeFitOOTPileupCorrection ( )

Definition at line 220 of file PulseShapeFitOOTPileupCorrection.cc.

References dpfunctor_, hybridfitter, spfunctor_, and tpfunctor_.

220  {
221  if(hybridfitter) delete hybridfitter;
222  if(spfunctor_) delete spfunctor_;
223  if(dpfunctor_) delete dpfunctor_;
224  if(tpfunctor_) delete tpfunctor_;
225 }

Member Function Documentation

void PulseShapeFitOOTPileupCorrection::apply ( const CaloSamples cs,
const std::vector< int > &  capidvec,
const HcalCalibrations calibs,
double &  reconstructedEnergy,
float &  reconstructedTime,
bool &  useTriple,
float &  chi2 
) const

Definition at line 301 of file PulseShapeFitOOTPileupCorrection.cc.

References RecoTauCleanerPlugins::charge, relval_parameters_module::energy, HcalConst::maxSamples, HcalCalibrations::pedestal(), psfPtr_, pulseShapeFit(), HcalCalibrations::respcorrgain(), CaloSamples::size(), ts4Chi2_, ts4Max_, ts4Min_, vts4Chi2_, and vts4Max_.

Referenced by heavyIonTools.ConfigureHeavyIons::__call__(), editorTools.UserCodeTool::__call__(), HiCoreTools.RestrictInputToAOD::__call__(), coreTools.RunOnData::__call__(), trackTools.MakeAODTrackCandidates::__call__(), runJetUncertainties.RunJetUncertainties::__call__(), metTools.AddMETCollection::__call__(), heavyIonTools.ProductionDefaults::__call__(), editorTools.ChangeSource::__call__(), HiCoreTools.RemoveMCMatching::__call__(), coreTools.RemoveMCMatching::__call__(), trackTools.MakePATTrackCandidates::__call__(), trigTools.SwitchOnTrigger::__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::__call__(), heavyIonTools.SelectionDefaults::__call__(), HiCoreTools.RemoveAllPATObjectsBut::__call__(), heavyIonTools.DisbaleMonteCarloDeps::__call__(), HiCoreTools.RemoveSpecificPATObjects::__call__(), trigTools.SwitchOnTriggerStandAlone::__call__(), trackTools.MakeTrackCandidates::__call__(), tauTools.AddTauCollection::__call__(), trigTools.SwitchOnTriggerMatching::__call__(), HiCoreTools.RemoveCleaning::__call__(), HiCoreTools.AddCleaning::__call__(), trigTools.SwitchOnTriggerMatchingStandAlone::__call__(), jetTools.AddJetCollection::__call__(), trigTools.SwitchOnTriggerMatchEmbedding::__call__(), jetTools.SwitchJetCollection::__call__(), jetTools.UpdateJetCollection::__call__(), jetTools.AddJetID::__call__(), jetTools.SetTagInfos::__call__(), HcalSimpleRecAlgoImpl::reco(), and HcalSimpleRecAlgoImpl::recoHBHE().

308 {
309  psfPtr_->setDefaultcntNANinfit();
310 
311  const unsigned int cssize = cs.size();
312 // initialize arrays to be zero
313  double chargeArr[HcalConst::maxSamples]={}, pedArr[HcalConst::maxSamples]={}, gainArr[HcalConst::maxSamples]={};
314  double energyArr[HcalConst::maxSamples]={}, pedenArr[HcalConst::maxSamples]={};
315  double noiseADCArr[HcalConst::maxSamples]={};
316 
317  double tsTOT = 0, tstrig = 0; // in fC
318  double tsTOTen = 0; // in GeV
319  for(unsigned int ip=0; ip<cssize; ++ip){
320  if( ip >= (unsigned) HcalConst::maxSamples ) continue; // Too many samples than what we wanna fit (10 is enough...) -> skip them
321  const int capid = capidvec[ip];
322  double charge = cs[ip];
323  double ped = calibs.pedestal(capid);
324  double gain = calibs.respcorrgain(capid);
325 
326  double energy = charge*gain;
327  double peden = ped*gain;
328 
329  chargeArr[ip] = charge; pedArr[ip] = ped; gainArr[ip] = gain;
330  energyArr[ip] = energy; pedenArr[ip] = peden;
331 
332  noiseADCArr[ip] = psfPtr_->sigmaHPDQIE8(chargeArr[ip]); // Add Greg's channel discretization
333 
334  tsTOT += charge - ped;
335  tsTOTen += energy - peden;
336  if( ip ==4 || ip==5 ){
337  tstrig += charge - ped;
338  }
339  }
340 
341  ts4Max_=vts4Max_[0]; // HB and HE are identical for Run2
342  ts4Chi2_=vts4Chi2_[0]; // HB and HE are identical for Run2
343 
344  std::vector<float> fitParsVec;
345 
346  if(tstrig >= ts4Min_&& tsTOTen > 0.) { //Two sigma from 0
347  pulseShapeFit(energyArr, pedenArr, chargeArr, pedArr, gainArr, tsTOTen, fitParsVec, noiseADCArr);
348  }
349  else if((tstrig < ts4Min_||tsTOTen < 0.)&&(ts4Min_==0)){
350  fitParsVec.clear();
351  fitParsVec.push_back(0.);
352  fitParsVec.push_back(0.);
353  fitParsVec.push_back(0.);
354  fitParsVec.push_back(999.);
355  fitParsVec.push_back(false);
356  } else {
357  fitParsVec.clear();
358  fitParsVec.push_back(0.); //charge
359  fitParsVec.push_back(-9999); // time
360  fitParsVec.push_back(0.); // ped
361  fitParsVec.push_back(-9999); // chi2
362  fitParsVec.push_back(false); // triple
363  }
364 
365  reconstructedEnergy=fitParsVec[0];
366  reconstructedTime=fitParsVec[1];
367  chi2 = fitParsVec[3];
368  useTriple=fitParsVec[4];
369 
370 }
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
double pedestal(int fCapId) const
get pedestal for capid=0..3
int size() const
get the size
Definition: CaloSamples.h:24
std::unique_ptr< FitterFuncs::PulseShapeFunctor > psfPtr_
int pulseShapeFit(const double *energyArr, const double *pedenArr, const double *chargeArr, const double *pedArr, const double *gainArr, const double tsTOTen, std::vector< float > &fitParsVec, const double *ADCnoise) const
void PulseShapeFitOOTPileupCorrection::fit ( int  iFit,
float &  timevalfit,
float &  chargevalfit,
float &  pedvalfit,
float &  chi2,
bool &  fitStatus,
double &  iTSMax,
const double &  iTSTOTen,
double *  iEnArr,
int(&)  iBX[3] 
) const
private

Definition at line 438 of file PulseShapeFitOOTPileupCorrection.cc.

References funct::abs(), assert(), PSFitter::HybridMinimizer::Clear(), dpfunctor_, fitTimes_, hybridfitter, i, iniTimesArr, PSFitter::HybridMinimizer::kMigrad, PSFitter::HybridMinimizer::kScan, PSFitter::HybridMinimizer::Minimize(), PSFitter::HybridMinimizer::MinValue(), gen::n, pedMean_, pedSig_, mps_update::results, PSFitter::HybridMinimizer::SetFixedVariable(), PSFitter::HybridMinimizer::SetFunction(), PSFitter::HybridMinimizer::SetLimitedVariable(), PSFitter::HybridMinimizer::SetMinimizerType(), spfunctor_, timeMean_, timeSig_, tpfunctor_, TSMax_, TSMin_, varNames, and PSFitter::HybridMinimizer::X().

Referenced by trackingPlots.Iteration::modules(), and pulseShapeFit().

438  {
439  int n = 3;
440  if(iFit == 2) n = 5; //Two Pulse Fit
441  if(iFit == 3) n = 7; //Three Pulse Fit
442  //Step 1 Single Pulse fit
443  float pedMax = iTSMax; //=> max timeslice
444  float tMin = TSMin_; //Fitting Time Min
445  float tMax = TSMax_; //Fitting Time Max
446  //Checks to make sure fitting happens
447  if(pedMax < 1.) pedMax = 1.;
448  // Set starting values andf step sizes for parameters
449  double vstart[n];
450  for(int i = 0; i < int((n-1)/2); i++) {
451  vstart[2*i+0] = iniTimesArr[iBX[i]]+timeMean_;
452  vstart[2*i+1] = iEnArr[iBX[i]];
453  }
454  vstart[n-1] = pedMean_;
455 
456  double step[n];
457  for(int i = 0; i < n; i++) step[i] = 0.1;
458 
459  if(iFit == 1) hybridfitter->SetFunction(*spfunctor_);
460  if(iFit == 2) hybridfitter->SetFunction(*dpfunctor_);
461  if(iFit == 3) hybridfitter->SetFunction(*tpfunctor_);
462  hybridfitter->Clear();
463  //Times and amplitudes
464  for(int i = 0; i < int((n-1)/2); i++) {
465  hybridfitter->SetLimitedVariable(0+i*2, varNames[2*i+0] , vstart[0+i*2], step[0+i*2],iniTimesArr[iBX[i]]+tMin, iniTimesArr[ iBX[i] ]+tMax);
466  hybridfitter->SetLimitedVariable(1+i*2, varNames[2*i+1] , vstart[1+i*2], step[1+i*2], 0, 1.2*iTSTOTEn);
467  //Secret Option to fix the time
468  if(timeSig_ < 0) hybridfitter->SetFixedVariable(0+i*2, varNames[2*i+0],vstart[0+i*2]);
469  }
470  //Pedestal
471  if(vstart[n-1] > std::abs(pedMax)) vstart[n-1] = pedMax;
472  hybridfitter->SetLimitedVariable(n-1, varNames[n-1], vstart[n-1], step[n-1],-pedMax,pedMax);
473  //Secret Option to fix the pedestal
474  if(pedSig_ < 0) hybridfitter->SetFixedVariable(n-1,varNames[n-1],vstart[n-1]);
475  //a special number to label the initial condition
476  chi2=-1;
477  //3 fits why?!
478  const double *results = 0;
479  for(int tries=0; tries<=3;++tries){
480  if( fitTimes_ != 2 || tries !=1 ){
482  fitStatus = hybridfitter->Minimize();
483  }
484  double chi2valfit = hybridfitter->MinValue();
485  const double *newresults = hybridfitter->X();
486  if(chi2 == -1 || chi2>chi2valfit+0.01) {
487  results=newresults;
488  chi2=chi2valfit;
489  if( tries == 0 && fitTimes_ == 1 ) break;
490  if( tries == 1 && (fitTimes_ == 2 || fitTimes_ ==3 ) ) break;
491  if( tries == 2 && fitTimes_ == 4 ) break;
492  if( tries == 3 && fitTimes_ == 5 ) break;
493  //Secret option to speed up the fit => perhaps we should drop this
494  if(timeSig_ < 0 || pedSig_ < 0) break;
495  if(tries==0){
497  fitStatus = hybridfitter->Minimize();
498  } else if(tries==1){
499  hybridfitter->SetStrategy(1);
500  } else if(tries==2){
501  hybridfitter->SetStrategy(2);
502  }
503  } else {
504  break;
505  }
506  }
507  assert(results);
508 
509  timevalfit = results[0];
510  chargevalfit = results[1];
511  pedvalfit = results[n-1];
512 
513 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
constexpr char const * varNames[]
virtual const double * X() const
return pointer to X values at the minimum
void SetMinimizerType(EMinimizerType type)
std::array< double, HcalConst::maxSamples > iniTimesArr
virtual double MinValue() const
return minimum function value
tuple results
Definition: mps_update.py:44
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual bool SetFixedVariable(unsigned int, const std::string &, double)
set fixed variable (override if minimizer supports them )
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the function to minimize
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double, double)
set upper/lower limited variable (override if minimizer supports them )
step
void PulseShapeFitOOTPileupCorrection::phase1Apply ( const HBHEChannelInfo channelData,
float &  reconstructedEnergy,
float &  reconstructedTime,
bool &  useTriple,
float &  chi2 
) const

Definition at line 515 of file PulseShapeFitOOTPileupCorrection.cc.

References RecoTauCleanerPlugins::charge, HBHEChannelInfo::darkCurrent(), relval_parameters_module::energy, HBHEChannelInfo::fcByPE(), HBHEChannelInfo::hasTimeInfo(), HBHEChannelInfo::lambda(), HcalConst::maxSamples, HBHEChannelInfo::nSamples(), psfPtr_, pulseShapeFit(), ts4Chi2_, ts4Max_, ts4Min_, HBHEChannelInfo::tsGain(), HBHEChannelInfo::tsPedestal(), HBHEChannelInfo::tsPedestalWidth(), HBHEChannelInfo::tsRawCharge(), vts4Chi2_, and vts4Max_.

Referenced by SimpleHBHEPhase1Algo::reconstruct().

520 {
521 
522  psfPtr_->setDefaultcntNANinfit();
523 
524  const unsigned cssize = channelData.nSamples();
525  // initialize arrays to be zero
526  double chargeArr[HcalConst::maxSamples]={}, pedArr[HcalConst::maxSamples]={}, gainArr[HcalConst::maxSamples]={};
527  double energyArr[HcalConst::maxSamples]={}, pedenArr[HcalConst::maxSamples]={};
528  double noiseADCArr[HcalConst::maxSamples]={};
529  double noiseDCArr[HcalConst::maxSamples]={};
530  double noiseArr[HcalConst::maxSamples]={};
531  double tsTOT = 0, tstrig = 0; // in fC
532  double tsTOTen = 0; // in GeV
533 
534  // go over the time slices
535  for(unsigned int ip=0; ip<cssize; ++ip){
536  if( ip >= (unsigned) HcalConst::maxSamples ) continue; // Too many samples than what we wanna fit (10 is enough...) -> skip them
537 
538  // const int capid = channelData.capid(); // not needed
539  double charge = channelData.tsRawCharge(ip);
540  double ped = channelData.tsPedestal(ip);
541  double gain = channelData.tsGain(ip);
542 
543  double energy = charge*gain;
544  double peden = ped*gain;
545 
546  chargeArr[ip] = charge; pedArr[ip] = ped; gainArr[ip] = gain;
547  energyArr[ip] = energy; pedenArr[ip] = peden;
548 
549  // quantization noise from the ADC (QIE8 or QIE10/11)
550  if(!channelData.hasTimeInfo()) noiseADCArr[ip] = psfPtr_->sigmaHPDQIE8(chargeArr[ip]);
551  if(channelData.hasTimeInfo()) noiseADCArr[ip] = psfPtr_->sigmaSiPMQIE10(chargeArr[ip]);
552 
553  // dark current noise relevant for siPM
554  noiseDCArr[ip] = 0;
555  if(channelData.hasTimeInfo() && (charge-ped)>channelData.tsPedestalWidth(ip)) {
556  noiseDCArr[ip] = psfPtr_->getSiPMDarkCurrent(channelData.darkCurrent(),channelData.fcByPE(),channelData.lambda());
557  }
558 
559  noiseArr[ip]= noiseADCArr[ip] + noiseDCArr[ip];
560 
561  tsTOT += charge - ped;
562  tsTOTen += energy - peden;
563  if( ip ==4 || ip==5 ){
564  tstrig += charge - ped;
565  }
566  }
567 
568  if(channelData.hasTimeInfo()) {
570  } else {
572  }
573 
574  std::vector<float> fitParsVec;
575  if(tstrig >= ts4Min_ && tsTOTen > 0.) { //Two sigma from 0
576  pulseShapeFit(energyArr, pedenArr, chargeArr, pedArr, gainArr, tsTOTen, fitParsVec,noiseArr);
577  }
578  else if((tstrig < ts4Min_||tsTOTen < 0.)&&(ts4Min_==0)){
579  fitParsVec.clear();
580  fitParsVec.push_back(0.);
581  fitParsVec.push_back(0.);
582  fitParsVec.push_back(0.);
583  fitParsVec.push_back(999.);
584  fitParsVec.push_back(false);
585  } else {
586  fitParsVec.clear();
587  fitParsVec.push_back(0.); //charge
588  fitParsVec.push_back(-9999); // time
589  fitParsVec.push_back(0.); // ped
590  fitParsVec.push_back(-9999); // chi2
591  fitParsVec.push_back(false); // triple
592  }
593 
594 
595  reconstructedEnergy = fitParsVec[0];
596  reconstructedTime = fitParsVec[1];
597  chi2 = fitParsVec[3];
598  useTriple = fitParsVec[4];
599 
600 }
double lambda() const
bool hasTimeInfo() const
double tsGain(const unsigned ts) const
double tsPedestal(const unsigned ts) const
double tsRawCharge(const unsigned ts) const
double fcByPE() const
double darkCurrent() const
double tsPedestalWidth(const unsigned ts) const
std::unique_ptr< FitterFuncs::PulseShapeFunctor > psfPtr_
unsigned nSamples() const
int pulseShapeFit(const double *energyArr, const double *pedenArr, const double *chargeArr, const double *pedArr, const double *gainArr, const double tsTOTen, std::vector< float > &fitParsVec, const double *ADCnoise) const
int PulseShapeFitOOTPileupCorrection::pulseShapeFit ( const double *  energyArr,
const double *  pedenArr,
const double *  chargeArr,
const double *  pedArr,
const double *  gainArr,
const double  tsTOTen,
std::vector< float > &  fitParsVec,
const double *  ADCnoise 
) const
private

Definition at line 374 of file PulseShapeFitOOTPileupCorrection.cc.

References funct::abs(), applyTimeSlew_, rpcdqm::BX, beam_dqm_sourceclient-live_cfg::chi2, HcalTimeSlew::delay(), fit(), i, bookConverter::max, HcalConst::maxSamples, noise_, psfPtr_, slewFlavor_, mathSSE::sqrt(), ts4Chi2_, and ts4Max_.

Referenced by apply(), and phase1Apply().

374  {
375  double tsMAX=0;
377  double tstrig = 0; // in fC
378  for(int i=0;i<HcalConst::maxSamples;++i){
379  tmpx[i]=i;
380  tmpy[i]=energyArr[i]-pedenArr[i];
381  //Add Time Slew !!! does this need to be pedestal subtracted
382  tmpslew[i] = 0;
383  if(applyTimeSlew_) tmpslew[i] = HcalTimeSlew::delay(std::max(1.0,chargeArr[i]),slewFlavor_);
384  // add the noise components
385  tmperry2[i]=noise_*noise_+ noiseADCArr[i]*noiseADCArr[i];
386 
387  //Propagate it through
388  tmperry2[i]*=(gainArr[i]*gainArr[i]); //Convert from fC to GeV
389  tmperry [i]=sqrt(tmperry2[i]);
390 
391  if(std::abs(energyArr[i])>tsMAX) tsMAX=std::abs(tmpy[i]);
392  if( i ==4 || i ==5 ){
393  tstrig += chargeArr[i] - pedArr[i];
394  }
395  }
396  psfPtr_->setpsFitx (tmpx);
397  psfPtr_->setpsFity (tmpy);
398  psfPtr_->setpsFiterry (tmperry);
399  psfPtr_->setpsFiterry2(tmperry2);
400  psfPtr_->setpsFitslew (tmpslew);
401 
402  //Fit 1 single pulse
403  float timevalfit = 0;
404  float chargevalfit= 0;
405  float pedvalfit = 0;
406  float chi2 = 999; //cannot be zero
407  bool fitStatus = false;
408  bool useTriple = false;
409 
410  int BX[3] = {4,5,3};
411  if(ts4Chi2_ != 0) fit(1,timevalfit,chargevalfit,pedvalfit,chi2,fitStatus,tsMAX,tsTOTen,tmpy,BX);
412 // Based on the pulse shape ( 2. likely gives the same performance )
413  if(tmpy[2] > 3.*tmpy[3]) BX[2] = 2;
414 // Only do three-pulse fit when tstrig < ts4Max_, otherwise one-pulse fit is used (above)
415  if(chi2 > ts4Chi2_ && tstrig < ts4Max_) { //fails chi2 cut goes straight to 3 Pulse fit
416  fit(3,timevalfit,chargevalfit,pedvalfit,chi2,fitStatus,tsMAX,tsTOTen,tmpy,BX);
417  useTriple=true;
418  }
419 
420  /*
421  if(chi2 > ts345Chi2_) { //fails do two pulse chi2 for TS5
422  BX[1] = 5;
423  fit(3,timevalfit,chargevalfit,pedvalfit,chi2,fitStatus,tsMAX,tsTOTen,BX);
424  }
425  */
426  //Fix back the timeslew
427  //if(applyTimeSlew_) timevalfit+=HcalTimeSlew::delay(std::max(1.0,chargeArr[4]),slewFlavor_);
428  int outfitStatus = (fitStatus ? 1: 0 );
429  fitParsVec.clear();
430  fitParsVec.push_back(chargevalfit);
431  fitParsVec.push_back(timevalfit);
432  fitParsVec.push_back(pedvalfit);
433  fitParsVec.push_back(chi2);
434  fitParsVec.push_back(useTriple);
435  return outfitStatus;
436 }
int i
Definition: DBlmapReader.cc:9
void fit(int iFit, float &timevalfit, float &chargevalfit, float &pedvalfit, float &chi2, bool &fitStatus, double &iTSMax, const double &iTSTOTen, double *iEnArr, int(&iBX)[3]) const
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::unique_ptr< FitterFuncs::PulseShapeFunctor > psfPtr_
static double delay(double fC, BiasSetting bias=Medium)
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
Definition: HcalTimeSlew.cc:15
void PulseShapeFitOOTPileupCorrection::resetPulseShapeTemplate ( const HcalPulseShapes::Shape ps)

Definition at line 292 of file PulseShapeFitOOTPileupCorrection.cc.

References addPulseJitter_, applyTimeSlew_, cntsetPulseShape, FitterFuncs::PulseShapeFunctor::doublePulseShapeFunc(), dpfunctor_, noise_, pedestalConstraint_, pedMean_, pedSig_, psfPtr_, pulseJitter_, FitterFuncs::PulseShapeFunctor::singlePulseShapeFunc(), spfunctor_, timeConstraint_, timeMean_, timeSig_, tpfunctor_, and FitterFuncs::PulseShapeFunctor::triplePulseShapeFunc().

Referenced by setPulseShapeTemplate().

292  {
293  ++ cntsetPulseShape;
296  spfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::singlePulseShapeFunc, 3);
297  dpfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::doublePulseShapeFunc, 5);
298  tpfunctor_ = new ROOT::Math::Functor(psfPtr_.get(),&FitterFuncs::PulseShapeFunctor::triplePulseShapeFunc, 7);
299 }
std::unique_ptr< FitterFuncs::PulseShapeFunctor > psfPtr_
void PulseShapeFitOOTPileupCorrection::setChi2Term ( bool  isHPD)

Definition at line 227 of file PulseShapeFitOOTPileupCorrection.cc.

References noise_, noiseHPD_, noiseSiPM_, pedSig_, pedSigHPD_, pedSigSiPM_, timeSig_, timeSigHPD_, and timeSigSiPM_.

Referenced by setPulseShapeTemplate().

void PulseShapeFitOOTPileupCorrection::setPulseShapeTemplate ( const HcalPulseShapes::Shape ps,
bool  isHPD 
)

Definition at line 280 of file PulseShapeFitOOTPileupCorrection.cc.

References resetPulseShapeTemplate(), and setChi2Term().

280  {
281  // initialize for every hit now to avoid incorrect settings for different channel types (HPD vs SiPM)
282  // FIXME: keep this as a reminder to improve and reduce CPU use
283  // if( cntsetPulseShape ) return;
284 
285  // set the M2 parameters before defining the shape
286  setChi2Term(isHPD);
287 
289 
290 }
void resetPulseShapeTemplate(const HcalPulseShapes::Shape &ps)
void PulseShapeFitOOTPileupCorrection::setPUParams ( bool  iPedestalConstraint,
bool  iTimeConstraint,
bool  iAddPulseJitter,
bool  iApplyTimeSlew,
double  iTS4Min,
const std::vector< double > &  iTS4Max,
double  iPulseJitter,
double  iTimeMean,
double  iTimeSigHPD,
double  iTimeSigSiPM,
double  iPedMean,
double  iPedSigHPD,
double  iPedSigSiPM,
double  iNoiseHPD,
double  iNoiseSiPM,
double  iTMin,
double  iTMax,
const std::vector< double > &  its4Chi2,
HcalTimeSlew::BiasSetting  slewFlavor,
int  iFitTimes 
)

Definition at line 243 of file PulseShapeFitOOTPileupCorrection.cc.

References addPulseJitter_, applyTimeSlew_, fitTimes_, noiseHPD_, noiseSiPM_, pedestalConstraint_, pedMean_, pedSigHPD_, pedSigSiPM_, pulseJitter_, slewFlavor_, timeConstraint_, timeMean_, timeSigHPD_, timeSigSiPM_, ts4Min_, TSMax_, TSMin_, vts4Chi2_, and vts4Max_.

250  {
251 
252  TSMin_ = iTMin;
253  TSMax_ = iTMax;
254  // ts4Chi2_ = its4Chi2;
255  vts4Chi2_ = its4Chi2;
256  pedestalConstraint_ = iPedestalConstraint;
257  timeConstraint_ = iTimeConstraint;
258  addPulseJitter_ = iAddPulseJitter;
259  applyTimeSlew_ = iApplyTimeSlew;
260  ts4Min_ = iTS4Min;
261  // ts4Max_ = iTS4Max;
262  vts4Max_ = iTS4Max;
263  pulseJitter_ = iPulseJitter*iPulseJitter;
264  timeMean_ = iTimeMean;
265  // timeSig_ = iTimeSig;
266  timeSigHPD_ = iTimeSigHPD;
267  timeSigSiPM_ = iTimeSigSiPM;
268  pedMean_ = iPedMean;
269  // pedSig_ = iPedSig;
270  pedSigHPD_ = iPedSigHPD;
271  pedSigSiPM_ = iPedSigSiPM;
272  // noise_ = iNoise;
273  noiseHPD_ = iNoiseHPD;
274  noiseSiPM_ = iNoiseSiPM;
275  slewFlavor_ = slewFlavor;
276  fitTimes_ = iFitTimes;
277 
278 }

Member Data Documentation

bool PulseShapeFitOOTPileupCorrection::addPulseJitter_
private

Definition at line 146 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by resetPulseShapeTemplate(), and setPUParams().

bool PulseShapeFitOOTPileupCorrection::applyTimeSlew_
private
double PulseShapeFitOOTPileupCorrection::chargeThreshold_
private

Definition at line 133 of file PulseShapeFitOOTPileupCorrection.h.

int PulseShapeFitOOTPileupCorrection::cntsetPulseShape
private

Definition at line 131 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by resetPulseShapeTemplate().

ROOT::Math::Functor* PulseShapeFitOOTPileupCorrection::dpfunctor_
private
int PulseShapeFitOOTPileupCorrection::fitTimes_
private

Definition at line 134 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by fit(), and setPUParams().

PSFitter::HybridMinimizer* PulseShapeFitOOTPileupCorrection::hybridfitter
private
std::array<double,HcalConst::maxSamples> PulseShapeFitOOTPileupCorrection::iniTimesArr
private

Definition at line 132 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by fit(), and PulseShapeFitOOTPileupCorrection().

double PulseShapeFitOOTPileupCorrection::noise_
private
double PulseShapeFitOOTPileupCorrection::noiseHPD_
private

Definition at line 162 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by setChi2Term(), and setPUParams().

double PulseShapeFitOOTPileupCorrection::noiseSiPM_
private

Definition at line 163 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by setChi2Term(), and setPUParams().

bool PulseShapeFitOOTPileupCorrection::pedestalConstraint_
private

Definition at line 144 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by resetPulseShapeTemplate(), and setPUParams().

double PulseShapeFitOOTPileupCorrection::pedMean_
private

Definition at line 157 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by fit(), resetPulseShapeTemplate(), and setPUParams().

double PulseShapeFitOOTPileupCorrection::pedSig_
private

Definition at line 158 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by fit(), resetPulseShapeTemplate(), and setChi2Term().

double PulseShapeFitOOTPileupCorrection::pedSigHPD_
private

Definition at line 159 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by setChi2Term(), and setPUParams().

double PulseShapeFitOOTPileupCorrection::pedSigSiPM_
private

Definition at line 160 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by setChi2Term(), and setPUParams().

std::unique_ptr<FitterFuncs::PulseShapeFunctor> PulseShapeFitOOTPileupCorrection::psfPtr_
private
double PulseShapeFitOOTPileupCorrection::pulseJitter_
private

Definition at line 152 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by resetPulseShapeTemplate(), and setPUParams().

HcalTimeSlew::BiasSetting PulseShapeFitOOTPileupCorrection::slewFlavor_
private

Definition at line 164 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by pulseShapeFit(), and setPUParams().

ROOT::Math::Functor* PulseShapeFitOOTPileupCorrection::spfunctor_
private
bool PulseShapeFitOOTPileupCorrection::timeConstraint_
private

Definition at line 145 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by resetPulseShapeTemplate(), and setPUParams().

double PulseShapeFitOOTPileupCorrection::timeMean_
private

Definition at line 153 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by fit(), resetPulseShapeTemplate(), and setPUParams().

double PulseShapeFitOOTPileupCorrection::timeSig_
private

Definition at line 154 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by fit(), resetPulseShapeTemplate(), and setChi2Term().

double PulseShapeFitOOTPileupCorrection::timeSigHPD_
private

Definition at line 155 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by setChi2Term(), and setPUParams().

double PulseShapeFitOOTPileupCorrection::timeSigSiPM_
private

Definition at line 156 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by setChi2Term(), and setPUParams().

ROOT::Math::Functor* PulseShapeFitOOTPileupCorrection::tpfunctor_
private
double PulseShapeFitOOTPileupCorrection::ts4Chi2_
mutableprivate

Definition at line 142 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by apply(), phase1Apply(), and pulseShapeFit().

double PulseShapeFitOOTPileupCorrection::ts4Max_
mutableprivate

Definition at line 150 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by apply(), phase1Apply(), and pulseShapeFit().

double PulseShapeFitOOTPileupCorrection::ts4Min_
private

Definition at line 149 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by apply(), phase1Apply(), and setPUParams().

int PulseShapeFitOOTPileupCorrection::TSMax_
private

Definition at line 141 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by fit(), and setPUParams().

int PulseShapeFitOOTPileupCorrection::TSMin_
private

Definition at line 140 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by fit(), and setPUParams().

bool PulseShapeFitOOTPileupCorrection::unConstrainedFit_
private

Definition at line 147 of file PulseShapeFitOOTPileupCorrection.h.

std::vector<double> PulseShapeFitOOTPileupCorrection::vts4Chi2_
private

Definition at line 143 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by apply(), phase1Apply(), and setPUParams().

std::vector<double> PulseShapeFitOOTPileupCorrection::vts4Max_
private

Definition at line 151 of file PulseShapeFitOOTPileupCorrection.h.

Referenced by apply(), phase1Apply(), and setPUParams().