CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
EcalUncalibRecHitRecAnalFitAlgo< C > Class Template Reference

#include <EcalUncalibRecHitRecAnalFitAlgo.h>

Inheritance diagram for EcalUncalibRecHitRecAnalFitAlgo< C >:
EcalUncalibRecHitRecAbsAlgo< C >

Public Member Functions

virtual EcalUncalibratedRecHit makeRecHit (const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix)
 Compute parameters. More...
 
virtual ~EcalUncalibRecHitRecAnalFitAlgo ()
 
- Public Member Functions inherited from EcalUncalibRecHitRecAbsAlgo< C >
virtual ~EcalUncalibRecHitRecAbsAlgo ()=default
 Constructor. More...
 

Private Member Functions

double pedestalFunction (double *var, double *par)
 
double pulseShapeFunction (double *var, double *par)
 

Additional Inherited Members

- Public Types inherited from EcalUncalibRecHitRecAbsAlgo< C >
enum  { nWeightsRows = 3, iAmplitude = 0, iPedestal = 1, iTime = 2 }
 

Detailed Description

template<class C>
class EcalUncalibRecHitRecAnalFitAlgo< C >

Template used to compute amplitude, pedestal, time jitter, chi2 of a pulse using an analytical fit

Author
A. Palma, Sh. Rahatlou Roma1

Definition at line 22 of file EcalUncalibRecHitRecAnalFitAlgo.h.

Constructor & Destructor Documentation

template<class C>
virtual EcalUncalibRecHitRecAnalFitAlgo< C >::~EcalUncalibRecHitRecAnalFitAlgo ( )
inlinevirtual

Definition at line 46 of file EcalUncalibRecHitRecAnalFitAlgo.h.

46 { };

Member Function Documentation

template<class C>
virtual EcalUncalibratedRecHit EcalUncalibRecHitRecAnalFitAlgo< C >::makeRecHit ( const C &  dataFrame,
const double *  pedestals,
const double *  gainRatios,
const EcalWeightSet::EcalWeightMatrix **  weights,
const EcalWeightSet::EcalChi2WeightMatrix **  chi2Matrix 
)
inlinevirtual

Compute parameters.

Implements EcalUncalibRecHitRecAbsAlgo< C >.

Definition at line 50 of file EcalUncalibRecHitRecAnalFitAlgo.h.

Referenced by EcalUncalibRecHitWorkerAnalFit::run().

54  {
55  double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
56 
57  // Get time samples
58  //HepMatrix frame(C::MAXSAMPLES, 1);
59  double frame[C::MAXSAMPLES];
60  // int gainId0 = dataFrame.sample(0).gainId();
61  int gainId0 = 1;
62  int iGainSwitch = 0;
63  double maxsample(-1);
64  int imax(-1);
65  bool isSaturated = 0;
66  uint32_t flag = 0;
67  for(int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
68  int gainId = dataFrame.sample(iSample).gainId();
69  if ( dataFrame.isSaturated() )
70  {
71  gainId = 3;
72  isSaturated = 1;
73  }
74 
75  if (gainId != gainId0) ++iGainSwitch ;
76  if (!iGainSwitch)
77  frame[iSample] = double(dataFrame.sample(iSample).adc());
78  else
79  frame[iSample] = double(((double)(dataFrame.sample(iSample).adc()) - pedestals[gainId-1]) * gainRatios[gainId-1]);
80 
81  if( frame[iSample]>maxsample ) {
82  maxsample= frame[iSample];
83  imax=iSample;
84  }
85  }
86 
87  // Compute parameters
88  //std::cout << "EcalUncalibRecHitRecAnalFitAlgo::makeRecHit() not yey implemented. returning dummy rechit" << std::endl;
89 
90  // prepare TGraph for analytic fit
91  double xarray[10]={0.,1.,2.,3.,4.,5.,6.,7.,8.,9.};
92  TGraph graph(10,xarray,frame);
93 
94  // fit functions
95  TF1 pulseShape = TF1("pulseShape",
96  "[0]*pow((x - [3])/[1],[2])*exp(-[2]*(x - [1] - [3])/[1])",
97  imax-1.,imax+3.);
98  TF1 pedestal = TF1("pedestal","[0]",0.,2.);
99 
100  //TF1 pulseShape = TF1("pulseShape",pulseShapeFunction,imax-1.,imax+3.);
101  //TF1 pedestal = TF1("pedestal",pedestalFunction,0.,2.);
102  TF1 pluseAndPed = TF1("pulseAndPed","pedestal+pulseShape");
103 
104  //pulseShape parameters
105  // Amplitude
106  double FIT_A=(double)maxsample; //Amplitude
107  pulseShape.SetParameter(0,FIT_A);
108  pulseShape.SetParName(0,"Amplitude");
109  // T peak
110  double FIT_Tp=(double)imax; //T peak
111  pulseShape.SetParameter(1,FIT_Tp);
112  pulseShape.SetParName(1,"t_{P}");
113  // Alpha
114  double FIT_ALFA=1.5; //Alpha
115  pulseShape.SetParameter(2,FIT_ALFA);
116  pulseShape.SetParName(2,"\\alpha");
117  // T off
118  double FIT_To=3.; //T off
119  pulseShape.SetParameter(3,FIT_To);
120  pulseShape.SetParName(3,"t_{0}");
121 
122  // pedestal
123  pedestal.SetParameter(0,frame[0]);
124  pedestal.SetParName(0,"Pedestal");
125 
126 
127 
128  graph.Fit(&pulseShape,"QRM");
129  //TF1 *pulseShape2=graph.GetFunction("pulseShape");
130 
131  if ( std::string(gMinuit->fCstatu.Data()) == std::string("CONVERGED ") ) {
132 
133  double amplitude_value=pulseShape.GetParameter(0);
134 
135  graph.Fit(&pedestal,"QRL");
136  //TF1 *pedestal2=graph.GetFunction("pedestal");
137  double pedestal_value=pedestal.GetParameter(0);
138 
139  if (!iGainSwitch)
140  amplitude_ = amplitude_value - pedestal_value;
141  else
142  amplitude_ = amplitude_value;
143 
144  pedestal_ = pedestal_value;
145  jitter_ = pulseShape.GetParameter(3);
146  chi2_ = 1.; // successful fit
147  if (isSaturated) flag = EcalUncalibratedRecHit::kSaturated;
148  /*
149  std::cout << "separate fits\nA: " << amplitude_value << ", Ped: " << pedestal_value
150  << ", t0: " << jitter_ << ", tp: " << pulseShape.GetParameter(1)
151  << ", alpha: " << pulseShape.GetParameter(2)
152  << std::endl;
153  */
154 
155  }
156 
157  return EcalUncalibratedRecHit( dataFrame.id(), amplitude_, pedestal_, jitter_ - 6, chi2_, flag);
158  }
int gainId(sample_type sample)
get the gainId (2 bits)
Definition: adjgraph.h:12
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
template<class C>
double EcalUncalibRecHitRecAnalFitAlgo< C >::pedestalFunction ( double *  var,
double *  par 
)
inlineprivate

Definition at line 39 of file EcalUncalibRecHitRecAnalFitAlgo.h.

39  {
40  double ped = par[0];
41  return ped;
42  };
template<class C>
double EcalUncalibRecHitRecAnalFitAlgo< C >::pulseShapeFunction ( double *  var,
double *  par 
)
inlineprivate

Definition at line 28 of file EcalUncalibRecHitRecAnalFitAlgo.h.

28  {
29  double x = var[0];
30  double ampl = par[0];
31  double tp = par[1];
32  double alpha = par[2];
33  double t0 = par[3];
34 
35  double f = pow( (x-t0)/tp , alpha ) * exp( -alpha*(x-tp-t0)/tp );
36  return ampl*f;
37  };
float alpha
Definition: AMPTWrapper.h:95
double f[11][100]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40