BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkOutAvgTimeCalculator.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkOutAvgTimeCalculator.cxx,v 1.2 2005/12/01 06:18:42 zhangy Exp $
4//
5// Description:
6// See header file
7//
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Copyright Information:
12// Copyright (C) 2001 UC, San Diego
13//
14// Author List:
15// Gerhard Raven 7/19/01
16//------------------------------------------------------------------------
17#include "TrkBase/TrkOutAvgTimeCalculator.h"
18#include "TrkBase/TrkHitList.h"
19#include "TrkBase/TrkHitOnTrk.h"
20#include "TrkBase/TrkHotSelector.h"
21#include "TrkBase/TrkRecoTrk.h"
22#include <vector>
23
25 double maxpull )
26 : TrkTimeCalculator( selector ), _maxpull( maxpull ) {}
27
29
30bool TrkOutAvgTimeCalculator::trackTime( const TrkRecoTrk& trk, double& time, double& timeerr,
31 int& nHotsUsed ) const {
32 const TrkHitList* hotlist = trk.hits();
33 std::vector<ws> l;
34 ws sum;
35 for ( TrkHitList::hot_iterator i( hotlist->begin() ); i != hotlist->end(); ++i )
36 {
37 double hottime, hottimeerr;
38 if ( !useHot( *i ) || !i->timeResid( hottime, hottimeerr ) ) continue;
39 hottime *= 1e9;
40 hottimeerr *= 1e9;
41 ws x( hottime, double( 1 ) / ( hottimeerr * hottimeerr ) );
42 l.push_back( x );
43 sum += x;
44 }
45 if ( _maxpull > 0 && sum.n() > 2 && sum.isPhysical() )
46 { // do pull based pruning
47 std::vector<ws>::iterator worst = l.end();
48 do {
49 worst = l.end();
50 double worstPull = _maxpull;
51 for ( std::vector<ws>::iterator i = l.begin(); i != l.end(); ++i )
52 {
53 ws u( sum );
54 u -= *i;
55 if ( !u.isPhysical() )
56 {
57#ifdef MDCPATREC_WARNING
58 std::cout << "ErrMsg(warning) rounding problem?" << std::endl;
59#endif
60 continue;
61 }
62 double p = fabs( u.pull( *i ) );
63 if ( p > worstPull )
64 {
65 worstPull = p;
66 worst = i;
67 }
68 }
69 if ( worst != l.end() )
70 {
71 sum -= *worst;
72 l.erase( worst );
73 }
74 } while ( sum.isPhysical() && sum.n() > 2 && worst != l.end() );
75 }
76 if ( sum.isPhysical() )
77 {
78 time = sum.mean() * 1e-9 + trk.trackT0();
79 ;
80 timeerr = sum.sigma() * 1e-9;
81 nHotsUsed = sum.n();
82 return true;
83 }
84 return false;
85}
Double_t x[10]
Double_t time
TrkOutAvgTimeCalculator(const TrkHotSelector &selector, double maxpull)
virtual bool trackTime(const TrkRecoTrk &trk, double &time, double &timeerr, int &nHotsUsed) const
double trackT0() const