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
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 ()
 

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

Id:
EcalUncalibRecHitRecAnalFitAlgo.h,v 1.11 2009/03/27 18:07:38 ferriff Exp
Date:
2009/03/27 18:07:38
Revision:
1.11
Author
A. Palma, Sh. Rahatlou Roma1

Definition at line 25 of file EcalUncalibRecHitRecAnalFitAlgo.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file EcalUncalibRecHitRecAnalFitAlgo.h.

50 { };

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 54 of file EcalUncalibRecHitRecAnalFitAlgo.h.

Referenced by EcalUncalibRecHitWorkerAnalFit::run().

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

Definition at line 42 of file EcalUncalibRecHitRecAnalFitAlgo.h.

42  {
43  double x = var[0];
44  double ped = par[0];
45  return ped;
46  };
Definition: DDAxes.h:10
template<class C>
double EcalUncalibRecHitRecAnalFitAlgo< C >::pulseShapeFunction ( double *  var,
double *  par 
)
inlineprivate

Definition at line 31 of file EcalUncalibRecHitRecAnalFitAlgo.h.

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