BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/TrkBase/include/TrkBase/TrkOutAvgTimeCalculator.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkOutAvgTimeCalculator.h,v 1.1.1.1 2005/04/21 06:01:42 zhangy Exp $
4//
5// Description:
6// class TrkOutAvgTimeCalculater. A simple implementation of TrkTimeCalculator
7// that takes the weighted average of all selected hot's times assuming a
8// Gaussian error, but rejecting outliers based on their pull.
9//
10// Environment:
11// Software developed for the BaBar Detector at the SLAC B-Factory.
12//
13// Copyright Information:
14// Copyright (C) 2001 UC, San Diego
15//
16// Author List:
17// Gerhard Raven 7/19/01
18//------------------------------------------------------------------------
19
20#ifndef TRKOUTAVGTIMECALCULATOR_HH
21#define TRKOUTAVGTIMECALCULATOR_HH
22
23#include "TrkBase/TrkTimeCalculator.h"
24#include <assert.h>
25#include <math.h>
26
28public:
29 TrkOutAvgTimeCalculator( const TrkHotSelector& selector, double maxpull );
31 // The Function
32 virtual bool trackTime( const TrkRecoTrk& trk, double& time, double& timeerr,
33 int& nHotsUsed ) const;
34
35private:
36 // disallow
39
40 double _maxpull;
41
42 class ws {
43 public:
44 ws( double x = 0, double w = 0 ) : _w( w ), _wx( w * x ), _n( w > 0 ? 1 : 0 ) {
45 assert( !( w < 0 ) );
46 }
47 ws& operator+=( const ws& x ) {
48 _wx += x._wx;
49 _w += x._w;
50 _n += x._n;
51 return *this;
52 }
53 ws& operator-=( const ws& x ) {
54 _wx -= x._wx;
55 _w -= x._w;
56 _n -= x._n;
57 return *this;
58 }
59 bool operator==( const ws& x ) const { return _w == x._w && _wx == x._wx && _n == x._n; }
60 bool isPhysical() const { return _w > 0; }
61 double mean() const { return _wx / _w; }
62 double sigma() const { return double( 1 ) / sqrt( _w ); }
63 double pull( const ws& x ) const {
64 return ( mean() - x.mean() ) / sqrt( sigma2() + x.sigma2() );
65 }
66 unsigned n() const { return _n; }
67
68 private:
69 double sigma2() const { return double( 1 ) / _w; }
70 double _w, _wx;
71 unsigned _n;
72 };
73};
74#endif
GPStime & operator+=(GPStime &t, const double &dt)
const Int_t n
Double_t x[10]
Double_t time
double w
TrkOutAvgTimeCalculator(const TrkHotSelector &selector, double maxpull)
virtual ~TrkOutAvgTimeCalculator()
virtual bool trackTime(const TrkRecoTrk &trk, double &time, double &timeerr, int &nHotsUsed) const