BOSS 7.0.2
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/TrkHotSelector.h"
19#include "TrkBase/TrkRecoTrk.h"
20#include "TrkBase/TrkHitOnTrk.h"
21#include "TrkBase/TrkHitList.h"
22#include <vector>
23
24
26 TrkTimeCalculator(selector),_maxpull(maxpull)
27{}
28
30{}
31
32bool
34 double& time, double& timeerr,
35 int& nHotsUsed) const
36{
37 const TrkHitList *hotlist = trk.hits();
38 std::vector<ws> l;
39 ws sum;
40 for(TrkHitList::hot_iterator i(hotlist->begin());i!=hotlist->end();++i){
41 double hottime,hottimeerr;
42 if(!useHot(*i) || !i->timeResid(hottime,hottimeerr)) continue;
43 hottime*=1e9; hottimeerr*=1e9;
44 ws x(hottime,double(1)/(hottimeerr*hottimeerr));
45 l.push_back(x);
46 sum +=x;
47 }
48 if (_maxpull>0 && sum.n()>2 && sum.isPhysical()) { // do pull based pruning
49 std::vector<ws>::iterator worst=l.end();
50 do {
51 worst=l.end(); double worstPull = _maxpull;
52 for(std::vector<ws>::iterator i=l.begin();i!=l.end();++i) {
53 ws u(sum); u-=*i;
54 if (!u.isPhysical()) {
55#ifdef MDCPATREC_WARNING
56 std::cout<<"ErrMsg(warning) rounding problem?" << std::endl;
57#endif
58 continue;
59 }
60 double p = fabs(u.pull( *i ));
61 if (p>worstPull) { worstPull = p; worst = i; }
62 }
63 if (worst!=l.end()) {
64 sum-=*worst; l.erase(worst);
65 }
66 } while (sum.isPhysical() && sum.n()>2 && worst!=l.end());
67 }
68 if (sum.isPhysical()) {
69 time = sum.mean()*1e-9 + trk.trackT0();;
70 timeerr = sum.sigma()*1e-9;
71 nHotsUsed = sum.n();
72 return true;
73 }
74 return false;
75}
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
Definition: TrkRecoTrk.cxx:140