#include <TimePointBetaFitter.h>
Definition at line 15 of file TimePointBetaFitter.h.
◆ HitVec
◆ TimePointBetaFitter()
| Muon::TimePointBetaFitter::TimePointBetaFitter |
( |
| ) |
|
|
inline |
◆ fit()
fit beta
Formula chi2 = sum( t_meas-t_pred)^2/sigma_meas^2 ) t_pred = dist / v = dist / ( beta*c )
minimize chi2 -> d chi2 / d beta = 0
beta = sum( ( d^2/( c * sigma_meas^2 ) ) )/ sum( (d*t_meas)/( sigma_meas^2 ) )
Definition at line 12 of file TimePointBetaFitter.cxx.
12 {
13
22
23
24 if(
hits.empty() )
return {};
25
27 if (
log.level()<=MSG::VERBOSE)
log << MSG::VERBOSE <<
"Performing fit, hits " <<
hits.size() <<
endmsg;
28
29
30 float sum1 = 0.;
31 float sum2 = 0.;
32 float maxInvBeta = 5;
33 float pullCut = 2.5;
34 for( HitVec::iterator it=
hits.begin(); it!=
hits.end(); ++it ){
36 float invBeta =
it->time/
a;
37 float invBetaError =
it->error/
a;
38 if (
log.level()<=MSG::VERBOSE) {
39 const char*
text =
it->useInFit ?
" hit " :
" outlier ";
43 <<
" error " <<
it->error <<
" beta " <<
beta <<
" error " << dbeta
44 <<
" 1./beta " << invBeta <<
" error " << invBetaError <<
" use " <<
it->useInFit <<
endmsg;
45 }
46 if(
it->useInFit && (invBeta - pullCut*invBetaError > maxInvBeta || invBeta + pullCut*invBetaError < 1) ) {
47 if (
log.level()<=MSG::VERBOSE)
log <<
"Removing hit outside beta range " <<
endmsg;
49 }
50 if( !
it->useInFit )
continue;
52 sum2 +=
it->distance*
it->time*
it->weight2;
53 }
54
55 if( sum2 == 0 ) return {};
56
57
58 float beta = sum1/sum2;
59 float invBeta = 1./
beta;
60 if (
log.level()<=MSG::VERBOSE)
log <<
"beta " <<
beta <<
" sum1 " << sum1 <<
" sum2 " << sum2 <<
endmsg;
61
64 for( HitVec::iterator it=
hits.begin(); it!=
hits.end(); ++it ){
67 if (
log.level()<=MSG::VERBOSE) {
68 const char*
text =
it->useInFit ?
" hit " :
" outlier ";
70 }
71 if( !
it->useInFit )
continue;
74 }
75 if( ndof == 0 ) return {};
76
80 }
std::pair< std::vector< unsigned int >, bool > res
static constexpr double const & invSpeedOfLight
double chi2(TH1 *h0, TH1 *h1)
IMessageSvc * getMessageSvc(bool quiet=false)
simple struct holding the fit result
◆ fitWithOutlierLogic()
fit beta with outlier logic
Definition at line 83 of file TimePointBetaFitter.cxx.
83 {
85 if (
log.level()<=MSG::VERBOSE)
log <<
"Performing fit with outlier logic, hits " <<
hits.size() <<
endmsg;
86
87
88 TimePointBetaFitter::FitResult
result =
fit( hits );
89
90
92 if (
log.level()<=MSG::VERBOSE)
log <<
"no outlier logic applied: hits " <<
hits.size()
95 }
96
97
98
99 int worstHit = -1;
100 float bestChi2Ndof =
result.chi2PerDOF();
101 for(
unsigned int i=0;
i<
hits.size();++
i ){
102
103
104 if( !hits[i].useInFit ) continue;
105
106
107 hits[
i].useInFit =
false;
108
109 TimePointBetaFitter::FitResult resultNew =
fit( hits );
110 if( resultNew.status != 0 ){
111 float chi2Ndof = resultNew.chi2PerDOF();
112 if( chi2Ndof < bestChi2Ndof ){
113 bestChi2Ndof = chi2Ndof;
115 }
116 }
117
118 hits[
i].useInFit =
true;
119 }
120
121
122 if( worstHit == -1 ) {
123 if (
log.level()<=MSG::VERBOSE)
log <<
"unable to improve result, keep initial result " <<
endmsg;
125 }
126
127 hits[worstHit].useInFit =
false;
128 if (
log.level()<=MSG::VERBOSE)
log <<
"removed hit " << worstHit <<
" new chi2 " << bestChi2Ndof <<
endmsg;
130 }
FitResult fitWithOutlierLogic(HitVec &hits) const
fit beta with outlier logic
static FitResult fit(HitVec &hits)
fit beta
The documentation for this class was generated from the following files: