AtNuTimingFit Class Reference

#include <AtNuTimingFit.h>

List of all members.

Public Member Functions

 AtNuTimingFit ()
 ~AtNuTimingFit ()
void AddEvent (AtmosEvent *event)
void Reset ()
void ResetTimeStrips ()
void ResetTimePoints ()
void PrintTimeStrips ()
void PrintTimePoints ()
void CalcTimePoints ()
Int_t GetPlane (UInt_t ihit)
Double_t GetS (UInt_t ihit)
Double_t GetT (UInt_t ihit)
Double_t GetQ (UInt_t ihit)
Double_t GetW (UInt_t ihit)
UInt_t GetNumPoints ()
void RunLinearFit (Double_t &invbeta, Double_t &vtime)
void RunLinearFit (Double_t &invbeta, Double_t &vtime, Double_t &err, Double_t &rms, Double_t &chi2)
void RunConstrainedFit (Double_t &invbeta, Double_t &vtime)
void RunConstrainedFit (Double_t &invbeta, Double_t &vtime, Double_t &err, Double_t &rms, Double_t &chi2)
void RunConstrainedFit (Int_t dir, Double_t &invbeta, Double_t &vtime, Double_t &err, Double_t &rms, Double_t &chi2)
void Debug (Bool_t onoff=1)
Double_t GetLength ()

Private Member Functions

void AddStrip (AtmosStrip *strip)
void AddData (Int_t plane, Int_t strip, Int_t eastwest, Int_t view, Double_t u_metres, Double_t v_metres, Double_t z_metres, Double_t t_nanosec, Double_t q_pes)
void AddData (Int_t plane, Double_t ds_metres, Double_t dt_nanosecs, Double_t q_pes)
Double_t GetTimeWeight (Double_t q)

Private Attributes

TimeStrip fTimeStrip
TimePoint fTimePoint
std::vector< TimeStripvecTimeStrips
std::vector< TimePointvecTimePoints
Bool_t fDebug
Double_t fLength
Double_t fScaleLength
Double_t fScaleResolution

Detailed Description

Definition at line 31 of file AtNuTimingFit.h.


Constructor & Destructor Documentation

AtNuTimingFit::AtNuTimingFit (  ) 

Definition at line 8 of file AtNuTimingFit.cxx.

00009 {
00010   std::cout << " *** Loading Timing Fit *** " << std::endl;
00011 
00012   fDebug = 0;
00013   fLength = 0.0;
00014   fScaleLength = 1.07; 
00015   fScaleResolution = 1.0;
00016 
00017 }

AtNuTimingFit::~AtNuTimingFit (  ) 

Definition at line 19 of file AtNuTimingFit.cxx.

00020 {
00021 
00022 }


Member Function Documentation

void AtNuTimingFit::AddData ( Int_t  plane,
Double_t  ds_metres,
Double_t  dt_nanosecs,
Double_t  q_pes 
) [private]

Definition at line 196 of file AtNuTimingFit.cxx.

References TimePoint::ds, TimePoint::dt, fTimePoint, TimePoint::plane, TimePoint::q, and vecTimePoints.

00197 {
00198   if( ( plane>=0 && plane<500 )
00199    && ( q_pes>2.0 ) ){  // <-- 2PE cut
00200 
00201     fTimePoint.plane = plane;
00202     fTimePoint.ds    = ds_metres;
00203     fTimePoint.dt    = dt_nanosecs;
00204     fTimePoint.q     = q_pes;
00205 
00206     vecTimePoints.push_back(fTimePoint);
00207   }
00208 }

void AtNuTimingFit::AddData ( Int_t  plane,
Int_t  strip,
Int_t  eastwest,
Int_t  view,
Double_t  u_metres,
Double_t  v_metres,
Double_t  z_metres,
Double_t  t_nanosec,
Double_t  q_pes 
) [private]

Definition at line 176 of file AtNuTimingFit.cxx.

References TimeStrip::end, fTimeStrip, TimeStrip::plane, TimeStrip::q, TimeStrip::strip, TimeStrip::t, TimeStrip::u, TimeStrip::v, vecTimeStrips, TimeStrip::view, and TimeStrip::z.

Referenced by AddStrip(), and CalcTimePoints().

00177 {
00178   if( ( plane>=0 && plane<500 )
00179    && ( view==0 || view==1 ) 
00180    && ( q_pes>2.0 ) ){  // <-- 2PE cut
00181 
00182     fTimeStrip.plane = plane;
00183     fTimeStrip.strip = strip;
00184     fTimeStrip.end   = eastwest;
00185     fTimeStrip.view  = view;
00186     fTimeStrip.u     = u_metres; 
00187     fTimeStrip.v     = v_metres; 
00188     fTimeStrip.z     = z_metres; 
00189     fTimeStrip.t     = t_nanosec; 
00190     fTimeStrip.q     = q_pes;
00191 
00192     vecTimeStrips.push_back(fTimeStrip);
00193   }
00194 }

void AtNuTimingFit::AddEvent ( AtmosEvent event  ) 

Definition at line 75 of file AtNuTimingFit.cxx.

References AddStrip(), fLength, fScaleLength, AtmosTrack::Index, AtmosTrack::Nplanes, AtmosTrack::RangeMetres, Reset(), and AtmosStrip::Trk.

00076 { 
00077   // Reset Fitter
00078   // ============
00079   this->Reset();
00080 
00081   std::cout << " *** New Event [" << event->Run << "/" << event->Snarl << "] *** " << std::endl;
00082  
00083   // Find Primary Track
00084   // ==================
00085   TClonesArray* tracklist = dynamic_cast<TClonesArray*>(event->TrackList);  
00086 
00087   AtmosTrack* mytrack = 0;
00088   for( Int_t i=0; i<event->NTracks; i++){
00089     AtmosTrack* track = (AtmosTrack*)(tracklist->At(i));
00090     if( track ){
00091       if( mytrack==0 ) mytrack = track;
00092       else if( track->Nplanes>mytrack->Nplanes ) mytrack = track;
00093     }
00094   }
00095   
00096   if( mytrack==0 ){
00097     std::cout << "  No Track [return] " << std::endl;
00098     return;
00099   }
00100 
00101   // Get Track Length
00102   // ================
00103   fLength = mytrack->RangeMetres/fScaleLength;
00104 
00105   // Add Strips
00106   // ==========
00107   TClonesArray* striplist = dynamic_cast<TClonesArray*>(event->StripList);
00108   
00109   for( Int_t j=0; j<1+striplist->GetLast(); j++ ){
00110     AtmosStrip* strip = dynamic_cast<AtmosStrip*>(striplist->At(j));
00111         
00112     if( strip->Trk>0 
00113      && (strip->Trk&mytrack->Index)==mytrack->Index  ){
00114       this->AddStrip(strip);
00115     }
00116   }
00117 
00118   return;
00119 }

void AtNuTimingFit::AddStrip ( AtmosStrip strip  )  [private]

Definition at line 121 of file AtNuTimingFit.cxx.

References AddData(), AtmosStrip::ClearFibre, AtmosStrip::dS, fLength, fScaleLength, AtmosStrip::GreenFibre, AtmosStrip::L, AtmosStrip::Plane, AtmosStrip::QPE, AtmosStrip::Strip, AtmosStrip::T, AtmosStrip::Tcal, AtmosStrip::Trk, AtmosStrip::View, AtmosStrip::WlsPigtail, and AtmosStrip::Z.

Referenced by AddEvent().

00122 {
00123   if( strip->Trk>0 && strip->View>-1 ){   
00124   
00125     Int_t myPlane = strip->Plane;
00126     Int_t myStrip = strip->Strip;
00127     Int_t myView  = strip->View;
00128 
00129     Double_t myU  = 0.0;
00130     Double_t myV  = 0.0;
00131     Double_t myZ  = strip->Z;
00132     Double_t myQe = strip->QPE[0];
00133     Double_t myQw = strip->QPE[1];
00134     Double_t myTe = 1.0e9*(strip->Tcal[0])-(1.77/0.3)*(strip->GreenFibre[0]+strip->WlsPigtail[0]+strip->ClearFibre[0]);
00135     Double_t myTw = 1.0e9*(strip->Tcal[1])-(1.77/0.3)*(strip->GreenFibre[1]+strip->WlsPigtail[1]+strip->ClearFibre[1]);
00136 
00137     Double_t dS   = strip->dS/fScaleLength;  
00138 
00139     if( myView == 0 ){
00140       myU = strip->T;
00141       myV = strip->L;
00142     }
00143 
00144     if( myView == 1 ){
00145       myU = strip->L;
00146       myV = strip->T;
00147     }
00148 
00149     if( (myPlane>=0 && myPlane<500)
00150      && (myView==0 || myView==1 ) ){
00151 
00152       if( myQe>2.0 ){ // <-- 2PE cut
00153         this->AddData( myPlane, myStrip, 0, myView,
00154                        myU, myV, myZ,
00155                        myTe, myQe);
00156         if( dS>=0.0 ){
00157           this->AddData( myPlane, fLength-dS, myTe, myQe );
00158         }
00159       }
00160 
00161       if( myQw>2.0 ){ // <-- 2PE cut
00162         this->AddData( myPlane, myStrip, 1, myView,
00163                        myU, myV, myZ,
00164                        myTw, myQw );
00165         if( dS>=0.0 ){
00166           this->AddData( myPlane, fLength-dS, myTw, myQw );
00167         }
00168       }
00169     }
00170 
00171   }
00172 
00173   return;
00174 }

void AtNuTimingFit::CalcTimePoints (  ) 

Definition at line 267 of file AtNuTimingFit.cxx.

References AddData(), fTimeStrip, n, TimeStrip::plane, TimeStrip::q, ResetTimePoints(), TimeStrip::t, TimeStrip::u, TimeStrip::v, vecTimeStrips, MinosMaterial::Z(), and TimeStrip::z.

00268 {
00269   // reset time points
00270   this->ResetTimePoints();
00271 
00272   // sanity check, do we have any data?
00273   if( vecTimeStrips.size()==0 ){
00274     std::cout << " <error> No Time Strips, Returning... " << std::endl;
00275     return;
00276   }
00277 
00278   // calculate 3D positions on track
00279   Double_t* U = new Double_t[500];
00280   Double_t* V = new Double_t[500];
00281   Double_t* Z = new Double_t[500];
00282   Double_t* Q = new Double_t[500];
00283   Double_t* S = new Double_t[500];
00284   
00285   for( Int_t i=0; i<500; i++ ){
00286     U[i] = 0.0;  
00287     V[i] = 0.0;
00288     Z[i] = 0.0;
00289     Q[i] = 0.0;
00290     S[i] = 0.0;
00291   }
00292 
00293   Int_t plane = 0;
00294   Double_t u = 0.0;
00295   Double_t v = 0.0;
00296   Double_t z = 0.0;
00297   Double_t t = 0.0;
00298   Double_t q = 0.0;
00299   Double_t s = 0.0;
00300 
00301   for( UInt_t n=0; n<vecTimeStrips.size(); n++ ){
00302     fTimeStrip = (TimeStrip)(vecTimeStrips.at(n)); 
00303 
00304     plane = fTimeStrip.plane;
00305     u     = fTimeStrip.u;
00306     v     = fTimeStrip.v;
00307     z     = fTimeStrip.z;
00308     q     = fTimeStrip.q;
00309     
00310     if( plane>=0 && plane<500 
00311      && q>2.0 ){  // <-- 2PE cut
00312       U[plane] += q*u;
00313       V[plane] += q*v;
00314       Z[plane] += q*z;
00315       Q[plane] += q;
00316     }
00317   }
00318 
00319   for( Int_t i=0; i<500; i++ ){
00320     if( Q[i]>0.0 ){
00321       U[i] /= Q[i];  
00322       V[i] /= Q[i];
00323       Z[i] /= Q[i];
00324     }
00325   }  
00326 
00327   // could try to smooth out positions here
00328   // but haven't done this for now
00329 
00330   // calculate 3D displacements along track
00331   Bool_t firstHit = 1;
00332   Int_t j  = +1; 
00333   Int_t jm = -1;
00334 
00335   Double_t du = 0.0;
00336   Double_t dv = 0.0;
00337   Double_t dz = 0.0;
00338   Double_t ds = 0.0;
00339 
00340   for( Int_t i=0; i<500; i++){
00341     if( Q[i]>0.0 ){
00342       if( firstHit ){
00343         firstHit = 0;
00344       }
00345       else{
00346         j=1; jm=-1;
00347         while( i-j>=0 && jm<0 ){
00348           if( Q[i-j]>0.0 ) jm=j;
00349           j++;
00350         }          
00351         if( jm>0 ){
00352           du = U[i] - U[i-jm]; 
00353           dv = V[i] - V[i-jm];
00354           dz = Z[i] - Z[i-jm];
00355           ds = sqrt(du*du+dv*dv+dz*dz);
00356           S[i] = S[i-jm] + ds;
00357         }
00358       }
00359     }
00360   } 
00361 
00362   // now create time points
00363   for( UInt_t n=0; n<vecTimeStrips.size(); n++ ){
00364     fTimeStrip = (TimeStrip)(vecTimeStrips.at(n)); 
00365 
00366     plane = fTimeStrip.plane;
00367     q     = fTimeStrip.q;
00368     t     = fTimeStrip.t;
00369 
00370     if( plane>=0 && plane<500 
00371      && q>2.0 ){ // <-- 2PE cut
00372       s = S[plane];
00373       this->AddData( plane, s, t, q );
00374     }
00375   }
00376 
00377   // delete arrays
00378   delete [] U;
00379   delete [] V;
00380   delete [] Z;
00381   delete [] Q;
00382   delete [] S;
00383 
00384   return;
00385 }

void AtNuTimingFit::Debug ( Bool_t  onoff = 1  )  [inline]

Definition at line 63 of file AtNuTimingFit.h.

References fDebug.

00063 { fDebug = onoff; }

Double_t AtNuTimingFit::GetLength (  )  [inline]

Definition at line 65 of file AtNuTimingFit.h.

References fLength.

00065 { return fLength; }

UInt_t AtNuTimingFit::GetNumPoints (  ) 

Definition at line 262 of file AtNuTimingFit.cxx.

References vecTimePoints.

Referenced by GetPlane(), GetQ(), GetS(), GetT(), RunConstrainedFit(), and RunLinearFit().

00263 {
00264   return vecTimePoints.size();
00265 }

Int_t AtNuTimingFit::GetPlane ( UInt_t  ihit  ) 

Definition at line 210 of file AtNuTimingFit.cxx.

References fTimePoint, GetNumPoints(), TimePoint::plane, and vecTimePoints.

00211 {
00212   if( ihit<GetNumPoints() ){
00213     fTimePoint = (TimePoint)(vecTimePoints.at(ihit));
00214     return fTimePoint.plane;
00215   }
00216 
00217   return -1;
00218 }

Double_t AtNuTimingFit::GetQ ( UInt_t  ihit  ) 

Definition at line 240 of file AtNuTimingFit.cxx.

References fTimePoint, GetNumPoints(), TimePoint::q, and vecTimePoints.

Referenced by GetW(), RunConstrainedFit(), and RunLinearFit().

00241 {
00242   if( ihit<GetNumPoints() ){
00243     fTimePoint = (TimePoint)(vecTimePoints.at(ihit));
00244     return fTimePoint.q;
00245   }
00246 
00247   return 0.0;
00248 }

Double_t AtNuTimingFit::GetS ( UInt_t  ihit  ) 

Definition at line 220 of file AtNuTimingFit.cxx.

References TimePoint::ds, fTimePoint, GetNumPoints(), and vecTimePoints.

Referenced by RunConstrainedFit(), and RunLinearFit().

00221 {
00222   if( ihit<GetNumPoints() ){
00223     fTimePoint = (TimePoint)(vecTimePoints.at(ihit));
00224     return fTimePoint.ds;
00225   }
00226 
00227   return 0.0;
00228 }

Double_t AtNuTimingFit::GetT ( UInt_t  ihit  ) 

Definition at line 230 of file AtNuTimingFit.cxx.

References TimePoint::dt, fTimePoint, GetNumPoints(), and vecTimePoints.

Referenced by RunConstrainedFit(), and RunLinearFit().

00231 {
00232   if( ihit<GetNumPoints() ){
00233     fTimePoint = (TimePoint)(vecTimePoints.at(ihit));
00234     return fTimePoint.dt;
00235   }
00236 
00237   return 0.0;
00238 }

Double_t AtNuTimingFit::GetTimeWeight ( Double_t  q  )  [private]

Definition at line 642 of file AtNuTimingFit.cxx.

References fScaleResolution.

Referenced by GetW(), RunConstrainedFit(), and RunLinearFit().

00643 {   
00644   // Sanity check
00645   if( q<0 ) return 0.0;
00646 
00647   // Parameterisation
00648   Double_t A = +0.58;
00649   Double_t B = +0.69;
00650   Double_t C = -0.33;    
00651 
00652   // Calculate Timing Resolution [metres]
00653   Double_t sigma = A;
00654   if( q<25.0 ) sigma = A + exp(B+C*q);
00655 
00656   // Convert to Nanoseconds
00657   sigma *= fScaleResolution/0.3;
00658 
00659   return 1.0/(sigma*sigma);
00660 }

Double_t AtNuTimingFit::GetW ( UInt_t  ihit  ) 

Definition at line 250 of file AtNuTimingFit.cxx.

References GetQ(), and GetTimeWeight().

00251 {
00252   Double_t q = GetQ(ihit);
00253 
00254   if( q>0.0 ){
00255     return this->GetTimeWeight(q);
00256   }
00257   else{
00258     return 0.0;
00259   }
00260 }

void AtNuTimingFit::PrintTimePoints (  ) 

Definition at line 65 of file AtNuTimingFit.cxx.

References TimePoint::ds, TimePoint::dt, fTimePoint, n, TimePoint::plane, TimePoint::q, and vecTimePoints.

00066 {
00067   std::cout << " *** Printing Time Points *** " << std::endl;
00068   
00069   for( UInt_t n=0; n<vecTimePoints.size(); n++ ){
00070     fTimePoint = (TimePoint)(vecTimePoints.at(n));
00071     std::cout << " [" << n << "] (" << fTimePoint.plane << ") (" << fTimePoint.ds << "," << fTimePoint.dt << "," << fTimePoint.q << ")" << std::endl;
00072   }
00073 }

void AtNuTimingFit::PrintTimeStrips (  ) 

Definition at line 53 of file AtNuTimingFit.cxx.

References TimeStrip::end, fTimeStrip, n, TimeStrip::plane, TimeStrip::q, TimeStrip::strip, TimeStrip::t, TimeStrip::u, TimeStrip::v, vecTimeStrips, TimeStrip::view, and TimeStrip::z.

00054 {
00055   std::cout << " *** Printing Time Strips *** " << std::endl;
00056   
00057   for( UInt_t n=0; n<vecTimeStrips.size(); n++ ){
00058     fTimeStrip = (TimeStrip)(vecTimeStrips.at(n));
00059     std::cout << " [" << n << "] (" << fTimeStrip.view << ") (" << fTimeStrip.plane << "|" << fTimeStrip.strip << "|" << fTimeStrip.end << ") (" << fTimeStrip.u << "," << fTimeStrip.v << "," << fTimeStrip.z << ") (" << fTimeStrip.t << "," << fTimeStrip.q << ") " << std::endl;
00060   }
00061 
00062   return;
00063 }

void AtNuTimingFit::Reset (  ) 

Definition at line 24 of file AtNuTimingFit.cxx.

References fLength, and ResetTimeStrips().

Referenced by AddEvent().

00025 {
00026   fLength = 0.0;
00027 
00028   this->ResetTimeStrips();
00029 
00030   return;
00031 }

void AtNuTimingFit::ResetTimePoints (  ) 

Definition at line 44 of file AtNuTimingFit.cxx.

References fDebug, and vecTimePoints.

Referenced by CalcTimePoints(), and ResetTimeStrips().

00045 {
00046   if( fDebug ) std::cout << " *** Resetting Time Points *** " << std::endl;
00047 
00048   vecTimePoints.clear();
00049 
00050   return;
00051 }

void AtNuTimingFit::ResetTimeStrips (  ) 

Definition at line 33 of file AtNuTimingFit.cxx.

References fDebug, ResetTimePoints(), and vecTimeStrips.

Referenced by Reset().

00034 {
00035   if( fDebug ) std::cout << " *** Resetting Time Strips *** " << std::endl;
00036   
00037   vecTimeStrips.clear();
00038 
00039   this->ResetTimePoints();
00040 
00041   return;
00042 }

void AtNuTimingFit::RunConstrainedFit ( Int_t  dir,
Double_t &  invbeta,
Double_t &  vtime,
Double_t &  err,
Double_t &  rms,
Double_t &  chi2 
)

Definition at line 423 of file AtNuTimingFit.cxx.

References fDebug, GetNumPoints(), GetQ(), GetS(), GetT(), GetTimeWeight(), and n.

00424 {
00425   // sanity check
00426   if( dir==0 ) return;
00427   
00428   if( dir>0 ){
00429     if( fDebug ) std::cout << " *** Run Constrained Fit (Forwards) *** " << std::endl;
00430   }
00431   if( dir<0 ){
00432     if( fDebug ) std::cout << " *** Run Constrained Fit (Backwards) *** " << std::endl;
00433   }
00434   
00435   Double_t delta = 0.0;
00436 
00437   Double_t t = 0.0;
00438   Double_t s = 0.0;
00439   Double_t q = 0.0;
00440   Double_t w = 0.0;
00441 
00442   Double_t Swtt = 0.0;
00443   Double_t Swt = 0.0;
00444   Double_t Sw = 0.0;
00445   Double_t S = 0.0;
00446 
00447   Double_t t0 = 0.0;
00448   Double_t terr = 0.0;
00449   Double_t sigma = -99999.9;
00450   Double_t trunc = -99999.9;
00451   Double_t chisq = -99999.9;
00452   
00453   Double_t beta = 0.0;
00454   if( dir>0 ) beta = +1.0;
00455   if( dir<0 ) beta = -1.0;
00456 
00457   Double_t dof = (double)(GetNumPoints()-1.0);
00458 
00459   for( Int_t itr=0; itr<3; itr++ ){
00460     Swtt = 0.0; 
00461     Swt  = 0.0; 
00462     Sw   = 0.0; 
00463     S    = 0.0;
00464 
00465     for( UInt_t n=0; n<GetNumPoints(); n++ ){
00466       s = GetS(n);
00467       t = GetT(n);
00468       q = GetQ(n);
00469       w = GetTimeWeight(q);
00470 
00471       delta = (t-t0) - (beta/0.3)*s;
00472 
00473       if( trunc<0.0 || fabs(delta)<trunc ){
00474         Swtt += w*delta*delta; 
00475         Swt  += w*delta; 
00476         Sw   += w; 
00477         S    += 1.0; 
00478       }
00479     }
00480 
00481     if( Sw>0.0 ){
00482       t0 += Swt/Sw; 
00483       terr = 1.0/sqrt(Sw);
00484       chisq = Swtt/dof;
00485     }
00486 
00487     sigma = 0.0; 
00488     if( (Swtt/Sw)-(Swt/Sw)*(Swt/Sw)>0.0 ){
00489       sigma = sqrt( (Swtt/Sw)-(Swt/Sw)*(Swt/Sw) );
00490     }      
00491     trunc = sigma + 10.0;
00492 
00493   }
00494    
00495   // return parameters
00496   invbeta = 1.0/beta;
00497   vtime   = t0;
00498   err     = terr;
00499   rms     = sigma;
00500   chi2    = chisq;
00501 
00502   if( fDebug ) std::cout << "  Results: 1/beta=" << invbeta << " vtime=" << vtime << " err=" << err << " rms=" << rms << " chi2=" << chi2 << std::endl;
00503 
00504   return;
00505 }

void AtNuTimingFit::RunConstrainedFit ( Double_t &  invbeta,
Double_t &  vtime,
Double_t &  err,
Double_t &  rms,
Double_t &  chi2 
)

Definition at line 396 of file AtNuTimingFit.cxx.

References RunConstrainedFit().

00397 {
00398   Double_t invbeta_fwd = 0.0;
00399   Double_t vtime_fwd   = 0.0;
00400   Double_t err_fwd     = 0.0;
00401   Double_t rms_fwd     = 0.0;
00402   Double_t chi2_fwd    = 0.0;
00403 
00404   Double_t invbeta_bwd = 0.0;
00405   Double_t vtime_bwd   = 0.0;
00406   Double_t err_bwd     = 0.0;
00407   Double_t rms_bwd     = 0.0;
00408   Double_t chi2_bwd    = 0.0;
00409 
00410   this->RunConstrainedFit( +1, invbeta_fwd, vtime_fwd, err_fwd, rms_fwd, chi2_fwd );
00411   this->RunConstrainedFit( -1, invbeta_bwd, vtime_bwd, err_bwd, rms_bwd, chi2_bwd );
00412   
00413   if( chi2_fwd<=chi2_bwd ){
00414     invbeta = invbeta_fwd; vtime = vtime_fwd; err = err_fwd; rms = rms_fwd; chi2 = chi2_fwd;
00415   }
00416   else {
00417     invbeta = invbeta_bwd; vtime = vtime_bwd; err = err_bwd; rms = rms_bwd; chi2 = chi2_bwd;
00418   }
00419 
00420   return;
00421 }

void AtNuTimingFit::RunConstrainedFit ( Double_t &  invbeta,
Double_t &  vtime 
)

Definition at line 387 of file AtNuTimingFit.cxx.

References err().

Referenced by RunConstrainedFit(), and RunLinearFit().

00388 {
00389   Double_t err  = 0.0;
00390   Double_t rms  = 0.0;
00391   Double_t chi2 = 0.0;
00392 
00393   return this->RunConstrainedFit(invbeta, vtime, err, rms, chi2);
00394 }

void AtNuTimingFit::RunLinearFit ( Double_t &  invbeta,
Double_t &  vtime,
Double_t &  err,
Double_t &  rms,
Double_t &  chi2 
)

Definition at line 516 of file AtNuTimingFit.cxx.

References fDebug, GetNumPoints(), GetQ(), GetS(), GetT(), GetTimeWeight(), n, and RunConstrainedFit().

00517 {
00518   Double_t input_invbeta = 0.0;
00519   Double_t input_offset  = 0.0;
00520   Double_t input_err     = 0.0;
00521   Double_t input_rms     = 0.0;
00522   Double_t input_chi2    = 0.0;
00523 
00524   this->RunConstrainedFit( input_invbeta, input_offset, input_err, input_rms, input_chi2);
00525 
00526   Double_t slope = input_invbeta/0.3;
00527   Double_t offset = input_offset;
00528 
00529   if( fDebug ) std::cout << " *** Run Linear Fit *** " << std::endl;  
00530 
00531   Double_t delta = 0.0;
00532 
00533   Double_t t = 0.0;
00534   Double_t s = 0.0;
00535   Double_t q = 0.0;
00536   Double_t w = 0.0;
00537 
00538   Double_t Sws  = 0.0; 
00539   Double_t Swt  = 0.0; 
00540   Double_t Swss = 0.0; 
00541   Double_t Swst = 0.0; 
00542   Double_t Swtt = 0.0; 
00543   Double_t Sw   = 0.0;
00544   Double_t S    = 0.0;
00545   
00546   Double_t new_delta = 0.0;
00547   Double_t new_slope = 0.0;
00548   Double_t new_offset = 0.0;
00549 
00550   Double_t terr   = 0.0;
00551   Double_t sigma = -99999.9;
00552   Double_t chisq = -99999.9;
00553 
00554   Double_t trunc = 15.0;
00555 
00556   Double_t dof = (double)(GetNumPoints()-2.0);
00557 
00558 
00559   for( Int_t itr=0; itr<3; itr++ ){
00560     Sws  = 0.0; 
00561     Swt  = 0.0; 
00562     Swss = 0.0; 
00563     Swst = 0.0; 
00564     Swtt = 0.0; 
00565     Sw   = 0.0;
00566     S    = 0.0;
00567 
00568     new_slope = slope;
00569     new_offset = offset;
00570 
00571     for( UInt_t n=0; n<GetNumPoints(); n++ ){
00572       s = GetS(n);
00573       t = GetT(n);
00574       q = GetQ(n);
00575       w = GetTimeWeight(q);
00576 
00577       delta = t - (slope*s+offset);
00578 
00579       if( trunc<0.0 || fabs(delta)<trunc ){
00580         Sws  += w*s; 
00581         Swt  += w*t; 
00582         Swss += w*s*s; 
00583         Swst += w*s*t; 
00584         Swtt += w*t*t; 
00585         Sw   += w; 
00586         S    += 1.0;
00587       }
00588     }
00589 
00590     if( Sw*Swss-Sws*Sws !=0 ){
00591       new_slope  = (Sw*Swst-Sws*Swt)/(Sw*Swss-Sws*Sws);
00592       new_offset = (Swt*Swss-Sws*Swst)/(Sw*Swss-Sws*Sws);
00593     }
00594 
00595     Swtt = 0.0; 
00596     Swt  = 0.0;
00597     Sw   = 0.0;
00598     
00599     for( UInt_t n=0; n<GetNumPoints(); n++ ){
00600       s = GetS(n);
00601       t = GetT(n);
00602       q = GetQ(n);
00603       w = GetTimeWeight(q);
00604 
00605       delta = t - (slope*s+offset);
00606       new_delta = t - (new_slope*s+new_offset);
00607 
00608       if( trunc<0.0 || fabs(delta)<trunc ){
00609         Swtt += w*new_delta*new_delta;
00610         Swt  += w*new_delta;
00611         Sw   += w;
00612       }
00613     }
00614 
00615     if( Sw>0.0 ){
00616       chisq = Swtt/dof;
00617       terr = 1.0/sqrt(Sw);
00618     }
00619 
00620     sigma = 0.0;
00621     if( (Swtt/Sw)-(Swt/Sw)*(Swt/Sw)>0.0 ) {
00622       sigma = sqrt( (Swtt/Sw)-(Swt/Sw)*(Swt/Sw) );
00623     }
00624     trunc = sigma + 10.0;
00625 
00626     slope = new_slope;
00627     offset = new_offset;
00628   }
00629 
00630   // return parameters
00631   invbeta = 0.3*slope;
00632   vtime   = offset;
00633   err     = terr;
00634   rms     = sigma;
00635   chi2    = chisq;
00636 
00637   if( fDebug ) std::cout << "  Results: 1/beta=" << invbeta << " vtime=" << vtime << "err=" << err << " rms=" << rms << " chi2=" << chi2 << std::endl;
00638     
00639   return;
00640 }

void AtNuTimingFit::RunLinearFit ( Double_t &  invbeta,
Double_t &  vtime 
)

Definition at line 507 of file AtNuTimingFit.cxx.

References err().

00508 {
00509   Double_t err  = 0.0;
00510   Double_t rms  = 0.0;
00511   Double_t chi2 = 0.0;
00512 
00513   return this->RunLinearFit(invbeta, vtime, err, rms, chi2);
00514 }


Member Data Documentation

Bool_t AtNuTimingFit::fDebug [private]
Double_t AtNuTimingFit::fLength [private]

Definition at line 88 of file AtNuTimingFit.h.

Referenced by AddEvent(), AddStrip(), GetLength(), and Reset().

Double_t AtNuTimingFit::fScaleLength [private]

Definition at line 89 of file AtNuTimingFit.h.

Referenced by AddEvent(), and AddStrip().

Double_t AtNuTimingFit::fScaleResolution [private]

Definition at line 90 of file AtNuTimingFit.h.

Referenced by GetTimeWeight().

Definition at line 81 of file AtNuTimingFit.h.

Referenced by AddData(), GetPlane(), GetQ(), GetS(), GetT(), and PrintTimePoints().

Definition at line 80 of file AtNuTimingFit.h.

Referenced by AddData(), CalcTimePoints(), and PrintTimeStrips().

std::vector<TimePoint> AtNuTimingFit::vecTimePoints [private]
std::vector<TimeStrip> AtNuTimingFit::vecTimeStrips [private]

Definition at line 83 of file AtNuTimingFit.h.

Referenced by AddData(), CalcTimePoints(), PrintTimeStrips(), and ResetTimeStrips().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1