PulseFit.cc

00001 #include "PulseFit.hh"
00002 #include "TF1.h"
00003 PulseFit::PulseFit()
00004 { 
00005   Clear(); 
00006 }
00007 
00008 PulseFit::~PulseFit()
00009 {
00010   //std::cerr<<"Deleting pulse fit object.\n";
00011 }
00012 
00013 void PulseFit::Clear()
00014 {
00015   fit_done = false;
00016   fit_result = -1;
00017   start_index = -1;
00018   end_index = -1;
00019   range_low = -1;
00020   range_high = -1;
00021   
00022   amplitude = 1;
00023   c1 = 0.5;
00024   tau1 = 1;
00025   tau2 = 1;
00026   sigma = 1;
00027   decay = 1;
00028   baseline = 1;
00029   t0 = 1;
00030   rc = 1;
00031 }
00032 
00033 TF1* PulseFit::GetTF1()
00034 {
00035   TF1* func = new TF1("pulsefit", this, 0,100,nparams,(char*)"PulseFit");
00036   func->SetParNames("Amplitude", "C1", "tau1", "tau2", "Sigma", 
00037                     "Decay Constant", "Offset", "Delay", "RC");
00038   func->SetParameters(amplitude, c1, tau1, tau2, sigma, decay, baseline, t0, rc);
00039   func->SetRange(range_low, range_high);
00040   return func;
00041 }
00042 
00043 void PulseFit::StoreParams(TF1* func)
00044 {
00045   amplitude = func->GetParameter(0);
00046   c1 = func->GetParameter(1);
00047   tau1 = func->GetParameter(2);
00048   tau2  = func->GetParameter(3);
00049   sigma = func->GetParameter(4);
00050   decay = func->GetParameter(5);
00051   baseline = func->GetParameter(6);
00052   t0 = func->GetParameter(7);
00053   rc = func->GetParameter(8);
00054   func->GetRange(range_low, range_high);
00055 }
00056   
00057 
00058 Double_t PulseFit::operator()(Double_t* x, Double_t* par)
00059 {
00060   Double_t t = x[0];
00061   amplitude = par[0];//Amplitude
00062   c1 = par[1]; //Fraction of fast component
00063   tau1 = par[2];//Fast Component lifetime
00064   tau2 = par[3];//Slow Component lifetime
00065   sigma = par[4];//PMT Jitter
00066   decay = par[5];//Decay time of integrator
00067   baseline = par[6];//Baseline
00068   t0 = par[7];//Event start time
00069   rc = par[8];//Decay time of RC circuit
00070   
00071   double result = baseline - amplitude * 
00072     ( c1*rc*decay/(2*(rc - decay))*
00073       (common_func3(t, t0, sigma, tau1, rc) + common_func3(t, t0, sigma, rc, tau1) -
00074        common_func3(t, t0, sigma, tau1, decay) - common_func3(t, t0, sigma, decay, tau1))
00075      
00076       +(1-c1)*rc*decay/(2*(rc - decay))*
00077       (common_func3(t, t0, sigma, tau2, rc) + common_func3(t, t0, sigma, rc, tau2) -
00078        common_func3(t, t0, sigma, tau2, decay) - common_func3(t, t0, sigma, decay, tau2))
00079       );
00080 
00081   return result;
00082 }
00083 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Jun 2014 for daqman by  doxygen 1.6.1