CMS 3D CMS Logo

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

#include <HcalDeterministicFit.h>

Public Types

enum  NegStrategy { DoNothing =0, ReqPos =1, FromGreg =2 }
 

Public Member Functions

void apply (const CaloSamples &cs, const std::vector< int > &capidvec, const HcalCalibrations &calibs, std::vector< double > &HLTOutput) const
 
void applyXM (const std::vector< double > &inputCharge, const std::vector< double > &inputPedestal, std::vector< double > &HLTOutput) const
 
double det2 (double *b, double *c) const
 
double det3 (double *a, double *b, double *c) const
 
void getLandauFrac (float tStart, float tEnd, float &sum) const
 
 HcalDeterministicFit ()
 
void init (HcalTimeSlew::ParaSource tsParam, HcalTimeSlew::BiasSetting bias, NegStrategy nStrat, PedestalSub pedSubFxn_)
 
void pulseFraction (const double fC, double *TS46) const
 
 ~HcalDeterministicFit ()
 

Private Attributes

NegStrategy fNegStrat
 
PedestalSub fPedestalSubFxn_
 
HcalTimeSlew::ParaSource fTimeSlew
 
HcalTimeSlew::BiasSetting fTimeSlewBias
 

Static Private Attributes

static float landauFrac []
 
static double TS4par [] = {0.71, -5.17, 12.23}
 
static double TS5par [] = {0.258, 0.0178, 4.786e-4}
 
static double TS6par [] = {0.06391, 0.002737, 8.396e-05, 1.475e-06}
 

Detailed Description

Definition at line 16 of file HcalDeterministicFit.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

HcalDeterministicFit::HcalDeterministicFit ( )

Definition at line 9 of file HcalDeterministicFit.cc.

9  {
10 }
HcalDeterministicFit::~HcalDeterministicFit ( )

Definition at line 12 of file HcalDeterministicFit.cc.

12  {
13 }

Member Function Documentation

void HcalDeterministicFit::apply ( const CaloSamples cs,
const std::vector< int > &  capidvec,
const HcalCalibrations calibs,
std::vector< double > &  HLTOutput 
) const

Definition at line 21 of file HcalDeterministicFit.cc.

References HcalTimeSlew::delay(), FromGreg, HcalTimeSlew::MC, HcalCalibrations::pedestal(), ReqPos, HcalCalibrations::respcorrgain(), and CaloSamples::size().

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__(), jetTools.AddJetCollection::__call__(), heavyIonTools.SelectionDefaults::__call__(), HiCoreTools.RemoveAllPATObjectsBut::__call__(), heavyIonTools.DisbaleMonteCarloDeps::__call__(), runType1CaloMEtUncertainties.RunType1CaloMEtUncertainties::__call__(), HiCoreTools.RemoveSpecificPATObjects::__call__(), trigTools.SwitchOnTriggerStandAlone::__call__(), trackTools.MakeTrackCandidates::__call__(), runMVAMEtUncertainties.RunMVAMEtUncertainties::__call__(), tauTools.AddTauCollection::__call__(), trigTools.SwitchOnTriggerMatching::__call__(), HiCoreTools.RemoveCleaning::__call__(), runType1PFMEtUncertainties.RunType1PFMEtUncertainties::__call__(), HiCoreTools.AddCleaning::__call__(), runNoPileUpMEtUncertainties.RunNoPileUpMEtUncertainties::__call__(), trigTools.SwitchOnTriggerMatchingStandAlone::__call__(), trigTools.SwitchOnTriggerMatchEmbedding::__call__(), jetTools.SwitchJetCollection::__call__(), jetTools.AddJetID::__call__(), jetTools.SetTagInfos::__call__(), and HcalSimpleRecAlgoImpl::reco().

21  {
22  std::vector<double> corrCharge;
23  std::vector<double> inputCharge;
24  std::vector<double> inputPedestal;
25  const unsigned int cssize = cs.size();
26  double gainCorr = 0;
27  for(unsigned int ip=0; ip<cssize; ++ip){
28  if( ip >= (unsigned) 10 ) continue; // Too many samples than what we wanna fit (10 is enough...) -> skip them
29  const int capid = capidvec[ip];
30  double charge = cs[ip];
31  double ped = calibs.pedestal(capid);
32  double gain = calibs.respcorrgain(capid);
33  gainCorr = gain;
34  inputCharge.push_back(charge);
35  inputPedestal.push_back(ped);
36  }
37 
38  fPedestalSubFxn_.calculate(inputCharge, inputPedestal, corrCharge);
39 
40  float tsShift3=HcalTimeSlew::delay(inputCharge[3],HcalTimeSlew::MC,fTimeSlewBias);
41  float tsShift4=HcalTimeSlew::delay(inputCharge[4],HcalTimeSlew::MC,fTimeSlewBias);
42  float tsShift5=HcalTimeSlew::delay(inputCharge[5],HcalTimeSlew::MC,fTimeSlewBias);
43 
44  // pulses are delayed by tshift. e.g. tshift = 10 means pulse is 10 seconds later
45  // landau frac moves limits of integration to the left by tsshift, which is equivalent
46  // to moving the pulse to the right
47  float i3=0;
48  getLandauFrac(-tsShift3,-tsShift3+25,i3);
49  float n3=0;
50  getLandauFrac(-tsShift3+25,-tsShift3+50,n3);
51  float nn3=0;
52  getLandauFrac(-tsShift3+50,-tsShift3+75,nn3);
53 
54  float i4=0;
55  getLandauFrac(-tsShift4,-tsShift4+25,i4);
56  float n4=0;
57  getLandauFrac(-tsShift4+25,-tsShift4+50,n4);
58 
59  float i5=0;
60  getLandauFrac(-tsShift5,-tsShift5+25,i5);
61  float n5=0;
62  getLandauFrac(-tsShift5+25,-tsShift5+50,n5);
63 
64  float ch3=corrCharge[3]/i3;
65  float ch4=(i3*corrCharge[4]-n3*corrCharge[3])/(i3*i4);
66  float ch5=(n3*n4*corrCharge[3]-i4*nn3*corrCharge[3]-i3*n4*corrCharge[4]+i3*i4*corrCharge[5])/(i3*i4*i5);
67 
68  if (ch3<-3 && fNegStrat==HcalDeterministicFit::ReqPos) {
69  ch3=-3;
70  ch4=corrCharge[4]/i4;
71  ch5=(i4*corrCharge[5]-n4*corrCharge[4])/(i4*i5);
72  }
73 
74  if (ch5<-3 && fNegStrat==HcalDeterministicFit::ReqPos) {
75  ch4=ch4+(ch5+3);
76  ch5=-3;
77  }
78 
80  if (ch3<-3) {
81  ch3=-3;
82  ch4=corrCharge[4]/i4;
83  ch5=(i4*corrCharge[5]-n4*corrCharge[4])/(i4*i5);
84  }
85  if (ch5<-3 && ch4>15) {
86  double ratio = (corrCharge[4]-ch3*i3)/(corrCharge[5]+3*i5);
87  if (ratio < 5 && ratio > 0.5) {
88  double invG = -13.11+11.29*TMath::Sqrt(2*TMath::Log(5.133/ratio));
89  float iG=0;
90  getLandauFrac(-invG,-invG+25,iG);
91  ch4=(corrCharge[4]-ch3*n3)/(iG);
92  ch5=-3;
93  tsShift4=invG;
94  }
95  }
96  }
97 
98  if (ch3<1) {// && (fNegStrat==HcalDeterministicFit::ReqPos || fNegStrat==HcalDeterministicFit::FromGreg)) {
99  ch3=0;
100  }
101  if (ch4<1) {// && (fNegStrat==HcalDeterministicFit::ReqPos || fNegStrat==HcalDeterministicFit::FromGreg)) {
102  ch4=0;
103  }
104  if (ch5<1) {// && (fNegStrat==HcalDeterministicFit::ReqPos || fNegStrat==HcalDeterministicFit::FromGreg)) {
105  ch5=0;
106  }
107 
108  // Print out
109  HLTOutput.clear();
110  HLTOutput.push_back(ch4*gainCorr);// amplitude
111  HLTOutput.push_back(tsShift4); // time shift of in-time pulse
112  HLTOutput.push_back(ch5); // whatever
113 
114 }
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
double pedestal(int fCapId) const
get pedestal for capid=0..3
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:21
int size() const
get the size
Definition: CaloSamples.h:24
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:8
void HcalDeterministicFit::applyXM ( const std::vector< double > &  inputCharge,
const std::vector< double > &  inputPedestal,
std::vector< double > &  HLTOutput 
) const

Definition at line 116 of file HcalDeterministicFit.cc.

116  {
117 
118  std::vector<double> corrCharge;
119  fPedestalSubFxn_.calculate(inputCharge, inputPedestal, corrCharge);
120 
121  double TS35[3];
122  double TS46[3];
123  double TS57[3];
124  pulseFraction(inputCharge[3], TS35);
125  pulseFraction(inputCharge[4], TS46);
126  pulseFraction(inputCharge[5], TS57);
127 
128  double a3[3] = {TS35[0], TS35[1], TS35[2]};
129  double b3[3] = {0., TS46[0], TS46[1]};
130  double c3[3] = {0., 0., TS57[0]};
131  double d3[3] = {corrCharge[3], corrCharge[4], corrCharge[5]};
132 
133  double deno3 = det3(a3, b3, c3);
134 
135  double A3 = det3(d3, b3, c3) / deno3;
136  double A4 = det3(a3, d3, c3) / deno3;
137  double A5 = det3(a3, b3, d3) / deno3;
138 
139  HLTOutput.clear();
140  HLTOutput.push_back(A3);
141  HLTOutput.push_back(A4);
142  HLTOutput.push_back(A5);
143 
144 }
double det3(double *a, double *b, double *c) const
void pulseFraction(const double fC, double *TS46) const
void calculate(const std::vector< double > &inputCharge, const std::vector< double > &inputPedestal, std::vector< double > &corrCharge) const
Definition: PedestalSub.cc:21
double HcalDeterministicFit::det2 ( double *  b,
double *  c 
) const

Definition at line 176 of file HcalDeterministicFit.cc.

176  {
177  return b[1]*c[2]-b[2]*c[1];
178 }
double b
Definition: hdecay.h:120
double HcalDeterministicFit::det3 ( double *  a,
double *  b,
double *  c 
) const

Definition at line 180 of file HcalDeterministicFit.cc.

180  {
181  return a[0]*(b[1]*c[2]-b[2]*c[1])-a[1]*(b[0]*c[2]-b[2]*c[0])+a[2]*(b[0]*c[1]-b[1]*c[0]);
182 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void HcalDeterministicFit::getLandauFrac ( float  tStart,
float  tEnd,
float &  sum 
) const

Definition at line 151 of file HcalDeterministicFit.cc.

References funct::abs().

151  {
152 
153  if (std::abs(tStart-tEnd-25)<0.1) {
154  sum=0;
155  return;
156  }
157  sum= landauFrac[int(ceil(tStart+25))];
158  return;
159 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void HcalDeterministicFit::init ( HcalTimeSlew::ParaSource  tsParam,
HcalTimeSlew::BiasSetting  bias,
NegStrategy  nStrat,
PedestalSub  pedSubFxn_ 
)

Definition at line 15 of file HcalDeterministicFit.cc.

Referenced by HcalSimpleRecAlgoImpl::reco().

15  {
16  fTimeSlew=tsParam;
17  fTimeSlewBias=bias;
18  fNegStrat=nStrat;
19  fPedestalSubFxn_=pedSubFxn_;
20 }
HcalTimeSlew::ParaSource fTimeSlew
HcalTimeSlew::BiasSetting fTimeSlewBias
void HcalDeterministicFit::pulseFraction ( const double  fC,
double *  TS46 
) const

Definition at line 165 of file HcalDeterministicFit.cc.

References HcalTimeSlew::delay(), and HcalTimeSlew::MC.

165  {
166 
168 
169  TS46[0] = TS4par[0] * TMath::Gaus(tslew,TS4par[1],TS4par[2]); // fraction of pulse in the TS4
170  TS46[1] = TS5par[0] + TS5par[1]*tslew + TS5par[2]*tslew*tslew; // fraction of pulse in the T5S
171  TS46[2] = TS6par[0] + TS6par[1]*tslew + TS6par[2]*tslew*tslew + TS6par[3]*tslew*tslew*tslew; //fraction of pulse in the TS6
172 
173  return;
174 }
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:8

Member Data Documentation

NegStrategy HcalDeterministicFit::fNegStrat
private

Definition at line 39 of file HcalDeterministicFit.h.

PedestalSub HcalDeterministicFit::fPedestalSubFxn_
private

Definition at line 40 of file HcalDeterministicFit.h.

HcalTimeSlew::ParaSource HcalDeterministicFit::fTimeSlew
private

Definition at line 37 of file HcalDeterministicFit.h.

HcalTimeSlew::BiasSetting HcalDeterministicFit::fTimeSlewBias
private

Definition at line 38 of file HcalDeterministicFit.h.

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 42 of file HcalDeterministicFit.h.

double HcalDeterministicFit::TS4par = {0.71, -5.17, 12.23}
staticprivate

Definition at line 59 of file HcalDeterministicFit.h.

double HcalDeterministicFit::TS5par = {0.258, 0.0178, 4.786e-4}
staticprivate

Definition at line 60 of file HcalDeterministicFit.h.

double HcalDeterministicFit::TS6par = {0.06391, 0.002737, 8.396e-05, 1.475e-06}
staticprivate

Definition at line 61 of file HcalDeterministicFit.h.