CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
HcalDeterministicFit Class Reference

#include <HcalDeterministicFit.h>

Public Member Functions

template<class Digi >
void apply (const CaloSamples &cs, const std::vector< int > &capidvec, const HcalCalibrations &calibs, const Digi &digi, double &ampl, float &time) const
 
void getLandauFrac (float tStart, float tEnd, float &sum) const
 
 HcalDeterministicFit ()
 
void init (HcalTimeSlew::ParaSource tsParam, HcalTimeSlew::BiasSetting bias, bool iApplyTimeSlew, PedestalSub pedSubFxn_, std::vector< double > pars, double respCorr)
 
void phase1Apply (const HBHEChannelInfo &channelData, float &reconstructedEnergy, float &reconstructedTime) const
 
 ~HcalDeterministicFit ()
 

Private Attributes

bool applyTimeSlew_
 
double fpars [9]
 
PedestalSub fPedestalSubFxn_
 
double frespCorr
 
HcalTimeSlew::ParaSource fTimeSlew
 
HcalTimeSlew::BiasSetting fTimeSlewBias
 

Static Private Attributes

static constexpr int HcalRegion [2] = {16, 17}
 
static constexpr float invGpar [3] = {-13.11, 11.29, 5.133}
 
static constexpr float landauFrac []
 
static constexpr float negThresh [2] = {-3., 15.}
 
static constexpr float rCorr [2] = {0.95, 0.95}
 
static constexpr float rCorrSiPM [2] = {1., 1.}
 
static constexpr int tsWidth = 25
 

Detailed Description

Definition at line 16 of file HcalDeterministicFit.h.

Constructor & Destructor Documentation

HcalDeterministicFit::HcalDeterministicFit ( )

Definition at line 14 of file HcalDeterministicFit.cc.

14  {
15 }
HcalDeterministicFit::~HcalDeterministicFit ( )

Definition at line 17 of file HcalDeterministicFit.cc.

17  {
18 }

Member Function Documentation

template<class Digi >
void HcalDeterministicFit::apply ( const CaloSamples cs,
const std::vector< int > &  capidvec,
const HcalCalibrations calibs,
const Digi &  digi,
double &  ampl,
float &  time 
) const

Definition at line 64 of file HcalDeterministicFit.h.

References funct::abs(), PedestalSub::calculate(), ALCARECOTkAlJpsiMuMu_cff::charge, HcalTimeSlew::delay(), fpars, fPedestalSubFxn_, frespCorr, fTimeSlew, fTimeSlewBias, muonCSCDigis_cfi::gain, getLandauFrac(), HcalRegion, HcalDetId::ieta(), invGpar, cmsBatch::log, negThresh, HcalCalibrations::pedestal(), particleFlowDisplacedVertex_cfi::ratio, rCorr, HcalCalibrations::respcorrgain(), CaloSamples::size(), mathSSE::sqrt(), and tsWidth.

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__(), trigTools.SwitchOnTriggerMatchEmbedding::__call__(), jetTools.AddJetCollection::__call__(), jetTools.SwitchJetCollection::__call__(), jetTools.UpdateJetCollection::__call__(), jetTools.AddJetID::__call__(), jetTools.SetTagInfos::__call__(), HcalSimpleRecAlgoImpl::reco(), and HcalSimpleRecAlgoImpl::recoHBHE().

64  {
65  std::vector<double> corrCharge;
66  std::vector<double> inputCharge;
67  std::vector<double> inputPedestal;
68  double gainCorr = 0;
69  double respCorr = 0;
70 
71  for(int ip=0; ip<cs.size(); ip++){
72  const int capid = capidvec[ip];
73  double charge = cs[ip];
74  double ped = calibs.pedestal(capid);
75  double gain = calibs.respcorrgain(capid);
76  gainCorr = gain;
77  inputCharge.push_back(charge);
78  inputPedestal.push_back(ped);
79  }
80 
81  fPedestalSubFxn_.calculate(inputCharge, inputPedestal, corrCharge);
82 
83  const HcalDetId& cell = digi.id();
84  double fpar0, fpar1, fpar2;
85  if(std::abs(cell.ieta())<HcalRegion[0]){
86  fpar0 = fpars[0];
87  fpar1 = fpars[1];
88  fpar2 = fpars[2];
89  }else if(std::abs(cell.ieta())==HcalRegion[0]||std::abs(cell.ieta())==HcalRegion[1]){
90  fpar0 = fpars[3];
91  fpar1 = fpars[4];
92  fpar2 = fpars[5];
93  }else{
94  fpar0 = fpars[6];
95  fpar1 = fpars[7];
96  fpar2 = fpars[8];
97  }
98 
99  if (fTimeSlew==0)respCorr=1.0;
100  else if (fTimeSlew==1)respCorr=rCorr[0];
101  else if (fTimeSlew==2)respCorr=rCorr[1];
102  else if (fTimeSlew==3)respCorr=frespCorr;
103 
104  float tsShift3=HcalTimeSlew::delay(inputCharge[3], fTimeSlew, fTimeSlewBias, fpar0, fpar1 ,fpar2);
105  float tsShift4=HcalTimeSlew::delay(inputCharge[4], fTimeSlew, fTimeSlewBias, fpar0, fpar1 ,fpar2);
106  float tsShift5=HcalTimeSlew::delay(inputCharge[5], fTimeSlew, fTimeSlewBias, fpar0, fpar1 ,fpar2);
107 
108  float i3=0;
109  getLandauFrac(-tsShift3,-tsShift3+tsWidth,i3);
110  float n3=0;
111  getLandauFrac(-tsShift3+tsWidth,-tsShift3+tsWidth*2,n3);
112  float nn3=0;
113  getLandauFrac(-tsShift3+tsWidth*2,-tsShift3+tsWidth*3,nn3);
114 
115  float i4=0;
116  getLandauFrac(-tsShift4,-tsShift4+tsWidth,i4);
117  float n4=0;
118  getLandauFrac(-tsShift4+tsWidth,-tsShift4+tsWidth*2,n4);
119 
120  float i5=0;
121  getLandauFrac(-tsShift5,-tsShift5+tsWidth,i5);
122  float n5=0;
123  getLandauFrac(-tsShift5+tsWidth,-tsShift5+tsWidth*2,n5);
124 
125  float ch3=0;
126  float ch4=0;
127  float ch5=0;
128 
129  if (i3 != 0 && i4 != 0 && i5 != 0) {
130 
131  ch3=corrCharge[3]/i3;
132  ch4=(i3*corrCharge[4]-n3*corrCharge[3])/(i3*i4);
133  ch5=(n3*n4*corrCharge[3]-i4*nn3*corrCharge[3]-i3*n4*corrCharge[4]+i3*i4*corrCharge[5])/(i3*i4*i5);
134 
135  if (ch3<negThresh[0]) {
136  ch3=negThresh[0];
137  ch4=corrCharge[4]/i4;
138  ch5=(i4*corrCharge[5]-n4*corrCharge[4])/(i4*i5);
139  }
140  if (ch5<negThresh[0] && ch4>negThresh[1]) {
141  double ratio = (corrCharge[4]-ch3*i3)/(corrCharge[5]-negThresh[0]*i5);
142  if (ratio < 5 && ratio > 0.5) {
143  double invG = invGpar[0]+invGpar[1]*std::sqrt(2*std::log(invGpar[2]/ratio));
144  float iG=0;
145  getLandauFrac(-invG,-invG+tsWidth,iG);
146  if (iG != 0 ) {
147  ch4=(corrCharge[4]-ch3*n3)/(iG);
148  tsShift4=invG;
149  }
150  }
151  }
152  }
153 
154  if (ch4<1) {
155  ch4=0;
156  }
157 
158  double ampl=ch4*gainCorr*respCorr;
159  reconstructedEnergy=ampl;
160  reconstructedTime=tsShift4;
161 }
static constexpr int tsWidth
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
static constexpr float rCorr[2]
static constexpr int HcalRegion[2]
double pedestal(int fCapId) const
get pedestal for capid=0..3
HcalTimeSlew::ParaSource fTimeSlew
T sqrt(T t)
Definition: SSEVec.h:18
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void getLandauFrac(float tStart, float tEnd, float &sum) const
void calculate(const std::vector< double > &inputCharge, const std::vector< double > &inputPedestal, std::vector< double > &corrCharge) const
Definition: PedestalSub.cc:20
int size() const
get the size
Definition: CaloSamples.h:24
static constexpr float negThresh[2]
HcalTimeSlew::BiasSetting fTimeSlewBias
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:16
static constexpr float invGpar[3]
void HcalDeterministicFit::getLandauFrac ( float  tStart,
float  tEnd,
float &  sum 
) const

Definition at line 38 of file HcalDeterministicFit.cc.

References funct::abs(), and createfilelist::int.

Referenced by apply().

38  {
39 
40  if (std::abs(tStart-tEnd-tsWidth)<0.1) {
41  sum=0;
42  return;
43  }
44  sum= landauFrac[int(ceil(tStart+tsWidth))];
45  return;
46 }
static constexpr int tsWidth
static constexpr float landauFrac[]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void HcalDeterministicFit::init ( HcalTimeSlew::ParaSource  tsParam,
HcalTimeSlew::BiasSetting  bias,
bool  iApplyTimeSlew,
PedestalSub  pedSubFxn_,
std::vector< double >  pars,
double  respCorr 
)

Definition at line 20 of file HcalDeterministicFit.cc.

References constexpr, and landauFrac.

20  {
21  for(int fi=0; fi<9; fi++){
22  fpars[fi] = pars.at(fi);
23  }
24 
25  applyTimeSlew_=iApplyTimeSlew;
26  fTimeSlew=tsParam;
27  fTimeSlewBias=bias;
28  fPedestalSubFxn_=pedSubFxn_;
29  frespCorr=respCorr;
30 
31 }
HcalTimeSlew::ParaSource fTimeSlew
HcalTimeSlew::BiasSetting fTimeSlewBias
void HcalDeterministicFit::phase1Apply ( const HBHEChannelInfo channelData,
float &  reconstructedEnergy,
float &  reconstructedTime 
) const

Definition at line 48 of file HcalDeterministicFit.cc.

References funct::abs(), ALCARECOTkAlJpsiMuMu_cff::charge, HcalTimeSlew::delay(), muonCSCDigis_cfi::gain, HBHEChannelInfo::hasTimeInfo(), HBHEChannelInfo::id(), HcalDetId::ieta(), cmsBatch::log, HBHEChannelInfo::nSamples(), particleFlowDisplacedVertex_cfi::ratio, mathSSE::sqrt(), HBHEChannelInfo::tsGain(), HBHEChannelInfo::tsPedestal(), and HBHEChannelInfo::tsRawCharge().

Referenced by SimpleHBHEPhase1Algo::reconstruct().

51 {
52 
53  std::vector<double> corrCharge;
54  std::vector<double> inputCharge;
55  std::vector<double> inputPedestal;
56  double gainCorr = 0;
57  double respCorr = 0;
58 
59  for(unsigned int ip=0; ip<channelData.nSamples(); ip++){
60 
61  double charge = channelData.tsRawCharge(ip);
62  double ped = channelData.tsPedestal(ip);
63  double gain = channelData.tsGain(ip);
64 
65  gainCorr = gain;
66  inputCharge.push_back(charge);
67  inputPedestal.push_back(ped);
68 
69  }
70 
71  fPedestalSubFxn_.calculate(inputCharge, inputPedestal, corrCharge);
72 
73  const HcalDetId& cell = channelData.id();
74 
75  double fpar0, fpar1, fpar2;
76  if(std::abs(cell.ieta())<HcalRegion[0]){
77  fpar0 = fpars[0];
78  fpar1 = fpars[1];
79  fpar2 = fpars[2];
80  }else if(std::abs(cell.ieta())==HcalRegion[0]||std::abs(cell.ieta())==HcalRegion[1]){
81  fpar0 = fpars[3];
82  fpar1 = fpars[4];
83  fpar2 = fpars[5];
84  }else{
85  fpar0 = fpars[6];
86  fpar1 = fpars[7];
87  fpar2 = fpars[8];
88  }
89 
90  if (fTimeSlew==0)respCorr=1.0;
91  else if (fTimeSlew==1) channelData.hasTimeInfo()?respCorr=rCorrSiPM[0]:respCorr=rCorr[0];
92  else if (fTimeSlew==2) channelData.hasTimeInfo()?respCorr=rCorrSiPM[1]:respCorr=rCorr[1];
93  else if (fTimeSlew==3)respCorr=frespCorr;
94 
95  float tsShift3=0;
96  float tsShift4=0;
97  float tsShift5=0;
98 
99  if(applyTimeSlew_) {
100 
101  tsShift3=HcalTimeSlew::delay(inputCharge[3], fTimeSlew, fTimeSlewBias, fpar0, fpar1 ,fpar2,!channelData.hasTimeInfo());
102  tsShift4=HcalTimeSlew::delay(inputCharge[4], fTimeSlew, fTimeSlewBias, fpar0, fpar1 ,fpar2,!channelData.hasTimeInfo());
103  tsShift5=HcalTimeSlew::delay(inputCharge[5], fTimeSlew, fTimeSlewBias, fpar0, fpar1 ,fpar2,!channelData.hasTimeInfo());
104 
105  }
106 
107  float i3=0;
108  getLandauFrac(-tsShift3,-tsShift3+tsWidth,i3);
109  float n3=0;
110  getLandauFrac(-tsShift3+tsWidth,-tsShift3+tsWidth*2,n3);
111  float nn3=0;
112  getLandauFrac(-tsShift3+tsWidth*2,-tsShift3+tsWidth*3,nn3);
113 
114  float i4=0;
115  getLandauFrac(-tsShift4,-tsShift4+tsWidth,i4);
116  float n4=0;
117  getLandauFrac(-tsShift4+tsWidth,-tsShift4+tsWidth*2,n4);
118 
119  float i5=0;
120  getLandauFrac(-tsShift5,-tsShift5+tsWidth,i5);
121  float n5=0;
122  getLandauFrac(-tsShift5+tsWidth,-tsShift5+tsWidth*2,n5);
123 
124  float ch3=0;
125  float ch4=0;
126  float ch5=0;
127 
128  if (i3 != 0 && i4 != 0 && i5 != 0) {
129 
130  ch3=corrCharge[3]/i3;
131  ch4=(i3*corrCharge[4]-n3*corrCharge[3])/(i3*i4);
132  ch5=(n3*n4*corrCharge[3]-i4*nn3*corrCharge[3]-i3*n4*corrCharge[4]+i3*i4*corrCharge[5])/(i3*i4*i5);
133 
134  if (ch3<negThresh[0]) {
135  ch3=negThresh[0];
136  ch4=corrCharge[4]/i4;
137  ch5=(i4*corrCharge[5]-n4*corrCharge[4])/(i4*i5);
138  }
139  if (ch5<negThresh[0] && ch4>negThresh[1]) {
140  double ratio = (corrCharge[4]-ch3*i3)/(corrCharge[5]-negThresh[0]*i5);
141  if (ratio < 5 && ratio > 0.5) {
142  double invG = invGpar[0]+invGpar[1]*std::sqrt(2*std::log(invGpar[2]/ratio));
143  float iG=0;
144  getLandauFrac(-invG,-invG+tsWidth,iG);
145  if (iG != 0 ) {
146  ch4=(corrCharge[4]-ch3*n3)/(iG);
147  tsShift4=invG;
148  }
149  }
150  }
151  }
152 
153  if (ch4<1) {
154  ch4=0;
155  }
156 
157  reconstructedEnergy=ch4*gainCorr*respCorr;
158  reconstructedTime=tsShift4;
159 }
static constexpr int tsWidth
static constexpr float rCorr[2]
bool hasTimeInfo() const
double tsGain(const unsigned ts) const
static constexpr float rCorrSiPM[2]
static constexpr int HcalRegion[2]
HcalDetId id() const
double tsPedestal(const unsigned ts) const
HcalTimeSlew::ParaSource fTimeSlew
double tsRawCharge(const unsigned ts) const
T sqrt(T t)
Definition: SSEVec.h:18
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void getLandauFrac(float tStart, float tEnd, float &sum) const
void calculate(const std::vector< double > &inputCharge, const std::vector< double > &inputPedestal, std::vector< double > &corrCharge) const
Definition: PedestalSub.cc:20
static constexpr float negThresh[2]
unsigned nSamples() const
HcalTimeSlew::BiasSetting fTimeSlewBias
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:16
static constexpr float invGpar[3]

Member Data Documentation

bool HcalDeterministicFit::applyTimeSlew_
private

Definition at line 36 of file HcalDeterministicFit.h.

double HcalDeterministicFit::fpars[9]
private

Definition at line 38 of file HcalDeterministicFit.h.

Referenced by apply().

PedestalSub HcalDeterministicFit::fPedestalSubFxn_
private

Definition at line 35 of file HcalDeterministicFit.h.

Referenced by apply().

double HcalDeterministicFit::frespCorr
private

Definition at line 39 of file HcalDeterministicFit.h.

Referenced by apply().

HcalTimeSlew::ParaSource HcalDeterministicFit::fTimeSlew
private

Definition at line 33 of file HcalDeterministicFit.h.

Referenced by apply().

HcalTimeSlew::BiasSetting HcalDeterministicFit::fTimeSlewBias
private

Definition at line 34 of file HcalDeterministicFit.h.

Referenced by apply().

constexpr int HcalDeterministicFit::HcalRegion = {16, 17}
staticprivate

Definition at line 41 of file HcalDeterministicFit.h.

Referenced by apply().

constexpr float HcalDeterministicFit::invGpar = {-13.11, 11.29, 5.133}
staticprivate

Definition at line 44 of file HcalDeterministicFit.h.

Referenced by apply().

constexpr float HcalDeterministicFit::landauFrac
staticprivate
Initial value:
= {0, 7.6377e-05, 0.000418655, 0.00153692, 0.00436844, 0.0102076,
0.0204177, 0.0360559, 0.057596, 0.0848493, 0.117069, 0.153152, 0.191858, 0.23198, 0.272461, 0.312438,
0.351262, 0.388476, 0.423788, 0.457036, 0.488159, 0.517167, 0.54412, 0.569112, 0.592254, 0.613668,
0.633402, 0.651391, 0.667242, 0.680131, 0.688868, 0.692188, 0.689122, 0.67928, 0.662924, 0.64087,
0.614282, 0.584457, 0.552651, 0.51997, 0.487317, 0.455378, 0.424647, 0.395445, 0.367963, 0.342288,
0.318433, 0.29636, 0.275994, 0.257243, 0.24, 0.224155, 0.2096, 0.196227, 0.183937, 0.172635,
0.162232, 0.15265, 0.143813, 0.135656, 0.128117, 0.12114, 0.114677, 0.108681, 0.103113, 0.0979354,
0.0931145, 0.0886206, 0.0844264, 0.0805074, 0.0768411, 0.0734075, 0.0701881, 0.0671664, 0.0643271,
0.0616564, 0.0591418, 0.0567718, 0.054536, 0.0524247, 0.0504292, 0.0485414, 0.046754, 0.0450602,
0.0434538, 0.041929, 0.0404806, 0.0391037, 0.0377937, 0.0365465, 0.0353583, 0.0342255, 0.0331447,
0.032113, 0.0311274, 0.0301854, 0.0292843, 0.0284221, 0.0275964, 0.0268053, 0.0253052, 0.0238536,
0.0224483, 0.0210872, 0.0197684, 0.0184899, 0.01725, 0.0160471, 0.0148795, 0.0137457, 0.0126445,
0.0115743, 0.0105341, 0.00952249, 0.00853844, 0.00758086, 0.00664871,0.00574103, 0.00485689, 0.00399541,
0.00315576, 0.00233713, 0.00153878, 0.000759962, 0 }

Definition at line 47 of file HcalDeterministicFit.h.

Referenced by init().

constexpr float HcalDeterministicFit::negThresh = {-3., 15.}
staticprivate

Definition at line 43 of file HcalDeterministicFit.h.

Referenced by apply().

constexpr float HcalDeterministicFit::rCorr = {0.95, 0.95}
staticprivate

Definition at line 45 of file HcalDeterministicFit.h.

Referenced by apply().

constexpr float HcalDeterministicFit::rCorrSiPM = {1., 1.}
staticprivate

Definition at line 46 of file HcalDeterministicFit.h.

constexpr int HcalDeterministicFit::tsWidth = 25
staticprivate

Definition at line 42 of file HcalDeterministicFit.h.

Referenced by apply().