Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
earms::ElasticArms Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/ElasticArms/func/ElasticArms.h"

Public Types

typedef std::vector< std::vector< double > > matrix
 

Public Member Functions

 ElasticArms (unsigned int n, unsigned int m, double lambda, double lambdav)
 
void SetHit (unsigned int i, double z, double xory, double sigma, int view)
 
void SetT (double t)
 
void SetLambda (double lam)
 
void UpdateVia ()
 
void UpdateDaa ()
 
void SetVertex (double x, double y, double z)
 
void GetVertex (double &x, double &y, double &z) const
 
void SetArm (unsigned int i, double theta, double phi)
 
void UpdateMia ()
 
double E ()
 
double SumVi (unsigned int a) const
 
unsigned int LeadingArm () const
 

Public Attributes

unsigned int fN
 Data to fit. More...
 
std::vector< double > fXorY
 Transverse hit positions (cm) More...
 
std::vector< intfView
 Which view is the hit in? More...
 
std::vector< double > fZ
 Z locations of hits (cm) More...
 
std::vector< double > fWsqr
 Combined weight for hit 1/(sigmaH^2 + sigmaMS^2) More...
 
std::vector< double > fDhi
 From hit to vertex location^2 [cm^2]. More...
 
std::vector< double > fDaa
 Distance from vertex to prong [cm]. More...
 
matrix fMia
 Distance^2 hit i to track a (sigma^2) More...
 
std::vector< std::vector< bool > > fMiaUnchanged
 Is fMia changed in UpdateMia? More...
 
std::vector< bool > fMiaRowUnchanged
 Is a row of fMia changed in UpdateMia? More...
 
std::vector< bool > fMiaColUnchanged
 Is a column of fMia changed in UpdateMia? More...
 
matrix fExpBetaMia
 exp(-fBeta*Mia) - compute once used many time More...
 
matrix fVia
 Strength of association hit i to track a. More...
 
double fX0
 Model parameters. More...
 
double fY0
 Vertex y location (cm) More...
 
double fZ0
 Vertex z location (cm) More...
 
unsigned int fM
 Number of arms. More...
 
std::vector< double > fdXds
 Track dx/ds. More...
 
std::vector< double > fdYds
 Track dy/ds. More...
 
std::vector< double > fdZds
 Track dz/ds. More...
 

Private Attributes

int fProngFit
 1 - treat arms as prongs in fit, 0 - treat as lines More...
 
double fT
 A measure of the "temperature" in units of sigma^2. More...
 
double fBeta
 1/T in units of 1/sigma^2 More...
 
bool fBetaUnchanged
 Whether fBeta is the same since last call to UpdateMia. More...
 
double fLambda
 Noise penalty term in units of sigma^2. More...
 
double fExpBetaLambda
 exp(-fBeta*fLambda) - computed once used many More...
 
double fLambdaV
 Distance scale for hits to appear on (cm) More...
 

Detailed Description

Fit a vertex and prongs to a collection of hits using the "elastic arms" method

Definition at line 10 of file ElasticArms.h.

Member Typedef Documentation

typedef std::vector< std::vector<double> > earms::ElasticArms::matrix

Definition at line 116 of file ElasticArms.h.

Constructor & Destructor Documentation

ElasticArms::ElasticArms ( unsigned int  n,
unsigned int  m,
double  lambda,
double  lambdav 
)

Construct an elastic arms fitter

Parameters
n- number of hits
m- number of prongs
lambda- noise penalty
lambdav- distance scale from vertex to first hit

Definition at line 33 of file ElasticArms.cxx.

References fExpBetaMia, fMia, fMiaUnchanged, fVia, MECModelEnuComparisons::i, getGoodRuns4SAM::n, and stan::math::resize().

36  :
37  fProngFit(1),
38  fT(200.0),
39  fBeta(1.0/fT),
40  fBetaUnchanged(false),
41  fLambda(l),
42  fLambdaV(lv),
43  fN(n),
44  fXorY(n),
45  fView(n),
46  fZ(n),
47  fWsqr(n),
48  fDhi(n),
49  fDaa(m),
50  fMia(n),
54  fExpBetaMia(n),
55  fVia(n),
56  fX0(0),
57  fY0(0),
58  fZ0(0),
59  fM(m),
60  fdXds(m),
61  fdYds(m),
62  fdZds(m)
63 {
64  unsigned int i;
65  for (i=0; i<n; ++i) {
66  fMia[i]. resize(m);
67  fMiaUnchanged[i].resize(m);
68  fExpBetaMia[i].resize(m);
69  fVia[i]. resize(m);
70  }
71 }
double fBeta
1/T in units of 1/sigma^2
Definition: ElasticArms.h:100
double fLambda
Noise penalty term in units of sigma^2.
Definition: ElasticArms.h:102
std::vector< double > fWsqr
Combined weight for hit 1/(sigmaH^2 + sigmaMS^2)
Definition: ElasticArms.h:112
double fY0
Vertex y location (cm)
Definition: ElasticArms.h:127
std::vector< bool > fMiaColUnchanged
Is a column of fMia changed in UpdateMia?
Definition: ElasticArms.h:120
std::vector< double > fDhi
From hit to vertex location^2 [cm^2].
Definition: ElasticArms.h:113
double fZ0
Vertex z location (cm)
Definition: ElasticArms.h:128
double fLambdaV
Distance scale for hits to appear on (cm)
Definition: ElasticArms.h:104
unsigned int fM
Number of arms.
Definition: ElasticArms.h:129
bool fBetaUnchanged
Whether fBeta is the same since last call to UpdateMia.
Definition: ElasticArms.h:101
std::vector< double > fXorY
Transverse hit positions (cm)
Definition: ElasticArms.h:109
std::vector< double > fdZds
Track dz/ds.
Definition: ElasticArms.h:132
void resize(T &x, std::vector< int > dims)
Definition: resize.hpp:41
unsigned int fN
Data to fit.
Definition: ElasticArms.h:108
std::vector< double > fDaa
Distance from vertex to prong [cm].
Definition: ElasticArms.h:114
int fProngFit
1 - treat arms as prongs in fit, 0 - treat as lines
Definition: ElasticArms.h:98
std::vector< double > fZ
Z locations of hits (cm)
Definition: ElasticArms.h:111
double fX0
Model parameters.
Definition: ElasticArms.h:126
std::vector< bool > fMiaRowUnchanged
Is a row of fMia changed in UpdateMia?
Definition: ElasticArms.h:119
std::vector< double > fdXds
Track dx/ds.
Definition: ElasticArms.h:130
matrix fVia
Strength of association hit i to track a.
Definition: ElasticArms.h:122
std::vector< std::vector< bool > > fMiaUnchanged
Is fMia changed in UpdateMia?
Definition: ElasticArms.h:118
std::vector< int > fView
Which view is the hit in?
Definition: ElasticArms.h:110
matrix fExpBetaMia
exp(-fBeta*Mia) - compute once used many time
Definition: ElasticArms.h:121
std::vector< double > fdYds
Track dy/ds.
Definition: ElasticArms.h:131
double fT
A measure of the "temperature" in units of sigma^2.
Definition: ElasticArms.h:99
matrix fMia
Distance^2 hit i to track a (sigma^2)
Definition: ElasticArms.h:117

Member Function Documentation

double ElasticArms::E ( )

Return the "energy" function, a chi^2-like goodness of fit

Definition at line 259 of file ElasticArms.cxx.

References a, fBetaUnchanged, fDaa, fLambda, fLambdaV, fM, fMia, fN, fVia, MECModelEnuComparisons::i, sqr(), UpdateDaa(), UpdateMia(), and UpdateVia().

Referenced by earms::GridSearch::ChooseBestProngDir(), earms::Minimizer::Fit(), gsFCN(), and earms::ElasticArmsHS::produce().

260 {
261  unsigned int i;
262  unsigned int a;
263  double sViaMia = 0.0; // First term in the energy
264  double sVia = 0.0; // The inside sum in the second term
265  double ssVia = 0.0; // The outside sum in the second term
266 
267  //
268  // Update all the pieces that go into the calculation
269  //
270  this->UpdateMia();
271  this->UpdateVia();
272  this->UpdateDaa();
273  fBetaUnchanged = true;
274 
275  //
276  // Loop for each hit i of N
277  //
278  for (i=0; i<fN; ++i) {
279  //
280  // Loop for each track a of M
281  //
282  sVia = 0.0;
283  for (a=0; a<fM; ++a) {
284  sViaMia += fVia[i][a]*fMia[i][a];
285  sVia += fVia[i][a];
286  }
287  ssVia += sqr(sVia-1.0);
288  }
289 
290  //
291  // Loop for each prong a of M
292  //
293  double sDaa = 0.0;
294  for (a=0; a<fM; ++a) sDaa += fDaa[a];
295  sDaa *= 2.0/fLambdaV;
296 
297  //
298  // Three terms:
299  //
300  // 1st accounts for distance from hits to prongs
301  // 2nd is a penalty term for hits labeled as noise
302  // 3rd is a penalty term for arms that are detached from the vertex
303  //
304  return sViaMia + fLambda*ssVia + sDaa;
305 }
double fLambda
Noise penalty term in units of sigma^2.
Definition: ElasticArms.h:102
double fLambdaV
Distance scale for hits to appear on (cm)
Definition: ElasticArms.h:104
unsigned int fM
Number of arms.
Definition: ElasticArms.h:129
bool fBetaUnchanged
Whether fBeta is the same since last call to UpdateMia.
Definition: ElasticArms.h:101
const double a
static double sqr(double x)
Definition: ElasticArms.cxx:20
unsigned int fN
Data to fit.
Definition: ElasticArms.h:108
std::vector< double > fDaa
Distance from vertex to prong [cm].
Definition: ElasticArms.h:114
matrix fVia
Strength of association hit i to track a.
Definition: ElasticArms.h:122
matrix fMia
Distance^2 hit i to track a (sigma^2)
Definition: ElasticArms.h:117
void ElasticArms::GetVertex ( double &  x,
double &  y,
double &  z 
) const

Definition at line 344 of file ElasticArms.cxx.

References fX0, fY0, and fZ0.

Referenced by earms::ElasticArmsHS::produce().

345 {
346  x = fX0;
347  y = fY0;
348  z = fZ0;
349 }
double fY0
Vertex y location (cm)
Definition: ElasticArms.h:127
double fZ0
Vertex z location (cm)
Definition: ElasticArms.h:128
z
Definition: test.py:28
double fX0
Model parameters.
Definition: ElasticArms.h:126
unsigned int ElasticArms::LeadingArm ( ) const

Find the leading arm. The with the highest weight

Definition at line 374 of file ElasticArms.cxx.

References a, fM, SumVi(), and w.

375 {
376  unsigned int a;
377  unsigned int amax = 0;
378  double w;
379  double wmax = 0;
380  for (a=0; a<fM; ++a) {
381  w = this->SumVi(a);
382  if (w>wmax) {
383  wmax = w;
384  amax = a;
385  }
386  }
387  return amax;
388 }
unsigned int fM
Number of arms.
Definition: ElasticArms.h:129
double SumVi(unsigned int a) const
const double a
Float_t w
Definition: plot.C:20
void ElasticArms::SetArm ( unsigned int  i,
double  theta,
double  phi 
)

Set the arm direction parameters

Parameters
theta- zenith angle in radians
phi- azimuthal angle in radians

Definition at line 309 of file ElasticArms.cxx.

References a, ana::assert(), std::cos(), fdXds, fdYds, fdZds, fM, and std::sin().

Referenced by earms::GridSearch::ChooseBestProngDir(), earms::GridSearch::FindBestVtx(), earms::Minimizer::Fit(), gsFCN(), and earms::Minimizer::SeedArm().

310 {
311  assert(a<fM);
312  fdXds[a] = sin(theta)*cos(phi);
313  fdYds[a] = sin(theta)*sin(phi);
314  fdZds[a] = cos(theta);
315 }
unsigned int fM
Number of arms.
Definition: ElasticArms.h:129
std::vector< double > fdZds
Track dz/ds.
Definition: ElasticArms.h:132
const double a
T sin(T number)
Definition: d0nt_math.hpp:132
std::vector< double > fdXds
Track dx/ds.
Definition: ElasticArms.h:130
T cos(T number)
Definition: d0nt_math.hpp:78
assert(nhit_max >=nhit_nbins)
std::vector< double > fdYds
Track dy/ds.
Definition: ElasticArms.h:131
void ElasticArms::SetHit ( unsigned int  i,
double  z,
double  xory,
double  sigma,
int  view 
)

Add a hit to the fit

Parameters
i- hit index [0...N)
z- z location of hit (cm)
xory- x or y location of hit (cm)
sigma- hit location uncertainty (cm)
view- X view or Y view?

Definition at line 75 of file ElasticArms.cxx.

References ana::assert(), fN, fView, fWsqr, fXorY, fZ, MECModelEnuComparisons::i, sigma(), POTSpillRate::view, and test::z.

Referenced by earms::ElasticArmsHS::produce().

80 {
81  assert(i<fN);
82  fZ[i] = z;
83  fXorY[i] = xory;
84  fWsqr[i] = 1.0/(sigma*sigma);
85  fView[i] = view;
86 }
std::vector< double > fWsqr
Combined weight for hit 1/(sigmaH^2 + sigmaMS^2)
Definition: ElasticArms.h:112
std::vector< double > fXorY
Transverse hit positions (cm)
Definition: ElasticArms.h:109
unsigned int fN
Data to fit.
Definition: ElasticArms.h:108
z
Definition: test.py:28
double sigma(TH1F *hist, double percentile)
std::vector< double > fZ
Z locations of hits (cm)
Definition: ElasticArms.h:111
assert(nhit_max >=nhit_nbins)
std::vector< int > fView
Which view is the hit in?
Definition: ElasticArms.h:110
void ElasticArms::SetLambda ( double  lam)

The the noise penalty

Parameters
lam- the noise penalty in units of chi^2

Definition at line 100 of file ElasticArms.cxx.

References stan::math::exp(), fBeta, fExpBetaLambda, and fLambda.

Referenced by earms::ElasticArmsHS::FindSeed(), and earms::ElasticArmsHS::produce().

101 {
102  fLambda = lam;
104 }
double fBeta
1/T in units of 1/sigma^2
Definition: ElasticArms.h:100
double fLambda
Noise penalty term in units of sigma^2.
Definition: ElasticArms.h:102
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
double fExpBetaLambda
exp(-fBeta*fLambda) - computed once used many
Definition: ElasticArms.h:103
void ElasticArms::SetT ( double  t)

The the annealing temperature.

Parameters
t- the temperature t is in units of chi^2

Definition at line 90 of file ElasticArms.cxx.

References stan::math::exp(), fBeta, fBetaUnchanged, fExpBetaLambda, fLambda, fT, and confusionMatrixTree::t.

Referenced by earms::ElasticArmsHS::FindSeed(), and earms::Minimizer::Fit().

91 {
92  fT = t;
93  fBeta = 1.0/fT;
94  fBetaUnchanged = false;
96 }
double fBeta
1/T in units of 1/sigma^2
Definition: ElasticArms.h:100
double fLambda
Noise penalty term in units of sigma^2.
Definition: ElasticArms.h:102
bool fBetaUnchanged
Whether fBeta is the same since last call to UpdateMia.
Definition: ElasticArms.h:101
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
double fExpBetaLambda
exp(-fBeta*fLambda) - computed once used many
Definition: ElasticArms.h:103
double fT
A measure of the "temperature" in units of sigma^2.
Definition: ElasticArms.h:99
void ElasticArms::SetVertex ( double  x,
double  y,
double  z 
)

Set the vertex parameters

Parameters
x- x position in cm
y- y position in cm
z- z position in cm

Definition at line 319 of file ElasticArms.cxx.

References fDhi, fN, fView, fX0, fXorY, fY0, fZ, fZ0, MECModelEnuComparisons::i, sqr(), submit_syst::x, submit_syst::y, and test::z.

Referenced by earms::GridSearch::FindBestVtx(), earms::Minimizer::Fit(), gsFCN(), earms::ElasticArmsHS::produce(), and earms::Minimizer::SeedVertex().

320 {
321  fX0 = x;
322  fY0 = y;
323  fZ0 = z;
324 
325  //
326  // Update the table of distances from the vertex to the hits
327  //
328  unsigned int i;
329  for (i=0; i<fN; ++i) {
330  switch (fView[i]) {
331  case 0:
332  fDhi[i] = sqr(fXorY[i]-fX0) + sqr(fZ[i]-fZ0);
333  break;
334  case 1:
335  fDhi[i] = sqr(fXorY[i]-fY0) + sqr(fZ[i]-fZ0);
336  break;
337  default: abort();
338  }
339  }
340 }
double fY0
Vertex y location (cm)
Definition: ElasticArms.h:127
std::vector< double > fDhi
From hit to vertex location^2 [cm^2].
Definition: ElasticArms.h:113
double fZ0
Vertex z location (cm)
Definition: ElasticArms.h:128
std::vector< double > fXorY
Transverse hit positions (cm)
Definition: ElasticArms.h:109
static double sqr(double x)
Definition: ElasticArms.cxx:20
unsigned int fN
Data to fit.
Definition: ElasticArms.h:108
z
Definition: test.py:28
std::vector< double > fZ
Z locations of hits (cm)
Definition: ElasticArms.h:111
double fX0
Model parameters.
Definition: ElasticArms.h:126
std::vector< int > fView
Which view is the hit in?
Definition: ElasticArms.h:110
double ElasticArms::SumVi ( unsigned int  a) const

Calculation the total weight of an arm a. Roughly speaking this is the number of hits on the arm.

Definition at line 353 of file ElasticArms.cxx.

References a, om::cerr, allTimeWatchdog::endl, fM, fN, fVia, MECModelEnuComparisons::i, and sum.

Referenced by LeadingArm().

354 {
355  //
356  // Play some defense by checking the bounds of a against the number
357  // of arms in the object. a cannot be larger than (# arms)-1
358  //
359  if (a>=this->fM) {
360  std::cerr << __FILE__ << ":" << __LINE__ << " Bad arm number "
361  << a << ">=" << this->fM << std::endl;
362  return -99.0; // An obviously bogus result
363  }
364  unsigned int i;
365  double sum = 0.0;
366  for (i=0; i<fN; ++i) {
367  sum += fVia[i][a];
368  }
369  return sum;
370 }
OStream cerr
Definition: OStream.cxx:7
unsigned int fM
Number of arms.
Definition: ElasticArms.h:129
const double a
unsigned int fN
Data to fit.
Definition: ElasticArms.h:108
matrix fVia
Strength of association hit i to track a.
Definition: ElasticArms.h:122
Double_t sum
Definition: plot.C:31
void ElasticArms::UpdateDaa ( )

Update the vector of arm-vertex distances

Definition at line 214 of file ElasticArms.cxx.

References a, fDaa, fDhi, fM, fMiaColUnchanged, fN, fVia, fView, MECModelEnuComparisons::i, and std::sqrt().

Referenced by E(), and earms::Minimizer::Fit().

215 {
216  unsigned int i, a;
217  double dminx, dminy;
218  double mavex, mavey;
219  double nx, ny;
220 
221  for (a=0; a<fM; ++a) {
222  if(fMiaColUnchanged[a]) continue;
223  //
224  // Compute the average weight for hits on this track
225  //
226  nx = 0.0;
227  ny = 0.0;
228  mavex = 0.0;
229  mavey = 0.0;
230  for (i=0; i<fN; ++i) {
231  switch (fView[i]) {
232  case 0: mavex += fVia[i][a]; nx += 1.0; break;
233  case 1: mavey += fVia[i][a]; ny += 1.0; break;
234  default: abort();
235  }
236  }
237  mavex /= nx;
238  mavey /= ny;
239 
240  dminx = 99E99;
241  dminy = 99E99;
242  for (i=0; i<fN; ++i) {
243  switch (fView[i]) {
244  case 0:
245  if (fVia[i][a]>=mavex && fDhi[i]<dminx) dminx = fDhi[i];
246  break;
247  case 1:
248  if (fVia[i][a]>=mavey && fDhi[i]<dminy) dminy = fDhi[i];
249  break;
250  default: abort();
251  }
252  }
253  fDaa[a] = sqrt(dminx)+sqrt(dminy);
254  }
255 }
T sqrt(T number)
Definition: d0nt_math.hpp:156
std::vector< bool > fMiaColUnchanged
Is a column of fMia changed in UpdateMia?
Definition: ElasticArms.h:120
std::vector< double > fDhi
From hit to vertex location^2 [cm^2].
Definition: ElasticArms.h:113
unsigned int fM
Number of arms.
Definition: ElasticArms.h:129
const double a
unsigned int fN
Data to fit.
Definition: ElasticArms.h:108
std::vector< double > fDaa
Distance from vertex to prong [cm].
Definition: ElasticArms.h:114
matrix fVia
Strength of association hit i to track a.
Definition: ElasticArms.h:122
std::vector< int > fView
Which view is the hit in?
Definition: ElasticArms.h:110
void ElasticArms::UpdateMia ( )

Compute the distances^2 from hit i to track a

Definition at line 108 of file ElasticArms.cxx.

References a, stan::math::dot(), dsqrtoline(), stan::math::exp(), fBeta, fBetaUnchanged, fdXds, fdYds, fdZds, fExpBetaMia, fM, fMia, fMiaColUnchanged, fMiaRowUnchanged, fMiaUnchanged, fN, fProngFit, fView, fWsqr, fX0, fXorY, fY0, fZ, fZ0, MECModelEnuComparisons::i, geo::kX, geo::kY, and sqr().

Referenced by earms::GridSearch::ChooseBestProngDir(), E(), and earms::Minimizer::Fit().

109 {
110  unsigned int i; // hit index
111  unsigned int a; // track index
112 
113  for(i = 0; i < fN; ++i) fMiaRowUnchanged[i] = true;
114  for(a = 0; i < fM; ++a) fMiaColUnchanged[a] = true;
115 
116  //
117  // Loop for each track a of the set of M track templates
118  //
119  for (a=0; a<fM; ++a) {
120 
121  // Update track end point
122  double trkX1 = fX0 + fdXds[a];
123  double trkY1 = fY0 + fdYds[a];
124  double trkZ1 = fZ0 + fdZds[a];
125 
126  //
127  // Loop for each hit i of the set of N hits
128  //
129  double trkXorY0;
130  double trkXorY1;
131  for (i=0; i<fN; ++i) {
132  double dot;
133  //
134  // Set coordinates based on which view the hit is in
135  //
136  switch (fView[i]) {
137  case geo::kX:
138  trkXorY0 = fX0;
139  trkXorY1 = trkX1;
140  dot = (trkZ1-fZ0)*(fZ[i]-fZ0) + (trkXorY1-fX0)*(fXorY[i]-fX0);
141  break;
142  case geo::kY:
143  trkXorY0 = fY0;
144  trkXorY1 = trkY1;
145  dot = (trkZ1-fZ0)*(fZ[i]-fZ0) + (trkXorY1-fY0)*(fXorY[i]-fY0);
146  break;
147  default: abort();
148  }
149  //
150  // If we're doing a line fit or it the hit is in the forward
151  // hemisphere use the distance from the hit to the arm template
152  //
153  const double oldmia = fMia[i][a];
154  if (fProngFit==0 || dot>0.0) {
155  fMia[i][a] = fWsqr[i]*dsqrtoline(fZ[i], fXorY[i],
156  fZ0, trkXorY0,
157  trkZ1, trkXorY1);
158  }
159  else {
160  //
161  // In the backwards hemisphere take the distance to the
162  // vertex. Make it get worse rapidly for differences larger
163  // than one sigma
164  //
165  fMia[i][a] = fWsqr[i]*(sqr(fZ[i]-fZ0)+sqr(fXorY[i]-trkXorY0));
166  if (fMia[i][a]>1.0) fMia[i][a] *= fMia[i][a];
167  }
168  const bool unchanged = (oldmia == fMia[i][a]);
169  fMiaUnchanged[i][a] = unchanged;
170  if(!unchanged){
171  fMiaRowUnchanged[i] = false;
172  fMiaColUnchanged[a] = false;
173  }
174 
175  // We only need to update fExpBetaMia if either fBeta or fMia has changed,
176  // and since it's expensive to call exp(), only do it if needed.
177  if(!fBetaUnchanged || !fMiaUnchanged[i][a]){
178  // If the argument of exp() is less than -746 in double precision, the
179  // result is zero. Saves 25% of all ElasticArms time to avoid these calls.
180  const double exparg = -fBeta*fMia[i][a];
181  fExpBetaMia[i][a] = exparg < -746? 0: exp(exparg);
182  }
183  } // loop on i hits
184  } // loop on a tracks
185 }
double fBeta
1/T in units of 1/sigma^2
Definition: ElasticArms.h:100
std::vector< double > fWsqr
Combined weight for hit 1/(sigmaH^2 + sigmaMS^2)
Definition: ElasticArms.h:112
double fY0
Vertex y location (cm)
Definition: ElasticArms.h:127
Vertical planes which measure X.
Definition: PlaneGeo.h:28
std::vector< bool > fMiaColUnchanged
Is a column of fMia changed in UpdateMia?
Definition: ElasticArms.h:120
double fZ0
Vertex z location (cm)
Definition: ElasticArms.h:128
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
unsigned int fM
Number of arms.
Definition: ElasticArms.h:129
bool fBetaUnchanged
Whether fBeta is the same since last call to UpdateMia.
Definition: ElasticArms.h:101
std::vector< double > fXorY
Transverse hit positions (cm)
Definition: ElasticArms.h:109
std::vector< double > fdZds
Track dz/ds.
Definition: ElasticArms.h:132
const double a
static double sqr(double x)
Definition: ElasticArms.cxx:20
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
unsigned int fN
Data to fit.
Definition: ElasticArms.h:108
int fProngFit
1 - treat arms as prongs in fit, 0 - treat as lines
Definition: ElasticArms.h:98
std::vector< double > fZ
Z locations of hits (cm)
Definition: ElasticArms.h:111
double dot(const std::vector< double > &x, const std::vector< double > &y)
Definition: dot.hpp:10
double fX0
Model parameters.
Definition: ElasticArms.h:126
std::vector< bool > fMiaRowUnchanged
Is a row of fMia changed in UpdateMia?
Definition: ElasticArms.h:119
std::vector< double > fdXds
Track dx/ds.
Definition: ElasticArms.h:130
std::vector< std::vector< bool > > fMiaUnchanged
Is fMia changed in UpdateMia?
Definition: ElasticArms.h:118
std::vector< int > fView
Which view is the hit in?
Definition: ElasticArms.h:110
matrix fExpBetaMia
exp(-fBeta*Mia) - compute once used many time
Definition: ElasticArms.h:121
std::vector< double > fdYds
Track dy/ds.
Definition: ElasticArms.h:131
static double dsqrtoline(double x0, double y0, double x1, double y1, double x2, double y2)
Definition: ElasticArms.cxx:21
matrix fMia
Distance^2 hit i to track a (sigma^2)
Definition: ElasticArms.h:117
void ElasticArms::UpdateVia ( )

Update the matrix of associations

Definition at line 189 of file ElasticArms.cxx.

References a, b, e, fBetaUnchanged, fExpBetaLambda, fExpBetaMia, fM, fMiaRowUnchanged, fN, fVia, and MECModelEnuComparisons::i.

Referenced by earms::GridSearch::ChooseBestProngDir(), E(), and earms::Minimizer::Fit().

190 {
191  static const double TINY = 1e-16;
192  unsigned int i;
193  unsigned int a;
194  unsigned int b;
195 
196  double d1, d2, denom;
197 
198  d1 = fExpBetaLambda+TINY;
199  for (i=0; i<fN; ++i) {
200  if(fBetaUnchanged && fMiaRowUnchanged[i]) continue;
201 
202  d2 = TINY;
203  for (b=0; b<fM; ++b) d2 += fExpBetaMia[i][b];
204 
205  denom = d1+d2;
206  for (a=0; a<fM; ++a) {
207  fVia[i][a] = fExpBetaMia[i][a]/denom;
208  }
209  } // loop on i=0...N hits
210 }
unsigned int fM
Number of arms.
Definition: ElasticArms.h:129
bool fBetaUnchanged
Whether fBeta is the same since last call to UpdateMia.
Definition: ElasticArms.h:101
const double a
unsigned int fN
Data to fit.
Definition: ElasticArms.h:108
std::vector< bool > fMiaRowUnchanged
Is a row of fMia changed in UpdateMia?
Definition: ElasticArms.h:119
matrix fVia
Strength of association hit i to track a.
Definition: ElasticArms.h:122
const hit & b
Definition: hits.cxx:21
matrix fExpBetaMia
exp(-fBeta*Mia) - compute once used many time
Definition: ElasticArms.h:121
double fExpBetaLambda
exp(-fBeta*fLambda) - computed once used many
Definition: ElasticArms.h:103
Float_t e
Definition: plot.C:35

Member Data Documentation

double earms::ElasticArms::fBeta
private

1/T in units of 1/sigma^2

Definition at line 100 of file ElasticArms.h.

Referenced by SetLambda(), SetT(), and UpdateMia().

bool earms::ElasticArms::fBetaUnchanged
private

Whether fBeta is the same since last call to UpdateMia.

Definition at line 101 of file ElasticArms.h.

Referenced by E(), SetT(), UpdateMia(), and UpdateVia().

std::vector<double> earms::ElasticArms::fDaa

Distance from vertex to prong [cm].

Definition at line 114 of file ElasticArms.h.

Referenced by E(), and UpdateDaa().

std::vector<double> earms::ElasticArms::fDhi

From hit to vertex location^2 [cm^2].

Definition at line 113 of file ElasticArms.h.

Referenced by SetVertex(), and UpdateDaa().

std::vector<double> earms::ElasticArms::fdXds
std::vector<double> earms::ElasticArms::fdYds
std::vector<double> earms::ElasticArms::fdZds
double earms::ElasticArms::fExpBetaLambda
private

exp(-fBeta*fLambda) - computed once used many

Definition at line 103 of file ElasticArms.h.

Referenced by SetLambda(), SetT(), and UpdateVia().

matrix earms::ElasticArms::fExpBetaMia

exp(-fBeta*Mia) - compute once used many time

Definition at line 121 of file ElasticArms.h.

Referenced by ElasticArms(), UpdateMia(), and UpdateVia().

double earms::ElasticArms::fLambda
private

Noise penalty term in units of sigma^2.

Definition at line 102 of file ElasticArms.h.

Referenced by E(), SetLambda(), and SetT().

double earms::ElasticArms::fLambdaV
private

Distance scale for hits to appear on (cm)

Definition at line 104 of file ElasticArms.h.

Referenced by E().

unsigned int earms::ElasticArms::fM
matrix earms::ElasticArms::fMia

Distance^2 hit i to track a (sigma^2)

Definition at line 117 of file ElasticArms.h.

Referenced by E(), ElasticArms(), earms::ElasticArmsHS::produce(), and UpdateMia().

std::vector<bool> earms::ElasticArms::fMiaColUnchanged

Is a column of fMia changed in UpdateMia?

Definition at line 120 of file ElasticArms.h.

Referenced by UpdateDaa(), and UpdateMia().

std::vector<bool> earms::ElasticArms::fMiaRowUnchanged

Is a row of fMia changed in UpdateMia?

Definition at line 119 of file ElasticArms.h.

Referenced by UpdateMia(), and UpdateVia().

std::vector< std::vector<bool> > earms::ElasticArms::fMiaUnchanged

Is fMia changed in UpdateMia?

Definition at line 118 of file ElasticArms.h.

Referenced by ElasticArms(), and UpdateMia().

unsigned int earms::ElasticArms::fN

Data to fit.

Number of hits

Definition at line 108 of file ElasticArms.h.

Referenced by earms::GridSearch::AddVtxPoints(), E(), earms::ElasticArmsHS::produce(), SetHit(), SetVertex(), SumVi(), UpdateDaa(), UpdateMia(), and UpdateVia().

int earms::ElasticArms::fProngFit
private

1 - treat arms as prongs in fit, 0 - treat as lines

Definition at line 98 of file ElasticArms.h.

Referenced by UpdateMia().

double earms::ElasticArms::fT
private

A measure of the "temperature" in units of sigma^2.

Definition at line 99 of file ElasticArms.h.

Referenced by SetT().

matrix earms::ElasticArms::fVia

Strength of association hit i to track a.

Definition at line 122 of file ElasticArms.h.

Referenced by E(), ElasticArms(), earms::ElasticArmsHS::produce(), SumVi(), UpdateDaa(), and UpdateVia().

std::vector<int> earms::ElasticArms::fView

Which view is the hit in?

Definition at line 110 of file ElasticArms.h.

Referenced by earms::GridSearch::AddVtxPoints(), earms::ElasticArmsHS::produce(), SetHit(), SetVertex(), UpdateDaa(), and UpdateMia().

std::vector<double> earms::ElasticArms::fWsqr

Combined weight for hit 1/(sigmaH^2 + sigmaMS^2)

Definition at line 112 of file ElasticArms.h.

Referenced by SetHit(), and UpdateMia().

double earms::ElasticArms::fX0

Model parameters.

Vertex x location (cm)

Definition at line 126 of file ElasticArms.h.

Referenced by GetVertex(), earms::Minimizer::Minimizer(), earms::ElasticArmsHS::produce(), SetVertex(), and UpdateMia().

std::vector<double> earms::ElasticArms::fXorY

Transverse hit positions (cm)

Definition at line 109 of file ElasticArms.h.

Referenced by earms::GridSearch::AddVtxPoints(), earms::ElasticArmsHS::produce(), SetHit(), SetVertex(), and UpdateMia().

double earms::ElasticArms::fY0

Vertex y location (cm)

Definition at line 127 of file ElasticArms.h.

Referenced by GetVertex(), earms::Minimizer::Minimizer(), earms::ElasticArmsHS::produce(), SetVertex(), and UpdateMia().

std::vector<double> earms::ElasticArms::fZ

Z locations of hits (cm)

Definition at line 111 of file ElasticArms.h.

Referenced by earms::GridSearch::AddVtxPoints(), earms::ElasticArmsHS::produce(), SetHit(), SetVertex(), and UpdateMia().

double earms::ElasticArms::fZ0

Vertex z location (cm)

Definition at line 128 of file ElasticArms.h.

Referenced by GetVertex(), earms::Minimizer::Minimizer(), earms::ElasticArmsHS::produce(), SetVertex(), and UpdateMia().


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